|
UniSet
2.6.0
|
00001 /* 00002 * Copyright (c) 2015 Pavel Vainerman. 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU Lesser General Public License as 00006 * published by the Free Software Foundation, version 2.1. 00007 * 00008 * This program is distributed in the hope that it will be useful, but 00009 * WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * Lesser General Lesser Public License for more details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public License 00014 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00015 */ 00016 // ----------------------------------------------------------------------------- 00017 #ifndef ComediInterface_H_ 00018 #define ComediInterface_H_ 00019 // ----------------------------------------------------------------------------- 00020 #include <string> 00021 #include <comedilib.h> 00022 #include "Exceptions.h" 00023 //-------------------------------------------------------------------------- 00024 namespace uniset 00025 { 00026 // ----------------------------------------------------------------------------- 00028 class ComediInterface 00029 { 00030 public: 00031 explicit ComediInterface( const std::string& dev ); 00032 ~ComediInterface(); 00033 00034 int getAnalogChannel( int subdev, int channel, int range = 0, int aref = AREF_GROUND ) 00035 throw(uniset::Exception); 00036 00037 void setAnalogChannel( int subdev, int channel, int data, int range = 0, int aref = AREF_GROUND ) 00038 throw(uniset::Exception); 00039 00040 bool getDigitalChannel( int subdev, int channel ) 00041 throw(uniset::Exception); 00042 00043 void setDigitalChannel( int subdev, int channel, bool bit ) 00044 throw(uniset::Exception); 00045 00046 00047 // Конфигурирование входов / выходов 00048 enum ChannelType 00049 { 00050 DI = INSN_CONFIG_DIO_INPUT, 00051 DO = INSN_CONFIG_DIO_OUTPUT, 00052 AI = 100, // INSN_CONFIG_AIO_INPUT, 00053 AO = 101 // INSN_CONFIG_AIO_OUTPUT 00054 }; 00055 00056 enum SubdevType 00057 { 00058 Unknown = 0, 00059 TBI24_0 = 1, 00060 TBI0_24 = 2, 00061 TBI16_8 = 3, 00062 GRAYHILL = 4 00063 }; 00064 00065 static std::string type2str( SubdevType t ); 00066 static SubdevType str2type( const std::string& s ); 00067 00068 void configureSubdev( int subdev, SubdevType type ) throw(uniset::Exception); 00069 00070 void configureChannel( int subdev, int channel, ChannelType type, int range = 0, int aref = 0 ) 00071 throw(uniset::Exception); 00072 00073 inline const std::string devname() 00074 { 00075 return dname; 00076 } 00077 00078 protected: 00079 00080 comedi_t* card; 00081 std::string dname; 00082 00083 private: 00084 }; 00085 // -------------------------------------------------------------------------- 00086 } // end of namespace uniset 00087 // ----------------------------------------------------------------------------- 00088 #endif // ComediInterface_H_ 00089 // ----------------------------------------------------------------------------- 00090
1.7.6.1