Skip to content

time_base

frog.hardware.plugins.time.time_base ¤

Provides a base class for time source devices or mock devices.

Attributes¤

Classes¤

TimeBase(name=None) ¤

Bases: Device

The base class for time source devices or mock devices.

Source code in frog/hardware/device.py
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
def __init__(self, name: str | None = None) -> None:
    """Create a new Device.

    Args:
        name: A name to distinguish devices of the same type.
    """
    self.topic = f"device.{self._device_base_type_info.name}"
    """The name of the root pubsub topic on which this device will broadcast."""

    self.name = name
    """The (optional) name of this device to use in pubsub messages."""

    self._subscriptions: list[tuple[Callable, str]] = []
    """Store of wrapped functions which are subscribed to pubsub messages."""

    self._is_open = False
    """Whether the device has finished opening."""

    if not self._device_base_type_info.names_short:
        if name:
            raise RuntimeError(
                "Name provided for device which cannot accept names."
            )
        return

    if name not in self._device_base_type_info.names_short:
        raise RuntimeError("Invalid name given for device")

    self.topic += f".{name}"
Functions¤
get_time_offset() abstractmethod ¤

Get the current time offset in seconds.

Returns:

Type Description
float

A float representing the current time offset.

Source code in frog/hardware/plugins/time/time_base.py
12
13
14
15
16
17
18
@abstractmethod
def get_time_offset(self) -> float:
    """Get the current time offset in seconds.

    Returns:
        A float representing the current time offset.
    """