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.ConfiguredDevice

Template (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.

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()
open() Any[source]

Open the device handler and assign it to self._device.

teardown() None[source]

Release the device handler and potentially de-initialize the API.

reset() None[source]

Reset the device by closing and re-opening the handler.

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. If False the old configurations with the provided names (keys) are overwritten.

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
push_image(slot: int, image: numpy.typing.NDArray[numpy.uint16], display_now: bool = True) bool[source]

Upload an image into a specified memory slot.

Parameters:
  • slot – Slot number

  • image – The image

  • display_now – Flag whether to display the image immediately

display_slot(slot: int = 1) bool[source]

Set the memory slot to display on the SLM.

Parameters:

slot – Slot number