ifw-fgf 1.0.0-pre1
Loading...
Searching...
No Matches
state.hpp
Go to the documentation of this file.
1
7#ifndef FGF_COM_STATE_HPP_H_
8#define FGF_COM_STATE_HPP_H_
9
10#include <boost/signals2.hpp>
11#include <boost/bimap.hpp>
12#include <boost/assign.hpp>
13#include <boost/algorithm/string.hpp>
14
15namespace ifw::fgf::common {
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 constexpr auto SUBSTATE_ACQUIRING_STR = "Acquiring";
37
45 struct State {
46 public:
47
51 enum class StateEnum : short {
52 OFF = -8,
53 UNDEFINED = -7,
55 OPERATIONAL = 2
56 };
57
61 enum class SubstateEnum : short {
62 UNDEFINED = 90,
63 ERROR = 95,
64 NOT_OP_NOT_READY = 100,
65 INITIALISING = 101,
66 NOT_OP_READY = 102,
67 ENABLING = 103,
68 IDLE = 110,
69 BUSY = 115,
70 ACQUIRING = 130
71
72 };
73
74 using StateNumMap_t = boost::bimap<std::string, StateEnum>;
75 using SubstateNumMap_t = boost::bimap<std::string, SubstateEnum>;
76
77 // C++17 feature: you can define static members when they are inline.
78 // Used BOOST bidirectional maps.
79 inline static StateNumMap_t StateMap =
80 boost::assign::list_of<State::StateNumMap_t::relation>
85
87 boost::assign::list_of<State::SubstateNumMap_t::relation>
97
103 inline static std::optional<StateEnum> GetState(const std::string& state);
104
110 inline static std::optional<std::string> GetStateStr(const StateEnum state);
111
117 inline static std::optional<SubstateEnum> GetSubstate(const std::string& substate);
118
124 inline static std::optional<std::string> GetSubstateStr(const SubstateEnum substate);
125
126 };
127
128}
129
130#include "state.ipp"
131
132#endif // FGF_COM_STATE_HPP_H_
Frame Grabber Camera Base Class definitions.
Definition binarySemaphore.hpp:43
constexpr auto SUBSTATE_READY_STR
Definition state.hpp:30
constexpr auto KEY_STATUS_SUBSYS_STATE
Definition state.hpp:18
constexpr auto SUBSTATE_RECOVERING_STR
Definition state.hpp:32
constexpr auto SUBSTATE_NOTREADY_STR
Definition state.hpp:28
constexpr auto KEY_STATUS_SUBSYS_SUBSTATE
Definition state.hpp:19
constexpr auto STATE_ERROR_STR
Definition state.hpp:23
constexpr auto SUBSTATE_BUSY_STR
Definition state.hpp:34
constexpr auto STATE_NOT_OPERATIONAL_STR
Definition state.hpp:25
constexpr auto STATE_OFF_STR
Definition state.hpp:24
constexpr auto SUBSTATE_ENABLING_STR
Definition state.hpp:31
constexpr auto SUBSTATE_INITIALISING_STR
Definition state.hpp:29
constexpr auto STATE_NOT_OP_ERROR_STR
Definition state.hpp:22
constexpr auto SUBSTATE_IDLE_STR
Definition state.hpp:33
constexpr auto SUBSTATE_ACQUIRING_STR
Definition state.hpp:36
constexpr auto STATE_UNDEFINED_STR
Definition state.hpp:21
constexpr auto STATE_OPERATIONAL_STR
Definition state.hpp:26
State struct defining enums to handle states/substates.
Definition state.hpp:45
StateEnum
State enums definition.
Definition state.hpp:51
static std::optional< std::string > GetSubstateStr(const SubstateEnum substate)
Get substate as an optional string.
static std::optional< SubstateEnum > GetSubstate(const std::string &substate)
Get state as an enumeration.
SubstateEnum
Substate enums definition.
Definition state.hpp:61
static std::optional< 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.
static SubstateNumMap_t SubstateMap
Definition state.hpp:86
boost::bimap< std::string, StateEnum > StateNumMap_t
Definition state.hpp:74
boost::bimap< std::string, SubstateEnum > SubstateNumMap_t
Definition state.hpp:75
static StateNumMap_t StateMap
Definition state.hpp:79