fix(npoint): retry on wait_for_connection
CI for csaxs_bec / test (pull_request) Successful in 1m31s
Read the Docs Deploy Trigger / trigger-rtd-webhook (push) Successful in 2s
CI for csaxs_bec / test (push) Successful in 1m33s

This commit was merged in pull request #204.
This commit is contained in:
x12sa
2026-05-13 16:06:19 +02:00
committed by wakonig_k
parent a4d8c570e1
commit abca4364bd
+12 -17
View File
@@ -448,26 +448,14 @@ class NPointAxis(Device, PositionerBase):
self.high_limit_travel.put(limits[1])
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.
"""
for attempt in range(5):
for _ in range(5):
try:
self.user_setpoint.setpoint = self.readback.get()
except Exception as e:
logger.warning(
f"NPointAxis {self.name}: Failed to update the setpoint from the readback value on attempt {attempt+1} during startup: {e}"
)
self.controller.on(timeout=timeout)
self._update_setpoint_from_readback()
except TimeoutError:
self.controller.off(update_config=False)
time.sleep(1)
else:
logger.info(
f"NPointAxis {self.name}: Successfully updated the setpoint from the readback value on attempt {attempt+1} during startup."
)
break
else:
raise TimeoutError(
@@ -475,6 +463,13 @@ class NPointAxis(Device, PositionerBase):
f"Try to reload the config and if the problem persists, check the connection to the nPoint controller "
f"and ensure that it is powered on and accessible at {self.controller._socket_host}:{self.controller._socket_port}."
)
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."""