UniSet @VERSION@
FakeIOControl.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 FakeIOControl_H_
18#define FakeIOControl_H_
19// -----------------------------------------------------------------------------
20#include <memory>
21#include "IOControl.h"
22// -------------------------------------------------------------------------
23namespace uniset
24{
27 public ComediInterface
28 {
29 public:
31 virtual ~FakeComediInterface();
32
33 static const size_t maxChannelNum = 32;
34
35 // Управление тестированием
36 // --------------------------------------------
37 // для простоты массивы специально объявлены в public
38 // warning: надо только иметь ввиду, что доступ к ним будет из разных потоков
39 // из теста и из потока опроса карт в/в (IOControl)
40 // в данном случае это не страшно..
41 // --------------------------------------------
42 std::vector<int> chInputs; // массив значений 'входов' (для проверки чтения)
43 mutable std::vector<int> chOutputs; // массив значений 'выходов' (для проверки функций вывода)
44
45
46 // --------------------------------------------
47 // при тестировании параметры range,aref,subdev игнорируются!
48
49 virtual int getAnalogChannel( int subdev, int channel, int range = 0, int aref = AREF_GROUND, int adelay = 10 * 1000 ) const override;
50
51 virtual void setAnalogChannel( int subdev, int channel, int data, int range = 0, int aref = AREF_GROUND ) const override;
52
53 virtual bool getDigitalChannel( int subdev, int channel ) const override;
54
55 virtual void setDigitalChannel( int subdev, int channel, bool bit ) const override;
56
57 virtual void configureSubdev( int subdev, SubdevType type ) const override;
58
59 virtual void configureChannel( int subdev, int channel, ChannelType type, int range = 0, int aref = 0 ) const override;
60 };
61 // --------------------------------------------------------------------------
64 public IOControl
65 {
66 public:
67 FakeIOControl( uniset::ObjectId id, xmlNode* cnode,
68 uniset::ObjectId icID, const std::shared_ptr<SharedMemory>& shm = nullptr, int numcards = 2, const std::string& prefix = "io" );
69 virtual ~FakeIOControl();
70
72 static std::shared_ptr<FakeIOControl> init_iocontrol( int argc, const char* const* argv,
73 uniset::ObjectId icID, const std::shared_ptr<SharedMemory>& ic = nullptr,
74 const std::string& prefix = "io" );
75
76
77 // намеренно делаем public для доступа в тестах
78 FakeComediInterface* fcard = nullptr;
79
80 protected:
81
82 private:
83 };
84 // --------------------------------------------------------------------------
85} // end of namespace uniset
86// -----------------------------------------------------------------------------
87#endif // FakeIOControl_H_
88// -----------------------------------------------------------------------------
Definition ComediInterface.h:29
Definition FakeIOControl.h:28
Definition FakeIOControl.h:65
static std::shared_ptr< FakeIOControl > init_iocontrol(int argc, const char *const *argv, uniset::ObjectId icID, const std::shared_ptr< SharedMemory > &ic=nullptr, const std::string &prefix="io")
Definition FakeIOControl.cc:59
Definition IOControl.h:241
Definition AccessConfig.h:30
long ObjectId
Definition UniSetTypes_i.idl:30