Module: dds.cond

Overview

The dds.cond module contains the Condition types as well as the related WaitSet type. These objects provide the facility to block until the desired condition is triggered, allowing for synchronous event processing. This is in contrast to the Listener callback mechanism which provides an asynchronous event notification mechanism.

Types

class dds.cond.Condition

Bases: object

Condition is the base class for all DDS Condition types. A condition maintains a boolean ‘trigger_value’.

get_trigger_value()

Access the current boolean value of the trigger.

Returns: boolean

class dds.cond.GuardCondition

Bases: dds.cond.Condition

A GuardCondition is a condition where the trigger_value is under application control.

get_trigger_value()

This routine returns the current value of the trigger_value.

Returns: boolean

set_trigger_value()

This routine set the current value of the trigger_value. Setting the trigger value to a True state will cause any threads that are waiting on a WaitSet with this GuardCondition attached to unblock. [In other words, the WaitSet.wait() routine will return if the WaitSet has this GuardCondition attached to it.]

class dds.cond.ReadCondition

Bases: dds.cond.Condition

A ReadCondition is a specialized Condition associated with a DataReader. The trigger_value is driven by the data available in the associated DataReader. A ReadCondition is obtained by calling DataReader.create_readcondition(). When the ReadCondition is no longer needed, it should be destroyed by a call to DataReader.delete_readcondition().

get_datareader()

This routine returns the single DataReader associated with this ReadCondition.

get_instance_state_mask()

This routine returns the current value of the instance_state in this ReadCondition.

get_sample_state_mask()

This routine returns the current value of the sample_state in this ReadCondition.

get_view_state_mask()

This routine returns the current value of the view_state in this ReadCondition.

class dds.cond.StatusCondition

Bases: dds.cond.Condition

A StatusCondition is a condition associated with an Entity. The trigger_value is driven by the communication status of the associated entity.

get_enabled_statuses()

This routine returns the statuses which are enabled in this StatusCondition. The statuses are returned as a bitmask (combination of dds.core.StatusMask values).

get_entity()

This routine returns the single entity associated with this StatusCondition.

set_enabled_statuses()

This routine sets the statuses which are enabled in this StatusCondition. The statuses are provided as a bitmask (combination of dds.core.StatusMask values).

class dds.cond.WaitSet

Bases: object

A WaitSet maintains a set of Condition objects and allows the application to wait until one or more of them have a ‘trigger_value’ of True. Multiple conditions may be attached to a WaitSet.

attach_condition()

Adds the condition to the WaitSet. If another thread is currently ‘waiting’ on the WaitSet, this newly added condition will unblock that thread if its ‘trigger_value’ is True.

detach_condition()

Removes a condition from the WaitSet. If the condition is not attached to the WaitSet, the error dds.core.PreconditionNotMet() will be raised.

get_conditions()

Retrieves the current list of attached conditions.

wait()

Causes the controlling thread to block until an attached condition is triggered or ‘timeout’ elapses.

If the timeout elapses without any of the conditions evaluating to True, it raises dds.core.Timeout() exception.

Otherwise, it returns the set of ‘active’ conditions.

If the timeout parameter is not provided, the default is Duration.infinite()