diff --git a/csaxs_bec/device_configs/ptycho_lamni.yaml b/csaxs_bec/device_configs/ptycho_lamni.yaml index 7c23157..e4e43a3 100644 --- a/csaxs_bec/device_configs/ptycho_lamni.yaml +++ b/csaxs_bec/device_configs/ptycho_lamni.yaml @@ -296,6 +296,7 @@ cam_xeye: transpose: false force_monochrome: true m_n_colormode: 1 + live_mode_poll_interval_s: 0.02 enabled: true onFailure: buffer readOnly: false diff --git a/csaxs_bec/devices/ids_cameras/ids_camera.py b/csaxs_bec/devices/ids_cameras/ids_camera.py index 2ea5bdc..e429c91 100644 --- a/csaxs_bec/devices/ids_cameras/ids_camera.py +++ b/csaxs_bec/devices/ids_cameras/ids_camera.py @@ -88,6 +88,7 @@ class IDSCamera(PSIDeviceBase): num_rotation_90: int = 0, transpose: bool = False, force_monochrome: bool = False, + live_mode_poll_interval_s: float = 0.2, **kwargs, ): """Initialize the IDS Camera. @@ -100,10 +101,15 @@ class IDSCamera(PSIDeviceBase): m_n_colormode (Literal[0, 1, 2, 3]): Color mode for the camera. bits_per_pixel (Literal[8, 24]): Number of bits per pixel for the camera. live_mode (bool): Whether to enable live mode for the camera. + live_mode_poll_interval_s (float): Delay between frame grabs in + the live-mode loop. Lower this for cameras/use cases that + need a higher live-mode push rate; the achievable rate is + still bounded by the camera's own exposure/acquisition time. """ super().__init__(name=name, prefix=prefix, scan_info=scan_info, **kwargs) self._live_mode_thread: threading.Thread | None = None self._stop_live_mode_event: threading.Event = threading.Event() + self._live_mode_poll_interval_s = live_mode_poll_interval_s # Rolling buffer of push timestamps from _live_mode_loop, used to # measure the actual live-mode frame rate (see get_live_fps()). self._live_frame_times: deque[float] = deque(maxlen=10) @@ -206,7 +212,7 @@ class IDSCamera(PSIDeviceBase): logger.error(f"Error in live mode loop: {e}") break self._live_frame_times.append(time.time()) - stop_event.wait(0.2) # 5 Hz + stop_event.wait(self._live_mode_poll_interval_s) self.cam.set_camera_rate_limiting(False) def get_live_fps(self) -> float | None: