From c7f9d37c12e2344f0c9c7fef84f04a32b628dd3f Mon Sep 17 00:00:00 2001 From: Holler Mirko Date: Thu, 4 Jul 2024 10:56:26 +0200 Subject: [PATCH] continue init script of omny, various mods in galil --- .../bec_ipython_client/plugins/omny/omny.py | 10 +++++++- csaxs_bec/devices/omny/galil/fgalil_ophyd.py | 14 ++++++++++- csaxs_bec/devices/omny/galil/galil_ophyd.py | 2 -- csaxs_bec/devices/omny/galil/lgalil_ophyd.py | 24 +++++++++++++++++-- csaxs_bec/devices/omny/galil/ogalil_ophyd.py | 18 +++++++++++++- 5 files changed, 61 insertions(+), 7 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/omny.py b/csaxs_bec/bec_ipython_client/plugins/omny/omny.py index 262435d..5340c6b 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/omny.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny.py @@ -129,8 +129,16 @@ class OMNYInitStagesMixin: dev.oeyex.limits = [-47, 10] dev.oeyez.limits = [-85, 10] + user_input = input("find reference mark of oeyey?") + if user_input == "y": + dev.oeyez.drive_axis_to_limit("forward") + dev.oeyey.controller.socket_put_confirmed(""indspeed[7]=2000"") + dev.oeyey.find_reference() + dev.oeyey.limits = [-61, 1] - + #ensure closed shuttle and shuttle aligner down + if not dev.oshuttleopen.get_motor_limit_switch()[0]: + dev.oshuttleopen.drive_axis_to_limit("reverse") diff --git a/csaxs_bec/devices/omny/galil/fgalil_ophyd.py b/csaxs_bec/devices/omny/galil/fgalil_ophyd.py index 42e86d7..de5a1f0 100644 --- a/csaxs_bec/devices/omny/galil/fgalil_ophyd.py +++ b/csaxs_bec/devices/omny/galil/fgalil_ophyd.py @@ -141,7 +141,7 @@ class FlomniGalilAxesReferenced(GalilAxesReferenced): class FlomniGalilMotor(Device, PositionerBase): - USER_ACCESS = ["controller"] + USER_ACCESS = ["controller", "drive_axis_to_limit"] readback = Cpt(FlomniGalilReadbackSignal, signal_name="readback", kind="hinted") user_setpoint = Cpt(FlomniGalilSetpointSignal, signal_name="setpoint") motor_resolution = Cpt(FlomniGalilMotorResolution, signal_name="resolution", kind="config") @@ -337,6 +337,18 @@ class FlomniGalilMotor(Device, PositionerBase): def unstage(self) -> list[object]: return super().unstage() + def drive_axis_to_limit(self, direction: str) -> None: + """ + Drive an axis to the limit in a specified direction. + + Args: + direction (str): Direction in which the axis should be driven to the limit. Either 'forward' or 'reverse'. + """ + self.controller.drive_axis_to_limit(self.axis_Id_numeric, direction) + #now force position read to cache + val = self.readback.read() + self._run_subs(sub_type=self.SUB_READBACK, value=val, timestamp=time.time()) + def stop(self, *, success=False): self.controller.stop_all_axes() return super().stop(success=success) diff --git a/csaxs_bec/devices/omny/galil/galil_ophyd.py b/csaxs_bec/devices/omny/galil/galil_ophyd.py index a799d7e..35b4d2b 100644 --- a/csaxs_bec/devices/omny/galil/galil_ophyd.py +++ b/csaxs_bec/devices/omny/galil/galil_ophyd.py @@ -171,8 +171,6 @@ class GalilController(Controller): if not limit: raise GalilError(f"Failed to drive axis {axis_Id}/{axis_Id_numeric} to limit.") - else: - print(f"Axis {}") def find_reference(self, axis_Id_numeric: int) -> None: """ diff --git a/csaxs_bec/devices/omny/galil/lgalil_ophyd.py b/csaxs_bec/devices/omny/galil/lgalil_ophyd.py index db1d08e..8eb0cbe 100644 --- a/csaxs_bec/devices/omny/galil/lgalil_ophyd.py +++ b/csaxs_bec/devices/omny/galil/lgalil_ophyd.py @@ -19,7 +19,6 @@ from csaxs_bec.devices.omny.galil.galil_ophyd import ( GalilSetpointSignal, GalilSignalRO, retry_once, - ) logger = bec_logger.logger @@ -101,7 +100,7 @@ class LamniGalilReadbackSignal(GalilSignalRO): return val class LamniGalilMotor(Device, PositionerBase): - USER_ACCESS = ["controller"] + USER_ACCESS = ["controller", "drive_axis_to_limit", "find_reference"] readback = Cpt(LamniGalilReadbackSignal, signal_name="readback", kind="hinted") user_setpoint = Cpt(GalilSetpointSignal, signal_name="setpoint") motor_resolution = Cpt(GalilMotorResolution, signal_name="resolution", kind="config") @@ -288,6 +287,27 @@ class LamniGalilMotor(Device, PositionerBase): """The engineering units (EGU) for positions""" return "mm" + def find_reference(self): + """ + Find the reference of the axis. + """ + self.controller.find_reference(self.axis_Id_numeric) + #now force position read to cache + val = self.readback.read() + self._run_subs(sub_type=self.SUB_READBACK, value=val, timestamp=time.time()) + + def drive_axis_to_limit(self, direction: str) -> None: + """ + Drive an axis to the limit in a specified direction. + + Args: + direction (str): Direction in which the axis should be driven to the limit. Either 'forward' or 'reverse'. + """ + self.controller.drive_axis_to_limit(self.axis_Id_numeric, direction) + #now force position read to cache + val = self.readback.read() + self._run_subs(sub_type=self.SUB_READBACK, value=val, timestamp=time.time()) + def stop(self, *, success=False): self.controller.stop_all_axes() return super().stop(success=success) diff --git a/csaxs_bec/devices/omny/galil/ogalil_ophyd.py b/csaxs_bec/devices/omny/galil/ogalil_ophyd.py index 0f95ed4..616ce67 100644 --- a/csaxs_bec/devices/omny/galil/ogalil_ophyd.py +++ b/csaxs_bec/devices/omny/galil/ogalil_ophyd.py @@ -160,6 +160,7 @@ class OMNYGalilController(GalilController): self._ogalil_folerr_not_ignore() + def _ogalil_folerr_not_ignore(self): self.socket_put_confirmed("IgNoFol=0") @@ -196,7 +197,7 @@ class OMNYGalilController(GalilController): class OMNYGalilMotor(Device, PositionerBase): - USER_ACCESS = ["controller", "find_reference", "drive_axis_to_limit", "_ogalil_folerr_reset_and_ignore", "_ogalil_set_axis_to_pos_wo_reference_search"] + USER_ACCESS = ["controller", "find_reference", "drive_axis_to_limit", "_ogalil_folerr_reset_and_ignore", "ogalil_set_axis_to_pos_wo_reference_search", "get_motor_limit_switch"] readback = Cpt(OMNYGalilReadbackSignal, signal_name="readback", kind="hinted") user_setpoint = Cpt(GalilSetpointSignal, signal_name="setpoint") motor_resolution = Cpt(GalilMotorResolution, signal_name="resolution", kind="config") @@ -390,12 +391,18 @@ class OMNYGalilMotor(Device, PositionerBase): def _ogalil_set_axis_to_pos_wo_reference_search(self, pos_mm): motor_resolution = self.motor_resolution.get() self.controller._ogalil_set_axis_to_pos_wo_reference_search(self.axis_Id_numeric, self.axis_Id, pos_mm, motor_resolution, self.sign) + #now force position read to cache + val = self.readback.read() + self._run_subs(sub_type=self.SUB_READBACK, value=val, timestamp=time.time()) def find_reference(self): """ Find the reference of the axis. """ self.controller.find_reference(self.axis_Id_numeric) + #now force position read to cache + val = self.readback.read() + self._run_subs(sub_type=self.SUB_READBACK, value=val, timestamp=time.time()) def drive_axis_to_limit(self, direction: str) -> None: """ @@ -405,6 +412,15 @@ class OMNYGalilMotor(Device, PositionerBase): direction (str): Direction in which the axis should be driven to the limit. Either 'forward' or 'reverse'. """ self.controller.drive_axis_to_limit(self.axis_Id_numeric, direction) + #now force position read to cache + val = self.readback.read() + self._run_subs(sub_type=self.SUB_READBACK, value=val, timestamp=time.time()) + + def get_motor_limit_switch(self) -> list: + """ + Get status of the motor limit switches + """ + self.controller.get_motor_limit_switch(self.axis_Id) def stop(self, *, success=False): self.controller.stop_all_axes()