Skip to content

Commit bdad222

Browse files
authored
Merge pull request #127 from willstott101/feature/sample_timestamp
Document SampleInfo
2 parents 50ff5bb + 89e9e6d commit bdad222

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

cyclonedds/internal.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,22 @@ def __init__(self, reference: int) -> None:
242242

243243
@dataclass
244244
class SampleInfo:
245+
"""
246+
Contains information about the associated data value
247+
248+
Attributes
249+
----------
250+
sample_state:
251+
Possible values: :class:`SampleState<cyclonedds.core.SampleState>`
252+
view_state:
253+
Possible values: :class:`ViewState<cyclonedds.core.ViewState>`
254+
instance_state:
255+
Possible values: :class:`InstanceState<cyclonedds.core.InstanceState>`
256+
source_timestamp:
257+
The time (in unix nanoseconds) that the associated sample was written.
258+
instance_handle:
259+
Handle to the data instance (if this is a keyed topic)
260+
"""
245261
sample_state: int
246262
view_state: int
247263
instance_state: int

cyclonedds/sub.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ def _notify_readers(self, subsriber: dds_c_t.entity) -> dds_c_t.returnv:
8282

8383
class DataReader(Entity, Generic[_T]):
8484
"""Subscribe to a topic and read/take the data published to it.
85+
86+
All returned samples are annotated with the :class:`sample.sample_info<cyclonedds.internal.SampleInfo>` attribute.
8587
"""
8688

8789
def __init__(
@@ -90,8 +92,7 @@ def __init__(
9092
topic: Topic[_T],
9193
qos: Optional[Qos] = None,
9294
listener: Optional[Listener] = None):
93-
"""Initialize the DataReader
94-
95+
"""
9596
Parameters
9697
----------
9798
subscriber_or_participant: cyclonedds.sub.Subscriber, cyclonedds.domain.DomainParticipant
@@ -309,7 +310,7 @@ def take_one(self, condition=None, timeout: int = None) -> _T:
309310
return sample
310311

311312
async def read_aiter(self, condition=None, timeout: int = None) -> AsyncGenerator[_T, None]:
312-
"""Shortcut method to asycn iterate reading samples. Iteration will stop once the timeout you supply expires.
313+
"""Shortcut method to async iterate reading samples. Iteration will stop once the timeout you supply expires.
313314
Every time a sample is received the timeout is reset.
314315
315316
Raises
@@ -335,7 +336,7 @@ async def read_aiter(self, condition=None, timeout: int = None) -> AsyncGenerato
335336
break
336337

337338
async def take_aiter(self, condition=None, timeout: int = None) -> AsyncGenerator[_T, None]:
338-
"""Shortcut method to asycn iterate taking samples. Iteration will stop once the timeout you supply expires.
339+
"""Shortcut method to async iterate taking samples. Iteration will stop once the timeout you supply expires.
339340
Every time a sample is received the timeout is reset.
340341
341342
Raises

docs/source/cyclonedds.internal.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ As the name suggests, the functionality in this module is meant for internal pac
88
:members:
99
:undoc-members:
1010

11+
.. autoclass:: cyclonedds.internal.SampleInfo()
12+
1113
.. autofunction:: cyclonedds.internal.load_cyclonedds
1214

1315
.. autodecorator:: cyclonedds.internal.c_call

0 commit comments

Comments
 (0)