diff --git a/csaxs_bec/devices/omny/galil/lgalil_ophyd.py b/csaxs_bec/devices/omny/galil/lgalil_ophyd.py index 31757fa..b17d429 100644 --- a/csaxs_bec/devices/omny/galil/lgalil_ophyd.py +++ b/csaxs_bec/devices/omny/galil/lgalil_ophyd.py @@ -15,7 +15,6 @@ from csaxs_bec.devices.omny.galil.galil_ophyd import ( GalilAxesReferenced, GalilController, GalilMotorIsMoving, - GalilMotorResolution, GalilSetpointSignal, GalilSignalRO, retry_once, @@ -24,6 +23,19 @@ from csaxs_bec.devices.omny.galil.galil_ophyd import ( logger = bec_logger.logger +class GalilMotorResolution(GalilSignalRO): + @retry_once + @threadlocked + def _socket_get(self): + if self.parent.axis_Id_numeric < 6: + return float( + self.controller.socket_put_and_receive(f"MG encpermm[{self.parent.axis_Id_numeric}]") + ) + else: + return float( + self.controller.socket_put_and_receive(f"MG stppermm[{self.parent.axis_Id_numeric}]") + ) + class LamniGalilController(GalilController): @@ -154,11 +166,18 @@ class LamniGalilReadbackSignal(GalilSignalRO): Returns: float: Readback value after adjusting for sign and motor resolution. """ - current_pos = float(self.controller.socket_put_and_receive(f"TD{self.parent.axis_Id}")) - current_pos *= self.parent.sign - step_mm = self.parent.motor_resolution.get() - return current_pos / step_mm - + if self.parent.axis_Id_numeric < 6: + current_pos = float(self.controller.socket_put_and_receive(f"TP{self.parent.axis_Id}")) + current_pos *= self.parent.sign + encoder_resolution = self.parent.motor_resolution.get() + logger.info(f"Read galil encoder position of axis {self.parent.axis_Id_numeric} to be TP {current_pos} with resolution {encoder_resolution}") + return current_pos / encoder_resolution + else: + current_pos = float(self.controller.socket_put_and_receive(f"TD{self.parent.axis_Id}")) + current_pos *= self.parent.sign + step_mm = self.parent.motor_resolution.get() + return current_pos / step_mm + def read(self): self._metadata["timestamp"] = time.time() val = super().read() diff --git a/csaxs_bec/scans/LamNIFermatScan.py b/csaxs_bec/scans/LamNIFermatScan.py index 128e372..98982c2 100644 --- a/csaxs_bec/scans/LamNIFermatScan.py +++ b/csaxs_bec/scans/LamNIFermatScan.py @@ -169,6 +169,9 @@ class LamNIMixin: self.device_manager.devices.lsamx.read_only = True self.device_manager.devices.lsamy.read_only = True + + #update angle readback before start of the scan + yield from self.stubs.send_rpc_and_wait("lsamrot", "readback.get") yield from self.stubs.send_rpc_and_wait("rtx", "controller.feedback_enable_without_reset")