plesty.lib.device

Device abstractions and base classes for Plesty.

Submodules

Classes

DeviceDocModel

All doc-relevant metadata of a device, decoupled from rendering.

FuncDoc

One documented operation, regardless of how it is implemented.

FuncOutput

Data class to hold function output metadata.

FuncParam

Data class to hold function argument metadata.

Package Contents

class plesty.lib.device.DeviceDocModel

All doc-relevant metadata of a device, decoupled from rendering.

Variables:
  • parameters – Configuration parameters grouped by configuration group ({group_name: [ConfigParameter, ...]}).

  • functions – The device’s own operations (schema-registered plus @expose_to_api methods) as unified FuncDoc objects.

  • standard_methods – The common device API shared by every device (connect, write, query, …), as FuncDoc.

parameters: dict[str, list[plesty.lib.device.params.ConfigParameter]]
functions: list[plesty.lib.device.funcs.FuncDoc]
standard_methods: list[plesty.lib.device.funcs.FuncDoc]
to_dict() → dict[str, Any]

Return the whole model as JSON primitives.

This is what leaves the device: the describe reply carries it, so a caller that never imports plesty-lib — a console on another process, a client on another machine — reads the same units, bounds, options and descriptions the device declared, instead of inventing them.

Returns:

A mapping with parameters (grouped, as the model holds them), functions and standard_methods, all JSON primitives.

Return type:

dict[str, Any]

class plesty.lib.device.FuncDoc

One documented operation, regardless of how it is implemented.

Unifies schema-registered operations and @expose_to_api custom methods into a single shape so documentation renders them identically.

Variables:
  • name – Operation / method name.

  • source – "schema" for a registered operation, "custom" for an @expose_to_api (or public child) method.

  • description – Human-readable description (from the schema or docstring).

  • iparams – Input parameters.

  • oparams – Output values.

  • kind – What the operation does to the world (see OpKind); read when the module declared nothing.

name: str
source: str
description: str
iparams: list[FuncParam]
oparams: list[FuncOutput]
kind: plesty.lib.device.device_utils.OpKind
to_dict() → dict[str, Any]

Return this operation as JSON primitives.

Returns:

The operation with its arguments, its outputs and its OpKind — enough for a caller to offer it, and to decide whether it should be one click away.

Return type:

dict[str, Any]

class plesty.lib.device.FuncOutput

Data class to hold function output metadata.

name: str
dtype: Any
unit: str = ''
required: bool = True
code_mapping: dict[Any, str] | None = None
range: tuple[Any, Any] | None = None
shape: tuple[Any, Ellipsis] | None = None
item_dtype: Any = None
headers: list[plesty.lib.data.TableHeader] | None = None
description: str = ''
to_dict() → dict[str, Any]

Return this output as JSON primitives.

Returns:

Name, type, unit and shape — what a caller needs to read the result, including a table’s column headers.

Return type:

dict[str, Any]

class plesty.lib.device.FuncParam

Data class to hold function argument metadata.

name: str
dtype: Any
unit: str = ''
default: Any = None
required: bool = True
options: list[Any] | None = None
range: tuple[Any, Any] | None = None
shape: tuple[Any, Ellipsis] | None = None
item_dtype: Any = None
description: str = ''
to_dict() → dict[str, Any]

Return this argument as JSON primitives.

Returns:

Name, type, unit, default and constraints — what a caller needs to offer the argument and check it before sending.

Return type:

dict[str, Any]