diff --git a/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp b/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp index ddd8505a..a0ca6c62 100644 --- a/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp +++ b/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp @@ -112,6 +112,41 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener fastrtps::rtps::RTPSReader*, fastrtps::rtps::MatchingInfo& info) noexcept override; + /** + * This method is called when a new Writer is discovered, with a Topic that + * matches that of a local reader, but with an offered QoS that is incompatible + * with the one requested by the local reader + * @param qos A mask with the bits of all incompatible Qos activated. + */ + DDSPIPE_PARTICIPANTS_DllAPI + void on_requested_incompatible_qos( + fastrtps::rtps::RTPSReader*, + eprosima::fastdds::dds::PolicyMask qos) noexcept override; + + /** + * This method is called when the reader detects that one or more samples have been lost. + * + * @param sample_lost_since_last_update The number of samples that were lost since the last time this + * method was called for the same reader. + */ + DDSPIPE_PARTICIPANTS_DllAPI + void on_sample_lost( + fastrtps::rtps::RTPSReader*, + int32_t sample_lost_since_last_update) noexcept override; + + /** + * This method is called when the reader rejects a samples. + * + * @param reason Indicates reason for sample rejection. + * @param change Pointer to the CacheChange_t. This is a const pointer to const data + * to indicate that the user should not dispose of this data himself. + */ + DDSPIPE_PARTICIPANTS_DllAPI + void on_sample_rejected( + fastrtps::rtps::RTPSReader*, + eprosima::fastdds::dds::SampleRejectedStatusKind reason, + const fastrtps::rtps::CacheChange_t* const change) noexcept override; + ///////////////////////// // RPC REQUIRED METHODS ///////////////////////// diff --git a/ddspipe_participants/include/ddspipe_participants/writer/rtps/CommonWriter.hpp b/ddspipe_participants/include/ddspipe_participants/writer/rtps/CommonWriter.hpp index 6009eef8..2a36fc7f 100644 --- a/ddspipe_participants/include/ddspipe_participants/writer/rtps/CommonWriter.hpp +++ b/ddspipe_participants/include/ddspipe_participants/writer/rtps/CommonWriter.hpp @@ -108,6 +108,17 @@ class CommonWriter : public BaseWriter, public fastrtps::rtps::WriterListener fastrtps::rtps::RTPSWriter*, fastrtps::rtps::MatchingInfo& info) noexcept override; + /** + * This method is called when a new Reader is discovered, with a Topic that + * matches that of a local writer, but with a requested QoS that is incompatible + * with the one offered by the local writer + * @param qos A mask with the bits of all incompatible Qos activated. + */ + DDSPIPE_PARTICIPANTS_DllAPI + void on_offered_incompatible_qos( + fastrtps::rtps::RTPSWriter*, + eprosima::fastdds::dds::PolicyMask qos) noexcept override; + ///////////////////// // STATIC ATTRIBUTES ///////////////////// diff --git a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp index b74bb87a..46af5849 100644 --- a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp +++ b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp @@ -454,6 +454,51 @@ void CommonReader::onReaderMatched( } } +void CommonReader::on_requested_incompatible_qos( + fastrtps::rtps::RTPSReader*, + eprosima::fastdds::dds::PolicyMask qos) noexcept +{ + logWarning(DDSPIPE_RTPS_COMMONREADER_LISTENER, + "Reader " << *this << " found a remote Writer with incompatible QoS: " << qos); +} + +void CommonReader::on_sample_lost( + fastrtps::rtps::RTPSReader*, + int32_t sample_lost_since_last_update) noexcept +{ + logWarning(DDSPIPE_RTPS_COMMONREADER_LISTENER, + "On reader " << *this << " a data sample was lost and will not be received"); +} + +void CommonReader::on_sample_rejected( + fastrtps::rtps::RTPSReader*, + eprosima::fastdds::dds::SampleRejectedStatusKind reason, + const fastrtps::rtps::CacheChange_t* const change) noexcept +{ + std::string reason_str; + switch (reason) + { + case eprosima::fastdds::dds::SampleRejectedStatusKind::NOT_REJECTED: + reason_str = "NOT_REJECTED"; + break; + case eprosima::fastdds::dds::SampleRejectedStatusKind::REJECTED_BY_INSTANCES_LIMIT: + reason_str = "REJECTED_BY_INSTANCES_LIMIT"; + break; + case eprosima::fastdds::dds::SampleRejectedStatusKind::REJECTED_BY_SAMPLES_LIMIT: + reason_str = "REJECTED_BY_SAMPLES_LIMIT"; + break; + case eprosima::fastdds::dds::SampleRejectedStatusKind::REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT: + reason_str = "REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT"; + break; + default: + reason_str = "UNKNOWN"; + break; + } + logInfo(DDSPIPE_RTPS_COMMONREADER_LISTENER, + "Reader " << *this << " rejected a sample from " << change->writerGUID + << ". Reason: " << reason_str); +} + utils::ReturnCode CommonReader::is_data_correct_( const fastrtps::rtps::CacheChange_t* received_change) const noexcept { diff --git a/ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp b/ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp index ba4eac76..f333c25a 100644 --- a/ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp @@ -123,6 +123,14 @@ void CommonWriter::onWriterMatched( } } +void CommonWriter::on_offered_incompatible_qos( + fastrtps::rtps::RTPSWriter*, + eprosima::fastdds::dds::PolicyMask qos) noexcept +{ + logWarning(DDSPIPE_RTPS_COMMONWRITER_LISTENER, + "Writer " << *this << " found a remote Reader with incompatible QoS: " << qos); +} + bool CommonWriter::come_from_this_participant_( const fastrtps::rtps::GUID_t guid) const noexcept {