diff --git a/debye_bec/devices/cameras/basler_cam.py b/debye_bec/devices/cameras/basler_cam.py index c53fb29..e38076a 100644 --- a/debye_bec/devices/cameras/basler_cam.py +++ b/debye_bec/devices/cameras/basler_cam.py @@ -6,6 +6,8 @@ from typing import TYPE_CHECKING from ophyd import ADBase from ophyd import ADComponent as ADCpt +from ophyd import Component as Cpt +from ophyd_devices import PreviewSignal from ophyd_devices.devices.areadetector.cam import AravisDetectorCam from ophyd_devices.devices.areadetector.plugins import ImagePlugin_V35 @@ -25,14 +27,10 @@ class BaslerCamBase(ADBase): class BaslerCam(DebyeBaseCamera, BaslerCamBase): """Basler camera class at Debye. IOC prefix: X01DA-ES-XRAYEYE:""" - def __init__(self, *, name: str, prefix: str = "", scan_info: ScanInfo | None = None, **kwargs): - """ - Initialize the Prosilica camera class. - - Args: - name (str): Name of the camera. - prefix (str): IOC prefix. - scan_info (ScanInfo): The scan info to use. - """ - super().__init__(name=name, prefix=prefix, scan_info=scan_info, **kwargs) - self._n_rot90 = -1 # Rotate the image by -90 degrees + preview = Cpt( + PreviewSignal, + name="preview", + ndim=2, + num_rotation_90=-1, + doc="Preview signal for the camera.", + ) diff --git a/debye_bec/devices/cameras/debye_base_cam.py b/debye_bec/devices/cameras/debye_base_cam.py index ef3011b..601894c 100644 --- a/debye_bec/devices/cameras/debye_base_cam.py +++ b/debye_bec/devices/cameras/debye_base_cam.py @@ -7,7 +7,9 @@ from typing import TYPE_CHECKING import numpy as np from bec_lib.logger import bec_logger +from ophyd import Component as Cpt from ophyd import DeviceStatus, StatusBase +from ophyd_devices import PreviewSignal from ophyd_devices.interfaces.base_classes.psi_device_base import PSIDeviceBase from typeguard import typechecked @@ -23,6 +25,13 @@ class DebyeBaseCamera(PSIDeviceBase): """Base class for Debye cameras.""" USER_ACCESS = ["live_mode"] + preview = Cpt( + PreviewSignal, + name="preview", + ndim=2, + num_rotation_90=-1, + doc="Preview signal for the camera.", + ) def __init__(self, *, name: str, prefix: str = "", scan_info: ScanInfo | None = None, **kwargs): super().__init__(name=name, prefix=prefix, scan_info=scan_info, **kwargs) @@ -31,7 +40,6 @@ class DebyeBaseCamera(PSIDeviceBase): self._live_mode = False self._live_mode_event = None self._task_status = None - self._n_rot90 = -1 @property def live_mode(self) -> bool: @@ -82,8 +90,8 @@ class DebyeBaseCamera(PSIDeviceBase): width = self.image1.array_size.width.get() height = self.image1.array_size.height.get() # Geometry correction for the image - data = np.rot90(np.reshape(value, (height, width)), k=self._n_rot90, axes=(0, 1)) - self._run_subs(sub_type=self.SUB_DEVICE_MONITOR_2D, value=data) + data = np.reshape(value, (height, width)) + self.preview.put(data) ######################################## # Beamline Specific Implementations # diff --git a/debye_bec/devices/cameras/prosilica_cam.py b/debye_bec/devices/cameras/prosilica_cam.py index a8cab07..cbbc259 100644 --- a/debye_bec/devices/cameras/prosilica_cam.py +++ b/debye_bec/devices/cameras/prosilica_cam.py @@ -6,6 +6,8 @@ from typing import TYPE_CHECKING from ophyd import ADBase from ophyd import ADComponent as ADCpt +from ophyd import Component as Cpt +from ophyd_devices import PreviewSignal from ophyd_devices.devices.areadetector.cam import ProsilicaDetectorCam from ophyd_devices.devices.areadetector.plugins import ImagePlugin_V35 @@ -28,14 +30,10 @@ class ProsilicaCam(DebyeBaseCamera, ProsilicaCamBase): Prefixes are: X01DA-OP-GIGE02: and X01DA-OP-GIGE01: """ - def __init__(self, *, name: str, prefix: str = "", scan_info: ScanInfo | None = None, **kwargs): - """ - Initialize the Prosilica camera class. - - Args: - name (str): Name of the camera. - prefix (str): IOC prefix. - scan_info (ScanInfo): The scan info to use. - """ - super().__init__(name=name, prefix=prefix, scan_info=scan_info, **kwargs) - self._n_rot90 = -1 # Rotate the image by -90 degrees + preview = Cpt( + PreviewSignal, + name="preview", + ndim=2, + num_rotation_90=-1, + doc="Preview signal for the camera.", + ) diff --git a/tests/tests_devices/test_cameras.py b/tests/tests_devices/test_cameras.py index d74df11..fba8ac3 100644 --- a/tests/tests_devices/test_cameras.py +++ b/tests/tests_devices/test_cameras.py @@ -39,7 +39,8 @@ def test_basler_init(mock_basler): assert mock_basler._live_mode is False assert mock_basler._live_mode_event is None assert mock_basler._task_status is None - assert mock_basler._n_rot90 == -1 + assert mock_basler.preview.ndim == 2 + assert mock_basler.preview.num_rotation_90 == -1 @pytest.fixture(scope="function") @@ -65,4 +66,5 @@ def test_prosilica_init(mock_prosilica): assert mock_prosilica._live_mode is False assert mock_prosilica._live_mode_event is None assert mock_prosilica._task_status is None - assert mock_prosilica._n_rot90 == -1 + assert mock_prosilica.preview.ndim == 2 + assert mock_prosilica.preview.num_rotation_90 == -1 diff --git a/tests/tests_devices/test_debye_base_cam.py b/tests/tests_devices/test_debye_base_cam.py index b014a02..35004af 100644 --- a/tests/tests_devices/test_debye_base_cam.py +++ b/tests/tests_devices/test_debye_base_cam.py @@ -34,7 +34,8 @@ def test_init(mock_cam): assert mock_cam._live_mode is False assert mock_cam._live_mode_event is None assert mock_cam._task_status is None - assert mock_cam._n_rot90 == -1 + assert mock_cam.preview.ndim == 2 + assert mock_cam.preview.num_rotation_90 == -1 def test_start_live_mode(mock_cam):