From 9d58dcfb8332dd71a19d95aa883356d9cead0149 Mon Sep 17 00:00:00 2001 From: appel_c Date: Fri, 13 Mar 2026 13:57:41 +0100 Subject: [PATCH] fix(mcs): Fix timing on mcs card to resolve during complete. --- .../devices/epics/mcs_card/mcs_card_csaxs.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/csaxs_bec/devices/epics/mcs_card/mcs_card_csaxs.py b/csaxs_bec/devices/epics/mcs_card/mcs_card_csaxs.py index bfe2c48..971e115 100644 --- a/csaxs_bec/devices/epics/mcs_card/mcs_card_csaxs.py +++ b/csaxs_bec/devices/epics/mcs_card/mcs_card_csaxs.py @@ -20,6 +20,7 @@ from typing import TYPE_CHECKING, Callable, Literal import numpy as np from bec_lib.logger import bec_logger +from ophyd.utils.errors import WaitTimeoutError from ophyd import Component as Cpt from ophyd import EpicsSignalRO, Kind from ophyd_devices import ( @@ -513,7 +514,22 @@ class MCSCardCSAXS(PSIDeviceBase, MCSCard): # that the acquisition finishes on the card and that data is emitted to BEC. If the acquisition # was already finished (i.e. normal step scan sends 1 extra pulse per burst cycle), this will # not have any effect as the card will already be in DONE state and signal. - self.software_channel_advance.put(1) + if self.scan_info.msg.scan_type == "fly": + expected_points = int( + self.scan_info.msg.num_points + * self.scan_info.msg.scan_parameters.get("frames_per_trigger", 1) + ) + + status = CompareStatus(self.current_channel, expected_points-1, operation_success=">=") + try: + status.wait(timeout=5) + except WaitTimeoutError: + text = f"Device {self.name} received num points {self.current_channel.get()} / {expected_points}. Device timed out after 5s." + logger.error(text) + raise TimeoutError(text) + + # Manually set the last advance + self.software_channel_advance.put(1) # Prepare and register status callback for the async monitoring loop status_async_data = StatusBase(obj=self)