RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
mudpiProcessor.hpp
Go to the documentation of this file.
1
12#ifndef RTCTK_REUSABLECOMPONENT_TELREPUB_MUDPIPROCESSOR_HPP
13#define RTCTK_REUSABLECOMPONENT_TELREPUB_MUDPIPROCESSOR_HPP
14
15#include <boost/asio.hpp>
16#include <cstdint>
17#include <fmt/format.h>
18
19#include "agnostictopicif.hpp"
20#include "llnetio/mudpi/mudpi.hpp"
22#include "queue.hpp"
25#include <gsl/span>
26#include <limits>
31#include <taiclock/taiClock.hpp>
32#include <vector>
33
34namespace rtctk::telRepub {
35
40 std::string dds_topic_name;
41 llnetio::mudpi::TopicId mudpi_topic_id;
42 std::uint32_t expected_sample_id_increment = 1u;
43 std::chrono::milliseconds receive_sample_timeout_ms =
44 std::chrono::milliseconds(20000); // default 20s
45};
46
56 using AgnosticTopic = rtctk::componentFramework::AgnosticTopic;
57 using ComponentMetricsIf = rtctk::componentFramework::ComponentMetricsIf;
58 using AlertServiceIf = rtctk::componentFramework::AlertServiceIf;
62 struct PacketData {
63 std::vector<QueueElement> queue_elements{};
64 std::vector<gsl::span<const uint8_t>> payloads{};
65 taiclock::TaiClock::time_point time_stamp{};
66 llnetio::mudpi::SampleId sample_id{0};
67
68 void Reset() {
69 queue_elements.clear();
70 payloads.clear();
71 time_stamp = {};
72 sample_id = 0;
73 }
74 };
75
76 QueuePtr m_queue;
77 PacketData m_packet_data{};
78
79 ComponentMetricsIf& m_metrics;
80 AlertServiceIf& m_alerts;
81
82 llnetio::mudpi::NumFrames m_num_frames = std::numeric_limits<llnetio::mudpi::NumFrames>::max();
83 llnetio::mudpi::TopicId m_topic_id = 0;
84
85 std::string m_topic_name;
86 std::string m_metric_path_prefix;
87
88 llnetio::mudpi::SampleId m_expected_sample_id = 0;
89 llnetio::mudpi::FrameId m_expected_frame_id = 0;
90
91 llnetio::mudpi::SampleId m_expected_sample_id_increment;
92
93 bool m_sample_finished = false;
94
95 enum ProcessorState : uint8_t { Synchronising, Processing };
96
97 ProcessorState m_state = Synchronising;
98
103 log4cplus::Logger m_logger;
104
105 ErrorCode<MudpiProcessorError> StateMachine(PacketFrame packet, AgnosticTopic& topic);
106
111 // @note: OLDB does not support uint64_t which we really want, so we have to use signed 64.
112 perfc::CounterI64 m_pc_frames_recvd;
113 perfc::ScopedRegistration m_pc_frames_recvd_reg;
114 perfc::CounterI64 m_pc_samples_recvd;
115 perfc::ScopedRegistration m_pc_samples_recvd_reg;
116 perfc::CounterI64 m_pc_frame_errors;
117 perfc::ScopedRegistration m_pc_frame_errors_reg;
118 perfc::CounterI64 m_pc_sample_errors;
119 perfc::ScopedRegistration m_pc_sample_errors_reg;
120 perfc::CounterI64 m_pc_last_sample_id_recvd;
121 perfc::ScopedRegistration m_pc_last_sample_id_recvd_reg;
122
124 componentFramework::DurationMonitor<> m_wrangler_duration;
125
126 std::atomic<std::chrono::steady_clock::time_point> m_last_sample_received;
127
128 // receive timeout alert
129 componentFramework::AlertSource m_receive_timeout_alert;
130 std::chrono::milliseconds m_receive_sample_timeout_ms =
131 std::chrono::milliseconds(0); // default - we do not check for timeout
132
133public:
141 explicit MudpiProcessor(QueuePtr queue,
142 CfgMudpiProc& cfg,
144
148 uint16_t GetTopicId() const;
149
158 ProcessMudpi(AgnosticTopic& topic, const WranglerFunction& wrangler);
159
163 void ResetCounters();
164
171 bool Monitor();
172
173}; // MudpiProcessor
174
175std::error_code
176DefaultWrangler(gsl::span<const gsl::span<const uint8_t>> input, std::vector<uint8_t>& output);
177
178} // namespace rtctk::telRepub
179
180#endif // RTCTK_REUSABLECOMPONENT_TELREPUB_MUDPIPROCESSOR_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
Monitors min, mean and max duration and publishes them to OLDB.
Definition durationMonitor.hpp:36
Estimates the frequency in which Tick is called and publishes result to OLDB.
Definition frequencyEstimator.hpp:30
Container class that holds services of any type.
Definition serviceContainer.hpp:38
void ResetCounters()
Reset the counters.
Definition mudpiProcessor.cpp:313
bool Monitor()
Monitoring MUDPI processor for different problems (alerts): like timeouts ....
Definition mudpiProcessor.cpp:325
ErrorCode< MudpiProcessorError > ProcessMudpi(AgnosticTopic &topic, const WranglerFunction &wrangler)
Here the actual processing is done (frame by frame (MUDPI datagram)).
Definition mudpiProcessor.cpp:138
uint16_t GetTopicId() const
To query the topic id of the current mudpi processor object.
Definition mudpiProcessor.cpp:133
MudpiProcessor(QueuePtr queue, CfgMudpiProc &cfg, componentFramework::ServiceContainer &service)
MUDPI Processor constructor.
Definition mudpiProcessor.cpp:44
Header file for ComponentMetricsIf.
Header file for Duration Monitor.
Header file for Frequency Estimator.
MUDPI processor error codes.
Definition ddsPubThread.cpp:16
std::shared_ptr< Queue > QueuePtr
Definition queue.hpp:35
std::error_code DefaultWrangler(const gsl::span< const gsl::span< const uint8_t > > input, std::vector< uint8_t > &output)
Definition mudpiProcessor.cpp:337
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
UDP Buffer management.
Wrangler: User extension point.
A container that can hold any type of service.
Structure to hold MudpiProcessor's configuration.
Definition mudpiProcessor.hpp:39
std::uint32_t expected_sample_id_increment
Definition mudpiProcessor.hpp:42
llnetio::mudpi::TopicId mudpi_topic_id
Definition mudpiProcessor.hpp:41
std::string dds_topic_name
Definition mudpiProcessor.hpp:40
std::chrono::milliseconds receive_sample_timeout_ms
Definition mudpiProcessor.hpp:43
Definition mudpiProcessingError.hpp:27
Definition queue.hpp:27