Skip to content

Types¤

Shared types: runtime dataclasses (Measurement/Command) and cross-protocol Pydantic configs.

ScaleType module-attribute ¤

ScaleType = LinearScale

BackgroundDaemonConfig dataclass ¤

BackgroundDaemonConfig(interval: float = 1.0, enabled: bool = True)

interval class-attribute instance-attribute ¤

interval: float = 1.0

enabled class-attribute instance-attribute ¤

enabled: bool = True

Measurement dataclass ¤

Measurement(
    channel_data: dict[str, list[float]],
    timestamps: list[int],
    tags: dict[str, str] | None = None,
)

Data structure to hold measurement data. All channels have a common timebase.

channel_data instance-attribute ¤

channel_data: dict[str, list[float]]

timestamps instance-attribute ¤

timestamps: list[int]

tags class-attribute instance-attribute ¤

tags: dict[str, str] | None = None

values property ¤

values: list[float] | list[str]

Values for the only channel; raises ValueError if the Measurement holds multiple channels.

latest property ¤

latest: float | str

Most recent value of the only channel; raises ValueError if the Measurement holds multiple.

create_timestamps_from_dt staticmethod ¤

create_timestamps_from_dt(
    t0: int, dt: int, length: int, backstamp: bool
) -> list[int]

Build a length-long timestamp list at dt ns spacing starting at t0 (ns since epoch).

With backstamp=True, shift t0 back by dt * (length - 1) so the last sample lands at the original t0 (useful when t0 is the completion time of a finite acquisition).

Command dataclass ¤

Command(
    channel_data: dict[str, float | str],
    timestamp: int,
    tags: dict[str, str] | None = None,
)

Data structure to hold command data.

channel_data instance-attribute ¤

channel_data: dict[str, float | str]

timestamp instance-attribute ¤

timestamp: int

tags class-attribute instance-attribute ¤

tags: dict[str, str] | None = None

DeviceInfo ¤

Bases: BaseModel

Device metadata. name is the channel-name prefix on publish (e.g. my_device.temperature).

name instance-attribute ¤

name: str

description class-attribute instance-attribute ¤

description: str = ''

manufacturer class-attribute instance-attribute ¤

manufacturer: str = ''

model class-attribute instance-attribute ¤

model: str = ''

LinearScale ¤

Bases: BaseModel

Linear scaling: physical = offset + (gain * raw).

Applied automatically on reads (raw -> physical) and reversed on writes (physical -> raw). Not all protocols or data point types support scaling -- check the protocol-specific documentation.

type class-attribute instance-attribute ¤

type: Literal['linear'] = 'linear'

gain class-attribute instance-attribute ¤

gain: float = Field(
    default=1.0, description="Scale factor (must not be zero)"
)

offset class-attribute instance-attribute ¤

offset: float = 0.0

model_post_init ¤

model_post_init(__context) -> None

Validate that gain is not zero.

to_physical ¤

to_physical(raw: float) -> float

Convert raw register value to physical units.

to_raw ¤

to_raw(physical: float) -> float

Convert physical value to raw register value.

Returns float to preserve precision for float registers. Integer registers should handle conversion in _encode_value.