sub¶
- class cyclonedds.sub.Subscriber(domain_participant, qos=None, listener=None)[source]¶
Bases:
Entity- Parameters:
domain_participant (cyclonedds.domain.DomainParticipant) –
- class cyclonedds.sub.DataReader(subscriber_or_participant, topic, qos=None, listener=None)[source]¶
-
Subscribe to a topic and read/take the data published to it.
All returned samples are annotated with the
sample.sample_infoattribute.- Parameters:
subscriber_or_participant (Union[cyclonedds.sub.Subscriber, cyclonedds.domain.DomainParticipant]) –
topic (Topic[_T]) –
- read(N=1, condition=None, instance_handle=None)[source]¶
Read a maximum of N samples, non-blocking. Optionally use a read/query-condition to select which samples you are interested in.
Reading samples does not remove them from the
DataReader'sreceive queue. So read methods may return the same sample in multiple calls.- Parameters:
N (int) – The maximum number of samples to read.
condition (cyclonedds.core.ReadCondition, cyclonedds.core.QueryCondition, optional) – Only read samples that satisfy the supplied condition.
instance_handle (int) –
- Raises:
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Return type:
List[_T]
- take(N=1, condition=None, instance_handle=None)[source]¶
Take a maximum of N samples, non-blocking. Optionally use a read/query-condition to select which samples you are interested in.
Taking samples removes them from the
DataReader'sreceive queue. So take methods will not return the same sample more than once.- Parameters:
N (int) – The maximum number of samples to read.
condition (cyclonedds.core.ReadCondition, cyclonedds.core.QueryCondition, optional) – Only take samples that satisfy the supplied condition.
instance_handle (int) –
- Raises:
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Return type:
List[_T]
- read_next()[source]¶
Shortcut method to read exactly one sample or return None.
- Raises:
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Return type:
Optional[_T]
- take_next()[source]¶
Shortcut method to take exactly one sample or return None.
- Raises:
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Return type:
Optional[_T]
- read_iter(condition=None, timeout=None)[source]¶
Shortcut method to iterate reading samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.
- Raises:
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Parameters:
timeout (int) –
- Return type:
Generator[_T, None, None]
- read_one(condition=None, timeout=None)[source]¶
Shortcut method to block and take exactly one sample or raise a timeout
- Parameters:
timeout (int) –
- Return type:
_T
- take_iter(condition=None, timeout=None)[source]¶
Shortcut method to iterate taking samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.
- Raises:
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Parameters:
timeout (int) –
- Return type:
Generator[_T, None, None]
- take_one(condition=None, timeout=None)[source]¶
Shortcut method to block and take exactly one sample or raise a timeout
- Parameters:
timeout (int) –
- Return type:
_T
- async read_aiter(condition=None, timeout=None)[source]¶
Shortcut method to async iterate reading samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.
- Raises:
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Parameters:
timeout (int) –
- Return type:
AsyncGenerator[_T, None]
- async take_aiter(condition=None, timeout=None)[source]¶
Shortcut method to async iterate taking samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.
- Raises:
DDSException – If any error code is returned by the DDS API it is converted into an exception.
- Parameters:
timeout (int) –
- Return type:
AsyncGenerator[_T, None]
- get_matched_publications()[source]¶
Get instance handles of the data writers matching a reader.
- Raises:
DDSException – When the number of matching writers < 0.:
- Returns:
A list of instance handles of the matching data writers.
- Return type:
List[int]
- property matched_pub: List[int]¶
Get instance handles of the data writers matching a reader.
- Raises:
DDSException – When the number of matching writers < 0.:
- Returns:
A list of instance handles of the matching data writers.
- Return type:
List[int]
- get_matched_publication_data(handle)[source]¶
Get a description of a writer matched with the provided reader.
- Parameters:
handle (Int) – The instance handle of a writer.
- Returns:
The sample of the DcpsEndpoint built-in topic.
- Return type:
- get_liveliness_changed_status()[source]¶
Get LIVELINESS_CHANGED status
- Raises:
- Returns:
The class ‘liveness_changed_status’ value.
- Return type:
liveness_changed_status
- get_requested_deadline_missed_status()[source]¶
Get REQUESTED DEALINE MISSED status
- Raises:
- Returns:
The class ‘requested_deadline_missed_status’ value.
- Return type:
- get_requested_incompatible_qos_status()[source]¶
Get REQUESTED INCOMPATIBLE QOS status
- Raises:
- Returns:
The class ‘requested_incompatible_qos_status’ value.
- Return type:
- get_sample_lost_status()[source]¶
Get SAMPLE LOST status
- Raises:
- Returns:
The class ‘sample_lost_status’ value.
- Return type:
- get_sample_rejected_status()[source]¶
Get SAMPLE REJECTED status
- Raises:
- Returns:
The class ‘sample_rejected_status’ value.
- Return type: