RTXI  2.4
The Real-Time eXperiment Interface Documentation
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 <daq.h>
23 #include <plugin.h>
24 #include <string>
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <errno.h>
28 #include <rtdm/analogy.h>
29 
30 class AnalogyDevice : public DAQ::Device
31 {
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 
62  void setAnalogConversion(DAQ::type_t,DAQ::index_t) {}; // Placeholder
65  // TODO: Finish defining the functions below for AnalogyDevice class
68  bool getAnalogCalibrationState(DAQ::type_t,DAQ::index_t) const {return false;};
69 
72 
73  void read(void);
74  void write(void);
75 
76 protected:
77  virtual void doLoad(const Settings::Object::State &);
78  virtual void doSave(Settings::Object::State &) const;
79 
80 private:
81  bool analog_exists(DAQ::type_t,DAQ::index_t) const;
82 
83  struct analog_channel_t
84  {
85  double gain;
86  DAQ::index_t range;
87  DAQ::index_t reference;
88  DAQ::index_t units;
89  double conv;
90  double offset;
91  double zerooffset;
92  lsampl_t maxdata;
93  DAQ::index_t offsetunits;
94  size_t downsample;
95  size_t counter;
96  bool calibrationActive;
97  double calOffset;
98  };
99 
100  struct digital_channel_t
101  {
102  DAQ::direction_t direction;
103  int previous_value;
104  };
105 
106  struct channel_t
107  {
108  bool active;
109  union
110  {
111  analog_channel_t analog;
112  digital_channel_t digital;
113  };
114  };
115 
116  struct subdevice_t
117  {
118  int id;
119  DAQ::index_t active;
120  DAQ::index_t count;
121  channel_t *chan;
122  };
123 
124  std::string deviceName;
125  subdevice_t subdevice[3];
126  a4l_desc_t dsc;
127 };
128 
129 #endif /* ANALOGY_DEVICE_H */
AnalogyDevice::setAnalogCounter
int setAnalogCounter(DAQ::type_t, DAQ::index_t)
Definition: analogy_device.cpp:458
AnalogyDevice::getAnalogUnitsString
std::string getAnalogUnitsString(DAQ::type_t, DAQ::index_t, DAQ::index_t) const
Definition: analogy_device.cpp:298
AnalogyDevice::getAnalogUnitsCount
size_t getAnalogUnitsCount(DAQ::type_t, DAQ::index_t) const
Definition: analogy_device.cpp:244
DAQ::type_t
type_t
Definition: daq.h:38
AnalogyDevice
Definition: analogy_device.h:30
AnalogyDevice::setAnalogRange
int setAnalogRange(DAQ::type_t, DAQ::index_t, DAQ::index_t)
Definition: analogy_device.cpp:362
AnalogyDevice::setAnalogOffsetUnits
int setAnalogOffsetUnits(DAQ::type_t, DAQ::index_t, DAQ::index_t)
Definition: analogy_device.cpp:406
AnalogyDevice::setAnalogUnits
int setAnalogUnits(DAQ::type_t, DAQ::index_t, DAQ::index_t)
Definition: analogy_device.cpp:397
AnalogyDevice::getAnalogCalibrationValue
double getAnalogCalibrationValue(DAQ::type_t, DAQ::index_t) const
Definition: analogy_device.cpp:441
DAQ::index_t
unsigned long index_t
Definition: daq.h:49
plugin.h
AnalogyDevice::setAnalogDownsample
int setAnalogDownsample(DAQ::type_t, DAQ::index_t, size_t)
Definition: analogy_device.cpp:449
AnalogyDevice::getChannelCount
size_t getChannelCount(DAQ::type_t) const
Definition: analogy_device.cpp:187
AnalogyDevice::setAnalogGain
int setAnalogGain(DAQ::type_t, DAQ::index_t, double)
Definition: analogy_device.cpp:424
AnalogyDevice::setAnalogReference
int setAnalogReference(DAQ::type_t, DAQ::index_t, DAQ::index_t)
Definition: analogy_device.cpp:388
AnalogyDevice::setDigitalDirection
int setDigitalDirection(DAQ::index_t, DAQ::direction_t)
Definition: analogy_device.cpp:477
AnalogyDevice::getAnalogDownsample
size_t getAnalogDownsample(DAQ::type_t, DAQ::index_t) const
Definition: analogy_device.cpp:252
AnalogyDevice::write
void write(void)
Definition: analogy_device.cpp:577
AnalogyDevice::doLoad
virtual void doLoad(const Settings::Object::State &)
Definition: analogy_device.cpp:651
AnalogyDevice::getAnalogReferenceString
std::string getAnalogReferenceString(DAQ::type_t, DAQ::index_t, DAQ::index_t) const
Definition: analogy_device.cpp:278
AnalogyDevice::setChannelActive
int setChannelActive(DAQ::type_t, DAQ::index_t, bool)
Definition: analogy_device.cpp:203
AnalogyDevice::getAnalogCalibrationState
bool getAnalogCalibrationState(DAQ::type_t, DAQ::index_t) const
Definition: analogy_device.h:68
AnalogyDevice::setAnalogCalibrationValue
int setAnalogCalibrationValue(DAQ::type_t, DAQ::index_t, double)
Definition: analogy_device.cpp:433
AnalogyDevice::setAnalogCalibrationActive
int setAnalogCalibrationActive(DAQ::type_t, DAQ::index_t, bool)
Definition: analogy_device.h:66
AnalogyDevice::AnalogyDevice
AnalogyDevice(a4l_desc_t *, std::string, IO::channel_t *, size_t)
Definition: analogy_device.cpp:31
AnalogyDevice::read
void read(void)
Definition: analogy_device.cpp:493
daq.h
AnalogyDevice::getAnalogCalibrationActive
bool getAnalogCalibrationActive(DAQ::type_t, DAQ::index_t) const
Definition: analogy_device.h:67
AnalogyDevice::~AnalogyDevice
~AnalogyDevice(void)
Definition: analogy_device.cpp:170
AnalogyDevice::getAnalogReferenceCount
size_t getAnalogReferenceCount(DAQ::type_t, DAQ::index_t) const
Definition: analogy_device.cpp:236
AnalogyDevice::setAnalogZeroOffset
int setAnalogZeroOffset(DAQ::type_t, DAQ::index_t, double)
Definition: analogy_device.cpp:415
AnalogyDevice::getChannelActive
bool getChannelActive(DAQ::type_t, DAQ::index_t) const
Definition: analogy_device.cpp:195
IO::channel_t
Definition: io.h:56
AnalogyDevice::getAnalogRangeCount
size_t getAnalogRangeCount(DAQ::type_t, DAQ::index_t) const
Definition: analogy_device.cpp:220
DAQ::direction_t
direction_t
Definition: daq.h:57
AnalogyDevice::getAnalogZeroOffset
double getAnalogZeroOffset(DAQ::type_t, DAQ::index_t) const
Definition: analogy_device.cpp:354
AnalogyDevice::getAnalogRange
DAQ::index_t getAnalogRange(DAQ::type_t, DAQ::index_t) const
Definition: analogy_device.cpp:314
AnalogyDevice::getAnalogGain
double getAnalogGain(DAQ::type_t, DAQ::index_t) const
Definition: analogy_device.cpp:346
Settings::Object::State
Definition: settings.h:62
AnalogyDevice::getAnalogReference
DAQ::index_t getAnalogReference(DAQ::type_t, DAQ::index_t) const
Definition: analogy_device.cpp:322
AnalogyDevice::getDigitalDirection
DAQ::direction_t getDigitalDirection(DAQ::index_t) const
Definition: analogy_device.cpp:468
AnalogyDevice::getAnalogRangeString
std::string getAnalogRangeString(DAQ::type_t, DAQ::index_t, DAQ::index_t) const
Definition: analogy_device.cpp:260
AnalogyDevice::doSave
virtual void doSave(Settings::Object::State &) const
Definition: analogy_device.cpp:692
DAQ::Device
Definition: daq.h:139
AnalogyDevice::setAnalogConversion
void setAnalogConversion(DAQ::type_t, DAQ::index_t)
Definition: analogy_device.h:62
AnalogyDevice::getAnalogUnits
DAQ::index_t getAnalogUnits(DAQ::type_t, DAQ::index_t) const
Definition: analogy_device.cpp:330
AnalogyDevice::getAnalogOffsetUnits
DAQ::index_t getAnalogOffsetUnits(DAQ::type_t, DAQ::index_t) const
Definition: analogy_device.cpp:338