UniSet 2.32.1
ComediInterface.h
1/*
2 * Copyright (c) 2015 Pavel Vainerman.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation, version 2.1.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Lesser Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16// -----------------------------------------------------------------------------
17#ifndef ComediInterface_H_
18#define ComediInterface_H_
19// -----------------------------------------------------------------------------
20#include <string>
21#include <comedilib.h>
22#include "Exceptions.h"
23//--------------------------------------------------------------------------
24namespace uniset
25{
26 // -----------------------------------------------------------------------------
29 {
30 public:
31 explicit ComediInterface( const std::string& dev, const std::string& cname );
32 virtual ~ComediInterface();
33
34 // throw uniset::Exception
35 virtual int getAnalogChannel( int subdev, int channel, int range = 0, int aref = AREF_GROUND, int adelay = 10 * 1000 ) const; // adelay = 10 мкс
36
37 // throw uniset::Exception
38 virtual void setAnalogChannel( int subdev, int channel, int data, int range = 0, int aref = AREF_GROUND ) const;
39
40 // throw uniset::Exception
41 virtual bool getDigitalChannel( int subdev, int channel ) const;
42
43 // throw uniset::Exception
44 virtual void setDigitalChannel( int subdev, int channel, bool bit ) const;
45
46 // Конфигурирование входов / выходов
47 enum ChannelType
48 {
49 DI = INSN_CONFIG_DIO_INPUT,
50 DO = INSN_CONFIG_DIO_OUTPUT,
51 AI = 100, // INSN_CONFIG_AIO_INPUT,
52 AO = 101 // INSN_CONFIG_AIO_OUTPUT
53 };
54
55 enum SubdevType
56 {
57 Unknown = 0,
58 TBI24_0 = 1,
59 TBI0_24 = 2,
60 TBI16_8 = 3,
61 GRAYHILL = 4
62 };
63
64 static std::string type2str( SubdevType t );
65 static SubdevType str2type( const std::string& s );
66
67 // throw uniset::Exception
68 virtual void configureSubdev( int subdev, SubdevType type ) const;
69
70 // throw uniset::Exception
71 virtual void configureChannel( int subdev, int channel, ChannelType type, int range = 0, int aref = 0 ) const;
72
73 inline const std::string devname() const
74 {
75 return dname;
76 }
77
78 inline const std::string cardname() const
79 {
80 return name;
81 }
82
83 protected:
84 ComediInterface(): card(nullptr) {}
85
86 comedi_t* card;
87 std::string dname;
88 std::string name;
89
90 private:
91 };
92 // --------------------------------------------------------------------------
93} // end of namespace uniset
94// -----------------------------------------------------------------------------
95#endif // ComediInterface_H_
96// -----------------------------------------------------------------------------
Definition ComediInterface.h:29
comedi_t * card
Definition ComediInterface.h:86
Definition Calibration.h:27