plestylib.device.base_device_sync#

Classes#

BaseDeviceSyncModel

Helper class that provides a standard way to create an ABC using

Module Contents#

class plestylib.device.base_device_sync.BaseDeviceSyncModel(id: str, op_schema=None, param_schema=None, op_solver=None, cmd_solver=None, **kwargs)#

Bases: abc.ABC, plestylib.device.params.ConfigSystem, plestylib.device.funcs.FunctionSystem

Helper class that provides a standard way to create an ABC using inheritance.

Parameters:
  • solver – Callable used to send a message dictionary and return a response dictionary.

  • id (str)

id#
abstractmethod init(main=None)#

Initialize the device. This should be called before any other operations.

property is_operatable: bool#

Check if the device is currently operatable (connected and responsive).

Return type:

bool

property state: dict#

Return a dictionary representing the current state of the device, including all configuration parameters and their values.

Return type:

dict

get_state() dict#

Return a dictionary of all configuration parameters and their current values.

Return type:

dict

synchronize_param_from_device(keys: list[str] = None, sync_constraints: bool = False) None#

synchronizing the model’s configuration with the actual device.

Parameters:
  • keys (list[str])

  • sync_constraints (bool)

Return type:

None

summary() str#

Return a summary string of the device’s API functions. This can be used for documentation or debugging purposes to quickly see what TCP/IP commands are available for the device.

Return type:

str

query_param_range(key: str) tuple[float | int | None, float | int | None]#

Query the device for the valid range of a numeric parameter.

Parameters:

key (str)

Return type:

tuple[float | int | None, float | int | None]

query_param_options(key: str) list[Any] | None#

Query the device for the valid options of a categorical parameter.

Parameters:

key (str)

Return type:

list[Any] | None

abstractmethod connect()#

Placeholder method for connecting to the device.

abstractmethod disconnect()#

Placeholder method for disconnecting from the device.

abstractmethod identity() str#

Query the device for its identity string.

Return type:

str

abstractmethod check_errors() list[str]#

Query the device for any error messages.

Return type:

list[str]

abstractmethod check_operatability() bool#

Check if the device is currently operatable (connected and responsive).

Return type:

bool

__enter__()#
__exit__(exc_type, exc_value, tb)#
response_to_target_type(key, response) Any#
Return type:

Any

write(key: str, value: str | float | int | bool)#
Parameters:
  • key (str)

  • value (str | float | int | bool)

query(key)#
abstractmethod _write_(key: str, value: str | float | int | bool) bool#

Placeholder method for writing a command to the device.

Parameters:
  • key (str)

  • value (str | float | int | bool)

Return type:

bool

abstractmethod _query_(key: str) str#

Placeholder method for querying the device.

Parameters:

key (str)

Return type:

str

reset()#

Reset the device to a known state.

clear()#

Clear the device state.