plesty.lib.solver

Abstract base classes for command and operation solvers.

Submodules

Classes

ConfigParameter

Represents a single configuration parameter for a device.

CmdSolver

Abstract base class for building device command strings.

OpSolver

Abstract base class for solving operation requests.

Package Contents

class plesty.lib.solver.ConfigParameter

Represents a single configuration parameter for a device.

name: str
default: Any = None
value: Any = None
dtype: type | Any = None
unit: str | None = None
read_only: bool = False
write_only: bool = False
min_value: float | int | None = None
max_value: float | int | None = None
options: list[Any] | None = None
command: str | Command | None = None
parser: plesty.lib.device.device_utils.ResponseParser | None = None
description: str | None = None
to_dict() → dict[str, Any]

Return the caller-facing description of this parameter.

Everything needed to render or bound the parameter, and nothing about how it reaches the instrument: command and parser are this device’s own business, and neither has a JSON form.

Returns:

The parameter as JSON primitives.

Return type:

dict[str, Any]

class plesty.lib.solver.CmdSolver

Bases: abc.ABC

Abstract base class for building device command strings.

abstractmethod get_write_cmd(cfg_param: plesty.lib.device.params.ConfigParameter, value: Any) → str | None

Build a write command string for the given parameter and value.

Parameters:
Return type:

str | None

abstractmethod get_query_cmd(cfg_param: plesty.lib.device.params.ConfigParameter) → str | None

Build a query command string for the given parameter.

Parameters:

cfg_param (plesty.lib.device.params.ConfigParameter)

Return type:

str | None

class plesty.lib.solver.OpSolver

Bases: abc.ABC

Abstract base class for solving operation requests.

abstractmethod solve_request(request: dict) → dict

Solve an operation request and return the response dict.

Parameters:

request (dict)

Return type:

dict