|
libFAUDES
Sections
Index
|
iop_comedi.hGo to the documentation of this file.00001 /** @file iop_comedi.h Hardware access via comedi */ 00002 00003 /* 00004 FAU Discrete Event Systems Library (libfaudes) 00005 00006 Copyright (C) 2008, Thomas Moor, Sebastian Perk 00007 Exclusive copyright is granted to Klaus Schmidt 00008 00009 */ 00010 00011 00012 00013 #ifndef FAUDES_COMEDI_H 00014 #define FAUDES_COMEDI_H 00015 00016 #include "corefaudes.h" 00017 #include "iop_sdevice.h" 00018 00019 00020 // comedi support 00021 #ifdef FAUDES_IODEVICE_COMEDI 00022 00023 #include <comedilib.h> 00024 00025 namespace faudes { 00026 00027 00028 /** 00029 * A cDevice implements signal based io via the comedi framework. 00030 * 00031 * The comedi framework provides an abstract interface to all sorts of 00032 * IO devices in a control and data sampling context. It includes digital 00033 * IO which faudes uses for physical signals. To use the cDevice class, 00034 * you need to install the comedi library and load the comedi kernel modul. 00035 * See www.comedi.org for further details. 00036 * 00037 * Note: the current implementation of cDevice is tailored to the lrt 00038 * lab experiment. it expects the following configuration: 00039 * - advantech 1754 device on /dev/comedi0 (64 input signals) 00040 * - advantech 1752 device on /dev/comedi1 (64 output signals) 00041 * You may adapt/use the provided "comedi_configure" script to set up the 00042 * comedi framework. Future versions of cDevice will provide a more general support 00043 * of comedi devices. 00044 * 00045 * @ingroup IODevicePlugin 00046 */ 00047 00048 class cDevice : public sDevice { 00049 00050 FAUDES_TYPE_DECLARATION(ComediDevice,cDevice,sDevice) 00051 00052 public: 00053 /** 00054 * Default constructor 00055 */ 00056 cDevice(void); 00057 00058 /** 00059 * Copy constructor (TODO!) 00060 */ 00061 cDevice(const cDevice&) : sDevice() {}; 00062 00063 /** 00064 * Explicit destructor. 00065 */ 00066 virtual ~cDevice(void); 00067 00068 00069 /** 00070 * Activate the device. This function opens relevant comedi devices and enables 00071 * output execution and input reading. 00072 * It starts the background thread for edge detection and input event buffer. 00073 * 00074 * @exception Exception 00075 * - not yet configured (id 551) 00076 * - failed to open comedi devices (id 552) 00077 */ 00078 virtual void Start(void); 00079 00080 /** 00081 * Deactivate the device. This function closes the comedi devices 00082 * and disables output execution and input reading. 00083 * It stops the background thread and resets all output signals to 0. 00084 */ 00085 virtual void Stop(void); 00086 00087 protected: 00088 00089 /** Reads non-event-configuration data from tokenreader 00090 * 00091 * This function is part of the non-event-configuration data input-system. Device data 00092 * will be read w.r.t the class-hierarchy. Therefore first thing to do is to call the base 00093 * class. See sDevice::DoReadPreface for further information. 00094 * 00095 * After base-class function returned the device-system-file will be read. This file 00096 * is needed to establish the communication-interface to IO-card provided by the comedi- 00097 * framework. See www.comedi.org for more information 00098 * 00099 * Note: in order to keep the inputfile-layout as easy as possible no label will be used to separate 00100 * this data-section. Never the less a default-label ("ComediDevice") is specified. 00101 * 00102 * @param rTr 00103 * TokenReader to read from 00104 * @param rLabel 00105 * Section to read 00106 * @param pContext 00107 * Read context to provide contextual information 00108 * 00109 * */ 00110 void DoReadPreface(TokenReader& rTr,const std::string& rLabel="", const Type* pContext=0); 00111 00112 /** Writes non-event-configuration data from tokenreader 00113 * 00114 * This function is part of the non-event-configuration data output-system. Device data 00115 * will be written w.r.t the class-hierarchy. Therefore first thing to do is to the base 00116 * class. See sDevice::DoWritePreface for further information. 00117 * 00118 * After base-class function returned the device-system-file will be written to tokenwriter. 00119 * 00120 * Note: in order to keep the outputfile-layout as easy as possible no label will be used to separate 00121 * this data-section. Never the less a default-label ("ComediDevice") is specified. 00122 * 00123 * @param rTw 00124 * TokenWriter to write 00125 * @param rLabel 00126 * Section to write 00127 * @param pContext 00128 * Context to provide contextual information 00129 * 00130 * */ 00131 void DoWritePreface(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const ; 00132 00133 /** 00134 * Set output signal. 00135 * 00136 * Hardware output via comedi. 00137 * 00138 * @param bitaddr 00139 * Abstract bit address 00140 * @param value 00141 * True for logic level high; 00142 * 00143 */ 00144 virtual void DoWriteSignal(int bitaddr, bool value); 00145 00146 /** 00147 * Get input signal. 00148 * 00149 * Hardware input via comedi. 00150 * 00151 * @param bitaddr 00152 * Abstract bit address 00153 * @return 00154 * True for logic level high; 00155 */ 00156 virtual bool DoReadSignal(int bitaddr); 00157 00158 00159 /** System file needed for device-initialization */ 00160 std::string mSystemFile; 00161 00162 /** ComediDevice-handle */ 00163 comedi_t* mDev; 00164 00165 }; 00166 00167 } // namespace 00168 00169 #endif // configure 00170 00171 #endif // include |
libFAUDES 2.18b --- 2010-12-17 --- c++ source docu by doxygen 1.6.3