RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
statusEstimator.hpp
Go to the documentation of this file.
1
11
12#ifndef RTCTK_RTCSUPERVISOR_STATUSESTIMATOR_HPP
13#define RTCTK_RTCSUPERVISOR_STATUSESTIMATOR_HPP
14
15#include <map>
16#include <set>
17#include <string>
18
19namespace rtctk::rtcSupervisor {
20
21// Set of default SRTC component states to expect
22constexpr auto STATE_OFF = "Off";
23constexpr auto STATE_STARTING = "On::NotOperational::Starting";
24constexpr auto STATE_NOT_READY = "On::NotOperational::NotReady";
25constexpr auto STATE_INITIALISING = "On::NotOperational::Initialising";
26constexpr auto STATE_READY = "On::NotOperational::Ready";
27constexpr auto STATE_ENABLING = "On::NotOperational::Enabling";
28constexpr auto STATE_DISABLING = "On::NotOperational::Disabling";
29constexpr auto STATE_IDLE = "On::Operational::Idle";
30constexpr auto STATE_RUNNING = "On::Operational::Running";
31constexpr auto STATE_GOING_RUNNING = "On::Operational::GoingRunning";
32constexpr auto STATE_GOING_IDLE = "On::Operational::GoingIdle";
33constexpr auto STATE_LOOP_OPENING = "On::Operational::Opening";
34constexpr auto STATE_LOOP_OPENED = "On::Operational::Opened";
35constexpr auto STATE_LOOP_CLOSING = "On::Operational::Closing";
36constexpr auto STATE_LOOP_CLOSED = "On::Operational::Closed";
37constexpr auto STATE_LOOP_SUSPENDED = "On::Operational::Suspended";
38constexpr auto STATE_LOOP_SUSPENDING = "On::Operational::Suspending";
39constexpr auto STATE_LOOP_RESUMING = "On::Operational::Resuming";
40constexpr auto STATE_ERROR = "On::Operational::Error";
41constexpr auto STATE_RECOVERING = "On::Operational::Recovering";
42
43// Set of status strings that are understood by the Status Widget and the IFW System Supervisor
44constexpr auto STATUS_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_OPEN_LOOP = "Operational::OpenLoop";
50constexpr auto STATUS_CLOSED_LOOP = "Operational::ClosedLoop";
51constexpr auto STATUS_ERROR = "Operational::Error";
52
53// Helpers
54bool Contains(const std::string& cont, const std::string& item);
55bool ContainsAny(const std::string& cont, const std::set<std::string>& item);
56bool Contains(const std::map<std::string, std::string>& cont, const std::string& item);
57bool ContainsAny(const std::map<std::string, std::string>& cont, const std::set<std::string>& item);
58
63public:
65 virtual ~StatusEstimator() = default;
66
70 void Reset();
71
86 std::string EstimateStatus(const std::string& name, const std::string& state);
87
88protected:
101 virtual std::string ApplyEstimationHeuristic(const std::map<std::string, std::string>& states);
102
103 // cppcheck-suppress-begin unusedStructMember
104
105 std::map<std::string, std::string> m_states;
106 std::map<std::string, std::string> m_prev_states;
107 std::string m_prev_status;
108
109 // cppcheck-suppress-end unusedStructMember
110};
111
112} // namespace rtctk::rtcSupervisor
113
114#endif // RTCTK_RTCSUPERVISOR_STATUSESTIMATOR_HPP
StatusEstimator()
Definition statusEstimator.cpp:18
std::map< std::string, std::string > m_prev_states
Definition statusEstimator.hpp:106
std::string EstimateStatus(const std::string &name, const std::string &state)
Public method to estimate system status.
Definition statusEstimator.cpp:27
std::map< std::string, std::string > m_states
Definition statusEstimator.hpp:105
virtual std::string ApplyEstimationHeuristic(const std::map< std::string, std::string > &states)
The actual system status estimation algorithm.
Definition statusEstimator.cpp:36
std::string m_prev_status
Definition statusEstimator.hpp:107
void Reset()
Reset internal state of the StatusEstimator object.
Definition statusEstimator.cpp:21
Definition alertAggregator.cpp:18
constexpr auto STATUS_IDLE
Definition statusEstimator.hpp:48
constexpr auto STATE_LOOP_OPENING
Definition statusEstimator.hpp:33
constexpr auto STATUS_NOT_READY
Definition statusEstimator.hpp:45
bool Contains(const std::string &cont, const std::string &item)
Definition statusEstimator.cpp:68
constexpr auto STATE_READY
Definition statusEstimator.hpp:26
constexpr auto STATE_STARTING
Definition statusEstimator.hpp:23
constexpr auto STATUS_OPEN_LOOP
Definition statusEstimator.hpp:49
constexpr auto STATE_GOING_IDLE
Definition statusEstimator.hpp:32
constexpr auto STATE_ENABLING
Definition statusEstimator.hpp:27
constexpr auto STATUS_ERROR
Definition statusEstimator.hpp:51
constexpr auto STATE_LOOP_SUSPENDED
Definition statusEstimator.hpp:37
constexpr auto STATE_LOOP_SUSPENDING
Definition statusEstimator.hpp:38
constexpr auto STATE_ERROR
Definition statusEstimator.hpp:40
constexpr auto STATE_IDLE
Definition statusEstimator.hpp:29
constexpr auto STATUS_OFF
Definition statusEstimator.hpp:44
constexpr auto STATE_NOT_READY
Definition statusEstimator.hpp:24
constexpr auto STATE_LOOP_CLOSED
Definition statusEstimator.hpp:36
constexpr auto STATUS_CLOSED_LOOP
Definition statusEstimator.hpp:50
constexpr auto STATE_LOOP_RESUMING
Definition statusEstimator.hpp:39
constexpr auto STATE_LOOP_CLOSING
Definition statusEstimator.hpp:35
constexpr auto STATUS_INITIALISING
Definition statusEstimator.hpp:46
bool ContainsAny(const std::string &cont, const std::set< std::string > &item)
Definition statusEstimator.cpp:72
constexpr auto STATE_LOOP_OPENED
Definition statusEstimator.hpp:34
constexpr auto STATE_INITIALISING
Definition statusEstimator.hpp:25
constexpr auto STATE_RECOVERING
Definition statusEstimator.hpp:41
constexpr auto STATE_DISABLING
Definition statusEstimator.hpp:28
constexpr auto STATE_GOING_RUNNING
Definition statusEstimator.hpp:31
constexpr auto STATE_RUNNING
Definition statusEstimator.hpp:30
constexpr auto STATE_OFF
Definition statusEstimator.hpp:22
constexpr auto STATUS_READY
Definition statusEstimator.hpp:47