RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
operationalLogic.hpp
Go to the documentation of this file.
1
11#ifndef RTCKT_TELSUB_OPERATIONALLOGIC_HPP
12#define RTCKT_TELSUB_OPERATIONALLOGIC_HPP
13#include <atomic>
14#include <mutex>
15#include <optional>
16#include <thread>
17
23
24namespace rtctk::telSub {
25
76public:
92 std::unique_ptr<CorrelatorIf>&& correlator,
93 std::unique_ptr<ShmPublisherIf>&& shm_publisher,
96 std::unique_ptr<std::pmr::monotonic_buffer_resource>&& resource = {},
97 std::unique_ptr<std::byte[]>&& memory = {});
98
102 ~OperationalLogic() noexcept override;
103
111 void RunAsync() noexcept override;
112
118 void IdleAsync() noexcept override;
119
120 LastError GetLastError() const noexcept override;
121 uint64_t GetErrorCount() const noexcept override;
122
123private:
124 enum class State : uint8_t { Idle = 0, Run, Exit };
125
129 void ProcessingLoop();
133 void MonitoringLoop();
134
135 log4cplus::Logger& m_logger;
136
137 // First members because other members might have memory allocated to these
138 std::unique_ptr<std::byte[]> m_mem;
139 std::unique_ptr<std::pmr::monotonic_buffer_resource> m_resource;
141
142 const OperationalParams m_params;
143
148
158 std::mutex mutable m_error_mutex;
159 std::optional<CorrelationError> m_last_corr_error;
160 ShmPublisherIf::PublisherError m_last_pub_error;
161 uint64_t m_error_count{0};
163 componentFramework::AlertSource m_correlator_alert;
164 componentFramework::AlertSource m_blender_alert;
167
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
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:163
Interface to the operational logic implementation.
Definition operationalLogicIf.hpp:72
void RunAsync() noexcept override
Start publishing.
Definition operationalLogic.cpp:97
~OperationalLogic() noexcept override
Requests threads to exit and joins with it.
Definition operationalLogic.cpp:85
uint64_t GetErrorCount() const noexcept override
Get current error count.
Definition operationalLogic.cpp:115
LastError GetLastError() const noexcept override
Return last recorded error.
Definition operationalLogic.cpp:110
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:36
void IdleAsync() noexcept override
Stop publishing.
Definition operationalLogic.cpp:105
std::variant< std::monostate, BlenderError, ShmError > PublisherError
Definition shmPublisherIf.hpp:44
Header file for ComponentMetricsIf.
Declares CorrelatorIf.
Definition main.cpp:23
Declares OperationalLogicIf.
Declares ShmPublisher.
Describes last errors.
Definition operationalLogicIf.hpp:79
Configuration parameters needed for operational logic.
Definition operationalLogicIf.hpp:53