RTC Toolkit 4.0.2
Loading...
Searching...
No Matches
mudpiProcessor.hpp
Go to the documentation of this file.
1
13#ifndef RTCTK_REUSABLECOMPONENT_TELREPUB_MUDPIPROCESSOR_HPP
14#define RTCTK_REUSABLECOMPONENT_TELREPUB_MUDPIPROCESSOR_HPP
15
16#include <boost/asio.hpp>
17#include <cstdint>
18#include <fmt/format.h>
19
20#include "agnostictopicif.h"
22#include "queue.hpp"
23#include <gsl/span>
26#include <vector>
27
28#include "mudpi.h"
31
32namespace rtctk::telRepub {
33
34uint32_t const MAX_TOPIC_SIZE = 2560000; // Large increase for Pixel topics
35
45 using AgnosticTopic = rtctk::componentFramework::AgnosticTopic;
50 struct PacketData {
51 std::vector<QueueElement> queue_elements{};
52 std::vector<gsl::span<const uint8_t>> payloads{};
53 double time_stamp{0};
54 uint32_t sample_id{0};
55 };
56
57 QueuePtr m_queue;
58 PacketData m_packet_data{};
59
60 ComponentMetricsIf& m_metrics;
61
62 uint16_t m_num_frames = -1; // TBC !!!
63 mudpi::int32_t m_topic_id = 0;
64
65 std::string m_topic_name;
66 std::string m_metric_path_prefix;
67
68 uint32_t m_expected_sample_id = 0;
69 uint16_t m_expected_frame_id = 0;
70
71 uint32_t m_expected_sample_id_increment;
72
73 bool m_sample_finished = false;
74
75 enum ProcessorState { Synchronising, Processing };
76
77 ProcessorState m_state = Synchronising;
78
83 log4cplus::Logger m_logger;
84
85 ErrorCode<MudpiProcessorError> StateMachine(PacketFrame packet, AgnosticTopic& topic);
86
91 // @note: OLDB does not support uint64_t which we really want, so we have to use signed 64.
92 perfc::CounterI64 m_pc_frames_recvd;
93 perfc::ScopedRegistration m_pc_frames_recvd_reg;
94 perfc::CounterI64 m_pc_samples_recvd;
95 perfc::ScopedRegistration m_pc_samples_recvd_reg;
96 perfc::CounterI64 m_pc_frame_errors;
97 perfc::ScopedRegistration m_pc_frame_errors_reg;
98 perfc::CounterI64 m_pc_sample_errors;
99 perfc::ScopedRegistration m_pc_sample_errors_reg;
100 perfc::CounterI64 m_pc_last_sample_id_recvd;
101 perfc::ScopedRegistration m_pc_last_sample_id_recvd_reg;
102
104 componentFramework::DurationMonitor<> m_wrangler_duration;
105
106public:
116 explicit MudpiProcessor(mudpi::int32_t mudpi_topic_id,
117 std::string topic_name,
118 QueuePtr queue,
119 uint32_t expected_sample_id_increment,
121
125 uint16_t GetTopicId() const;
126
135 ProcessMudpi(AgnosticTopic& topic, const WranglerFunction& wrangler);
136
140 void ResetCounters();
141
142}; // MudpiProcessor
143
144std::error_code
145DefaultWrangler(gsl::span<const gsl::span<const uint8_t>> input, std::vector<uint8_t>& output);
146
147} // namespace rtctk::telRepub
148
149#endif // RTCTK_REUSABLECOMPONENT_TELREPUB_MUDPIPROCESSOR_HPP
Component metrics interface.
Definition: componentMetricsIf.hpp:184
Monitors min, mean and max duration and publishes them to OLDB.
Definition: durationMonitor.hpp:37
Estimates the frequency in which Tick is called and publishes result to OLDB.
Definition: frequencyEstimator.hpp:31
Processing MUDPI data received by UDP receiver: rtctk::telRepub::UdpReceiver.
Definition: mudpiProcessor.hpp:44
void ResetCounters()
Reset the counters.
Definition: mudpiProcessor.cpp:261
ErrorCode< MudpiProcessorError > ProcessMudpi(AgnosticTopic &topic, const WranglerFunction &wrangler)
Here the actual processing is done (frame by frame (MUDPI datagram)).
Definition: mudpiProcessor.cpp:116
uint16_t GetTopicId() const
To query the topic id of the current mudpi processor object.
Definition: mudpiProcessor.cpp:111
Header file for ComponentMetricsIf.
Header file for Duration Monitor.
Header file for Frequency Estimator.
MUDPI processor error codes.
MUDPI structure definition.
int int32_t
Definition: mudpi.h:22
Definition: ddsPubThread.cpp:17
uint32_t const MAX_TOPIC_SIZE
Definition: mudpiProcessor.hpp:34
std::shared_ptr< Queue > QueuePtr
Definition: queue.hpp:37
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:29
std::error_code DefaultWrangler(const gsl::span< const gsl::span< const uint8_t > > input, std::vector< uint8_t > &output)
Definition: mudpiProcessor.cpp:272
UDP Buffer management.
Wrangler: User extension point.
Definition: mudpiProcessingError.hpp:28
Definition: queue.hpp:29