f
CI for xtreme_bec / test (push) Successful in 31s

This commit is contained in:
2026-07-06 17:44:28 +02:00
parent 104e31a536
commit 16ef7edd1f
2 changed files with 20 additions and 3 deletions
+17 -3
View File
@@ -38,7 +38,7 @@ class PGMMonochromator(PSIDeviceBase, PGMMonochromatorBase):
PGM monochromator device that combines the functionality of PSIDeviceBase and PGMMonochromator.
"""
USER_ACCESS = ["get_max_speeds", "set_progress_range"]
USER_ACCESS = ["get_max_speeds", "set_progress_range", "start_progress_tracking"]
sync_with_undulator = Cpt(Signal, value=0, kind=Kind.config)
sync_update_period = Cpt(Signal, value=0.05, kind=Kind.config)
@@ -83,6 +83,17 @@ class PGMMonochromator(PSIDeviceBase, PGMMonochromatorBase):
e2 (float): End energy in eV.
"""
self.energy_range = [e1, e2]
self._progress_active = False
self._progress_done_emitted = False
def start_progress_tracking(self) -> None:
"""
Enable progress updates for the currently configured energy range.
"""
if len(self.energy_range) != 2:
return
self._progress_active = True
self._progress_done_emitted = False
########################################
# Beamline Specific Implementations #
@@ -97,6 +108,7 @@ class PGMMonochromator(PSIDeviceBase, PGMMonochromatorBase):
"""
self._sync_config_guard = False
self._last_sync_update_ts = 0.0
self._progress_active = False
self._progress_done_emitted = False
self.readback.name = self.name
self.max_speed = 0.038 # maximum speed in degrees per second
@@ -117,6 +129,7 @@ class PGMMonochromator(PSIDeviceBase, PGMMonochromatorBase):
Called while staging the device.
Information about the upcoming scan can be accessed from the scan_info (self.scan_info.msg) object.
"""
self._progress_active = False
self._progress_done_emitted = False
self.energy_range = []
@@ -137,6 +150,7 @@ class PGMMonochromator(PSIDeviceBase, PGMMonochromatorBase):
def on_stop(self) -> None:
"""Called when the device is stopped."""
self._progress_active = False
self.energy_range = []
def on_destroy(self) -> None:
@@ -218,12 +232,13 @@ class PGMMonochromator(PSIDeviceBase, PGMMonochromatorBase):
Args:
value (float): The current readback value of the monochromator.
"""
if len(self.energy_range) != 2:
if not self._progress_active or len(self.energy_range) != 2:
return
if bool(self.done.get()):
if not self._progress_done_emitted:
self.progress.put(value=100, max_value=100, done=True)
self._progress_done_emitted = True
self._progress_active = False
return
self._progress_done_emitted = False
@@ -233,7 +248,6 @@ class PGMMonochromator(PSIDeviceBase, PGMMonochromatorBase):
progress = 100.0
else:
progress = np.round((float(value) - e1) / (e2 - e1) * 100.0)
print(progress)
progress = max(0.0, min(100.0, progress))
self.progress.put(value=progress, max_value=100, done=False)
+3
View File
@@ -16,6 +16,7 @@ Scan procedure:
from __future__ import annotations
from time import time
from typing import Annotated
from bec_lib.logger import bec_logger
@@ -160,10 +161,12 @@ class OTFScan(ScanBase):
"""
self.dev.signals.store_updates.put(1)
self.mono.start_progress_tracking()
status = self.mono.set(self.e2)
while not status.done:
self.at_each_point()
time.sleep(1)
@scan_hook
def at_each_point(self):