RTC Toolkit 4.0.2
Loading...
Searching...
No Matches
operationalLogic.hpp
Go to the documentation of this file.
1
12#ifndef RTCKT_TELSUB_OPERATIONALLOGIC_HPP
13#define RTCKT_TELSUB_OPERATIONALLOGIC_HPP
14#include <atomic>
15#include <chrono>
16#include <mutex>
17#include <optional>
18#include <thread>
19
25
26namespace rtctk::telSub {
27
78public:
94 std::unique_ptr<CorrelatorIf>&& correlator,
95 std::unique_ptr<ShmPublisherIf>&& shm_publisher,
98 std::unique_ptr<std::pmr::monotonic_buffer_resource>&& resource = {},
99 std::unique_ptr<std::byte[]>&& memory = {});
100
104 ~OperationalLogic() noexcept;
105
113 void RunAsync() RTCTK_NOEXCEPT override;
114
120 void IdleAsync() RTCTK_NOEXCEPT override;
121
122 LastError GetLastError() const RTCTK_NOEXCEPT override;
123 uint64_t GetErrorCount() const RTCTK_NOEXCEPT override;
124
125private:
126 enum class State : int { Idle = 0, Run, Exit };
127
131 void ProcessingLoop();
135 void MonitoringLoop();
136
137 log4cplus::Logger& m_logger;
138
139 // First members because other members might have memory allocated to these
140 std::unique_ptr<std::byte[]> m_mem;
141 std::unique_ptr<std::pmr::monotonic_buffer_resource> m_resource;
143
144 OperationalParams const m_params;
145
160 std::mutex mutable m_error_mutex;
161 std::error_code m_last_corr_error;
162 std::error_code m_last_pub_error;
163 uint64_t m_error_count;
165 componentFramework::AlertSource m_output_alert;
171 std::atomic<State> m_requested_state;
172 std::unique_ptr<CorrelatorIf> m_correlator;
173 std::unique_ptr<ShmPublisherIf> m_shm_publisher;
174 std::thread m_processing_thread;
179 std::thread m_monitoring_thread;
180};
181
182} // namespace rtctk::telSub
183
184#endif // RTCKT_TELSUB_OPERATIONALLOGIC_HPP
Header file for AlertServiceIf and related classes.
Interface to create AlertSource.
Definition: alertServiceIf.hpp:187
Models a single alert source that can be set or cleared.
Definition: alertServiceIf.hpp:48
Component metrics interface.
Definition: componentMetricsIf.hpp:184
Interface to the operational logic implementation.
Definition: operationalLogicIf.hpp:68
Implements the behaviour for Operational state.
Definition: operationalLogic.hpp:77
uint64_t GetErrorCount() const RTCTK_NOEXCEPT override
Get current error count.
Definition: operationalLogic.cpp:100
void IdleAsync() RTCTK_NOEXCEPT override
Stop publishing.
Definition: operationalLogic.cpp:90
~OperationalLogic() noexcept
Requests threads to exit and joins with it.
Definition: operationalLogic.cpp:72
LastError GetLastError() const RTCTK_NOEXCEPT override
Return last recorded error.
Definition: operationalLogic.cpp:95
void RunAsync() RTCTK_NOEXCEPT override
Start publishing.
Definition: operationalLogic.cpp:84
Header file for ComponentMetricsIf.
#define RTCTK_NOEXCEPT
Definition: config.hpp:63
Declares CorrelatorIf.
Definition: main.cpp:18
Declares OperationalLogicIf.
Declares ShmPublisher.
Describes last errors.
Definition: operationalLogicIf.hpp:76
Configuration parameters needed for operational logic.
Definition: operationalLogicIf.hpp:49