From bda859e93d171602e8fa7de1d88d8f2bfe22230f Mon Sep 17 00:00:00 2001 From: appel_c Date: Tue, 7 Nov 2023 19:55:43 +0100 Subject: [PATCH] refactor: addressed comments from review; fixed docstring; add DeviceClassInitError --- ophyd_devices/epics/devices/eiger9m_csaxs.py | 9 ++++++++- ophyd_devices/epics/devices/pilatus_csaxs.py | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ophyd_devices/epics/devices/eiger9m_csaxs.py b/ophyd_devices/epics/devices/eiger9m_csaxs.py index ae03f64..812486d 100644 --- a/ophyd_devices/epics/devices/eiger9m_csaxs.py +++ b/ophyd_devices/epics/devices/eiger9m_csaxs.py @@ -38,6 +38,13 @@ class EigerTimeoutError(EigerError): pass +class DeviceClassInitError(EigerError): + """Raised when initiation of the device class fails, + due to missing device manager or not started in sim_mode.""" + + pass + + class SLSDetectorCam(Device): """SLS Detector Camera - Eiger 9M @@ -134,7 +141,7 @@ class Eiger9McSAXS(DetectorBase): **kwargs, ) if device_manager is None and not sim_mode: - raise Exception( + raise DeviceClassInitError( f"No device manager for device: {name}, and not started sim_mode: {sim_mode}. Add DeviceManager to initialization or init with sim_mode=True" ) self.sim_mode = sim_mode diff --git a/ophyd_devices/epics/devices/pilatus_csaxs.py b/ophyd_devices/epics/devices/pilatus_csaxs.py index fe9a667..228e1d9 100644 --- a/ophyd_devices/epics/devices/pilatus_csaxs.py +++ b/ophyd_devices/epics/devices/pilatus_csaxs.py @@ -37,6 +37,13 @@ class PilatusTimeoutError(PilatusError): pass +class DeviceClassInitError(PilatusError): + """Raised when initiation of the device class fails, + due to missing device manager or not started in sim_mode.""" + + pass + + class TriggerSource(enum.IntEnum): INTERNAL = 0 EXT_ENABLE = 1 @@ -127,7 +134,7 @@ class PilatuscSAXS(DetectorBase): **kwargs, ) if device_manager is None and not sim_mode: - raise Exception( + raise DeviceClassInitError( f"No device manager for device: {name}, and not started sim_mode: {sim_mode}. Add DeviceManager to initialization or init with sim_mode=True" ) self.sim_mode = sim_mode @@ -416,7 +423,11 @@ class PilatuscSAXS(DetectorBase): # TODO might be useful for base class def pre_scan(self) -> None: - """ " Pre_scan gets executed right before""" + """Pre_scan is an (optional) function that is executed by BEC just before the scan core + + For the pilatus detector, it is used to arm the detector for the acquisition, + because the detector times out after ˜7-8seconds without seeing a trigger. + """ self._arm_acquisition() def _arm_acquisition(self) -> None: