diff --git a/ophyd_devices/galil/galil_ophyd.py b/ophyd_devices/galil/galil_ophyd.py index 11f751a..4c3db22 100644 --- a/ophyd_devices/galil/galil_ophyd.py +++ b/ophyd_devices/galil/galil_ophyd.py @@ -235,6 +235,7 @@ class GalilSignalRO(GalilSignalBase): class GalilReadbackSignal(GalilSignalRO): @retry_once + @threadlocked def _socket_get(self) -> float: """Get command for the readback signal @@ -309,6 +310,7 @@ class GalilSetpointSignal(GalilSignalBase): class GalilMotorResolution(GalilSignalRO): @retry_once + @threadlocked def _socket_get(self): return float( self.controller.socket_put_and_receive(f"MG stppermm[{self.parent.axis_Id_numeric}]") @@ -316,6 +318,7 @@ class GalilMotorResolution(GalilSignalRO): class GalilMotorIsMoving(GalilSignalRO): + @threadlocked def _socket_get(self): return ( self.controller.is_axis_moving(self.parent.axis_Id) @@ -335,6 +338,7 @@ class GalilMotorIsMoving(GalilSignalRO): class GalilAxesReferenced(GalilSignalRO): + @threadlocked def _socket_get(self): return self.controller.socket_put_and_receive("MG allaxref") diff --git a/ophyd_devices/rt_lamni/rt_lamni_ophyd.py b/ophyd_devices/rt_lamni/rt_lamni_ophyd.py index d11ba6d..d216945 100644 --- a/ophyd_devices/rt_lamni/rt_lamni_ophyd.py +++ b/ophyd_devices/rt_lamni/rt_lamni_ophyd.py @@ -148,12 +148,15 @@ class RtLamniController(Controller): return var.split("\r\n")[0] return var + @threadlocked def set_rotation_angle(self, val: float): self.socket_put(f"a{(val-300+30.538)/180*np.pi}") + @threadlocked def stop_all_axes(self): self.socket_put("sc") - + + @threadlocked def feedback_disable(self): self.socket_put("J0") logger.info("LamNI Feedback disabled.") @@ -163,16 +166,20 @@ class RtLamniController(Controller): # motor_par("lopty","disable",0) # motor_par("loptz","disable",0) + @threadlocked def _set_axis_velocity(self, um_per_s): self.socket_put(f"V{um_per_s}") + @threadlocked def _set_axis_velocity_maximum_speed(self): self.socket_put(f"V0") # for developement of soft continuous scanning + @threadlocked def _position_sampling_single_reset_and_start_sampling(self): self.socket_put(f"Ss") + @threadlocked def _position_sampling_single_read(self): (number_of_samples, sum0, sum0_2, sum1, sum1_2, sum2, sum2_2) = self.socket_put_and_receive( f"Sr" @@ -189,6 +196,7 @@ class RtLamniController(Controller): ) return (avg_x, avg_y, stdev_x, stdev_y) + @threadlocked def feedback_enable_without_reset(self): # read current interferometer position return_table = (self.socket_put_and_receive(f"J4")).split(",") @@ -206,6 +214,7 @@ class RtLamniController(Controller): # motor_par("loptz","disable",1) # umv rtx x_curr rty y_curr + @threadlocked def feedback_disable_and_even_reset_lamni_angle_interferometer(self): self.socket_put("J6") logger.info("LamNI Feedback disabled including the angular interferometer.") @@ -228,6 +237,7 @@ class RtLamniController(Controller): return axis raise RuntimeError(f"Could not find an axis with name {name}") + @threadlocked def clear_trajectory_generator(self): self.socket_put("sc") logger.info("LamNI scan stopped and deleted, moving to start position") @@ -244,6 +254,7 @@ class RtLamniController(Controller): threading.Thread(target=send_positions, args=(self, positions), daemon=True).start() @retry_once + @threadlocked def get_scan_status(self): return_table = (self.socket_put_and_receive(f"sr")).split(",") if len(return_table) != 3: @@ -260,6 +271,7 @@ class RtLamniController(Controller): current_position_in_scan = int(return_table[2]) return (mode, number_of_positions_planned, current_position_in_scan) + @threadlocked def start_scan(self): interferometer_feedback_not_running = int((self.socket_put_and_receive("J2")).split(",")[0]) if interferometer_feedback_not_running == 1: @@ -478,6 +490,7 @@ class RtLamniSignalRO(RtLamniSignalBase): class RtLamniReadbackSignal(RtLamniSignalRO): @retry_once + @threadlocked def _socket_get(self) -> float: """Get command for the readback signal @@ -512,6 +525,7 @@ class RtLamniSetpointSignal(RtLamniSignalBase): return self.setpoint @retry_once + @threadlocked def _socket_set(self, val: float) -> None: """Set a new target value / setpoint value. Before submission, the target value is adjusted for the axis' sign. Furthermore, it is ensured that all axes are referenced before a new setpoint is submitted. @@ -552,6 +566,7 @@ class RtLamniMotorIsMoving(RtLamniSignalRO): class RtLamniFeedbackRunning(RtLamniSignalRO): + @threadlocked def _socket_get(self): if int((self.controller.socket_put_and_receive("J2")).split(",")[0]) == 0: return 1 diff --git a/ophyd_devices/smaract/smaract_ophyd.py b/ophyd_devices/smaract/smaract_ophyd.py index 5ab23b4..860dbd7 100644 --- a/ophyd_devices/smaract/smaract_ophyd.py +++ b/ophyd_devices/smaract/smaract_ophyd.py @@ -10,6 +10,7 @@ from ophyd.status import wait as status_wait from ophyd.utils import ReadOnlyError, LimitError from ophyd_devices.smaract.smaract_controller import SmaractController from ophyd_devices.smaract.smaract_errors import SmaractCommunicationError, SmaractError +from ophyd_devices.utils.controller import threadlocked from ophyd_devices.utils.socket import SocketIO, SocketSignal, raise_if_disconnected from bec_utils import bec_logger @@ -29,11 +30,13 @@ class SmaractSignalRO(SmaractSignalBase): super().__init__(signal_name, **kwargs) self._metadata["write_access"] = False + @threadlocked def _socket_set(self, val): raise ReadOnlyError("Read-only signals cannot be set") class SmaractReadbackSignal(SmaractSignalRO): + @threadlocked def _socket_get(self): return self.controller.get_position(self.parent.axis_Id_numeric)*self.parent.sign @@ -41,9 +44,11 @@ class SmaractReadbackSignal(SmaractSignalRO): class SmaractSetpointSignal(SmaractSignalBase): setpoint = 0 + @threadlocked def _socket_get(self): return self.setpoint + @threadlocked def _socket_set(self, val): target_val = val * self.parent.sign self.setpoint = target_val @@ -56,16 +61,19 @@ class SmaractSetpointSignal(SmaractSignalBase): class SmaractMotorIsMoving(SmaractSignalRO): + @threadlocked def _socket_get(self): return self.controller.is_axis_moving(self.parent.axis_Id_numeric) class SmaractAxisReferenced(SmaractSignalRO): + @threadlocked def _socket_get(self): return self.parent.controller.axis_is_referenced(self.parent.axis_Id_numeric) class SmaractAxisLimits(SmaractSignalBase): + @threadlocked def _socket_get(self): limits_msg = self.controller.socket_put_and_receive(f"GPL{self.parent.axis_Id_numeric}") if limits_msg.startswith(":PL"):