ifw  0.0.1-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lampConfig.hpp
Go to the documentation of this file.
1 
10 #ifndef DEVMGR_DEVICE_LAMP_CONFIG_HPP
11 #define DEVMGR_DEVICE_LAMP_CONFIG_HPP
12 
13 // System headers
14 #include <string>
15 
16 // Third party headers
17 #include <yaml-cpp/yaml.h>
18 
19 
20 #include <fcf/common/iComm.hpp>
21 #include <devmgr/common/deviceConfig.hpp>
22 #include <devmgr/common/configSet.hpp>
23 #include <devmgr/common/dataContext.hpp>
24 #include <devmgr/devices/lampRpcErrors.hpp>
25 #include <devmgr/devices/lampHwErrors.hpp>
26 
27 namespace devmgr {
28  namespace lamp {
29 
30  // Constants for internal mapping
31  const std::string CI_ACTIVE_LOW_FAULT = "low_fault";
32  const std::string CI_ACTIVE_LOW_ON = "low_on";
33  const std::string CI_ACTIVE_LOW_SWITCH = "low_switch";
34  const std::string CI_IGNORE_FAULT = "ignore_fault";
35  const std::string CI_INVERT_ANALOG = "invert_analog";
36  const std::string CI_ANALOG_THRESHOLD = "analog_threshold";
37  const std::string CI_ANALOG_RANGE = "analog_range";
38  const std::string CI_COOLDDOWN = "cooldown";
39  const std::string CI_MAX_ON = "maxon";
40  const std::string CI_WARMUP = "warmup";
41  const std::string CI_INITIAL_STATE = "initial_state";
42  const std::string CI_TIMEOUT = "timeout";
43 
44  // Specifics lamp status values
45  const std::string CI_STAT_INTENSITY = "intensity";
46 
47  // Specific lamp RPC
48  const std::string RPC_ON = "rpcSwitchOn";
49  const std::string RPC_OFF = "rpcSwitchOff";
50 
51  // Specific constant values for lamp device state/substate
52  const short SUBSTATE_NOTREADY = 100;
53  const short SUBSTATE_INITIALISING = 101;
54  const short SUBSTATE_READY_OFF = 102;
55  const short SUBSTATE_READY_ON = 103;
56  const short SUBSTATE_STANDBY_FAILURE = 104;
57 
58  const short SUBSTATE_OP_DISABLING = 200;
59  const short SUBSTATE_OP_OFF = 201;
60  const short SUBSTATE_OP_SWITCHING_OFF = 202;
61  const short SUBSTATE_OP_COOLING = 203;
62  const short SUBSTATE_OP_ON = 204;
63  const short SUBSTATE_OP_SWITCHING_ON = 205;
64  const short SUBSTATE_OP_WARMING = 206;
65  const short SUBSTATE_OP_FAILURE = 207;
66 
67  const std::string SUBSTATE_NOTREADY_STR = "NotReady";
68  const std::string SUBSTATE_INITIALISING_STR = "Initialising";
69  const std::string SUBSTATE_READY_OFF_STR = "Ready/Off";
70  const std::string SUBSTATE_READY_ON_STR = "Ready/On";
71  const std::string SUBSTATE_FAILURE_STR = "Failure";
72 
73  const std::string SUBSTATE_OP_DISABLING_STR = "Disabling";
74  const std::string SUBSTATE_OP_OFF_STR = "Off";
75  const std::string SUBSTATE_OP_SWITCHING_OFF_STR = "Switching off";
76  const std::string SUBSTATE_OP_COOLING_STR = "Cooling down";
77  const std::string SUBSTATE_OP_ON_STR = "On";
78  const std::string SUBSTATE_OP_SWITCHING_ON_STR = "Switching on";
79  const std::string SUBSTATE_OP_WARMING_STR = "Warming up";
80  const std::string SUBSTATE_OP_FAILURE_STR = "Failure";
81 
82  const std::unordered_map<short, std::string> SubstateMap = {
96  };
97 
98  const std::vector<std::string> cfgMapping = {
101  };
102 
103  const std::vector<std::string> statMapping = {
109  };
110 
111  const std::vector<std::string> rpcMapping = {
117  RPC_OFF,
118  RPC_ON
119  };
120 
128  class LampConfig : public devmgr::common::DeviceConfig
129  {
130 
131  // Enumerations of configuration paramters
132  enum {
133  CFG_LOWFAULT = 1,
134  CFG_LOWON = 2,
135  CFG_LOWSWITCH = 3,
136  CFG_IGFAULT = 4,
137  CFG_INANALOG = 5,
138  CFG_ANTHRES = 6,
139  CFG_ANRANGE = 7,
140  CFG_COOLDOWN = 8,
141  CFG_MAXON = 9,
142  CFG_WARMUP = 10,
143  CFG_INITSTATE = 11,
144  CFG_TIMEOUT = 12,
145  END_ENUM_LAMP // WARNING: This should be always last enumerator.
146  };
147 
148  public:
149 
155  LampConfig(const std::string filename,
156  const std::string name);
157 
161  virtual ~LampConfig();
162 
171  virtual void ReadConfig();
172 
180  virtual void GetConfig(fcf::common::VectorVariant& params);
181 
186  virtual std::string GetMapFile();
187 
197  virtual void GetConfigList(std::vector<std::string>& cfg_list,
198  std::string prefix);
199 
200  private:
201  devmgr::common::MapCfgBool m_map_cfg_bool;
202  devmgr::common::MapCfgInt m_map_cfg_int;
203  devmgr::common::MapCfgUInt m_map_cfg_uint;
204  };
205  }
206 }
207 
208 
209 #endif //DEVMGR_DEVICE_LAMP_CONFIG_H
const short SUBSTATE_OP_COOLING
Definition: lampConfig.hpp:61
const std::string SUBSTATE_OP_ON_STR
Definition: lampConfig.hpp:77
const std::string SUBSTATE_INITIALISING_STR
Definition: lampConfig.hpp:68
const std::string RPC_STOP
Definition: deviceConfig.hpp:45
const std::unordered_map< short, std::string > SubstateMap
Definition: lampConfig.hpp:82
std::map< int, CfgBool > MapCfgBool
Definition: deviceConfig.hpp:104
const std::string SUBSTATE_OP_SWITCHING_ON_STR
Definition: lampConfig.hpp:78
const std::string RPC_DISABLE
Definition: deviceConfig.hpp:44
virtual void GetConfig(fcf::common::VectorVariant &params)
Obtain the list of configuration parameters.
Definition: lampConfig.cpp:131
virtual ~LampConfig()
DeviceConfig destructor.
Definition: lampConfig.cpp:64
const std::string CI_STAT_ERROR_CODE
Definition: deviceConfig.hpp:53
const std::string SUBSTATE_OP_DISABLING_STR
Definition: lampConfig.hpp:73
const std::string CI_ANALOG_THRESHOLD
Definition: lampConfig.hpp:36
const std::string CI_STAT_SUBSTATE
Definition: deviceConfig.hpp:49
const std::string CI_STAT_INTENSITY
Definition: lampConfig.hpp:45
const std::string CI_COOLDDOWN
Definition: lampConfig.hpp:38
const std::string SUBSTATE_NOTREADY_STR
Definition: lampConfig.hpp:67
const std::string CI_INITIAL_STATE
Definition: lampConfig.hpp:41
Device Configuration class.
Definition: deviceConfig.hpp:116
const std::string RPC_INIT
Definition: deviceConfig.hpp:42
const std::vector< std::string > rpcMapping
Definition: lampConfig.hpp:111
const short SUBSTATE_STANDBY_FAILURE
Definition: lampConfig.hpp:56
const std::string CI_INVERT_ANALOG
Definition: lampConfig.hpp:35
const std::string SUBSTATE_OP_WARMING_STR
Definition: lampConfig.hpp:79
const short SUBSTATE_READY_ON
Definition: lampConfig.hpp:55
const std::string CI_TIMEOUT
Definition: lampConfig.hpp:42
LampConfig(const std::string filename, const std::string name)
DeviceConfig constructor.
Definition: lampConfig.cpp:27
const short SUBSTATE_OP_SWITCHING_ON
Definition: lampConfig.hpp:63
virtual void ReadConfig()
Read the configuration.
Definition: lampConfig.cpp:68
const std::string RPC_RESET
Definition: deviceConfig.hpp:46
const short SUBSTATE_READY_OFF
Definition: lampConfig.hpp:54
std::map< int, CfgInt > MapCfgInt
Definition: deviceConfig.hpp:105
const std::string SUBSTATE_OP_COOLING_STR
Definition: lampConfig.hpp:76
const std::string SUBSTATE_OP_OFF_STR
Definition: lampConfig.hpp:74
const short SUBSTATE_OP_SWITCHING_OFF
Definition: lampConfig.hpp:60
const std::string CI_WARMUP
Definition: lampConfig.hpp:40
const std::string SUBSTATE_OP_SWITCHING_OFF_STR
Definition: lampConfig.hpp:75
const std::string CI_STAT_LOCAL
Definition: deviceConfig.hpp:52
const std::string CI_IGNORE_FAULT
Definition: lampConfig.hpp:34
const std::string CI_ACTIVE_LOW_SWITCH
Definition: lampConfig.hpp:33
const std::vector< std::string > statMapping
Definition: lampConfig.hpp:103
const std::string CI_ANALOG_RANGE
Definition: lampConfig.hpp:37
const std::vector< std::string > cfgMapping
Definition: lampConfig.hpp:98
const short SUBSTATE_OP_ON
Definition: lampConfig.hpp:62
const std::string CI_ACTIVE_LOW_ON
Definition: lampConfig.hpp:32
const std::string SUBSTATE_OP_FAILURE_STR
Definition: lampConfig.hpp:80
const std::string SUBSTATE_FAILURE_STR
Definition: lampConfig.hpp:71
std::map< int, CfgUInt > MapCfgUInt
Definition: deviceConfig.hpp:106
const std::string CI_ACTIVE_LOW_FAULT
Definition: lampConfig.hpp:31
const short SUBSTATE_OP_WARMING
Definition: lampConfig.hpp:64
const std::string CI_STAT_STATE
Definition: deviceConfig.hpp:50
const std::string RPC_ON
Definition: lampConfig.hpp:48
const short SUBSTATE_INITIALISING
Definition: lampConfig.hpp:53
virtual void GetConfigList(std::vector< std::string > &cfg_list, std::string prefix)
Get configuration list.
Definition: lampConfig.cpp:168
const std::string RPC_OFF
Definition: lampConfig.hpp:49
const std::string RPC_ENABLE
Definition: deviceConfig.hpp:43
const short SUBSTATE_OP_OFF
Definition: lampConfig.hpp:59
virtual std::string GetMapFile()
Definition: lampConfig.cpp:161
const short SUBSTATE_OP_FAILURE
Definition: lampConfig.hpp:65
const short SUBSTATE_OP_DISABLING
Definition: lampConfig.hpp:58
const std::string CI_MAX_ON
Definition: lampConfig.hpp:39
const std::string SUBSTATE_READY_ON_STR
Definition: lampConfig.hpp:70
optional string name
Definition: topics.proto:50
const std::string SUBSTATE_READY_OFF_STR
Definition: lampConfig.hpp:69
const short SUBSTATE_NOTREADY
Definition: lampConfig.hpp:52