refactor (mo1-bragg): refactored Mo1 Bragg class with new base class PSIDeviceBase

This commit is contained in:
2025-03-11 16:03:40 +01:00
parent 849b2d2bdb
commit ce046f55f6
2 changed files with 8 additions and 7 deletions

View File

@@ -119,6 +119,8 @@ class Mo1Bragg(PSIDeviceBase, Mo1BraggPositioner):
Information about the upcoming scan can be accessed from the scan_info (self.scan_info.msg) object.
"""
if not self.scan_info.msg.scan_type == "fly":
return
self._check_scan_msg(ScanControlLoadMessage.PENDING)
scan_name = self.scan_info.msg.scan_name
@@ -196,7 +198,9 @@ class Mo1Bragg(PSIDeviceBase, Mo1BraggPositioner):
mode=ScanControlMode.ADVANCED, scan_duration=self.scan_parameter.scan_duration
)
else:
return
raise Mo1BraggError(
f"Scan mode {scan_name} not implemented for scan_type={self.scan_info.msg.scan_type} on device {self.name}"
)
# Load the scan parameters to the controller
self.scan_control.scan_load.put(1)
# Wait for params to be checked from controller
@@ -321,10 +325,10 @@ class Mo1Bragg(PSIDeviceBase, Mo1BraggPositioner):
timeout = self.timeout_for_pvwait
start_time = time.time()
while time.time() - start_time < timeout:
if self.stopped is True:
raise DeviceStopError(f"Device {self.name} was stopped while waiting for signal")
if signal.get() == value:
return None
if self.stopped is True: # Should this check be optional or configurable?!
raise DeviceStopError(f"Device {self.name} was stopped while waiting for signal")
time.sleep(0.1)
# If we end up here, the status did not resolve
raise TimeoutError(
@@ -438,9 +442,6 @@ class Mo1Bragg(PSIDeviceBase, Mo1BraggPositioner):
def _update_scan_parameter(self):
"""Get the scan_info parameters for the scan."""
for key, value in self.scan_info.msg.request_inputs["inputs"].items():
if hasattr(self.scan_parameter, key):
setattr(self.scan_parameter, key, value)
for key, value in self.scan_info.msg.request_inputs["kwargs"].items():
if hasattr(self.scan_parameter, key):
setattr(self.scan_parameter, key, value)

View File

@@ -1,4 +1,4 @@
"""Module for additional utils of the Mo1 Bragg Positioner"""
""" Module for additional utils of the Mo1 Bragg Positioner"""
import numpy as np
from scipy.interpolate import BSpline