fix: bugfix online fixes

This commit is contained in:
2023-09-04 20:50:42 +02:00
parent 2dd8f25c87
commit ba9cb77ed9
4 changed files with 31 additions and 82 deletions

View File

@@ -285,9 +285,7 @@ class GalilController(Controller):
start_y *= sign_y
end_y *= sign_y
speed = np.abs(end_y - start_y) / (
(interval_y) * exp_time + (interval_y - 1) * readtime
)
speed = np.abs(end_y - start_y) / ((interval_y) * exp_time + (interval_y - 1) * readtime)
if speed > 2.00 or speed < 0.02:
raise LimitError(
f"Speed of {speed:.03f}mm/s is outside of acceptable range of 0.02 to 2 mm/s"
@@ -299,9 +297,7 @@ class GalilController(Controller):
# Hard coded to maximum offset of 0.1mm to avoid long motions.
self.socket_put_and_receive(f"off={(0):f}")
self.socket_put_and_receive(
f"a_start={start_y:.04f};a_end={end_y:.04f};speed={speed:.04f}"
)
self.socket_put_and_receive(f"a_start={start_y:.04f};a_end={end_y:.04f};speed={speed:.04f}")
self.socket_put_and_receive(
f"b_start={start_x:.04f};gridmax={gridmax:d};b_step={step_grid:.04f}"
)
@@ -321,9 +317,7 @@ class GalilController(Controller):
val_axis4 = [] # x axis
while self.is_thread_active(thread_id):
posct = int(self.socket_put_and_receive(f"MGposct").strip().split(".")[0])
logger.info(
f"SGalil is scanning - latest enconder position {posct+1} from {n_samples}"
)
logger.info(f"SGalil is scanning - latest enconder position {posct+1} from {n_samples}")
time.sleep(1)
if posct > last_readout:
positions = self.read_encoder_position(last_readout, posct)
@@ -334,9 +328,7 @@ class GalilController(Controller):
time.sleep(1)
# Readout of last positions after scan finished
posct = int(self.socket_put_and_receive(f"MGposct").strip().split(".")[0])
logger.info(
f"SGalil is scanning - latest enconder position {posct} from {n_samples}"
)
logger.info(f"SGalil is scanning - latest enconder position {posct} from {n_samples}")
if posct > last_readout:
positions = self.read_encoder_position(last_readout, posct)
val_axis4.extend(positions[0])
@@ -348,9 +340,7 @@ class GalilController(Controller):
val_axis2 = [] # y axis
val_axis4 = [] # x axis
for ii in range(fromval, toval + 1):
rts = self.socket_put_and_receive(
f"MGaposavg[{ii%2000}]*10,cposavg[{ii%2000}]*10"
)
rts = self.socket_put_and_receive(f"MGaposavg[{ii%2000}]*10,cposavg[{ii%2000}]*10")
if rts == ":":
val_axis4.append(rts)
val_axis2.append(rts)
@@ -389,15 +379,11 @@ class GalilReadbackSignal(GalilSignalRO):
"""
if self.parent.axis_Id_numeric == 2:
current_pos = float(
self.controller.socket_put_and_receive(
f"MG _TP{self.parent.axis_Id}/mm"
)
self.controller.socket_put_and_receive(f"MG _TP{self.parent.axis_Id}/mm")
)
elif self.parent.axis_Id_numeric == 4:
# hardware controller readback from axis 4 is on axis 0, A instead of E
current_pos = float(
self.controller.socket_put_and_receive(f"MG _TP{'A'}/mm")
)
current_pos = float(self.controller.socket_put_and_receive(f"MG _TP{'A'}/mm"))
current_pos *= self.parent.sign
return current_pos
@@ -443,17 +429,11 @@ class GalilSetpointSignal(GalilSignalBase):
time.sleep(0.1)
if self.parent.axis_Id_numeric == 2:
self.controller.socket_put_confirmed(
f"PA{self.parent.axis_Id}={target_val:.4f}*mm"
)
self.controller.socket_put_confirmed(f"PA{self.parent.axis_Id}={target_val:.4f}*mm")
self.controller.socket_put_and_receive(f"BG{self.parent.axis_Id}")
elif self.parent.axis_Id_numeric == 4:
self.controller.socket_put_confirmed(
f"targ{self.parent.axis_Id}={target_val:.4f}"
)
self.controller.socket_put_and_receive(
f"XQ#POSE,{self.parent.axis_Id_numeric}"
)
self.controller.socket_put_confirmed(f"targ{self.parent.axis_Id}={target_val:.4f}")
self.controller.socket_put_and_receive(f"XQ#POSE,{self.parent.axis_Id_numeric}")
while self.controller.is_thread_active(0):
time.sleep(0.005)
@@ -462,9 +442,7 @@ class GalilMotorIsMoving(GalilSignalRO):
@threadlocked
def _socket_get(self):
if self.parent.axis_Id_numeric == 2:
ret = self.controller.is_axis_moving(
self.parent.axis_Id, self.parent.axis_Id_numeric
)
ret = self.controller.is_axis_moving(self.parent.axis_Id, self.parent.axis_Id_numeric)
return ret
if self.parent.axis_Id_numeric == 4:
# Motion signal from axis 4 is mapped to axis 5
@@ -502,12 +480,8 @@ class SGalilMotor(Device, PositionerBase):
kind="hinted",
)
user_setpoint = Cpt(GalilSetpointSignal, signal_name="setpoint")
motor_is_moving = Cpt(
GalilMotorIsMoving, signal_name="motor_is_moving", kind="normal"
)
all_axes_referenced = Cpt(
GalilAxesReferenced, signal_name="all_axes_referenced", kind="config"
)
motor_is_moving = Cpt(GalilMotorIsMoving, signal_name="motor_is_moving", kind="normal")
all_axes_referenced = Cpt(GalilAxesReferenced, signal_name="all_axes_referenced", kind="config")
high_limit_travel = Cpt(Signal, value=0, kind="omitted")
low_limit_travel = Cpt(Signal, value=0, kind="omitted")
@@ -688,9 +662,7 @@ class SGalilMotor(Device, PositionerBase):
def axis_Id_numeric(self, val):
if isinstance(val, int):
if val not in [2, 4]:
raise ValueError(
f"Numeric value {val} is not supported, it must be either 2 or 4."
)
raise ValueError(f"Numeric value {val} is not supported, it must be either 2 or 4.")
self._axis_Id_alpha = val
self._axis_Id_numeric = (chr(val + 97)).capitalize()
else:
@@ -714,11 +686,7 @@ if __name__ == "__main__":
else:
from ophyd_devices.utils.socket import SocketMock
samx = SGalilMotor(
"E", name="samx", host="129.129.122.26", port=23, socket_cls=SocketMock
)
samy = SGalilMotor(
"C", name="samy", host="129.129.122.26", port=23, socket_cls=SocketMock
)
samx = SGalilMotor("E", name="samx", host="129.129.122.26", port=23, socket_cls=SocketMock)
samy = SGalilMotor("C", name="samy", host="129.129.122.26", port=23, socket_cls=SocketMock)
samx.controller.galil_show_all()