|
26 | 26 | #include <fastdds/dds/core/status/StatusMask.hpp>
|
27 | 27 | #include <fastdds/dds/domain/DomainParticipant.hpp>
|
28 | 28 | #include <fastdds/dds/domain/DomainParticipantFactory.hpp>
|
29 |
| -#include <fastdds/dds/domain/qos/DomainParticipantQos.hpp> |
30 | 29 | #include <fastdds/dds/subscriber/DataReader.hpp>
|
31 | 30 | #include <fastdds/dds/subscriber/qos/DataReaderQos.hpp>
|
32 | 31 | #include <fastdds/dds/subscriber/qos/SubscriberQos.hpp>
|
@@ -174,6 +173,80 @@ void register_statistics_type_and_topic(
|
174 | 173 | }
|
175 | 174 | }
|
176 | 175 |
|
| 176 | +int16_t retrieve_entity_id( |
| 177 | + const std::string& topic_name) |
| 178 | +{ |
| 179 | + if (HISTORY_LATENCY_TOPIC == topic_name) |
| 180 | + { |
| 181 | + return 1; |
| 182 | + } |
| 183 | + else if (NETWORK_LATENCY_TOPIC == topic_name) |
| 184 | + { |
| 185 | + return 2; |
| 186 | + } |
| 187 | + else if (PUBLICATION_THROUGHPUT_TOPIC == topic_name) |
| 188 | + { |
| 189 | + return 4; |
| 190 | + } |
| 191 | + else if (SUBSCRIPTION_THROUGHPUT_TOPIC == topic_name) |
| 192 | + { |
| 193 | + return 8; |
| 194 | + } |
| 195 | + else if (RTPS_SENT_TOPIC == topic_name) |
| 196 | + { |
| 197 | + return 16; |
| 198 | + } |
| 199 | + else if (RTPS_LOST_TOPIC == topic_name) |
| 200 | + { |
| 201 | + return 32; |
| 202 | + } |
| 203 | + else if (RESENT_DATAS_TOPIC == topic_name) |
| 204 | + { |
| 205 | + return 64; |
| 206 | + } |
| 207 | + else if (HEARTBEAT_COUNT_TOPIC == topic_name) |
| 208 | + { |
| 209 | + return 128; |
| 210 | + } |
| 211 | + else if (ACKNACK_COUNT_TOPIC == topic_name) |
| 212 | + { |
| 213 | + return 256; |
| 214 | + } |
| 215 | + else if (NACKFRAG_COUNT_TOPIC == topic_name) |
| 216 | + { |
| 217 | + return 512; |
| 218 | + } |
| 219 | + else if (GAP_COUNT_TOPIC == topic_name) |
| 220 | + { |
| 221 | + return 1024; |
| 222 | + } |
| 223 | + else if (DATA_COUNT_TOPIC == topic_name ) |
| 224 | + { |
| 225 | + return 2048; |
| 226 | + } |
| 227 | + else if (PDP_PACKETS_TOPIC == topic_name) |
| 228 | + { |
| 229 | + return 4096; |
| 230 | + } |
| 231 | + else if (EDP_PACKETS_TOPIC == topic_name) |
| 232 | + { |
| 233 | + return 8192; |
| 234 | + } |
| 235 | + else if (DISCOVERY_TOPIC == topic_name) |
| 236 | + { |
| 237 | + return 16384; |
| 238 | + } |
| 239 | + else if (SAMPLE_DATAS_TOPIC == topic_name) |
| 240 | + { |
| 241 | + return 32768; |
| 242 | + } |
| 243 | + else if (PHYSICAL_DATA_TOPIC == topic_name) |
| 244 | + { |
| 245 | + } |
| 246 | + |
| 247 | + return -1; |
| 248 | +} |
| 249 | + |
177 | 250 | EntityId create_and_register_monitor(
|
178 | 251 | const std::string& domain_name,
|
179 | 252 | DomainListener* domain_listener,
|
@@ -249,10 +322,15 @@ EntityId create_and_register_monitor(
|
249 | 322 | throw Error("Error initializing monitor. Could not create topic " + std::string(topic));
|
250 | 323 | }
|
251 | 324 |
|
| 325 | + DataReaderQos datareader_qos = eprosima::fastdds::statistics::dds::STATISTICS_DATAREADER_QOS; |
| 326 | + datareader_qos.endpoint().entity_id = retrieve_entity_id(topic); |
| 327 | + datareader_qos.endpoint().user_defined_id = -2; |
| 328 | + |
| 329 | + |
252 | 330 | /* Create DataReaders */
|
253 | 331 | monitor->readers[topic] = monitor->subscriber->create_datareader(
|
254 | 332 | monitor->topics[topic],
|
255 |
| - eprosima::fastdds::statistics::dds::STATISTICS_DATAREADER_QOS, |
| 333 | + datareader_qos, |
256 | 334 | monitor->reader_listener,
|
257 | 335 | StatusMask::all());
|
258 | 336 |
|
@@ -328,6 +406,35 @@ EntityId StatisticsBackend::init_monitor(
|
328 | 406 | domain_id);
|
329 | 407 | }
|
330 | 408 |
|
| 409 | +EntityId StatisticsBackend::init_monitor( |
| 410 | + DomainId domain_id, |
| 411 | + const DomainParticipantQos& participant_qos, |
| 412 | + DomainListener* domain_listener, |
| 413 | + CallbackMask callback_mask, |
| 414 | + DataKindMask data_mask) |
| 415 | +{ |
| 416 | + /* Set domain_name */ |
| 417 | + std::stringstream domain_name; |
| 418 | + domain_name << domain_id; |
| 419 | + |
| 420 | + /* Set DomainParticipantQoS */ |
| 421 | + DomainParticipantQos participant_qos_copy = participant_qos; |
| 422 | + /* Previous string conversion is needed for string_255 */ |
| 423 | + std::string participant_name = "monitor_domain_" + std::to_string(domain_id); |
| 424 | + participant_qos_copy.name(participant_name); |
| 425 | + if (participant_qos_copy.transport().use_builtin_transports) |
| 426 | + { |
| 427 | + /* Avoid using SHM transport by default */ |
| 428 | + std::shared_ptr<eprosima::fastdds::rtps::UDPv4TransportDescriptor> udp_transport = |
| 429 | + std::make_shared<eprosima::fastdds::rtps::UDPv4TransportDescriptor>(); |
| 430 | + participant_qos_copy.transport().user_transports.push_back(udp_transport); |
| 431 | + participant_qos_copy.transport().use_builtin_transports = false; |
| 432 | + } |
| 433 | + return create_and_register_monitor( |
| 434 | + domain_name.str(), domain_listener, callback_mask, data_mask, participant_qos_copy, |
| 435 | + domain_id); |
| 436 | +} |
| 437 | + |
331 | 438 | void StatisticsBackend::stop_monitor(
|
332 | 439 | EntityId monitor_id)
|
333 | 440 | {
|
|
0 commit comments