RTC Toolkit 6.0.0-pre2
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 <mutex>
16#include <optional>
17#include <thread>
18
24
25namespace rtctk::telSub {
26
77public:
93 std::unique_ptr<CorrelatorIf>&& correlator,
94 std::unique_ptr<ShmPublisherIf>&& shm_publisher,
97 std::unique_ptr<std::pmr::monotonic_buffer_resource>&& resource = {},
98 std::unique_ptr<std::byte[]>&& memory = {});
99
103 ~OperationalLogic() noexcept override;
104
112 void RunAsync() noexcept override;
113
119 void IdleAsync() noexcept override;
120
121 LastError GetLastError() const noexcept override;
122 uint64_t GetErrorCount() const noexcept override;
123
124private:
125 enum class State : uint8_t { Idle = 0, Run, Exit };
126
130 void ProcessingLoop();
134 void MonitoringLoop();
135
136 log4cplus::Logger& m_logger;
137
138 // First members because other members might have memory allocated to these
139 std::unique_ptr<std::byte[]> m_mem;
140 std::unique_ptr<std::pmr::monotonic_buffer_resource> m_resource;
142
143 const OperationalParams m_params;
144
149
159 std::mutex mutable m_error_mutex;
160 std::optional<CorrelationError> m_last_corr_error;
161 ShmPublisherIf::PublisherError m_last_pub_error;
162 uint64_t m_error_count{0};
164 componentFramework::AlertSource m_correlator_alert;
165 componentFramework::AlertSource m_blender_alert;
168
172 std::atomic<State> m_requested_state;
173 std::unique_ptr<CorrelatorIf> m_correlator;
174 std::unique_ptr<ShmPublisherIf> m_shm_publisher;
175 std::thread m_processing_thread;
180 std::thread m_monitoring_thread;
181};
182
183} // namespace rtctk::telSub
184
185#endif // RTCKT_TELSUB_OPERATIONALLOGIC_HPP
Declares AlertService.
Alert Service interface.
Definition alertServiceIf.hpp:138
Models a single alert source that can be set or cleared.
Definition alertServiceIf.hpp:47
Component metrics interface.
Definition componentMetricsIf.hpp:164
Interface to the operational logic implementation.
Definition operationalLogicIf.hpp:73
void RunAsync() noexcept override
Start publishing.
Definition operationalLogic.cpp:98
~OperationalLogic() noexcept override
Requests threads to exit and joins with it.
Definition operationalLogic.cpp:86
uint64_t GetErrorCount() const noexcept override
Get current error count.
Definition operationalLogic.cpp:116
LastError GetLastError() const noexcept override
Return last recorded error.
Definition operationalLogic.cpp:111
OperationalLogic(OperationalParams params, std::unique_ptr< CorrelatorIf > &&correlator, std::unique_ptr< ShmPublisherIf > &&shm_publisher, componentFramework::ComponentMetricsIf &metrics, componentFramework::AlertServiceIf &alerts, std::unique_ptr< std::pmr::monotonic_buffer_resource > &&resource={}, std::unique_ptr< std::byte[]> &&memory={})
Spawns reader thread and starts subscribing to DDS data, but does not publish until StartAsync() is i...
Definition operationalLogic.cpp:37
void IdleAsync() noexcept override
Stop publishing.
Definition operationalLogic.cpp:106
std::variant< std::monostate, BlenderError, ShmError > PublisherError
Definition shmPublisherIf.hpp:45
Header file for ComponentMetricsIf.
Declares CorrelatorIf.
Definition main.cpp:24
Declares OperationalLogicIf.
Declares ShmPublisher.
Describes last errors.
Definition operationalLogicIf.hpp:80
Configuration parameters needed for operational logic.
Definition operationalLogicIf.hpp:54