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