fix: improve move method of mo1_bragg_devices

This commit is contained in:
2025-05-09 16:25:41 +02:00
parent 4d9a062b8c
commit 87ea95e975

View File

@@ -251,9 +251,7 @@ class Mo1BraggPositioner(Device, PositionerBase):
success (bool) : Flag to indicate if the motion was successful success (bool) : Flag to indicate if the motion was successful
""" """
self.move_stop.put(1) self.move_stop.put(1)
if self._move_thread is not None: self._stopped = True
self._move_thread.join()
self._move_thread = None
super().stop(success=success) super().stop(success=success)
def stop_scan(self) -> None: def stop_scan(self) -> None:
@@ -323,12 +321,14 @@ class Mo1BraggPositioner(Device, PositionerBase):
update_frequency (float): Optional, frequency to update the current position of update_frequency (float): Optional, frequency to update the current position of
the motion, defaults to 0.1s the motion, defaults to 0.1s
""" """
motor_name = None
try: try:
# Set the target position on IOC # Set the target position on IOC
self.setpoint.put(target_pos) self.setpoint.put(target_pos)
self.move_abs.put(1) self.move_abs.put(1)
# Currently sleep is needed due to delay in updates on PVs, maybe time can be reduced # Currently sleep is needed due to delay in updates on PVs, maybe time can be reduced
time.sleep(0.5) time.sleep(0.5)
motor_name = self.name
while self.motor_is_moving.get() == 0: while self.motor_is_moving.get() == 0:
if self.stopped: if self.stopped:
raise Mo1BraggStoppedError(f"Device {self.name} was stopped") raise Mo1BraggStoppedError(f"Device {self.name} was stopped")
@@ -338,7 +338,9 @@ class Mo1BraggPositioner(Device, PositionerBase):
# pylint: disable=broad-except # pylint: disable=broad-except
except Exception as exc: except Exception as exc:
content = traceback.format_exc() content = traceback.format_exc()
logger.error(f"Error in move thread of device {self.name}: {content}") logger.error(
f"Error in move thread of device {motor_name if motor_name else ''}: {content}"
)
status.set_exception(exc=exc) status.set_exception(exc=exc)
def move(self, value: float, **kwargs) -> DeviceStatus: def move(self, value: float, **kwargs) -> DeviceStatus: