herosdevices.hardware.picotechnology ==================================== .. py:module:: herosdevices.hardware.picotechnology .. autoapi-nested-parse:: Driver classes for Pico Technology Ltd. devices. Module Contents --------------- .. py:data:: PICO_CHANNEL_FLAGS :value: [1, 2, 4, 8, 16, 32, 64, 128] .. py:data:: PICO_RANGE .. py:data:: DEFAULT_CONFIG .. py:data:: ps6000a :value: None .. py:class:: Picoscope(serial_num: str, config_dict: dict, default_config: str | None = None, **kwargs) Bases: :py:obj:`herosdevices.core.templates.oscilloscope.OscilloscopeTemplate` A class to interface Pico Technology computer oscilloscopes. This is the base class for the different models and can not be used standalone. Please refer to the specific model drivers. .. py:attribute:: serial_num :type: str .. py:attribute:: default_config_dict .. py:method:: assert_status(result: int) -> None Check if a command result was successful. :param result: Returnvalue from a picoscope command. :raises AssertionError: If the result is not ``PICO_OK``. .. py:attribute:: get_scope .. py:attribute:: acquisition_running :type: bool :value: False .. py:attribute:: payload_metadata :type: dict .. py:attribute:: keep_device_open :value: True .. py:attribute:: default_config :type: str .. py:method:: get_device() -> collections.abc.Iterator[None] Yield a device handle. .. code-block:: python # use the device in a with statement with self.get_device() as camera: camera.do_something() .. py:method:: open() -> Any Open the device handler and assign it to `self._device`. .. py:method:: teardown() -> None Release the device handler and potentially de-initialize the API. .. py:method:: start() -> bool Fire a software trigger. :returns: True if successful .. py:method:: stop() -> bool Abort the exposure and release queued buffers. :returns: True if successful .. py:method:: reset() -> None Reset the device by aborting any ongoing exposure, closing and re-opening the handler. .. py:method:: get_status() -> dict Get a dict with the current device status. :returns: A dict with the device status .. py:property:: config_dict :type: dict Get a copy of the configuration dict. :returns: Copy of the configuration dict .. py:method:: update_configuration(new_config_dict: dict, merge: bool = True) -> None 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. :param new_config_dict: A dict of configurations where the keys are the configuration names :param 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. .. py:method:: get_configuration() -> dict Get the currently active configuration. :returns: The currently active configuration. .. py:method:: configure(config: str = '', metadata: dict | None = None) -> bool Configure the device with the known configuration `config`. To add a configuration to the device, use :meth:`update_configuration`. :param config: Key (name) of the configuration :param metadata: Metadata that is merged into the current payload metadata dict which is send with every emitted :code:`acquisition_data` event. .. py:attribute:: set_configuration .. py:method:: update_payload_metadata(metadata: dict, merge: bool = True) -> None Update metadata dict send with every emitted frame by the :code:`acquisition_data` event method. :param metadata: Metadata that is merged into the current payload metadata dict which is send with every emitted :code:`acquisition_data` event. :param merge: If ``True``, the new dict is merged with the current set metadata dict. If ``False`` the old metadata is overwritten by the given dict. .. py:method:: arm(metadata: dict | None = None, kill_running: bool = False) -> bool Arm the device with the currently active configuration. :param metadata: Metadata that is merged into the current payload metadata dict which is send with every emitted :code:`acquisition_data` event. :param kill_running: If ``True`` any running acquisition will be stopped. If ``False`` and an acquisition is :param already running: :param an error will be raised.: :returns: True if arming was successful else False .. py:method:: acquisition_data(frame: numpy.ndarray, metadata: dict | None = None) -> tuple Event to emit new frames. .. note:: The dtype of the frame is not changed here. :param frame: The frame payload data (for example an image or an scope trace) :param metadata: The metadata which is passed along the payload. This argument takes precedence over the :code:`payload_metadata` attribute (for example set by the :code:`update_payload_metadata` method) while merging the two dicts. :returns: A tuple of image and metadata(-dict) .. py:method:: acquisition_started(metadata: dict | None = None) -> dict Event emitted when the acquisition thread starts. :returns: A dict with acquisition metadata .. py:method:: acquisition_stopped(metadata: dict | None = None) -> dict Event emitted when the acquisition thread stops. :returns: A dict with acquisition metadata .. py:class:: Picoscope6000a(serial_num: str, config_dict: dict, default_config: str | None = None, **kwargs) Bases: :py:obj:`Picoscope` Driver class for the Picoscope 6000 series. .. note:: You need the official picoscope sdk installed. Note that it is not on PyPi and you need to follow the instructions `here `_ .. rubric:: Example The class can be started with BOSS with the following example JSON dict:: { "_id": "myscope", "classname": "herosdevices.hardware.picotechnology.Picoscope6000a", "arguments": { "serial_num": "JP306/0102", "default_config": "default", "config_dict": { "default": { "ch0": { "coupling": "PICO_DC_50OHM", "range": "PICO_100MV" }, "ch1": { "coupling": "PICO_DC_50OHM", "range": "PICO_5V", "record_trace": false }, "trigger": { "source": 1, "threshold": 1.5 }, "acquisition": { "trace_length": 0.000006, "sample_time": 2e-10 } } } } } .. py:attribute:: serial_num :type: str .. py:attribute:: default_config_dict .. py:method:: assert_status(result: int) -> None Check if a command result was successful. :param result: Returnvalue from a picoscope command. :raises AssertionError: If the result is not ``PICO_OK``. .. py:attribute:: get_scope .. py:attribute:: acquisition_running :type: bool :value: False .. py:attribute:: payload_metadata :type: dict .. py:attribute:: keep_device_open :value: True .. py:attribute:: default_config :type: str .. py:method:: get_device() -> collections.abc.Iterator[None] Yield a device handle. .. code-block:: python # use the device in a with statement with self.get_device() as camera: camera.do_something() .. py:method:: open() -> Any Open the device handler and assign it to `self._device`. .. py:method:: teardown() -> None Release the device handler and potentially de-initialize the API. .. py:method:: start() -> bool Fire a software trigger. :returns: True if successful .. py:method:: stop() -> bool Abort the exposure and release queued buffers. :returns: True if successful .. py:method:: reset() -> None Reset the device by aborting any ongoing exposure, closing and re-opening the handler. .. py:method:: get_status() -> dict Get a dict with the current device status. :returns: A dict with the device status .. py:property:: config_dict :type: dict Get a copy of the configuration dict. :returns: Copy of the configuration dict .. py:method:: update_configuration(new_config_dict: dict, merge: bool = True) -> None 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. :param new_config_dict: A dict of configurations where the keys are the configuration names :param 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. .. py:method:: get_configuration() -> dict Get the currently active configuration. :returns: The currently active configuration. .. py:method:: configure(config: str = '', metadata: dict | None = None) -> bool Configure the device with the known configuration `config`. To add a configuration to the device, use :meth:`update_configuration`. :param config: Key (name) of the configuration :param metadata: Metadata that is merged into the current payload metadata dict which is send with every emitted :code:`acquisition_data` event. .. py:attribute:: set_configuration .. py:method:: update_payload_metadata(metadata: dict, merge: bool = True) -> None Update metadata dict send with every emitted frame by the :code:`acquisition_data` event method. :param metadata: Metadata that is merged into the current payload metadata dict which is send with every emitted :code:`acquisition_data` event. :param merge: If ``True``, the new dict is merged with the current set metadata dict. If ``False`` the old metadata is overwritten by the given dict. .. py:method:: arm(metadata: dict | None = None, kill_running: bool = False) -> bool Arm the device with the currently active configuration. :param metadata: Metadata that is merged into the current payload metadata dict which is send with every emitted :code:`acquisition_data` event. :param kill_running: If ``True`` any running acquisition will be stopped. If ``False`` and an acquisition is :param already running: :param an error will be raised.: :returns: True if arming was successful else False .. py:method:: acquisition_data(frame: numpy.ndarray, metadata: dict | None = None) -> tuple Event to emit new frames. .. note:: The dtype of the frame is not changed here. :param frame: The frame payload data (for example an image or an scope trace) :param metadata: The metadata which is passed along the payload. This argument takes precedence over the :code:`payload_metadata` attribute (for example set by the :code:`update_payload_metadata` method) while merging the two dicts. :returns: A tuple of image and metadata(-dict) .. py:method:: acquisition_started(metadata: dict | None = None) -> dict Event emitted when the acquisition thread starts. :returns: A dict with acquisition metadata .. py:method:: acquisition_stopped(metadata: dict | None = None) -> dict Event emitted when the acquisition thread stops. :returns: A dict with acquisition metadata