ifw-sup 5.1.0
 
Loading...
Searching...
No Matches
states.hpp
Go to the documentation of this file.
1
7
8#ifndef SUP_SYSSUP_COMMON_STATES_HPP
9#define SUP_SYSSUP_COMMON_STATES_HPP
10
11#include <boost/signals2.hpp>
12#include <boost/bimap.hpp>
13#include <boost/assign.hpp>
14
16
17 // State and substate definitions
18 constexpr auto KEY_STATUS_SUBSYS_STATE = "state";
19 constexpr auto KEY_STATUS_SUBSYS_SUBSTATE = "substate";
20
21 constexpr auto STATE_UNDEFINED_STR = "Undefined";
22 constexpr auto STATE_NOT_OP_ERROR_STR = "NotOpError";
23 constexpr auto STATE_ERROR_STR = "Error";
24 constexpr auto STATE_OFF_STR = "Off";
25 constexpr auto STATE_NOT_OPERATIONAL_STR = "NotOperational";
26 constexpr auto STATE_OPERATIONAL_STR = "Operational";
27
28 constexpr auto SUBSTATE_NOTREADY_STR = "NotReady";
29 constexpr auto SUBSTATE_INITIALISING_STR = "Initialising";
30 constexpr auto SUBSTATE_READY_STR = "Ready";
31 constexpr auto SUBSTATE_ENABLING_STR = "Enabling";
32 constexpr auto SUBSTATE_RECOVERING_STR = "Recovering";
33 constexpr auto SUBSTATE_IDLE_STR = "Idle";
34 constexpr auto SUBSTATE_BUSY_STR = "Busy";
35
36 //FCF Substates
37 constexpr auto SUBSTATE_SETTING_UP_STR = "SettingUp";
38
39 //CCF Substates
40 constexpr auto SUBSTATE_NOT_RECORDING_STR = "Acquiring";
41 constexpr auto SUBSTATE_RECORDING_STR = "Recording";
42 constexpr auto SUBSTATE_REC_PAUSED_STR = "RecPaused";
43
44 //OCM Substate
45 constexpr auto SUBSTATE_ACTIVE_STR = "Active";
46
47 //RTC Substates
48 constexpr auto SUBSTATE_OPENLOOP_STR = "OpenLoop";
49 constexpr auto SUBSTATE_CLOSEDLOOP_STR = "ClosedLoop";
50
58 struct State {
59 public:
60
61 enum class StateEnum : short {
62 OFF = -8,
66 };
67 enum class SubstateEnum : short {
69 ERROR = 95,
73 ENABLING = 103,
75 IDLE = 110,
76 BUSY = 115,
79 RECORDING = 201,
81 ACTIVE = 205,
82 OPENLOOP = 206,
84 };
85
86 using StateNumMap_t = boost::bimap<std::string, StateEnum>;
87 using SubstateNumMap_t = boost::bimap<std::string, SubstateEnum>;
88
89
90 //C++17 feature: you can define static members when they are inline.
91 //Used BOOST bidirectional maps.
92 inline static StateNumMap_t StateMap = boost::assign::list_of<State::StateNumMap_t::relation >
97
98 inline static SubstateNumMap_t SubstateMap = boost::assign::list_of<State::SubstateNumMap_t::relation >
114
115
121 inline static StateEnum GetState(const std::string& state);
127 inline static std::optional<std::string> GetStateStr(const StateEnum state);
133 inline static SubstateEnum GetSubstate(const std::string& substate);
139 inline static std::optional<std::string> GetSubstateStr(const SubstateEnum substate);
140
141 };
142
143}
144
145#include "states.ipp"
146
147#endif //SUP_SYSSUP_COMMON_STATES_HPP
ActionMgr class source file.
Definition actionMgr.cpp:30
constexpr auto SUBSTATE_NOT_RECORDING_STR
Definition states.hpp:40
constexpr auto STATE_NOT_OPERATIONAL_STR
Definition states.hpp:25
constexpr auto SUBSTATE_OPENLOOP_STR
Definition states.hpp:48
constexpr auto SUBSTATE_RECORDING_STR
Definition states.hpp:41
constexpr auto KEY_STATUS_SUBSYS_SUBSTATE
Definition states.hpp:19
constexpr auto SUBSTATE_BUSY_STR
Definition states.hpp:34
constexpr auto SUBSTATE_IDLE_STR
Definition states.hpp:33
constexpr auto SUBSTATE_ENABLING_STR
Definition states.hpp:31
constexpr auto SUBSTATE_NOTREADY_STR
Definition states.hpp:28
constexpr auto SUBSTATE_CLOSEDLOOP_STR
Definition states.hpp:49
constexpr auto SUBSTATE_RECOVERING_STR
Definition states.hpp:32
constexpr auto STATE_OPERATIONAL_STR
Definition states.hpp:26
constexpr auto SUBSTATE_READY_STR
Definition states.hpp:30
constexpr auto STATE_OFF_STR
Definition states.hpp:24
constexpr auto SUBSTATE_INITIALISING_STR
Definition states.hpp:29
constexpr auto SUBSTATE_REC_PAUSED_STR
Definition states.hpp:42
constexpr auto KEY_STATUS_SUBSYS_STATE
Definition states.hpp:18
constexpr auto STATE_NOT_OP_ERROR_STR
Definition states.hpp:22
constexpr auto STATE_ERROR_STR
Definition states.hpp:23
constexpr auto SUBSTATE_SETTING_UP_STR
Definition states.hpp:37
constexpr auto SUBSTATE_ACTIVE_STR
Definition states.hpp:45
constexpr auto STATE_UNDEFINED_STR
Definition states.hpp:21
The State struct.
Definition states.hpp:58
static StateNumMap_t StateMap
Definition states.hpp:92
boost::bimap< std::string, StateEnum > StateNumMap_t
Definition states.hpp:86
static StateEnum GetState(const std::string &state)
Get state as an enumeration.
static SubstateEnum GetSubstate(const std::string &substate)
Get state as an enumeration.
static std::optional< std::string > GetStateStr(const StateEnum state)
Get state as an optional string.
boost::bimap< std::string, SubstateEnum > SubstateNumMap_t
Definition states.hpp:87
static std::optional< std::string > GetSubstateStr(const SubstateEnum substate)
Get substate as an optional string.
StateEnum
Definition states.hpp:61
@ NOT_OPERATIONAL
Definition states.hpp:64
@ OPERATIONAL
Definition states.hpp:65
SubstateEnum
Definition states.hpp:67
@ NOT_OP_NOT_READY
Definition states.hpp:70
static SubstateNumMap_t SubstateMap
Definition states.hpp:98