RTXI  2.4
The Real-Time eXperiment Interface Documentation
daq.h
Go to the documentation of this file.
1 /*
2  The Real-Time eXperiment Interface (RTXI)
3  Copyright (C) 2011 Georgia Institute of Technology, University of Utah, Weill Cornell Medical College
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 
20 #ifndef DAQ_DEVICE_H
21 #define DAQ_DEVICE_H
22 
23 #include <io.h>
24 #include <map>
25 #include <rt.h>
26 
28 
32 namespace DAQ
33 {
34 
38 enum type_t
39 {
40  AI,
41  AO,
42  DIO,
43  DI,
44  DO,
45 };
49 typedef unsigned long index_t;
53 static const index_t INVALID = (0-1);
58 {
61 };
62 
63 class Device;
64 class Driver;
65 
73 class Manager
74 {
75 
76  friend class Device;
77  friend class Driver;
78 
79 public:
80 
87  static Manager *getInstance(void);
88 
99  void foreachDevice(void (*callback)(Device *,void *),void *param);
100 
110  Device *loadDevice(const std::string &driver,const std::list<std::string> &params);
111 
112 private:
113 
114  Manager(void) : mutex(Mutex::RECURSIVE) {};
115  ~Manager(void) {};
116  Manager(const Manager &) {};
117  Manager &operator=(const Manager &)
118  {
119  return *getInstance();
120  };
121 
122  static Manager *instance;
123 
124  void insertDevice(Device *);
125  void removeDevice(Device *);
126 
127  void registerDriver(Driver *,const std::string &);
128  void unregisterDriver(const std::string &);
129 
130  Mutex mutex;
131  std::list<Device *> devices;
132  std::map<std::string,Driver *> driverMap;
133 
134 }; // class Manager
135 
139 class Device : public RT::Device, public IO::Block
140 {
141 
142 public:
143 
150  Device(std::string,IO::channel_t *,size_t);
151  virtual ~Device(void);
152 
159  virtual size_t getChannelCount(type_t type) const=0;
167  virtual bool getChannelActive(type_t type,index_t index) const=0;
175  virtual int setChannelActive(type_t type,index_t index,bool state)=0;
183  virtual size_t getAnalogRangeCount(type_t type,index_t index) const=0;
191  virtual size_t getAnalogReferenceCount(type_t type,index_t index) const=0;
199  virtual size_t getAnalogUnitsCount(type_t type,index_t index) const=0;
200  virtual size_t getAnalogDownsample(type_t type,index_t index) const=0;
209  virtual std::string getAnalogRangeString(type_t type,index_t index,index_t range) const=0;
218  virtual std::string getAnalogReferenceString(type_t type,index_t index,index_t reference) const=0;
227  virtual std::string getAnalogUnitsString(type_t type,index_t index,index_t units) const=0;
235  virtual double getAnalogGain(type_t type,index_t index) const=0;
243  virtual double getAnalogZeroOffset(type_t type,index_t index) const=0;
251  virtual index_t getAnalogRange(type_t type,index_t index) const=0;
259  virtual index_t getAnalogReference(type_t type,index_t index) const=0;
267  virtual index_t getAnalogUnits(type_t type,index_t index) const=0;
275  virtual index_t getAnalogOffsetUnits(type_t type,index_t index) const=0;
284  virtual int setAnalogGain(type_t type,index_t index,double gain)=0;
293  virtual int setAnalogRange(type_t type,index_t index,index_t range)=0;
302  virtual int setAnalogZeroOffset(type_t type,index_t index,double offset)=0;
311  virtual int setAnalogReference(type_t type,index_t index,index_t reference)=0;
320  virtual int setAnalogUnits(type_t type,index_t index,index_t units)=0;
329  virtual int setAnalogOffsetUnits(type_t type,index_t index,index_t units)=0;
330  virtual int setAnalogDownsample(type_t type, index_t index, size_t downsample)=0;
331  virtual int setAnalogCounter(type_t type, index_t index)=0;
340  virtual int setAnalogCalibrationValue(type_t type,index_t index, double value)=0;
348  virtual double getAnalogCalibrationValue(type_t type,index_t index) const=0;
356  virtual int setAnalogCalibrationActive(type_t type,index_t index, bool state)=0;
364  virtual bool getAnalogCalibrationActive(type_t type,index_t index) const=0;
372  virtual bool getAnalogCalibrationState(type_t type,index_t index) const=0;
379  virtual direction_t getDigitalDirection(index_t index) const=0;
387  virtual int setDigitalDirection(index_t index,direction_t direction)=0;
388 
389 
390 }; // class Device
391 
397 class Driver
398 {
399 
400 public:
401 
407  Driver(const std::string &name);
408  virtual ~Driver(void);
409 
418  virtual Device *createDevice(const std::list<std::string> &args)=0;
419 
420 private:
421 
422  std::string name;
423 
424 }; // class Driver
425 
426 }; // namespace DAQ
427 
428 #endif // DAQ_DEVICE_H
DAQ::Driver::createDevice
virtual Device * createDevice(const std::list< std::string > &args)=0
DAQ::Device::setAnalogOffsetUnits
virtual int setAnalogOffsetUnits(type_t type, index_t index, index_t units)=0
DAQ::Manager::Driver
friend class Driver
Definition: daq.h:77
DAQ::type_t
type_t
Definition: daq.h:38
DAQ::Device::getChannelCount
virtual size_t getChannelCount(type_t type) const =0
DAQ::Device::getAnalogDownsample
virtual size_t getAnalogDownsample(type_t type, index_t index) const =0
DAQ::Device::getAnalogUnits
virtual index_t getAnalogUnits(type_t type, index_t index) const =0
DAQ::Device::setAnalogCounter
virtual int setAnalogCounter(type_t type, index_t index)=0
DAQ::index_t
unsigned long index_t
Definition: daq.h:49
DAQ::Device::getAnalogGain
virtual double getAnalogGain(type_t type, index_t index) const =0
DAQ::Device::setAnalogZeroOffset
virtual int setAnalogZeroOffset(type_t type, index_t index, double offset)=0
DAQ::Device::setAnalogCalibrationValue
virtual int setAnalogCalibrationValue(type_t type, index_t index, double value)=0
DAQ::Manager::getInstance
static Manager * getInstance(void)
Definition: daq.cpp:129
DAQ::Device::getAnalogRange
virtual index_t getAnalogRange(type_t type, index_t index) const =0
DAQ::Device::setAnalogUnits
virtual int setAnalogUnits(type_t type, index_t index, index_t units)=0
DAQ::Device::getAnalogCalibrationValue
virtual double getAnalogCalibrationValue(type_t type, index_t index) const =0
DAQ
DAQ Oriented Classes.
Definition: daq.h:32
DAQ::DI
@ DI
Definition: daq.h:43
RT::Device
Definition: rt.h:517
DAQ::Device::setChannelActive
virtual int setChannelActive(type_t type, index_t index, bool state)=0
Mutex
Definition: mutex.h:28
DAQ::Manager::foreachDevice
void foreachDevice(void(*callback)(Device *, void *), void *param)
Definition: daq.cpp:43
DAQ::Device::getChannelActive
virtual bool getChannelActive(type_t type, index_t index) const =0
DAQ::Device::getAnalogRangeCount
virtual size_t getAnalogRangeCount(type_t type, index_t index) const =0
DAQ::Device::getAnalogUnitsCount
virtual size_t getAnalogUnitsCount(type_t type, index_t index) const =0
DAQ::Device::setAnalogCalibrationActive
virtual int setAnalogCalibrationActive(type_t type, index_t index, bool state)=0
IO::Block
Definition: io.h:188
IO::channel_t
Definition: io.h:56
DAQ::Device::getAnalogZeroOffset
virtual double getAnalogZeroOffset(type_t type, index_t index) const =0
DAQ::direction_t
direction_t
Definition: daq.h:57
DAQ::DO
@ DO
Definition: daq.h:44
RT::Device::Device
Device(void)
Definition: rt.cpp:119
DAQ::Device::getAnalogReference
virtual index_t getAnalogReference(type_t type, index_t index) const =0
DAQ::Manager
Definition: daq.h:73
DAQ::DIO
@ DIO
Definition: daq.h:42
rt.h
DAQ::Device::getAnalogRangeString
virtual std::string getAnalogRangeString(type_t type, index_t index, index_t range) const =0
DAQ::Device::getDigitalDirection
virtual direction_t getDigitalDirection(index_t index) const =0
DAQ::Manager::loadDevice
Device * loadDevice(const std::string &driver, const std::list< std::string > &params)
Definition: daq.cpp:52
DAQ::Device::getAnalogCalibrationState
virtual bool getAnalogCalibrationState(type_t type, index_t index) const =0
DAQ::Device::getAnalogReferenceCount
virtual size_t getAnalogReferenceCount(type_t type, index_t index) const =0
DAQ::Device::getAnalogReferenceString
virtual std::string getAnalogReferenceString(type_t type, index_t index, index_t reference) const =0
io.h
DAQ::Device::setAnalogRange
virtual int setAnalogRange(type_t type, index_t index, index_t range)=0
DAQ::Device::setDigitalDirection
virtual int setDigitalDirection(index_t index, direction_t direction)=0
DAQ::Device::getAnalogCalibrationActive
virtual bool getAnalogCalibrationActive(type_t type, index_t index) const =0
DAQ::Device::setAnalogReference
virtual int setAnalogReference(type_t type, index_t index, index_t reference)=0
DAQ::Manager::Device
friend class Device
Definition: daq.h:76
DAQ::INPUT
@ INPUT
Definition: daq.h:59
DAQ::Device::getAnalogUnitsString
virtual std::string getAnalogUnitsString(type_t type, index_t index, index_t units) const =0
DAQ::Device::setAnalogGain
virtual int setAnalogGain(type_t type, index_t index, double gain)=0
DAQ::AI
@ AI
Definition: daq.h:40
DAQ::Driver::Driver
Driver(const std::string &name)
Definition: daq.cpp:33
DAQ::Driver::~Driver
virtual ~Driver(void)
Definition: daq.cpp:38
DAQ::OUTPUT
@ OUTPUT
Definition: daq.h:60
DAQ::Device::setAnalogDownsample
virtual int setAnalogDownsample(type_t type, index_t index, size_t downsample)=0
DAQ::Device
Definition: daq.h:139
DAQ::Device::~Device
virtual ~Device(void)
Definition: daq.cpp:28
DAQ::Device::getAnalogOffsetUnits
virtual index_t getAnalogOffsetUnits(type_t type, index_t index) const =0
DAQ::AO
@ AO
Definition: daq.h:41
DAQ::Driver
Definition: daq.h:397