From 00b769c7249e6fa4a31cd9f2aea533e77982152a Mon Sep 17 00:00:00 2001 From: appel_c Date: Fri, 19 Jun 2026 14:02:43 +0200 Subject: [PATCH] fix(ddg): fix prepare_mcs_on_trigger method --- csaxs_bec/devices/epics/delay_generator_csaxs/ddg_1.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/csaxs_bec/devices/epics/delay_generator_csaxs/ddg_1.py b/csaxs_bec/devices/epics/delay_generator_csaxs/ddg_1.py index 6a032dc..fc10406 100644 --- a/csaxs_bec/devices/epics/delay_generator_csaxs/ddg_1.py +++ b/csaxs_bec/devices/epics/delay_generator_csaxs/ddg_1.py @@ -364,7 +364,7 @@ class DDG1(PSIDeviceBase, DelayGeneratorCSAXS): time.sleep(0.2) logger.info(f"DDG {self.name} on_stage completed in {time.time() - start_time:.3f}s.") - def prepare_mcs_on_trigger(self, mcs: MCSCardCSAXS) -> None: + def prepare_mcs_on_trigger(self) -> CompareStatus: """ This method is used by the DDG1 on_trigger method to prepare the MCS card for the next trigger. @@ -373,6 +373,12 @@ class DDG1(PSIDeviceBase, DelayGeneratorCSAXS): It relies on the MCS card implementation and needs to be adapted if the MCS card logic changes. """ + mcs_name = "mcs" + if self.device_manager is None or not hasattr(self.device_manager, "devices"): + raise ValueError("Device manager is not properly initialized.") + mcs = self.device_manager.devices.get(mcs_name, None) + if mcs is None: + raise ValueError(f"MCS card {mcs_name} not found in device manager.") # NOTE First we wait that the MCS card is not acquiring. We add here a timeout of 5s to avoid # a deadlock in case the MCS card is stuck for some reason. This should not happen normally. @@ -588,7 +594,7 @@ class DDG1(PSIDeviceBase, DelayGeneratorCSAXS): else: start_time = time.time() logger.debug(f"Preparing mcs card ") - status_mcs = self._prepare_mcs_on_trigger(mcs) + status_mcs = self._prepare_mcs_on_trigger() # NOTE Timeout of 3s should be plenty, any longer wait should checked. If this happens to crash # an acquisition regularly with a WaitTimeoutError, the timeout can be increased but it should # be investigated why the EPICS interface is slow to respond.