RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
telRepubBusinessLogic.hpp
Go to the documentation of this file.
1
12#ifndef RTCTK_REUSABLECOMPONENT_TELREPUB_TELREPUBBUSINESSLOGIC_HPP
13#define RTCTK_REUSABLECOMPONENT_TELREPUB_TELREPUBBUSINESSLOGIC_HPP
14
15#include <fastdds/dds/publisher/DataWriter.hpp>
18
19#include "numapp/numapolicies.hpp"
26
27#include <rad/logger.hpp>
28#include <rad/mal/utils.hpp>
29
30#include <cstdint>
31
32namespace rtctk::telRepub {
33
34using namespace rtctk::componentFramework;
35
37
38using RepubWranglerFactory = std::function<WranglerFunction(int32_t)>;
39
40class PubThread;
41
42class PubThreadMudpi;
43
44class MudpiProcessor;
45
46class UdpReceiver;
47
53class TelRepubBusinessLogic : public LifeCycle::BizLogicIf {
54public:
57 std::string name, ServiceContainer& service, RepubWranglerFactory&& factory = [](auto x) {
58 return nullptr;
59 });
60
61 virtual ~TelRepubBusinessLogic();
62
63 void ActivityStarting(StopToken st) override;
64
65 void ActionClearAlerts() override;
66
67 void ActivityRecovering(StopToken st) override;
68
69 void ActivityInitialising(StopToken st) override;
70
71 void ActivityEnabling(StopToken st) override;
72
73 void ActivityDisabling(StopToken st) override;
74
75 void ActivityGoingRunning(StopToken st) override;
76
77 void ActivityGoingIdle(StopToken st) override;
78
79 void ActivityRunning(StopToken st) override;
80
81 void ActivityUpdating(StopToken st, const JsonPayload& args) override;
82
83 bool GuardUpdatingAllowed(const JsonPayload& args) override;
84
85protected:
90 void ReadGlobalCfg();
91
97
102
108 PubThreadMudpi& CreatePubThread(const std::string& dds_topic_path_static);
109
114 void CreateSimPubThreads();
115
119 void DeletePubThreads();
120
125 void CreateDdsPubs();
126
130 void DeleteDdsPubs();
131
136 void Monitor();
137
141 log4cplus::Logger& m_logger;
142
146 const std::string m_name;
147
148 std::unique_ptr<DdsPub> m_dds_pub;
149
154
159
165
171
175 std::vector<std::unique_ptr<UdpReceiver>> m_udp_receivers;
176
180 std::vector<std::unique_ptr<PubThread>> m_pub_threads;
181
186
190 std::chrono::milliseconds m_monitor_report_interval_ms = std::chrono::milliseconds(1000);
191
195 std::optional<numapp::NumaPolicies> monitoring_thread_policies = std::nullopt;
196};
197
198} // namespace rtctk::telRepub
199
200#endif // RTCTK_REUSABLECOMPONENT_TELREPUB_TELREPUBBUSINESSLOGIC_HPP
Declares AlertService.
Alert Service interface.
Definition alertServiceIf.hpp:138
Component metrics interface.
Definition componentMetricsIf.hpp:163
Base interface for all Runtime Configuration Repository adapters.
Definition runtimeRepoIf.hpp:26
Container class that holds services of any type.
Definition serviceContainer.hpp:38
Processing MUDPI data received by UDP receiver: rtctk::telRepub::UdpReceiver.
Definition mudpiProcessor.hpp:55
DDS publisher thread class that supports (re)publishing of MUDPI samples.
Definition ddsPubThread.hpp:141
DDS publisher thread class that supports production and simulation mode.
Definition ddsPubThread.hpp:59
void CreateMudpiReceivers()
Creates MUDPI receivers (rtctk::telRepub::UdpReceiver) incl corresponding Publisher threads,...
Definition telRepubBusinessLogic.cpp:95
std::unique_ptr< DdsPub > m_dds_pub
Definition telRepubBusinessLogic.hpp:148
void ActivityEnabling(StopToken st) override
Definition telRepubBusinessLogic.cpp:507
void ActivityStarting(StopToken st) override
Definition telRepubBusinessLogic.cpp:496
void ActivityInitialising(StopToken st) override
Definition telRepubBusinessLogic.cpp:478
const std::string m_name
Component name.
Definition telRepubBusinessLogic.hpp:146
void ActivityUpdating(StopToken st, const JsonPayload &args) override
Definition telRepubBusinessLogic.cpp:557
void ActivityGoingIdle(StopToken st) override
Definition telRepubBusinessLogic.cpp:516
PubThreadMudpi & CreatePubThread(const std::string &dds_topic_path_static)
Creates Publisher Thread (rtctk::telRepub::PubThread), reading configuration from the Runtime Configu...
Definition telRepubBusinessLogic.cpp:301
void Monitor()
Monitoring alerts etc that is executed in a loop.
Definition telRepubBusinessLogic.cpp:569
void DeleteMudpiReceivers()
Deletes UDPI receivers (rtctk::telRepub::UdpReceiver).
Definition telRepubBusinessLogic.cpp:229
AlertServiceIf & m_alerts
references to component alert service
Definition telRepubBusinessLogic.hpp:170
LifeCycle ComponentType
Definition telRepubBusinessLogic.hpp:55
TelRepubBusinessLogic(std::string name, ServiceContainer &service, RepubWranglerFactory &&factory=[](auto x) { return nullptr;})
Definition telRepubBusinessLogic.cpp:47
std::chrono::milliseconds m_monitor_report_interval_ms
Monitoring report interval in msecs.
Definition telRepubBusinessLogic.hpp:190
componentFramework::ComponentMetricsIf & m_metrics
references to component metrices service
Definition telRepubBusinessLogic.hpp:164
rtctk::componentFramework::ServiceContainer & m_service
Reference to container service.
Definition telRepubBusinessLogic.hpp:153
std::optional< numapp::NumaPolicies > monitoring_thread_policies
Monitoring thread policies.
Definition telRepubBusinessLogic.hpp:195
void ActivityRunning(StopToken st) override
Definition telRepubBusinessLogic.cpp:519
void ActivityRecovering(StopToken st) override
Definition telRepubBusinessLogic.cpp:504
RepubWranglerFactory m_wrangler_factory
Factory for wrangler functions, depending on the topic id.
Definition telRepubBusinessLogic.hpp:185
void ActionClearAlerts() override
Definition telRepubBusinessLogic.cpp:582
log4cplus::Logger & m_logger
Logger object reference of this class.
Definition telRepubBusinessLogic.hpp:141
virtual ~TelRepubBusinessLogic()
Definition telRepubBusinessLogic.cpp:60
std::vector< std::unique_ptr< UdpReceiver > > m_udp_receivers
vector of UDP receivers
Definition telRepubBusinessLogic.hpp:175
bool GuardUpdatingAllowed(const JsonPayload &args) override
Definition telRepubBusinessLogic.cpp:562
std::vector< std::unique_ptr< PubThread > > m_pub_threads
DDS publishers.
Definition telRepubBusinessLogic.hpp:180
void CreateSimPubThreads()
Creates all Simulated Publisher Threads (rtctk::telRepub::PubThread), reading configuration from the ...
Definition telRepubBusinessLogic.cpp:399
void ActivityGoingRunning(StopToken st) override
Definition telRepubBusinessLogic.cpp:513
componentFramework::RuntimeRepoIf & m_rtr
Reference to run-time repository needed to access the configuration.
Definition telRepubBusinessLogic.hpp:158
void ActivityDisabling(StopToken st) override
Definition telRepubBusinessLogic.cpp:510
void ReadGlobalCfg()
Reads Global configuration.
Definition telRepubBusinessLogic.cpp:66
void DeletePubThreads()
Deletes all (incl.
Definition telRepubBusinessLogic.cpp:474
void CreateDdsPubs()
Creates DDS publishers (rtctk::componentFramework::DdsPub), reading configuration from the Runtime Co...
Definition telRepubBusinessLogic.cpp:236
void DeleteDdsPubs()
Deletes DDS publishers (rtctk::componentFramework::DdsPub).
Definition telRepubBusinessLogic.cpp:288
Receiving UDP data asynchronously and forwards received packets to provided packet processors.
Definition udpReceiver.hpp:59
Header file for ComponentMetricsIf.
DDS Publisher.
Logging Support Library based on log4cplus.
rad::StopToken StopToken
Definition stopToken.hpp:19
nlohmann::json JsonPayload
Type requirements:
Definition jsonPayload.hpp:24
Definition ddsPubThread.cpp:16
Runnable< RtcComponent > LifeCycle
Definition telRepubBusinessLogic.hpp:36
std::function< std::error_code( const gsl::span< const gsl::span< const uint8_t > >, std::vector< uint8_t > &)> WranglerFunction
The wrangler function that is called with a span of spans containing the payload and an vector where ...
Definition wrangler.hpp:27
std::function< WranglerFunction(int32_t)> RepubWranglerFactory
Definition telRepubBusinessLogic.hpp:38
Wrangler: User extension point.
Lifecycle of a basic 'RtcComponent'.
Lifecycle Extension that makes an RTC Component 'Runnable'.
Header file for RuntimeRepoIf, which defines the API for RuntimeRepoAdapters.
Life cycle extension to make RtcComponent Runnable.
Definition runnable.hpp:30