moddef.device module

Runtime device facade (spec §32.4): binds a Transport to one device profile for point- and measurand-based reads/writes. Port of moddef-ts Device / go/client/client.go.

SunSpec model_relative_offset is resolved against the model ID register (offset 0 = model id, 1 = length, data at 2+) per spec §7.3 — the same convention as the Go/TS/Rust clients and the profiles in devices/.

Shared limitation kept in lockstep: composed (multi-register mantissa/exponent) points decode via the codec directly, not through the facade.

class moddef.device.Device(profile: DeviceProfile, transport: Transport)[source]

Bases: object

The untyped runtime facade over one device profile.

classmethod create(doc: ModDefDocument, device_id: str | None, transport: Transport) Device[source]

Bind a transport to the named device profile in doc (or the only one).

point(point_id: str) tuple[Point, RegisterBlock][source]
points() list[Point][source]
async read_measurand(q: MeasurandQuery) float | int | bool | str | bytes | list[str] | dict[str, int] | datetime | Unavailable[source]

Read a point by its semantic measurand tuple (spec §26.1).

async read_point(point_id: str) float | int | bool | str | bytes | list[str] | dict[str, int] | datetime | Unavailable[source]

Read and decode a single point by id.

async read_points(ids: Iterable[str]) dict[str, float | int | bool | str | bytes | list[str] | dict[str, int] | datetime | Unavailable][source]
async write_point(point_id: str, value: float | int | bool | str | bytes | Sequence[str] | datetime) None[source]

Encode and write a value, validating access mode and §11.4 constraints.

moddef.device.validate_constraints(p: Point, value: float | int | bool | str | bytes | Sequence[str] | datetime) None[source]

Validate a write value against WriteConstraints (spec §11.4).