diff --git a/csaxs_bec/devices/ids_cameras/ids_camera.py b/csaxs_bec/devices/ids_cameras/ids_camera.py index 750e877..0a7f11d 100644 --- a/csaxs_bec/devices/ids_cameras/ids_camera.py +++ b/csaxs_bec/devices/ids_cameras/ids_camera.py @@ -3,21 +3,19 @@ from __future__ import annotations import threading -import time -from typing import TYPE_CHECKING, Literal, Tuple, TypedDict +from typing import TYPE_CHECKING, Literal import numpy as np +from ophyd import Component as Cpt, Signal, Kind + from bec_lib import messages from bec_lib.logger import bec_logger -from ophyd import Component as Cpt +from csaxs_bec.devices.ids_cameras.base_integration.camera import Camera from ophyd_devices.interfaces.base_classes.psi_device_base import PSIDeviceBase from ophyd_devices.utils.bec_signals import AsyncSignal, PreviewSignal -from csaxs_bec.devices.ids_cameras.base_integration.camera import Camera - if TYPE_CHECKING: from bec_lib.devicemanager import ScanInfo - from pydantic import ValidationInfo logger = bec_logger.logger @@ -45,6 +43,7 @@ class IDSCamera(PSIDeviceBase): doc="Signal for the region of interest (ROI).", async_update={"type": "add", "max_shape": [None]}, ) + live_mode_enabled = Cpt(Signal, name="live_mode_enabled", value=False ,doc="Enable or disable live mode.",kind=Kind.config) USER_ACCESS = ["live_mode", "mask", "set_rect_roi", "get_last_image"] @@ -83,7 +82,6 @@ class IDSCamera(PSIDeviceBase): bits_per_pixel=bits_per_pixel, connect=False, ) - self._live_mode = False self._inputs = {"live_mode": live_mode} self._mask = np.zeros((1, 1), dtype=np.uint8) self.image.num_rotation_90 = num_rotation_90 @@ -117,15 +115,15 @@ class IDSCamera(PSIDeviceBase): @property def live_mode(self) -> bool: """Return whether the camera is in live mode.""" - return self._live_mode + return bool(self.live_mode_enabled.get()) @live_mode.setter def live_mode(self, value: bool): """Set the live mode for the camera.""" - if value != self._live_mode: + if value != bool(self.live_mode_enabled.get()): if self.cam._connected is False: # $ pylint: disable=protected-access self.cam.on_connect() - self._live_mode = value + self.live_mode_enabled.put(bool(value)) if value: self._start_live() else: