UniSet  2.2.1
ComediInterface.h
00001 // -----------------------------------------------------------------------------
00002 #ifndef ComediInterface_H_
00003 #define ComediInterface_H_
00004 // -----------------------------------------------------------------------------
00005 #include <string>
00006 #include <comedilib.h>
00007 #include "Exceptions.h"
00008 // -----------------------------------------------------------------------------
00010 class ComediInterface
00011 {
00012     public:
00013         explicit ComediInterface( const std::string& dev );
00014         ~ComediInterface();
00015 
00016         int getAnalogChannel( int subdev, int channel, int range = 0, int aref = AREF_GROUND )
00017         throw(UniSetTypes::Exception);
00018 
00019         void setAnalogChannel( int subdev, int channel, int data, int range = 0, int aref = AREF_GROUND )
00020         throw(UniSetTypes::Exception);
00021 
00022         bool getDigitalChannel( int subdev, int channel )
00023         throw(UniSetTypes::Exception);
00024 
00025         void setDigitalChannel( int subdev, int channel, bool bit )
00026         throw(UniSetTypes::Exception);
00027 
00028 
00029         // Конфигурирование входов / выходов
00030         enum ChannelType
00031         {
00032             DI     = INSN_CONFIG_DIO_INPUT,
00033             DO     = INSN_CONFIG_DIO_OUTPUT,
00034             AI    = 100,     // INSN_CONFIG_AIO_INPUT,
00035             AO    = 101    // INSN_CONFIG_AIO_OUTPUT
00036         };
00037 
00038         enum SubdevType
00039         {
00040             Unknown = 0,
00041             TBI24_0 = 1,
00042             TBI0_24 = 2,
00043             TBI16_8 = 3,
00044             GRAYHILL = 4
00045         };
00046 
00047         static std::string type2str( SubdevType t );
00048         static SubdevType str2type( const std::string& s );
00049 
00050         void configureSubdev( int subdev, SubdevType type )    throw(UniSetTypes::Exception);
00051 
00052 
00053         void configureChannel( int subdev, int channel, ChannelType type, int range = 0, int aref = 0 )
00054         throw(UniSetTypes::Exception);
00055 
00056         inline const std::string devname()
00057         {
00058             return dname;
00059         }
00060 
00061     protected:
00062 
00063         comedi_t* card;    
00064         std::string dname;
00065 
00066     private:
00067 };
00068 // -----------------------------------------------------------------------------
00069 #endif // ComediInterface_H_
00070 // -----------------------------------------------------------------------------
00071