diff --git a/csaxs_bec/devices/ids_cameras/ids_camera.py b/csaxs_bec/devices/ids_cameras/ids_camera.py index 0a7f11d..e344848 100644 --- a/csaxs_bec/devices/ids_cameras/ids_camera.py +++ b/csaxs_bec/devices/ids_cameras/ids_camera.py @@ -87,6 +87,7 @@ class IDSCamera(PSIDeviceBase): self.image.num_rotation_90 = num_rotation_90 self.image.transpose = transpose self._force_monochrome = force_monochrome + self.live_mode_enabled.subscribe(self.on_live_mode_changed) ############## Live Mode Methods ############## @@ -121,13 +122,17 @@ class IDSCamera(PSIDeviceBase): def live_mode(self, value: bool): """Set the live mode for the camera.""" 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_enabled.put(bool(value)) - if value: - self._start_live() - else: - self._stop_live() + + def on_live_mode_changed(self, *args, value, **kwargs): + """Callback for when live mode is changed.""" + if self.cam._connected is False: # $ pylint: disable=protected-access + self.cam.on_connect() + self.live_mode_enabled.put(bool(value)) + if value: + self._start_live() + else: + self._stop_live() def set_rect_roi(self, x: int, y: int, width: int, height: int): """Set the rectangular region of interest (ROI) for the camera."""