From 2ad321ada86cc07634985e6d52e0ed0d1f350520 Mon Sep 17 00:00:00 2001 From: wakonig_k Date: Thu, 9 Apr 2026 13:39:42 +0200 Subject: [PATCH] fix(smaract): ensure setpoint is in sync after restart --- csaxs_bec/devices/smaract/smaract_ophyd.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/csaxs_bec/devices/smaract/smaract_ophyd.py b/csaxs_bec/devices/smaract/smaract_ophyd.py index 044d3a1..c2e4db7 100644 --- a/csaxs_bec/devices/smaract/smaract_ophyd.py +++ b/csaxs_bec/devices/smaract/smaract_ophyd.py @@ -43,7 +43,10 @@ class SmaractReadbackSignal(SmaractSignalRO): class SmaractSetpointSignal(SmaractSignalBase): - setpoint = 0 + + def __init__(self, signal_name, **kwargs): + super().__init__(signal_name, **kwargs) + self.setpoint = 0 @threadlocked def _socket_get(self): @@ -156,6 +159,14 @@ class SmaractMotor(Device, PositionerBase): def wait_for_connection(self, timeout: float = 30.0) -> bool: self.controller.on(timeout=timeout) + self._update_setpoint_from_readback() + + def _update_setpoint_from_readback(self): + """ + The setpoint is only stored locally. After a restart, + we need to update it to match the current readback value. + """ + self.user_setpoint.setpoint = self.readback.get() def destroy(self): """Make sure to turn off the controller socket on destroy."""