ifw-sup 5.1.0
 
Loading...
Searching...
No Matches
dataContext.hpp
Go to the documentation of this file.
1
7
8#ifndef SUP_SUBSIM_COMMON_DATA_CONTEXT_HPP_
9#define SUP_SUBSIM_COMMON_DATA_CONTEXT_HPP_
10
11#include <unordered_map>
12
13#include <rad/topicPub.hpp>
14#include <rad/mal/publisher.hpp>
15
17#include <ifw/core/utils/bat/dbInterface.hpp>
18#include <Stdif.hpp>
19
20
22
23 // Constants for state values
25 const short SRV_STATE_OPERATIONAL = 2;
26
27 // Constants for substate values
28 const short SRV_SUBSTATE_NOTREADY = 1;
29 const short SRV_SUBSTATE_READY = 2;
30 const short SRV_SUBSTATE_IDLE = 3;
32 const short SRV_SUBSTATE_ENABLING = 5;
33 const short SRV_SUBSTATE_SETTINGUP = 6;
34 const short SRV_SUBSTATE_ERROR = 10;
35 const short SRV_SUBSTATE_OPENLOOP = 206;
36 const short SRV_SUBSTATE_CLOSEDLOOP = 207;
37
38 const std::string SRV_STATE_NOT_OPERATIONAL_STR = "NotOperational";
39 const std::string SRV_STATE_OPERATIONAL_STR = "Operational";
40 const std::string SRV_STATE_UNAVAILABLE_STR = "Unavailable";
41
42 const std::string SRV_SUBSTATE_NOTREADY_STR = "NotReady";
43 const std::string SRV_SUBSTATE_READY_STR = "Ready";
44 const std::string SRV_SUBSTATE_IDLE_STR = "Idle";
45 const std::string SRV_SUBSTATE_INITIALISING_STR = "Initialising";
46 const std::string SRV_SUBSTATE_ENABLING_STR = "Enabling";
47 const std::string SRV_SUBSTATE_SETTINGUP_STR = "SettingUp";
48 const std::string SRV_SUBSTATE_ERROR_STR = "Error";
49 const std::string SRV_SUBSTATE_OPENLOOP_STR = "OpenLoop";
50 const std::string SRV_SUBSTATE_CLOSEDLOOP_STR = "ClosedLoop";
51
52
57
62
74
86
92 public:
103
104 DataContext(Config& config, bool with_publisher = true, bool with_oldb = true);
105
109 virtual ~DataContext();
110
114 void ReloadConfig();
115
119 void UpdateDb();
120
121
125 Config& GetConfig();
126
127 short GetState();
128 std::string GetStateStr();
129 void SetState(const short state);
130 void SetState(const std::string state);
131 short GetSubstate();
132 std::string GetSubstateStr();
133 void SetSubstate(const short state);
134 void SetSubstate(const std::string state);
135
136 void PublishStates();
137
138 DataContext(const DataContext&) = delete;
140
141 private:
142 Config& m_config;
143 std::unique_ptr<ifw::core::utils::bat::DbInterface> m_db_interface;
145 std::unique_ptr<rad::cii::Publisher<stdif::Status>> m_publisher;
146
147 short m_state;
148 short m_substate;
149 log4cplus::Logger m_logger;
150 };
151
152} // namespace devmgr
153
154#endif // SUP_SUBSIM_COMMON_DATA_CONTEXT_HPP_
Definition config.hpp:69
DataContext & operator=(const DataContext &)=delete
Disable assignment operator.
std::string GetStateStr()
Definition dataContext.cpp:92
void SetState(const short state)
Definition dataContext.cpp:102
DataContext(Config &config, bool with_publisher=true, bool with_oldb=true)
Definition dataContext.cpp:20
short GetSubstate()
Definition dataContext.cpp:116
short GetState()
Definition dataContext.cpp:88
void SetSubstate(const short state)
Definition dataContext.cpp:130
Config & GetConfig()
Definition dataContext.cpp:83
std::string GetSubstateStr()
Definition dataContext.cpp:120
void UpdateDb()
Definition dataContext.cpp:63
virtual ~DataContext()
Definition dataContext.cpp:50
void PublishStates()
Definition dataContext.cpp:145
DataContext(const DataContext &)=delete
Disable copy constructor.
void ReloadConfig()
Definition dataContext.cpp:56
ActionMgr class source file.
Definition actionMgr.cpp:28
const std::string SRV_SUBSTATE_ERROR_STR
Definition dataContext.hpp:48
const short SRV_SUBSTATE_IDLE
Definition dataContext.hpp:30
const short SRV_SUBSTATE_ERROR
Definition dataContext.hpp:34
const std::string SRV_SUBSTATE_SETTINGUP_STR
Definition dataContext.hpp:47
const std::string SRV_STATE_NOT_OPERATIONAL_STR
Definition dataContext.hpp:38
const std::string SRV_SUBSTATE_READY_STR
Definition dataContext.hpp:43
const short SRV_SUBSTATE_INITIALISING
Definition dataContext.hpp:31
const short SRV_SUBSTATE_SETTINGUP
Definition dataContext.hpp:33
const std::string SRV_STATE_OPERATIONAL_STR
Definition dataContext.hpp:39
const std::string SRV_SUBSTATE_INITIALISING_STR
Definition dataContext.hpp:45
const std::unordered_map< short, std::string > SrvSubstateMap
Definition dataContext.hpp:63
const std::unordered_map< std::string, short > SrvSubstateStrMap
Definition dataContext.hpp:75
const short SRV_STATE_OPERATIONAL
Definition dataContext.hpp:25
const std::string SRV_SUBSTATE_OPENLOOP_STR
Definition dataContext.hpp:49
const short SRV_SUBSTATE_CLOSEDLOOP
Definition dataContext.hpp:36
const short SRV_SUBSTATE_READY
Definition dataContext.hpp:29
const std::string SRV_SUBSTATE_ENABLING_STR
Definition dataContext.hpp:46
const std::string SRV_STATE_UNAVAILABLE_STR
Definition dataContext.hpp:40
const std::unordered_map< short, std::string > SrvStateMap
Definition dataContext.hpp:53
const std::string SRV_SUBSTATE_IDLE_STR
Definition dataContext.hpp:44
const std::string SRV_SUBSTATE_CLOSEDLOOP_STR
Definition dataContext.hpp:50
const short SRV_SUBSTATE_NOTREADY
Definition dataContext.hpp:28
const short SRV_SUBSTATE_OPENLOOP
Definition dataContext.hpp:35
const short SRV_SUBSTATE_ENABLING
Definition dataContext.hpp:32
const std::string SRV_SUBSTATE_NOTREADY_STR
Definition dataContext.hpp:42
const short SRV_STATE_NOT_OPERATIONAL
Definition dataContext.hpp:24
const std::unordered_map< std::string, short > SrvStateStrMap
Definition dataContext.hpp:58