util

The util module contains some utility functions that have no good place elsewhere but are not for internal use only (otherwise they would live in cyclonedds.internal).

cyclonedds.util.isgoodentity(v)[source]

Helper function that checks to see if an object is a valid Entity returned from DDS. This function will never raise an exception.

Parameters

v (object, optional) – The object to check

Returns

Whether this entity is a valid Entity.

Return type

bool

cyclonedds.util.duration(*, weeks=0, days=0, hours=0, minutes=0, seconds=0, milliseconds=0, microseconds=0, nanoseconds=0, infinite=False)[source]

Durations are always expressed in nanoseconds in DDS (dds_duration_t). This helper function lets you write time in a human readable format.

Examples

>>> duration(weeks=2, days=10, minutes=10)
Parameters
  • weeks (float, default=0) –

  • days (float, default=0) –

  • hours (float, default=0) –

  • minutes (float, default=0) –

  • seconds (float, default=0) –

  • milliseconds (float, default=0) –

  • microseconds (float, default=0) –

  • nanoseconds (int, default=0) –

  • infinite (bool, default=False) –

Returns

Duration expressed in nanoseconds.

Return type

int

cyclonedds.util.timestamp.now()

In DDS timestamps are typically expressed as nanoseconds since the Unix Epoch (dds_time_t). This helper function returns the current time in nanoseconds.

Returns

Number of nanoseconds since the Unix Epoch.

Return type

int