RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
genSubReaderListener.hpp
Go to the documentation of this file.
1
11#ifndef RTCTK_GENSUBREADERLISTENER_H
12#define RTCTK_GENSUBREADERLISTENER_H
13
15
16#include <atomic>
17#include <chrono>
18#include <string>
19
20// NOLINTNEXTLINE(google-global-names-in-headers): Private header
21using namespace rtctk::componentFramework;
22
28class GenSubReaderListener : public rtctk::componentFramework::DataReaderListener {
29public:
30 // Constructor
31 GenSubReaderListener(const char* name, uint16_t topic_id);
32
33 // Destructor
34 ~GenSubReaderListener(void) override = default;
35
36 void on_requested_deadline_missed(DataReader* reader,
37 const RequestedDeadlineMissedStatus& status) override;
38
39 void on_requested_incompatible_qos(DataReader* reader,
40 const RequestedIncompatibleQosStatus& status) override;
41
42 void on_liveliness_changed(DataReader* reader, const LivelinessChangedStatus& status) override;
43
44 void
45 on_subscription_matched(DataReader* reader, const SubscriptionMatchedStatus& status) override;
46
47 void on_sample_rejected(DataReader* reader, const SampleRejectedStatus& status) override;
48
49 void on_data_available(DataReader* reader) override;
50
51 void on_sample_lost(DataReader* reader, const SampleLostStatus& status) override;
52
53 long GetNumSamples() const {
54 return m_num_reads;
55 }
56
57 unsigned long GetLostSamples() const {
58 return m_lost_samples;
59 }
60
61 void Enable() {
62 m_enabled = true;
63 }
64
65 void Disable() {
66 m_enabled = false;
67 }
68
69 unsigned int GetIndex() const {
70 return m_topic_id;
71 }
72
73 const std::string& GetName() const {
74 return m_list_name;
75 }
76
77 static int GetSleepPeriod() {
78 return m_sleep_period;
79 }
80
81 static void SetSleepPeriod(int value) {
82 m_sleep_period = value;
83 }
84
85 static int GetCheckRamp() {
86 return m_check_ramp;
87 }
88
89 static void SetCheckRamp(bool value) {
90 m_check_ramp = value;
91 }
92
93 static const std::string& GetExpectedPayloadPattern() {
94 return m_expected_payload_pattern;
95 }
96
97 static void SetExpectedPayloadPattern(const std::string& value) {
98 m_expected_payload_pattern = value;
99 }
101 return m_expected_sample_id_increment;
102 }
103
104 static void SetExpectedSampleIdIncrement(uint32_t value) {
105 m_expected_sample_id_increment = value;
106 }
107
108private:
109 void CheckRamp(rtctk::componentFramework::AgnosticTopic& sample);
110 void CheckExpectedPayloadPattern(rtctk::componentFramework::AgnosticTopic& sample);
111
112 log4cplus::Logger& m_logger;
113 long m_num_reads;
114 unsigned long m_lost_samples;
115 std::string m_list_name;
116
117 std::uint32_t m_last_sample_id;
118 std::uint32_t m_sample_id;
119
120 std::chrono::high_resolution_clock::time_point m_start_time;
121 std::chrono::duration<double> m_elapsed_time;
122 // cppcheck-suppress-begin unusedStructMember
123 double m_sum_send_time;
124 float m_log_time;
125 bool m_is_first;
126 // cppcheck-suppress-end unusedStructMember
127
128 rtctk::componentFramework::AgnosticTopicSeq m_data_seq;
129 SampleInfoSeq m_info_seq;
130
131 unsigned int m_topic_id;
132 bool m_enabled;
133
134 static std::atomic<int> m_sleep_period;
135 static std::atomic<bool> m_check_ramp;
136 static std::atomic<uint32_t> m_expected_sample_id_increment;
137 static std::string m_expected_payload_pattern;
138};
139
140#endif // RTCTK_GENSUBREADERLISTENER_H
static int GetCheckRamp()
Definition genSubReaderListener.hpp:85
void Enable()
Definition genSubReaderListener.hpp:61
void on_liveliness_changed(DataReader *reader, const LivelinessChangedStatus &status) override
Definition genSubReaderListener.cpp:269
const std::string & GetName() const
Definition genSubReaderListener.hpp:73
static void SetExpectedPayloadPattern(const std::string &value)
Definition genSubReaderListener.hpp:97
void Disable()
Definition genSubReaderListener.hpp:65
void on_data_available(DataReader *reader) override
Definition genSubReaderListener.cpp:52
void on_requested_incompatible_qos(DataReader *reader, const RequestedIncompatibleQosStatus &status) override
Definition genSubReaderListener.cpp:264
void on_requested_deadline_missed(DataReader *reader, const RequestedDeadlineMissedStatus &status) override
Definition genSubReaderListener.cpp:259
static int GetExpectedSampleIdIncrement()
Definition genSubReaderListener.hpp:100
static void SetSleepPeriod(int value)
Definition genSubReaderListener.hpp:81
~GenSubReaderListener(void) override=default
static const std::string & GetExpectedPayloadPattern()
Definition genSubReaderListener.hpp:93
unsigned int GetIndex() const
Definition genSubReaderListener.hpp:69
static void SetCheckRamp(bool value)
Definition genSubReaderListener.hpp:89
static int GetSleepPeriod()
Definition genSubReaderListener.hpp:77
void on_sample_rejected(DataReader *reader, const SampleRejectedStatus &status) override
Definition genSubReaderListener.cpp:308
GenSubReaderListener(const char *name, uint16_t topic_id)
Definition genSubReaderListener.cpp:34
void on_subscription_matched(DataReader *reader, const SubscriptionMatchedStatus &status) override
Definition genSubReaderListener.cpp:299
long GetNumSamples() const
Definition genSubReaderListener.hpp:53
static void SetExpectedSampleIdIncrement(uint32_t value)
Definition genSubReaderListener.hpp:104
unsigned long GetLostSamples() const
Definition genSubReaderListener.hpp:57
void on_sample_lost(DataReader *reader, const SampleLostStatus &status) override
Definition genSubReaderListener.cpp:320
Declares common DDS class.
Definition commandReplier.cpp:21