fix: reduce update rate of pilatur poll thread, add logs for complete
This commit is contained in:
@@ -232,7 +232,7 @@ class Mo1Bragg(PSIDeviceBase, Mo1BraggPositioner):
|
||||
"break_enable_high", None
|
||||
)
|
||||
break_time_low = self.scan_parameters.additional_scan_parameters.get(
|
||||
"break_time_low", None
|
||||
"break_self.scatime_low", None
|
||||
)
|
||||
break_time_high = self.scan_parameters.additional_scan_parameters.get(
|
||||
"break_time_high", None
|
||||
@@ -335,9 +335,16 @@ class Mo1Bragg(PSIDeviceBase, Mo1BraggPositioner):
|
||||
|
||||
def on_complete(self) -> DeviceStatus | StatusBase | None:
|
||||
"""Called to inquire if a device has completed a scans."""
|
||||
time_started = time.time()
|
||||
logger.info(f"Calling complete on {self.name}.")
|
||||
status = CompareStatus(self.scan_control.scan_done, 1)
|
||||
status.add_callback(self._status_callback)
|
||||
self.cancel_on_stop(status)
|
||||
logger.info(f"Finished calling complete on {self.name} within {time.time()-time_started}s.")
|
||||
return status
|
||||
|
||||
def _status_callback(self, status, **kwargs):
|
||||
logger.info(f"Complete finished on mo1bragg with {status.done} and {status.success}")
|
||||
|
||||
def on_kickoff(self) -> DeviceStatus | StatusBase | None:
|
||||
"""Called to kickoff a device for a fly scan. Has to be called explicitly."""
|
||||
@@ -369,14 +376,21 @@ class Mo1Bragg(PSIDeviceBase, Mo1BraggPositioner):
|
||||
if scan_parameters.scan_name in self.valid_scan_names:
|
||||
return True
|
||||
return False
|
||||
|
||||
def _progress_update(self, value, **kwargs) -> None:
|
||||
|
||||
def _progress_update(self, value, old_value, **kwargs) -> None:
|
||||
"""Callback method to update the scan progress, runs a callback
|
||||
to SUB_PROGRESS subscribers, i.e. BEC.
|
||||
|
||||
Args:
|
||||
value (int) : current progress value
|
||||
"""
|
||||
if self.scan_info.msg is None:
|
||||
return
|
||||
if self.scan_info.msg.status != "open":
|
||||
if old_value == value:
|
||||
return
|
||||
# TODO check if logic is true
|
||||
self.progress_signal.put(value=100, max_value=100, done=True)
|
||||
max_value = 100
|
||||
self.progress_signal.put(value=value, max_value=max_value, done=bool(max_value == value))
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
from typing import TYPE_CHECKING, Literal
|
||||
|
||||
from bec_lib.logger import bec_logger
|
||||
@@ -485,6 +486,8 @@ class Nidaq(PSIDeviceBase, NidaqControl):
|
||||
For the NIDAQ we use this method to stop the backend since it
|
||||
would not stop by itself in its current implementation since the number of points are not predefined.
|
||||
"""
|
||||
time_started = time.time()
|
||||
logger.info(f"Calling complete on {self.name}.")
|
||||
if not self._check_if_scan_name_is_valid(self.scan_parameters):
|
||||
return None
|
||||
|
||||
@@ -492,6 +495,7 @@ class Nidaq(PSIDeviceBase, NidaqControl):
|
||||
self.cancel_on_stop(status)
|
||||
if self.scan_parameters.scan_name != "nidaq_continuous_scan":
|
||||
self.on_stop()
|
||||
logger.info(f"Finished calling complete on {self.name} within {time.time()-time_started}s.")
|
||||
return status
|
||||
|
||||
def _progress_update(self, value, **kwargs) -> None:
|
||||
|
||||
@@ -261,6 +261,7 @@ class Pilatus(PSIDeviceBase, ADBase):
|
||||
# self._live_mode_stopped_event = threading.Event()
|
||||
# self._live_mode_stopped_event.set() # Initial state is stopped
|
||||
self.scan_parameters: ScanServerScanInfo = None
|
||||
self._unique_array_id : int = 0
|
||||
|
||||
########################################
|
||||
# Custom Beamline Methods #
|
||||
@@ -271,6 +272,11 @@ class Pilatus(PSIDeviceBase, ADBase):
|
||||
while not self._poll_thread_kill_event.wait(1 / self._poll_rate):
|
||||
try:
|
||||
# logger.info(f"Running poll loop for {self.name}..")
|
||||
array_id = self.image1.unique_id.get()
|
||||
if array_id != self._unique_array_id:
|
||||
self._unique_array_id = array_id
|
||||
else:
|
||||
continue
|
||||
value = self.image1.array_data.get()
|
||||
if value is None:
|
||||
continue
|
||||
@@ -288,7 +294,7 @@ class Pilatus(PSIDeviceBase, ADBase):
|
||||
# )
|
||||
# continue
|
||||
|
||||
logger.info(f"Setting preview data for {self.name}")
|
||||
# logger.info(f"Setting preview data for {self.name}")
|
||||
self.preview.put(data)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
content = traceback.format_exc()
|
||||
|
||||
Reference in New Issue
Block a user