From 12de24ea1061224d52a5b79349419d58f0fb5e8e Mon Sep 17 00:00:00 2001 From: Barry Xu Date: Wed, 15 Mar 2023 20:10:12 +0800 Subject: [PATCH] Updated to only support rmw matched event Signed-off-by: Barry Xu --- .../rmw_connextdds/rmw_waitset_std.hpp | 63 +++++-------------- rmw_connextdds_common/src/common/rmw_impl.cpp | 19 ------ .../src/common/rmw_impl_waitset_std.cpp | 42 ++++--------- 3 files changed, 29 insertions(+), 95 deletions(-) diff --git a/rmw_connextdds_common/include/rmw_connextdds/rmw_waitset_std.hpp b/rmw_connextdds_common/include/rmw_connextdds/rmw_waitset_std.hpp index 696dd722..877f8442 100644 --- a/rmw_connextdds_common/include/rmw_connextdds/rmw_waitset_std.hpp +++ b/rmw_connextdds_common/include/rmw_connextdds/rmw_waitset_std.hpp @@ -476,27 +476,14 @@ class RMW_Connext_PublisherStatusCondition : public RMW_Connext_StatusCondition [this, status]() { this->triggered_matched = false; - status->current_matched_count = this->status_matched.current_count; - status->current_count_change = this->saved_matched_status.current_count_change; - - this->saved_matched_status.current_count_change = 0; - }, false /* notify */); - - return RMW_RET_OK; - } - - inline rmw_ret_t - get_unmatched_status( - rmw_unmatched_status_t * const status) - { - update_state( - [this, status]() { - this->triggered_unmatched = false; - - status->current_matched_count = this->status_matched.current_count; - status->current_count_change = this->saved_unmatched_status.current_count_change; - - this->saved_unmatched_status.current_count_change = 0; + status->total_count = this->status_matched.total_count; + status->total_count_change = this->status_matched.total_count_change; + status->current_count = this->status_matched.current_count; + status->current_count_change = this->status_matched.current_count_change; + + this->status_matched.total_count_change = 0; + this->status_matched.current_count_change = 0; + this->status_matched_last = this->status_matched; }, false /* notify */); return RMW_RET_OK; @@ -519,7 +506,6 @@ class RMW_Connext_PublisherStatusCondition : public RMW_Connext_StatusCondition bool triggered_liveliness{false}; bool triggered_qos{false}; bool triggered_matched{false}; - bool triggered_unmatched{false}; DDS_OfferedDeadlineMissedStatus status_deadline; DDS_OfferedIncompatibleQosStatus status_qos; @@ -529,8 +515,7 @@ class RMW_Connext_PublisherStatusCondition : public RMW_Connext_StatusCondition DDS_OfferedDeadlineMissedStatus status_deadline_last; DDS_OfferedIncompatibleQosStatus status_qos_last; DDS_LivelinessLostStatus status_liveliness_last; - rmw_matched_status_t saved_matched_status; // save matched status from last read - rmw_unmatched_status_t saved_unmatched_status; // save matched status from last read + DDS_PublicationMatchedStatus status_matched_last; RMW_Connext_Publisher * pub; }; @@ -774,26 +759,14 @@ class RMW_Connext_SubscriberStatusCondition : public RMW_Connext_StatusCondition [this, status]() { this->triggered_matched = false; - status->current_matched_count = this->status_matched.current_count; - status->current_count_change = this->saved_matched_status.current_count_change; - - this->saved_matched_status.current_count_change = 0; - }, false /* notify */); - - return RMW_RET_OK; - } - - inline rmw_ret_t - get_unmatched_status(rmw_matched_status_t * const status) - { - update_state( - [this, status]() { - this->triggered_unmatched = false; - - status->current_matched_count = this->status_matched.current_count; - status->current_count_change = this->saved_unmatched_status.current_count_change; + status->total_count = static_cast(this->status_matched.total_count); + status->total_count_change = static_cast(this->status_matched.total_count_change); + status->current_count = static_cast(this->status_matched.current_count); + status->current_count_change = this->status_matched.current_count_change; - this->saved_unmatched_status.current_count_change = 0; + this->status_matched.total_count_change = 0; + this->status_matched.current_count_change = 0; + this->status_matched_last = this->status_matched; }, false /* notify */); return RMW_RET_OK; @@ -822,7 +795,6 @@ class RMW_Connext_SubscriberStatusCondition : public RMW_Connext_StatusCondition bool triggered_qos{false}; bool triggered_sample_lost{false}; bool triggered_matched{false}; - bool triggered_unmatched{false}; bool triggered_data{false}; DDS_RequestedDeadlineMissedStatus status_deadline; @@ -835,8 +807,7 @@ class RMW_Connext_SubscriberStatusCondition : public RMW_Connext_StatusCondition DDS_RequestedIncompatibleQosStatus status_qos_last; DDS_LivelinessChangedStatus status_liveliness_last; DDS_SampleLostStatus status_sample_lost_last; - rmw_matched_status_t saved_matched_status; // save matched status from last read - rmw_unmatched_status_t saved_unmatched_status; // save unmatched status from last read + DDS_SubscriptionMatchedStatus status_matched_last; RMW_Connext_Subscriber * sub; diff --git a/rmw_connextdds_common/src/common/rmw_impl.cpp b/rmw_connextdds_common/src/common/rmw_impl.cpp index e36d830e..0b2cd9ab 100644 --- a/rmw_connextdds_common/src/common/rmw_impl.cpp +++ b/rmw_connextdds_common/src/common/rmw_impl.cpp @@ -3075,12 +3075,10 @@ ros_event_to_dds(const rmw_event_type_t ros, bool * const invalid) return DDS_SAMPLE_LOST_STATUS; } case RMW_EVENT_PUBLICATION_MATCHED: - case RMW_EVENT_PUBLICATION_UNMATCHED: { return DDS_PUBLICATION_MATCHED_STATUS; } case RMW_EVENT_SUBSCRIPTION_MATCHED: - case RMW_EVENT_SUBSCRIPTION_UNMATCHED: { return DDS_SUBSCRIPTION_MATCHED_STATUS; } @@ -3142,7 +3140,6 @@ ros_event_for_reader(const rmw_event_type_t ros) case RMW_EVENT_REQUESTED_QOS_INCOMPATIBLE: case RMW_EVENT_MESSAGE_LOST: case RMW_EVENT_SUBSCRIPTION_MATCHED: - case RMW_EVENT_SUBSCRIPTION_UNMATCHED: { return true; } @@ -3200,14 +3197,6 @@ RMW_Connext_SubscriberStatusCondition::get_status( rc = this->get_matched_status(status); break; } - case RMW_EVENT_SUBSCRIPTION_UNMATCHED: - { - rmw_matched_status_t * const status = - reinterpret_cast(event_info); - - rc = this->get_unmatched_status(status); - break; - } default: { RMW_CONNEXT_LOG_ERROR_A_SET( @@ -3259,14 +3248,6 @@ RMW_Connext_PublisherStatusCondition::get_status( rc = this->get_matched_status(status); break; } - case RMW_EVENT_PUBLICATION_UNMATCHED: - { - rmw_matched_status_t * status = - reinterpret_cast(event_info); - - rc = this->get_unmatched_status(status); - break; - } default: { RMW_CONNEXT_LOG_ERROR_A_SET("unsupported publisher qos: %d", event_type) diff --git a/rmw_connextdds_common/src/common/rmw_impl_waitset_std.cpp b/rmw_connextdds_common/src/common/rmw_impl_waitset_std.cpp index 0b00a137..dd920395 100644 --- a/rmw_connextdds_common/src/common/rmw_impl_waitset_std.cpp +++ b/rmw_connextdds_common/src/common/rmw_impl_waitset_std.cpp @@ -642,8 +642,7 @@ RMW_Connext_SubscriberStatusCondition::RMW_Connext_SubscriberStatusCondition( status_qos_last(DDS_RequestedIncompatibleQosStatus_INITIALIZER), status_liveliness_last(DDS_LivelinessChangedStatus_INITIALIZER), status_sample_lost_last(DDS_SampleLostStatus_INITIALIZER), - saved_matched_status({0, 0}), - saved_unmatched_status({0, 0}), + status_matched_last(DDS_SubscriptionMatchedStatus_INITIALIZER), sub(nullptr) { if (internal && nullptr == this->loan_guard_condition) { @@ -686,10 +685,6 @@ RMW_Connext_SubscriberStatusCondition::has_status( { return this->triggered_matched; } - case RMW_EVENT_SUBSCRIPTION_UNMATCHED: - { - return this->triggered_unmatched; - } default: { RMW_CONNEXT_ASSERT(0) @@ -801,16 +796,12 @@ RMW_Connext_SubscriberStatusCondition::update_status_matched( const DDS_SubscriptionMatchedStatus * const status) { this->status_matched = *status; + this->triggered_matched = true; - if (status->current_count_change == 1) { - this->triggered_matched = true; - this->saved_matched_status.current_count_change += status->current_count_change; - } else if (status->current_count_change == -1) { - this->triggered_unmatched = true; - this->saved_unmatched_status.current_count_change += abs(status->current_count_change); - } else { - return; - } + this->status_matched.total_count_change = + this->status_matched.total_count - this->status_matched_last.total_count; + this->status_matched.current_count_change = + this->status_matched.current_count - this->status_matched_last.current_count; } rmw_ret_t @@ -859,8 +850,7 @@ RMW_Connext_PublisherStatusCondition::RMW_Connext_PublisherStatusCondition( status_deadline_last(DDS_OfferedDeadlineMissedStatus_INITIALIZER), status_qos_last(DDS_OfferedIncompatibleQosStatus_INITIALIZER), status_liveliness_last(DDS_LivelinessLostStatus_INITIALIZER), - saved_matched_status({0, 0}), - saved_unmatched_status({0, 0}) + status_matched_last(DDS_PublicationMatchedStatus_INITIALIZER) {} bool @@ -884,10 +874,6 @@ RMW_Connext_PublisherStatusCondition::has_status( { return this->triggered_matched; } - case RMW_EVENT_PUBLICATION_UNMATCHED: - { - return this->triggered_unmatched; - } default: RMW_CONNEXT_ASSERT(0) return false; @@ -973,14 +959,10 @@ RMW_Connext_PublisherStatusCondition::update_status_matched( const DDS_PublicationMatchedStatus * const status) { this->status_matched = *status; + this->triggered_matched = true; - if (status->current_count_change == 1) { - this->triggered_matched = true; - this->saved_matched_status.current_count_change += status->current_count_change; - } else if (status->current_count_change == -1) { - this->triggered_unmatched = true; - this->saved_unmatched_status.current_count_change += abs(status->current_count_change); - } else { - return; - } + this->status_matched.total_count_change = + this->status_matched.total_count - this->status_matched_last.total_count; + this->status_matched.current_count_change = + this->status_matched.current_count - this->status_matched_last.current_count; }