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