feat(npoint): add retry to initial readout and improve error message
CI for csaxs_bec / test (push) Successful in 1m35s
CI for csaxs_bec / test (pull_request) Successful in 1m42s

This commit is contained in:
2026-05-08 09:22:30 +02:00
parent 3ea4e9195a
commit 9b09d5a64d
+22 -1
View File
@@ -3,6 +3,7 @@ import threading
import time
import numpy as np
from bec_lib.logger import bec_logger
from ophyd import Component as Cpt
from ophyd import Device, PositionerBase, Signal, SignalRO
from ophyd.status import wait as status_wait
@@ -11,6 +12,8 @@ from ophyd_devices.utils.controller import Controller, threadlocked
from ophyd_devices.utils.socket import SocketIO, SocketSignal, raise_if_disconnected
from prettytable import PrettyTable
logger = bec_logger.logger
def channel_checked(fcn):
"""Decorator to catch attempted access to channels that are not available."""
@@ -453,7 +456,25 @@ class NPointAxis(Device, PositionerBase):
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()
for attempt 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}"
)
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(
f"NPointAxis {self.name}: Failed to update the setpoint from the readback value after 5 attempts during startup. This may happen occasionally. "
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 destroy(self):
"""Make sure to turn off the controller socket on destroy."""