ifw  0.0.1-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shutterConfig.hpp
Go to the documentation of this file.
1 
10 #ifndef DEVMGR_DEVICE_SHUTTER_CONFIG_HPP
11 #define DEVMGR_DEVICE_SHUTTER_CONFIG_HPP
12 
13 // System headers
14 #include <string>
15 
16 // Third party headers
17 #include <yaml-cpp/yaml.h>
18 
19 #include <fcf/common/iComm.hpp>
20 #include <devmgr/common/deviceConfig.hpp>
21 #include <devmgr/common/configSet.hpp>
22 #include <devmgr/common/dataContext.hpp>
23 #include <devmgr/devices/shutterRpcErrors.hpp>
24 #include <devmgr/devices/shutterHwErrors.hpp>
25 
26 namespace devmgr {
27  namespace shutter {
28 
29  // Constants for internal mapping
30  const std::string CI_ACTIVE_LOW_CLOSED = "low_closed";
31  const std::string CI_ACTIVE_LOW_FAULT = "low_fault";
32  const std::string CI_ACTIVE_LOW_OPEN = "low_open";
33  const std::string CI_ACTIVE_LOW_SWITCH = "low_switch";
34  const std::string CI_IGNORE_CLOSED = "ignore_closed";
35  const std::string CI_IGNORE_FAULT = "ignore_fault";
36  const std::string CI_IGNORE_OPEN = "ignore_open";
37  const std::string CI_INITIAL_STATE = "initial_state";
38  const std::string CI_TIMEOUT = "timeout";
39 
40  const bool DEFAULT_ACTIVE_LOW_CLOSE = false;
41  const bool DEFAULT_ACTIVE_LOW_FAULT = false;
42  const bool DEFAULT_ACTIVE_LOW_OPEN = false;
43  const bool DEFAULT_ACTIVE_LOW_SWITCH = false;
44  const bool DEFAULT_IGNORE_CLOSED = false;
45  const bool DEFAULT_IGNORE_FAULT = false;
46  const bool DEFAULT_IGNORE_OPEN = false;
47  const bool DEFAULT_INITIAL_STATE = false;
48  const unsigned int DEFAULT_TIMEOUT = 10000;
49 
50  // Specific shutter RPC
51  const std::string RPC_OPEN = "rpcOpen";
52  const std::string RPC_CLOSE = "rpcClose";
53 
54  // Specific constant values for shutter device state/substate
55  const short SUBSTATE_NOTREADY = 100;
56  const short SUBSTATE_INITIALISING = 101;
57  const short SUBSTATE_READY_CLOSE = 102;
58  const short SUBSTATE_READY_OPEN = 103;
59  const short SUBSTATE_STANDBY_FAILURE = 104;
60 
61  const short SUBSTATE_OP_DISABLING = 200;
62  const short SUBSTATE_OP_CLOSE = 201;
63  const short SUBSTATE_OP_CLOSING = 202;
64  const short SUBSTATE_OP_OPEN = 203;
65  const short SUBSTATE_OP_OPENING = 204;
66  const short SUBSTATE_OP_FAILURE = 205;
67 
68  const std::string SUBSTATE_NOTREADY_STR = "NotReady";
69  const std::string SUBSTATE_INITIALISING_STR = "Initialising";
70  const std::string SUBSTATE_READY_CLOSE_STR = "Ready/Close";
71  const std::string SUBSTATE_READY_OPEN_STR = "Ready/Open";
72  const std::string SUBSTATE_FAILURE_STR = "Failure";
73 
74  const std::string SUBSTATE_OP_DISABLING_STR = "Disabling";
75  const std::string SUBSTATE_OP_CLOSE_STR = "Close";
76  const std::string SUBSTATE_OP_CLOSING_STR = "Closing";
77  const std::string SUBSTATE_OP_OPEN_STR = "Open";
78  const std::string SUBSTATE_OP_OPENING_STR = "Opening";
79  const std::string SUBSTATE_OP_FAILURE_STR = "Failure";
80 
81  const std::unordered_map<short, std::string> SubstateMap = {
93  };
94 
95  const std::vector<std::string> cfgMapping = {
98  };
99 
100  const std::vector<std::string> statMapping = {
105  };
106 
107  const std::vector<std::string> rpcMapping = {
113  RPC_CLOSE,
114  RPC_OPEN
115  };
116 
124  class ShutterConfig : public devmgr::common::DeviceConfig {
125 
126  // Enumerations of configuration paramters
127  enum {
128  CFG_IGCLOSED = 0,
129  CFG_IGFAULT = 1,
130  CFG_IGOPEN = 2,
131  CFG_LOWCLOSED = 3,
132  CFG_LOWFAULT = 4,
133  CFG_LOWOPEN = 5,
134  CFG_LOWSWITCH = 6,
135  CFG_INITSTATE = 7,
136  CFG_TIMEOUT = 8,
137  END_ENUM_SHUTTER // WARNING: This should be always last enumerator.
138  };
139 
140  public:
141 
148  ShutterConfig(const std::string filename,
149  const std::string name);
150 
154  virtual ~ShutterConfig();
155 
164  virtual void ReadConfig();
165 
173  virtual void GetConfig(fcf::common::VectorVariant& params);
174 
179  virtual std::string GetMapFile();
180 
190  virtual void GetConfigList(std::vector<std::string>& cfg_list, std::string prefix);
191 
192 
193 
194  private:
195  devmgr::common::MapCfgBool m_map_cfg_bool;
196  devmgr::common::MapCfgUInt m_map_cfg_uint;
197 
198  };
199  }
200 }
201 
202 
203 #endif //DEVMGR_DEVICE_SHUTTER_CONFIG_HPP
const std::string CI_IGNORE_OPEN
Definition: shutterConfig.hpp:36
const bool DEFAULT_ACTIVE_LOW_CLOSE
Definition: shutterConfig.hpp:40
const std::string CI_INITIAL_STATE
Definition: shutterConfig.hpp:37
const unsigned int DEFAULT_TIMEOUT
Definition: shutterConfig.hpp:48
const std::string RPC_STOP
Definition: deviceConfig.hpp:45
const std::string SUBSTATE_OP_FAILURE_STR
Definition: shutterConfig.hpp:79
virtual void GetConfigList(std::vector< std::string > &cfg_list, std::string prefix)
Get configuration list.
Definition: shutterConfig.cpp:145
virtual ~ShutterConfig()
ShutterConfig destructor.
Definition: shutterConfig.cpp:67
const std::string SUBSTATE_FAILURE_STR
Definition: shutterConfig.hpp:72
std::map< int, CfgBool > MapCfgBool
Definition: deviceConfig.hpp:104
const std::string RPC_DISABLE
Definition: deviceConfig.hpp:44
const std::string CI_ACTIVE_LOW_FAULT
Definition: shutterConfig.hpp:31
const std::string RPC_CLOSE
Definition: shutterConfig.hpp:52
const std::string CI_STAT_ERROR_CODE
Definition: deviceConfig.hpp:53
const bool DEFAULT_ACTIVE_LOW_FAULT
Definition: shutterConfig.hpp:41
const short SUBSTATE_OP_OPENING
Definition: shutterConfig.hpp:65
const std::string SUBSTATE_OP_OPENING_STR
Definition: shutterConfig.hpp:78
const std::string CI_STAT_SUBSTATE
Definition: deviceConfig.hpp:49
const std::string CI_ACTIVE_LOW_CLOSED
Definition: shutterConfig.hpp:30
const std::string CI_TIMEOUT
Definition: shutterConfig.hpp:38
const bool DEFAULT_IGNORE_CLOSED
Definition: shutterConfig.hpp:44
const bool DEFAULT_ACTIVE_LOW_OPEN
Definition: shutterConfig.hpp:42
const std::string CI_ACTIVE_LOW_OPEN
Definition: shutterConfig.hpp:32
const std::string SUBSTATE_INITIALISING_STR
Definition: shutterConfig.hpp:69
const bool DEFAULT_IGNORE_FAULT
Definition: shutterConfig.hpp:45
const bool DEFAULT_INITIAL_STATE
Definition: shutterConfig.hpp:47
Device Configuration class.
Definition: deviceConfig.hpp:116
const std::string RPC_INIT
Definition: deviceConfig.hpp:42
const short SUBSTATE_OP_FAILURE
Definition: shutterConfig.hpp:66
const short SUBSTATE_READY_OPEN
Definition: shutterConfig.hpp:58
const std::vector< std::string > rpcMapping
Definition: shutterConfig.hpp:107
virtual void ReadConfig()
Read the configuration.
Definition: shutterConfig.cpp:71
const std::vector< std::string > statMapping
Definition: shutterConfig.hpp:100
const short SUBSTATE_READY_CLOSE
Definition: shutterConfig.hpp:57
const std::string CI_IGNORE_FAULT
Definition: shutterConfig.hpp:35
const std::string SUBSTATE_READY_CLOSE_STR
Definition: shutterConfig.hpp:70
const short SUBSTATE_OP_CLOSING
Definition: shutterConfig.hpp:63
const short SUBSTATE_OP_DISABLING
Definition: shutterConfig.hpp:61
virtual void GetConfig(fcf::common::VectorVariant &params)
Obtain the list of configuration parameters.
Definition: shutterConfig.cpp:116
const std::string RPC_OPEN
Definition: shutterConfig.hpp:51
const std::string SUBSTATE_OP_CLOSE_STR
Definition: shutterConfig.hpp:75
const std::string SUBSTATE_OP_OPEN_STR
Definition: shutterConfig.hpp:77
const std::string RPC_RESET
Definition: deviceConfig.hpp:46
const short SUBSTATE_OP_CLOSE
Definition: shutterConfig.hpp:62
virtual std::string GetMapFile()
Definition: shutterConfig.cpp:137
const bool DEFAULT_ACTIVE_LOW_SWITCH
Definition: shutterConfig.hpp:43
const std::string CI_STAT_LOCAL
Definition: deviceConfig.hpp:52
const std::vector< std::string > cfgMapping
Definition: shutterConfig.hpp:95
const std::string SUBSTATE_OP_CLOSING_STR
Definition: shutterConfig.hpp:76
std::map< int, CfgUInt > MapCfgUInt
Definition: deviceConfig.hpp:106
const short SUBSTATE_OP_OPEN
Definition: shutterConfig.hpp:64
const std::string CI_STAT_STATE
Definition: deviceConfig.hpp:50
const std::string SUBSTATE_NOTREADY_STR
Definition: shutterConfig.hpp:68
const std::unordered_map< short, std::string > SubstateMap
Definition: shutterConfig.hpp:81
ShutterConfig(const std::string filename, const std::string name)
MotorConfig constructor.
Definition: shutterConfig.cpp:26
const std::string CI_IGNORE_CLOSED
Definition: shutterConfig.hpp:34
const bool DEFAULT_IGNORE_OPEN
Definition: shutterConfig.hpp:46
const std::string RPC_ENABLE
Definition: deviceConfig.hpp:43
const short SUBSTATE_NOTREADY
Definition: shutterConfig.hpp:55
const short SUBSTATE_INITIALISING
Definition: shutterConfig.hpp:56
const std::string CI_ACTIVE_LOW_SWITCH
Definition: shutterConfig.hpp:33
const std::string SUBSTATE_OP_DISABLING_STR
Definition: shutterConfig.hpp:74
optional string name
Definition: topics.proto:50
const std::string SUBSTATE_READY_OPEN_STR
Definition: shutterConfig.hpp:71
const short SUBSTATE_STANDBY_FAILURE
Definition: shutterConfig.hpp:59