ifw-sup 4.0.0
Loading...
Searching...
No Matches
states.hpp
Go to the documentation of this file.
1
9#ifndef SUP_SYSSUP_COMMON_STATES_HPP
10#define SUP_SYSSUP_COMMON_STATES_HPP
11
12#include <boost/signals2.hpp>
13#include <boost/bimap.hpp>
14#include <boost/assign.hpp>
15
16namespace sup::syssup::common {
17
18 // State and substate definitions
19 constexpr auto KEY_STATUS_SUBSYS_STATE = "state";
20 constexpr auto KEY_STATUS_SUBSYS_SUBSTATE = "substate";
21
22 constexpr auto STATE_UNDEFINED_STR = "Undefined";
23 constexpr auto STATE_NOT_OP_ERROR_STR = "NotOpError";
24 constexpr auto STATE_ERROR_STR = "Error";
25 constexpr auto STATE_OFF_STR = "Off";
26 constexpr auto STATE_NOT_OPERATIONAL_STR = "NotOperational";
27 constexpr auto STATE_OPERATIONAL_STR = "Operational";
28
29 constexpr auto SUBSTATE_NOTREADY_STR = "NotReady";
30 constexpr auto SUBSTATE_INITIALISING_STR = "Initialising";
31 constexpr auto SUBSTATE_READY_STR = "Ready";
32 constexpr auto SUBSTATE_ENABLING_STR = "Enabling";
33 constexpr auto SUBSTATE_RECOVERING_STR = "Recovering";
34 constexpr auto SUBSTATE_IDLE_STR = "Idle";
35 constexpr auto SUBSTATE_BUSY_STR = "Busy";
36
37 //FCF Substates
38 constexpr auto SUBSTATE_SETTING_UP_STR = "SettingUp";
39
40 //CCF Substates
41 constexpr auto SUBSTATE_NOT_RECORDING_STR = "NotRecording";
42 constexpr auto SUBSTATE_RECORDING_STR = "Recording";
43 constexpr auto SUBSTATE_REC_PAUSED_STR = "RecPaused";
44
45
53 struct State {
54 public:
55
56 enum class StateEnum : short {
57 OFF = -8,
58 UNDEFINED = -7,
60 OPERATIONAL = 2
61 };
62 enum class SubstateEnum : short {
63 UNDEFINED = 90,
64 ERROR = 95,
65 NOT_OP_NOT_READY = 100,
66 INITIALISING = 101,
67 NOT_OP_READY = 102,
68 ENABLING = 103,
69 RECOVERING = 106,
70 IDLE = 110,
71 BUSY = 115,
72 SETTING_UP = 130,
73 NOT_RECORDING = 200,
74 RECORDING = 201,
75 REC_PAUSED = 202
76 };
77
78 using StateNumMap_t = boost::bimap<std::string, StateEnum>;
79 using SubstateNumMap_t = boost::bimap<std::string, SubstateEnum>;
80
81
82 //C++17 feature: you can define static members when they are inline.
83 //Used BOOST bidirectional maps.
84 inline static StateNumMap_t StateMap = boost::assign::list_of<State::StateNumMap_t::relation >
89
90 inline static SubstateNumMap_t SubstateMap = boost::assign::list_of<State::SubstateNumMap_t::relation >
104
110 inline static StateEnum GetState(const std::string& state);
116 inline static std::optional<std::string> GetStateStr(const StateEnum state);
122 inline static SubstateEnum GetSubstate(const std::string& substate);
128 inline static std::optional<std::string> GetSubstateStr(const SubstateEnum substate);
129
130 };
131
132}
133
134#include "states.ipp"
135
136#endif //SUP_SYSSUP_COMMON_STATES_HPP
Definition: actionMgr.cpp:31
constexpr auto SUBSTATE_IDLE_STR
Definition: states.hpp:34
constexpr auto STATE_OFF_STR
Definition: states.hpp:25
constexpr auto SUBSTATE_RECOVERING_STR
Definition: states.hpp:33
constexpr auto KEY_STATUS_SUBSYS_SUBSTATE
Definition: states.hpp:20
constexpr auto SUBSTATE_RECORDING_STR
Definition: states.hpp:42
constexpr auto SUBSTATE_SETTING_UP_STR
Definition: states.hpp:38
constexpr auto STATE_ERROR_STR
Definition: states.hpp:24
constexpr auto STATE_NOT_OP_ERROR_STR
Definition: states.hpp:23
constexpr auto SUBSTATE_ENABLING_STR
Definition: states.hpp:32
constexpr auto SUBSTATE_NOT_RECORDING_STR
Definition: states.hpp:41
constexpr auto SUBSTATE_REC_PAUSED_STR
Definition: states.hpp:43
constexpr auto SUBSTATE_NOTREADY_STR
Definition: states.hpp:29
constexpr auto STATE_NOT_OPERATIONAL_STR
Definition: states.hpp:26
constexpr auto STATE_OPERATIONAL_STR
Definition: states.hpp:27
constexpr auto STATE_UNDEFINED_STR
Definition: states.hpp:22
constexpr auto SUBSTATE_INITIALISING_STR
Definition: states.hpp:30
constexpr auto SUBSTATE_READY_STR
Definition: states.hpp:31
constexpr auto SUBSTATE_BUSY_STR
Definition: states.hpp:35
constexpr auto KEY_STATUS_SUBSYS_STATE
Definition: states.hpp:19
The State struct.
Definition: states.hpp:53
static SubstateNumMap_t SubstateMap
Definition: states.hpp:90
static SubstateEnum GetSubstate(const std::string &substate)
Get state as an enumeration.
static StateNumMap_t StateMap
Definition: states.hpp:84
StateEnum
Definition: states.hpp:56
boost::bimap< std::string, StateEnum > StateNumMap_t
Definition: states.hpp:78
static std::optional< std::string > GetSubstateStr(const SubstateEnum substate)
Get substate as an optional string.
static StateEnum GetState(const std::string &state)
Get state as an enumeration.
static std::optional< std::string > GetStateStr(const StateEnum state)
Get state as an optional string.
SubstateEnum
Definition: states.hpp:62
boost::bimap< std::string, SubstateEnum > SubstateNumMap_t
Definition: states.hpp:79