herosdevices.core.templates.display¶
Templates for creating camera device representations.
Module Contents¶
- class herosdevices.core.templates.display.DisplayDeviceTemplate(config_dict: dict, default_config: str | None = None, keep_device_open: bool = True)[source]¶
Bases:
herosdevices.interfaces.heros.ConfiguredDeviceTemplate (base class) for displays.
To make a functional display device, the user needs to implement all abstract methods. In addition, this class does not cover the mechanism the actually push the image to eventaual image buffers or to actually display the imag since it is typically special to each vendor/API.
The driver must also define the default_config_dict attribute, intended for configuration values which are applied to all user configurations if the corresponding keys are not specified.
Two class attributes describe config keys the driver treats specially.
_special_config_keyslists keys which are handled by the driver itself instead of being passed on to the vendor SDK. They may be absent from a configuration._required_config_keyslists keys that must be present in every configuration, either set explicitly or provided bydefault_config_dict.update_configuration()withmerge=Falseenforces the latter.- default_config_dict: dict¶
- keep_device_open = True¶
- default_config: str¶
- get_device() collections.abc.Iterator[None][source]¶
Yield a device handle.
# use the device in a with statement with self.get_device() as slm: slm.do_something()
- get_status() dict[source]¶
Get a dict with the current device status.
- Returns:
A dict with the device status
- property config_dict: dict¶
Get a copy of the configuration dict.
- Returns:
Copy of the configuration dict
- update_configuration(new_config_dict: dict, merge: bool = True) None[source]¶
Update the configuration dict with new configuration.
Each dict key corresponds a (new) configuration name. Each value is a dict with config property -> config value.
- Parameters:
new_config_dict – A dict of configurations where the keys are the configuration names
merge – If
True, the new dict is recursively merged with the current set config dict. IfFalsethe old configurations with the provided names (keys) are overwritten. In this case each new configuration, merged overdefault_config_dict, must contain all_required_config_keys.
- Raises:
ValueError – If
mergeisFalseand a required config key is missing. No configuration is changed.
- get_configuration() dict[source]¶
Get the currently active configuration.
- Returns:
The currently active configuration.
- configure(config: str = '') bool[source]¶
Configure the device with the known configuration config.
To add a configuration to the device, use
update_configuration().- Parameters:
config – Key (name) of the configuration
- set_configuration¶