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 72213b3..d28a992 100644 --- a/csaxs_bec/devices/epics/delay_generator_csaxs/ddg_1.py +++ b/csaxs_bec/devices/epics/delay_generator_csaxs/ddg_1.py @@ -390,8 +390,9 @@ class DDG1(PSIDeviceBase, DelayGeneratorCSAXS): # counters are forwarded to BEC. Once the flag is set, we create a TransitionStatus DONE->ACQUIRING # and start the acquisition through erase_start.put(1). Finally, we wait for the card to go to ACQUIRING state. mcs._omit_mca_callbacks.clear() # pylint: disable=protected-access - mcs.erase_start.put(1) status_acquiring = CompareStatus(mcs.acquiring, ACQUIRING.ACQUIRING) + mcs.erase_start.put(1) + self.cancel_on_stop(status_acquiring) return status_acquiring @@ -609,10 +610,17 @@ class DDG1(PSIDeviceBase, DelayGeneratorCSAXS): # logger.error( # f"MCS card is not finishing after 3s, current state: {mcs.acquiring.get()}, waiting another 3s for its return to ACQUIRING state. If this happens regularly, please check the EPICS interface and the MCS card logic." # ) + if not status_mcs.done: + mcs.acquiring.get(use_monitor=False) status_mcs.wait(timeout=3) except Exception as exc: - logger.warning(f"MCS did not go to Acquiring within 3s. Retrying erase_start {exc}") - raise exc + if ( + mcs.acquiring.get(use_monitor=False) != ACQUIRING.ACQUIRING + ): # Get the current state without monitoring to avoid any side effects + logger.warning( + f"MCS did not go to Acquiring within 3s. Retrying erase_start {exc}" + ) + raise exc # mcs.erase_start.put(1) # status_mcs.wait(timeout=3) status = CompareStatus(mcs.acquiring, ACQUIRING.DONE)