RTXI  3.0.0
The Real-Time eXperiment Interface Reference Manual
analogy_device.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 University of Bristol, UK
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18 
19 #ifndef ANALOGY_DEVICE_H
20 #define ANALOGY_DEVICE_H
21 
22 #include <string>
23 
24 #include <daq.h>
25 #include <errno.h>
26 #include <plugin.h>
27 #include <rtdm/analogy.h>
28 #include <sys/stat.h>
29 #include <sys/types.h>
30 
31 class AnalogyDevice : public DAQ::Device
32 {
33 public:
34  AnalogyDevice(a4l_desc_t*, std::string, IO::channel_t*, size_t);
35  ~AnalogyDevice(void);
36 
37  size_t getChannelCount(DAQ::type_t) const;
40 
47  DAQ::index_t) const;
50  DAQ::index_t) const;
53  DAQ::index_t) const;
54  double getAnalogGain(DAQ::type_t, DAQ::index_t) const;
68  void setAnalogConversion(DAQ::type_t, DAQ::index_t) {}; // Placeholder
71  // TODO: Finish defining the functions below for AnalogyDevice class
74  {
75  return false;
76  };
78  {
79  return false;
80  };
81 
84 
85  void read(void);
86  void write(void);
87 
88 protected:
89  virtual void doLoad(const Settings::Object::State&);
90  virtual void doSave(Settings::Object::State&) const;
91 
92 private:
93  bool analog_exists(DAQ::type_t, DAQ::index_t) const;
94 
95  struct analog_channel_t
96  {
97  double gain;
98  DAQ::index_t range;
99  DAQ::index_t reference;
100  DAQ::index_t units;
101  double conv;
102  double offset;
103  double zerooffset;
104  lsampl_t maxdata;
105  DAQ::index_t offsetunits;
106  size_t downsample;
107  size_t counter;
108  bool calibrationActive;
109  double calOffset;
110  };
111 
112  struct digital_channel_t
113  {
114  DAQ::direction_t direction;
115  int previous_value;
116  };
117 
118  struct channel_t
119  {
120  bool active;
121  union
122  {
123  analog_channel_t analog;
124  digital_channel_t digital;
125  };
126  };
127 
128  struct subdevice_t
129  {
130  int id;
131  DAQ::index_t active;
132  DAQ::index_t count;
133  channel_t* chan;
134  };
135 
136  std::string deviceName;
137  subdevice_t subdevice[3];
138  a4l_desc_t dsc;
139 };
140 
141 #endif /* ANALOGY_DEVICE_H */
int setAnalogCounter(DAQ::type_t, DAQ::index_t)
size_t getAnalogUnitsCount(DAQ::type_t, DAQ::index_t) const
std::string getAnalogRangeString(DAQ::type_t, DAQ::index_t, DAQ::index_t) const
int setAnalogGain(DAQ::type_t, DAQ::index_t, double)
int setAnalogCalibrationActive(DAQ::type_t, DAQ::index_t, bool)
int setAnalogUnits(DAQ::type_t, DAQ::index_t, DAQ::index_t)
AnalogyDevice(a4l_desc_t *, std::string, IO::channel_t *, size_t)
int setAnalogZeroOffset(DAQ::type_t, DAQ::index_t, double)
void write(void)
bool getAnalogCalibrationState(DAQ::type_t, DAQ::index_t) const
double getAnalogCalibrationValue(DAQ::type_t, DAQ::index_t) const
int setAnalogDownsample(DAQ::type_t, DAQ::index_t, size_t)
double getAnalogZeroOffset(DAQ::type_t, DAQ::index_t) const
int setDigitalDirection(DAQ::index_t, DAQ::direction_t)
double getAnalogGain(DAQ::type_t, DAQ::index_t) const
bool getAnalogCalibrationActive(DAQ::type_t, DAQ::index_t) const
std::string getAnalogReferenceString(DAQ::type_t, DAQ::index_t, DAQ::index_t) const
virtual void doSave(Settings::Object::State &) const
virtual void doLoad(const Settings::Object::State &)
DAQ::index_t getAnalogRange(DAQ::type_t, DAQ::index_t) const
size_t getChannelCount(DAQ::type_t) const
bool getChannelActive(DAQ::type_t, DAQ::index_t) const
void setAnalogConversion(DAQ::type_t, DAQ::index_t)
size_t getAnalogDownsample(DAQ::type_t, DAQ::index_t) const
std::string getAnalogUnitsString(DAQ::type_t, DAQ::index_t, DAQ::index_t) const
DAQ::direction_t getDigitalDirection(DAQ::index_t) const
int setAnalogReference(DAQ::type_t, DAQ::index_t, DAQ::index_t)
int setAnalogCalibrationValue(DAQ::type_t, DAQ::index_t, double)
size_t getAnalogReferenceCount(DAQ::type_t, DAQ::index_t) const
size_t getAnalogRangeCount(DAQ::type_t, DAQ::index_t) const
int setChannelActive(DAQ::type_t, DAQ::index_t, bool)
DAQ::index_t getAnalogReference(DAQ::type_t, DAQ::index_t) const
int setAnalogOffsetUnits(DAQ::type_t, DAQ::index_t, DAQ::index_t)
int setAnalogRange(DAQ::type_t, DAQ::index_t, DAQ::index_t)
DAQ::index_t getAnalogOffsetUnits(DAQ::type_t, DAQ::index_t) const
DAQ::index_t getAnalogUnits(DAQ::type_t, DAQ::index_t) const
uint64_t index_t
Definition: daq.hpp:82
direction_t
Definition: daq.hpp:93
struct IO::channel_t channel_t