RTC Toolkit 5.0.0
Loading...
Searching...
No Matches
statusEstimator.hpp
Go to the documentation of this file.
1
13#ifndef RTCTK_RTCSUPERVISOR_STATUSESTIMATOR_HPP
14#define RTCTK_RTCSUPERVISOR_STATUSESTIMATOR_HPP
15
16#include <map>
17#include <set>
18#include <string>
19
20namespace rtctk::rtcSupervisor {
21
22// Set of default SRTC component states to expect
23constexpr auto STATE_OFF = "Off";
24constexpr auto STATE_STARTING = "On::NotOperational::Starting";
25constexpr auto STATE_NOT_READY = "On::NotOperational::NotReady";
26constexpr auto STATE_INITIALISING = "On::NotOperational::Initialising";
27constexpr auto STATE_READY = "On::NotOperational::Ready";
28constexpr auto STATE_ENABLING = "On::NotOperational::Enabling";
29constexpr auto STATE_DISABLING = "On::NotOperational::Disabling";
30constexpr auto STATE_IDLE = "On::Operational::Idle";
31constexpr auto STATE_RUNNING = "On::Operational::Running";
32constexpr auto STATE_GOING_RUNNING = "On::Operational::GoingRunning";
33constexpr auto STATE_GOING_IDLE = "On::Operational::GoingIdle";
34constexpr auto STATE_LOOP_OPENED = "On::Operational::Opened";
35constexpr auto STATE_LOOP_CLOSED = "On::Operational::Closed";
36constexpr auto STATE_LOOP_SUSPENDED = "On::Operational::Suspended";
37constexpr auto STATE_LOOP_SUSPENDING = "On::Operational::Suspending";
38constexpr auto STATE_LOOP_RESUMING = "On::Operational::Resuming";
39constexpr auto STATE_ERROR = "On::Operational::Error";
40constexpr auto STATE_RECOVERING = "On::Operational::Recovering";
41
42// Set of status strings that are understood by the IFW System Supervisor
43// use these while IFW System Supervisor still uses old status format with semicolon delimiter.
44constexpr auto STATUS_OFF = "Off;Off";
45constexpr auto STATUS_NOT_READY = "NotOperational;NotReady";
46constexpr auto STATUS_INITIALISING = "NotOperational;Initialising";
47constexpr auto STATUS_READY = "NotOperational;Ready";
48constexpr auto STATUS_IDLE = "Operational;Idle";
49constexpr auto STATUS_LOOP_OPENED = "Operational;LoopOpened";
50constexpr auto STATUS_LOOP_CLOSED = "Operational;LoopClosed";
51constexpr auto STATUS_ERROR = "Operational;Error";
52
53// Set of status strings that are understood by the IFW System Supervisor
54/* use these once IFW System Supervisor uses new status format
55constexpr auto STATUS_OFF = "Off";
56constexpr auto STATUS_NOT_READY = "On::NotOperational::NotReady";
57constexpr auto STATUS_INITIALISING = "On::NotOperational::Initialising";
58constexpr auto STATUS_READY = "On::NotOperational::Ready";
59constexpr auto STATUS_IDLE = "On::Operational::Idle";
60constexpr auto STATUS_LOOP_OPENED = "On::Operational::LoopOpened";
61constexpr auto STATUS_LOOP_CLOSED = "On::Operational::LoopClosed";
62constexpr auto STATUS_ERROR = "On::Operational::Error";
63*/
64
65// Helpers
66bool Contains(const std::string& cont, const std::string& item);
67bool ContainsAny(const std::string& cont, const std::set<std::string>& item);
68bool Contains(const std::map<std::string, std::string>& cont, const std::string& item);
69bool ContainsAny(const std::map<std::string, std::string>& cont, const std::set<std::string>& item);
70
75public:
77 virtual ~StatusEstimator() = default;
78
82 void Reset();
83
98 std::string EstimateStatus(const std::string& name, const std::string& state);
99
100protected:
113 virtual std::string ApplyEstimationHeuristic(const std::map<std::string, std::string>& states);
114
115 // cppcheck-suppress-begin unusedStructMember
116
117 std::map<std::string, std::string> m_states;
118 std::map<std::string, std::string> m_prev_states;
119 std::string m_prev_status;
120
121 // cppcheck-suppress-end unusedStructMember
122};
123
124} // namespace rtctk::rtcSupervisor
125
126#endif // RTCTK_RTCSUPERVISOR_STATUSESTIMATOR_HPP
Class for system status estimation.
Definition statusEstimator.hpp:74
StatusEstimator()
Definition statusEstimator.cpp:19
std::map< std::string, std::string > m_prev_states
Definition statusEstimator.hpp:118
std::string EstimateStatus(const std::string &name, const std::string &state)
Public method to estimate system status.
Definition statusEstimator.cpp:28
std::map< std::string, std::string > m_states
Definition statusEstimator.hpp:117
virtual std::string ApplyEstimationHeuristic(const std::map< std::string, std::string > &states)
The actual system status estimation algorithm.
Definition statusEstimator.cpp:37
std::string m_prev_status
Definition statusEstimator.hpp:119
void Reset()
Reset internal state of the StatusEstimator object.
Definition statusEstimator.cpp:22
elt::mal::future< std::string > InjectReqRepEvent(StateMachineEngine &engine)
Definition malEventInjector.hpp:23
Definition rtcSupervisor.cpp:24
constexpr auto STATUS_IDLE
Definition statusEstimator.hpp:48
constexpr auto STATUS_NOT_READY
Definition statusEstimator.hpp:45
bool Contains(const std::string &cont, const std::string &item)
Definition statusEstimator.cpp:69
constexpr auto STATE_READY
Definition statusEstimator.hpp:27
constexpr auto STATE_STARTING
Definition statusEstimator.hpp:24
constexpr auto STATUS_LOOP_CLOSED
Definition statusEstimator.hpp:50
constexpr auto STATE_GOING_IDLE
Definition statusEstimator.hpp:33
constexpr auto STATE_ENABLING
Definition statusEstimator.hpp:28
constexpr auto STATUS_ERROR
Definition statusEstimator.hpp:51
constexpr auto STATE_LOOP_SUSPENDED
Definition statusEstimator.hpp:36
constexpr auto STATE_LOOP_SUSPENDING
Definition statusEstimator.hpp:37
constexpr auto STATE_ERROR
Definition statusEstimator.hpp:39
constexpr auto STATE_IDLE
Definition statusEstimator.hpp:30
constexpr auto STATUS_OFF
Definition statusEstimator.hpp:44
constexpr auto STATE_NOT_READY
Definition statusEstimator.hpp:25
constexpr auto STATE_LOOP_CLOSED
Definition statusEstimator.hpp:35
constexpr auto STATE_LOOP_RESUMING
Definition statusEstimator.hpp:38
constexpr auto STATUS_INITIALISING
Definition statusEstimator.hpp:46
constexpr auto STATUS_LOOP_OPENED
Definition statusEstimator.hpp:49
bool ContainsAny(const std::string &cont, const std::set< std::string > &item)
Definition statusEstimator.cpp:73
constexpr auto STATE_LOOP_OPENED
Definition statusEstimator.hpp:34
constexpr auto STATE_INITIALISING
Definition statusEstimator.hpp:26
constexpr auto STATE_RECOVERING
Definition statusEstimator.hpp:40
constexpr auto STATE_DISABLING
Definition statusEstimator.hpp:29
constexpr auto STATE_GOING_RUNNING
Definition statusEstimator.hpp:32
constexpr auto STATE_RUNNING
Definition statusEstimator.hpp:31
constexpr auto STATE_OFF
Definition statusEstimator.hpp:23
constexpr auto STATUS_READY
Definition statusEstimator.hpp:47