UniSet  2.8.0
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 // -------------------------------------------------------------------------
23 namespace uniset
24 {
26  class FakeComediInterface final:
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, uniset::ObjectId icID, const std::shared_ptr<SharedMemory>& shm = nullptr, int numcards = 2, const std::string& prefix = "io" );
68  virtual ~FakeIOControl();
69 
71  static std::shared_ptr<FakeIOControl> init_iocontrol( int argc, const char* const* argv,
72  uniset::ObjectId icID, const std::shared_ptr<SharedMemory>& ic = nullptr,
73  const std::string& prefix = "io" );
74 
75 
76  // намеренно делаем public для доступа в тестах
77  FakeComediInterface* fcard = nullptr;
78 
79  protected:
80 
81  private:
82  };
83  // --------------------------------------------------------------------------
84 } // end of namespace uniset
85 // -----------------------------------------------------------------------------
86 #endif // FakeIOControl_H_
87 // -----------------------------------------------------------------------------
Definition: CommonEventLoop.h:14
Definition: ComediInterface.h:28
Definition: FakeIOControl.h:26
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:58
Definition: IOControl.h:237
Definition: FakeIOControl.h:63
long ObjectId
Definition: UniSetTypes_i.idl:30