hardware#

class mesofield.hardware.HardwareManager[source]#

Bases: object

High-level class that initializes all hardware (cameras, encoder, etc.) using the ParameterManager. Keeps references easily accessible.

When config_file is None or the file does not exist the manager starts in an unconfigured default state. Call load_config() later to point it at a real YAML file and then initialize() to bring hardware up.

__init__(config_file=None, devices=None)[source]#
Parameters:

config_file (str | None)

property is_configured: bool#

True when a valid YAML config has been loaded.

load_config(config_file)[source]#

Load (or reload) a hardware YAML file.

This does not initialise devices – call initialize() afterwards.

Parameters:

config_file (str)

Return type:

None

initialize(cfg)[source]#

Initialize all devices from YAML and configure engines.

Does nothing if the manager has no loaded YAML configuration. Validates that exactly one device is flagged primary: true.

Return type:

None

to_yaml(path=None)[source]#

Serialize the current devices into a hardware.yaml mapping.

Each device becomes a top-level type:-tagged stanza keyed by its device id, re-importable through _init_extras(). This is the migration path from a scripted procedure to a reusable rig file.

When path is given the mapping is also written to disk. Raises RuntimeError if any device’s class was never registered via @DeviceRegistry.register (no registry_key -> not migratable).

Parameters:

path (str | None)

Return type:

dict

property primary#

Return the device flagged primary: true in YAML.

arm_all(cfg)[source]#

Call arm(cfg) on every device for per-run preparation.

Return type:

None

start_all()[source]#

Call start() on every device.

Return type:

None

deinitialize()[source]#

Tear down all devices and reset to unconfigured state.

After this call the manager can be re-initialised with a fresh load_config() / initialize() cycle.

stop()[source]#

Stop all devices.

stop_all()#

Stop all devices.

shutdown()[source]#

Shutdown all devices.

get_device(device_id)[source]#

Get a device by its ID.

Parameters:

device_id (str)

Return type:

HardwareDevice | None

cam_backends(backend)[source]#

Generator to iterate through cameras with a specific backend.