fix(panda): make complete asyncronous for PandaBoxOmny

This commit is contained in:
2026-03-02 08:13:37 +01:00
parent 6ed84664f2
commit 40ef387134
2 changed files with 12 additions and 9 deletions

View File

@@ -18,6 +18,7 @@ class PandaBoxCSAXS(PandaBox):
self._timeout_on_completed = 10
def on_stage(self):
super().on_stage()
# TODO, adjust as seen fit.
# Adjust the acquisition group based on scan parameters if needed
if self.scan_info.msg.scan_type == "fly":
@@ -35,7 +36,10 @@ class PandaBoxCSAXS(PandaBox):
captured = 0
start_time = time.monotonic()
try:
expected_points = int(self.scan_info.msg.num_points * self.scan_info.msg.scan_parameters.get("frames_per_trigger",1))
expected_points = int(
self.scan_info.msg.num_points
* self.scan_info.msg.scan_parameters.get("frames_per_trigger", 1)
)
while captured < expected_points:
logger.info(
f"Run with captured {captured} and expected points : {expected_points}."
@@ -44,7 +48,9 @@ class PandaBoxCSAXS(PandaBox):
captured = int(ret[0].split("=")[-1])
time.sleep(0.01)
if (time.monotonic() - start_time) > self._timeout_on_completed:
raise TimeoutError(f"Pandabox {self.name} did not complete after {self._timeout_on_completed} with points captured {captured}/{expected_points}")
raise TimeoutError(
f"Pandabox {self.name} did not complete after {self._timeout_on_completed} with points captured {captured}/{expected_points}"
)
finally:
self._disarm()

View File

@@ -3,9 +3,8 @@
import time
from bec_lib.logger import bec_logger
from ophyd_devices import AsyncMultiSignal, StatusBase
from ophyd_devices import StatusBase
from ophyd_devices.devices.panda_box.panda_box import PandaBox, PandaState
from pandablocks.responses import FrameData
logger = bec_logger.logger
@@ -31,7 +30,6 @@ class PandaBoxOMNY(PandaBox):
def on_complete(self):
"""On complete is called after the scan is complete. We need to wait for the capture to complete before we can disarm the PandaBox."""
status = super().on_complete()
def _check_capture_complete():
captured = 0
@@ -55,10 +53,9 @@ class PandaBoxOMNY(PandaBox):
finally:
self._disarm()
_check_capture_complete()
if status is not None:
status.wait(timeout=self._timeout_on_completed)
status_captured = self.task_handler.submit_task(_check_capture_complete, run=True)
self.cancel_on_stop(status_captured)
return status_captured
# NOTE: This utility class allows to submit a blocking function to a thread and return a status object
# that can be awaited for. This allows for asynchronous waiting for the capture to complete without blocking