RTC Toolkit  2.0.0
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 "ddsPubThread.hpp"
17 #include "udpReceiver.hpp"
18 
22 
23 #include <rad/logger.hpp>
24 #include <rad/mal/utils.hpp>
25 
26 #include <cstdint>
27 #include <chrono>
28 #include <iostream>
29 
30 namespace rtctk::telRepub {
31 
32 using namespace rtctk::componentFramework;
33 
35 
42 public:
44  TelRepubBusinessLogic(const std::string& name,
45  ServiceContainer& services);
46 
47  virtual ~TelRepubBusinessLogic();
48 
49  void ActivityStarting(StopToken st) override;
50 
51  void ActivityRecovering(StopToken st) override;
52 
53  void ActivityInitialising(StopToken st) override;
54 
55  void ActivityEnabling(StopToken st) override;
56 
57  void ActivityDisabling(StopToken st) override;
58 
59  void ActivityGoingRunning(StopToken st) override;
60 
61  void ActivityGoingIdle(StopToken st) override;
62 
63  void ActivityRunning(StopToken st) override;
64 
65  void ActivityUpdating(StopToken st, Payload args) override;
66 
67  bool GuardUpdatingAllowed(Payload args) override;
68 
69 protected:
72  std::int32_t mudpi_topic_id_arg,
73  std::int32_t receiver_index_arg,
74  componentFramework::DataWriter* dw,
76  std::uint32_t queue_size)
77  : sim_freq(sim_freq_arg)
78  , mudpi_topic_id(mudpi_topic_id_arg)
79  , receiver_index(receiver_index_arg)
80  , publisher(std::make_unique<PubThread<rtctk::componentFramework::AgnosticTopic>>(dw, metrics, queue_size)) {
81  }
86  std::uint16_t sim_freq;
87  std::uint16_t mudpi_topic_id;
91  std::uint16_t receiver_index;
92  std::unique_ptr<PubThread<rtctk::componentFramework::AgnosticTopic>> publisher;
93  };
97  std::map<mudpi::uint16_t, PubThreadBase<>&>
98  BuildUdpReceiverAssociation(std::uint16_t receiver_idx);
99 
104  void CreateMudpiReceivers();
105 
109  void DeleteMudpiReceivers();
110 
117  void CreateDdsPubs();
121  void DeleteDdsPubs();
122 
126  const std::string m_name;
130  uint16_t m_sim_freq;
131 
132  std::unique_ptr<DdsPub> m_dds_pub;
133 
137  rtctk::componentFramework::ServiceContainer& m_service_container;
138 
143  componentFramework::ComponentMetricsIf& m_component_metrics;
144 
148  std::vector<std::unique_ptr<UdpReceiver>> m_udp_receivers;
149 
153  std::vector<DdsPublisherContext> m_pub_threads;
154 };
155 
156 } // namespace rtctk::telRepub
157 
158 #endif // RTCTK_REUSABLECOMPONENT_TELREPUB_TELREPUBBUSINESSLOGIC_HPP_
serviceContainer.hpp
A container that can hold any type of service.
udpReceiver.hpp
UDP receiver: receiving MUDPI and send to MUDPI processor.
rtctk::telRepub::PubThread
Definition: ddsPubThread.hpp:106
wscript.name
name
Definition: wscript:15
mudpi
Definition: mudpi.h:12
rtctk::componentFramework::Runnable::BizLogicIf
Definition: runnable.hpp:34
rtctk::telRepub::TelRepubBusinessLogic::DdsPublisherContext::DdsPublisherContext
DdsPublisherContext(DdsPublisherContext &&) noexcept=default
ddsPubThread.hpp
DDS agnostic topic publioshing thread.
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::telRepub
Definition: ddsPubThread.hpp:26
rtctk::telRepub::TelRepubBusinessLogic::DdsPublisherContext
Definition: telRepubBusinessLogic.hpp:70
rtctk::componentFramework::StopToken
rad::StopToken StopToken
Definition: stopToken.hpp:19
mudpi::uint16_t
unsigned short uint16_t
Definition: mudpi.h:15
rtctk::componentFramework::ComponentMetricsIf
Component metrics interface.
Definition: componentMetricsIf.hpp:177
runnable.hpp
Lifecycle Extension that makes an RTC Component 'Runnable'.
rtctk::telRepub::LifeCycle
Runnable< RtcComponent > LifeCycle
Definition: telRepubBusinessLogic.hpp:34
rtctk::componentFramework::Payload
std::string Payload
Definition: payload.hpp:19
rtctk::componentFramework::ServiceContainer
Container class that holds services of any type.
Definition: serviceContainer.hpp:35
ddsPub.hpp
DDS Publisher.
rtctk::telRepub::UdpReceiver
Receiving UDP data asynchronously and forwards received packets to provided packet processors.
Definition: udpReceiver.hpp:43
rtctk::componentFramework::DdsPub
All functionallty needed to create DDS entities for DDS data publishing is concentrated in this class...
Definition: ddsPub.hpp:42
rtcComponent.hpp
Lifecycle of a basic 'RtcComponent'.
mudpi::uint32_t
unsigned int uint32_t
Definition: mudpi.h:16
std
Definition: mudpiProcessingError.hpp:119
mudpi::int32_t
int int32_t
Definition: mudpi.h:17
rtctk::componentFramework::Runnable
Life cycle extension to make RtcComponent Runnable.
Definition: runnable.hpp:30
rtctk::telRepub::TelRepubBusinessLogic::DdsPublisherContext::DdsPublisherContext
DdsPublisherContext(std::uint16_t sim_freq_arg, std::int32_t mudpi_topic_id_arg, std::int32_t receiver_index_arg, componentFramework::DataWriter *dw, componentFramework::ComponentMetricsIf &metrics, std::uint32_t queue_size)
Definition: telRepubBusinessLogic.hpp:71
rtctk_config_tool.default
default
Enter an interactive shell.
Definition: rtctk_config_tool.py:119
rtctk::telRepub::PubThreadBase
DDS publisher thread class that provides queue with aggregated topic to be published by DDS.
Definition: ddsPubThread.hpp:36
rtctk
Definition: commandReplier.cpp:20
rtctk::telRepub::TelRepubBusinessLogic
Telemetry Republisher business logic.
Definition: telRepubBusinessLogic.hpp:41