RTC Toolkit  1.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 using namespace rtctk::componentFramework;
31 using namespace std::chrono_literals;
32 
33 namespace rtctk::telRepub {
34 
36 
43 public:
45  TelRepubBusinessLogic(const std::string& name,
46  ServiceContainer& services);
47 
48  virtual ~TelRepubBusinessLogic();
49 
50  void ActivityStarting(StopToken st) override;
51 
52  void ActivityRecovering(StopToken st) override;
53 
54  void ActivityInitialising(StopToken st) override;
55 
56  void ActivityEnabling(StopToken st) override;
57 
58  void ActivityDisabling(StopToken st) override;
59 
60  void ActivityGoingRunning(StopToken st) override;
61 
62  void ActivityGoingIdle(StopToken st) override;
63 
64  void ActivityRunning(StopToken st) override;
65 
66  void ActivityUpdating(StopToken st, Payload args) override;
67 
68  bool GuardUpdatingAllowed(Payload args) override;
69 
70 protected:
73  std::int32_t mudpi_topic_id_arg,
74  std::int32_t receiver_index_arg,
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::AgnosticTopic>>(dw, 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::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 
135  rtctk::componentFramework::ServiceContainer& m_service_container;
136 
137  DdsPub m_dds_pub;
138 
142  std::vector<std::unique_ptr<UdpReceiver>> m_udp_receivers;
143 
147  std::vector<DdsPublisherContext> m_pub_threads;
148 };
149 
150 } // namespace rtctk::telRepub
151 
152 #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::componentFramework::TypedDataWriter
eprosima::fastdds::dds::DataWriter TypedDataWriter
Definition: ddsCommon.hpp:88
rtctk::telRepub::PubThread
Definition: ddsPubThread.hpp:161
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
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::TypedDataWriter *dw, std::uint32_t queue_size)
Definition: telRepubBusinessLogic.hpp:72
ddsPubThread.hpp
DDS agnostic topic publioshing thread.
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::telRepub
Definition: ddsPubThread.hpp:27
rtctk::telRepub::TelRepubBusinessLogic::DdsPublisherContext
Definition: telRepubBusinessLogic.hpp:71
rtctk::componentFramework::StopToken
rad::StopToken StopToken
Definition: stopToken.hpp:19
mudpi::uint16_t
unsigned short uint16_t
Definition: mudpi.h:15
rtctk::AgnosticTopic
This class represents the structure AgnosticTopic defined by the user in the IDL file.
Definition: agnostictopicif.h:72
runnable.hpp
Lifecycle Extension that makes an RTC Component 'Runnable'.
rtctk::telRepub::LifeCycle
Runnable< RtcComponent > LifeCycle
Definition: telRepubBusinessLogic.hpp:35
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:41
rtctk::componentFramework::DdsPub
All functionallty needed to create DDS entities for DDS data publishing is concentrated in this class...
Definition: ddsPub.hpp:39
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::PubThreadBase
DDS publisher thread class that provides queue with aggregated topic to be published by DDS.
Definition: ddsPubThread.hpp:50
rtctk
Definition: agnostictopicifPubSubTypes.cpp:31
rtctk::telRepub::TelRepubBusinessLogic
Telemetry Republisher business logic.
Definition: telRepubBusinessLogic.hpp:42