Getting Status and Status Changes

The get_status_changes() operation retrieves the set of events, also known in DDS terminology as communication statuses, in the Entity that have changed since the last time get_status_changes() was called. This method actually returns a value that must be bitwise AND’ed with an enumerated bit mask to test whether or not a specific status has changed. The operation can be used in a polling mechanism to see if any statuses related to the Entity have changed. If an entity is disabled, all communication statuses are in the “unchanged” state so the list returned by the get_status_changes() operation will be empty.

A set of statuses is defined for each class of Entities. For each status, there is a corresponding operation, get_<status-name>_status(), that can be used to get its current value. For example, a DataWriter has a DDS_OFFERED_DEADLINE_MISSED status; it also has a get_offered_deadline_missed_status() operation:

DDS_StatusMask statuses;
DDS_OfferedDeadlineMissedStatus deadline_stat;
statuses = datawriter->get_status_changes();
if (statuses & DDS_OFFERED_DEADLINE_MISSED_STATUS) {
datawriter->get_offered_deadline_missed_status(
		&deadline_stat);
	printf(“Deadline missed %d times.\n”,
		deadline_stat.total_count);
}

To reset a status (so that it is no longer considered “changed”), call get_<status-name>_status(). Or, in the case of the DDS_DATA_AVAILABLE status, call read(), take(), or one of their variants.

If you use a StatusCondition to be notified that a particular status has changed, the StatusCondition’s trigger_value will remain true unless you call get_*_status() to reset the status.

See also: Statuses and StatusConditions.

© 2018 RTI