Skip to content

Commit

Permalink
Updated to only support rmw matched event
Browse files Browse the repository at this point in the history
Signed-off-by: Barry Xu <barry.xu@sony.com>
  • Loading branch information
Barry-Xu-2018 committed Mar 15, 2023
1 parent bbc1780 commit 12de24e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 95 deletions.
63 changes: 17 additions & 46 deletions rmw_connextdds_common/include/rmw_connextdds/rmw_waitset_std.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
};
Expand Down Expand Up @@ -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<size_t>(this->status_matched.total_count);
status->total_count_change = static_cast<size_t>(this->status_matched.total_count_change);
status->current_count = static_cast<size_t>(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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down
19 changes: 0 additions & 19 deletions rmw_connextdds_common/src/common/rmw_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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<rmw_matched_status_t *>(event_info);

rc = this->get_unmatched_status(status);
break;
}
default:
{
RMW_CONNEXT_LOG_ERROR_A_SET(
Expand Down Expand Up @@ -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<rmw_matched_status_t *>(event_info);

rc = this->get_unmatched_status(status);
break;
}
default:
{
RMW_CONNEXT_LOG_ERROR_A_SET("unsupported publisher qos: %d", event_type)
Expand Down
42 changes: 12 additions & 30 deletions rmw_connextdds_common/src/common/rmw_impl_waitset_std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

0 comments on commit 12de24e

Please sign in to comment.