From 291e9ba04b4e899536d1a5a69c123df7decfdb13 Mon Sep 17 00:00:00 2001 From: e21206 Date: Tue, 15 Aug 2023 16:15:28 +0200 Subject: [PATCH] refactor: bugfix of sgalil flyscans --- ophyd_devices/galil/sgalil_ophyd.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/ophyd_devices/galil/sgalil_ophyd.py b/ophyd_devices/galil/sgalil_ophyd.py index 0c95ce9..19a4b7b 100644 --- a/ophyd_devices/galil/sgalil_ophyd.py +++ b/ophyd_devices/galil/sgalil_ophyd.py @@ -264,15 +264,13 @@ class GalilController(Controller): LimitError: Raised if the speed is above 2mm/s or below 0.02mm/s """ - #Check limits - # TODO check sign of stage, or not necessary + # Check limits + # TODO check sign of stage, or not necessary check_values = [start_y, end_y, start_x, end_x] for val in check_values: self.check_value(val) - 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" @@ -292,14 +290,11 @@ class GalilController(Controller): time.sleep(0.1) self.socket_put_and_receive("XQ#SCANG") - def read_encoder_position(fromval: int = 0, toval: int = None) -> tuple: + def read_encoder_position(fromval: int, toval: int) -> tuple: val_axis2 = [] # y axis val_axis4 = [] # x axis - if toval is None: - toval = 1999 for ii in range(fromval, toval + 1): - print(ii) - ret = self.socket_put_and_receive(f"MGaposavg[{ii}]*10,cposavg[{ii}]*10") + self.socket_put_and_receive(f"MGaposavg[{ii}]*10,cposavg[{ii}]*10") val_axis4.append(float(ret.strip().split(" ")[0]) / 100000) val_axis2.append(float(ret.strip().split(" ")[1]) / 100000) return val_axis4, val_axis2 @@ -558,7 +553,6 @@ class SGalilMotor(Device, PositionerBase): status = super().move(position, timeout=timeout, **kwargs) self.user_setpoint.put(position, wait=False) - # TODO include here soft limits for motions, otherwise there is the danger of crashing.. def move_and_finish(): while self.motor_is_moving.get(): logger.info("motor is moving")