From b1f420773851670558188f7cec5267e7c7a2ecc3 Mon Sep 17 00:00:00 2001 From: Holler Mirko Date: Mon, 2 Sep 2024 16:53:34 +0200 Subject: [PATCH] sample transfer put and get at shuttle positions commissioned --- .../omny/omny_sample_transfer_mixin.py | 45 ++++++++++--------- csaxs_bec/device_configs/omny_config.yaml | 2 +- csaxs_bec/devices/omny/galil/galil_ophyd.py | 2 +- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/omny_sample_transfer_mixin.py b/csaxs_bec/bec_ipython_client/plugins/omny/omny_sample_transfer_mixin.py index c279e31..587101b 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/omny_sample_transfer_mixin.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny_sample_transfer_mixin.py @@ -353,7 +353,7 @@ class OMNYSampleTransferMixin: def _otransfer_gripper_up(self): up_position = self._get_user_param_safe("otransy", "up_position") if dev.otransy.get().readback < up_position - 0.1: - umv(dev.otransy, -1.2) + umv(dev.otransy, up_position) if dev.otransy.get().readback < up_position - 0.1: raise OMNYTransferError("The gripper did not move up.") @@ -683,12 +683,10 @@ class OMNYSampleTransferMixin: else: self._omnycam_parking() - _ogalil_encoder_steps_per_mm = dev.oparkz.get().motor_resolution - self._otransfer_gripper_to_park_z() _otransy_approach_height = self._otransfer_move_gripper_to_pin_pos(pin_position) self._otransfer_controller_enable_mount_mode() - dev.otransy.controller.socket_put_confirmed(f"mntaprch={_otransy_approach_height*_ogalil_encoder_steps_per_mm:.0f}") + dev.otransy.controller.socket_put_confirmed(f"mntaprch={_otransy_approach_height:.2f}") input("Ready. Press Enter to start the mount process now...") dev.otransy.controller.socket_put_confirmed("XQ#GRPUT") @@ -699,7 +697,10 @@ class OMNYSampleTransferMixin: self._otransfer_controller_disable_mount_mode() #update the new sample status in storage self._otransfer_check_free_slot_available_at_position(pin_position,1) - #this also moves the gripper to parking position + #this also moves the gripper to parking position + #alternatively a next sample is to be picked + #keep shuttle open and ask user which sample to pick + #but have to make sure that shield will be closed for sample pos movements beyond shuttle positions self._otransfer_shield_close(pin_position) dev.omny_samples.show_all() @@ -709,27 +710,29 @@ class OMNYSampleTransferMixin: while(mntprgs != 0): time.sleep(1) - confirm = (bool(float(dev.otransy.controller.socket_put_and_receive("MGconfirm")))) + confirm = (int(float(dev.otransy.controller.socket_put_and_receive("MGconfirm")))) time.sleep(0.02) - mntprgs = (bool(float(dev.otransy.controller.socket_put_and_receive("MGmntprgs")))) + mntprgs = (int(float(dev.otransy.controller.socket_put_and_receive("MGmntprgs")))) time.sleep(0.02) if confirm == 0: - print("Confirm check - no confirmation needed yet.") + pass + #print("Confirm check - no confirmation needed yet.") elif confirm == -1: #we are getting a sample if mntprgs == -1: toppin = self._otransfer_get_toppin_position() print(f"TopPin position is {toppin:.3f} mm") if self._otransfer_get_toppin_position()>-25.4: - print("THIS IS LARGER THAN THE CURRENT THRESHOLD OF -25.4. ARE YOU SURE THE PIN IS OK AND DOES NOT HAVE A DAMAGE IN THE BOTTOM?") - user_input = input("All OK? Please confirm. y/n?") + if not self.OMNYTools.yesno("THIS IS LARGER THAN THE CURRENT THRESHOLD OF -25.4. ARE YOU SURE THE PIN IS OK AND DOES NOT HAVE A DAMAGE IN THE BOTTOM? Continue?"): + raise OMNYTransferError("Abort by user because of top pin position.") + text = "All OK?" #we are mounting a sample elif mntprgs == 1: - print("All OK? Please confirm. First confirmation = sample release. y/n?") + text = "All OK? Please confirm. First confirmation = sample release" elif mntprgs == 0: - print("All OK? Please confirm. y/n?") + text = "All OK? Please confirm" - if user_input == "y": + if self.OMNYTools.yesno(text,"y"): dev.otransy.controller.socket_put_confirmed("confirm=1") else: raise OMNYTransferError("The sample mount progress was aborted by user.") @@ -738,14 +741,17 @@ class OMNYSampleTransferMixin: def _otransfer_check_sensor_connected(self): sensorvoltage = (float(dev.otransy.controller.socket_put_and_receive("MG@AN[8001]"))) gripper_sensorvoltagetarget = self._get_user_param_safe("otransy", "gripper_sensorvoltagetarget") - if not (sensorvoltage > gripper_sensorvoltagetarget-0.5 and sensorvoltage < gripper_sensorvoltagetarget): + if not np.fabs(sensorvoltage - gripper_sensorvoltagetarget) < 0.5: raise OMNYTransferError(f"Sensorvoltage is {sensorvoltage:.2f} V. This indicates a sensor error.") def otransfer_get_sample(self, pin_position: int): self._omnycam_parking() - user_input = ("Please confirm that currently there is no sample in the gripper. It would be dropped! y/n?") - if user_input != "y": + if not self.OMNYTools.yesno("Please confirm that currently there is no sample in the gripper. It would be dropped!","y"): raise OMNYTransferError("Transfer process has been manually aborted.") + #clean abort before starting + dev.otransx.controller.socket_put_confirmed("XQ#STOP,1") + time.sleep(0.1) + self._otransfer_check_sensor_connected() if not self._otransfer_check_sample_available_at_position(pin_position,0): raise OMNYTransferError(f"There is no sample available at position {pin_position}") @@ -769,15 +775,14 @@ class OMNYSampleTransferMixin: _otransy_approach_height = self._otransfer_move_gripper_to_pin_pos(pin_position) self._otransfer_controller_enable_mount_mode() - - _ogalil_encoder_steps_per_mm = dev.oparkz.get().motor_resolution - dev.otransy.controller.socket_put_confirmed(f"getaprch={_otransy_approach_height*_ogalil_encoder_steps_per_mm:.0f}") + dev.otransy.controller.socket_put_confirmed(f"getaprch={_otransy_approach_height:.2f}") input("Ready. Press Enter to start the mount process now...") dev.otransy.controller.socket_put_confirmed("XQ#GRGET") print("The Unmount process started.") + time.sleep(1) self._otransfer_confirm() self._otransfer_controller_disable_mount_mode() @@ -856,7 +861,7 @@ class OMNYSampleTransferMixin: else: umv(dev.osamroy, -25, dev.osamy, 2.7, dev.osamx, 0, dev.otransx, -350, dev.oeyex, 0) umv(dev.oshield, 0, dev.otransx, -458.1545+0.05, dev.oeyey, -4.8) - umv(dev.oshield, -12, otransz, -45.6494) + umv(dev.oshield, -12, dev.otransz, -45.6494) else: umv(dev.osamroy, -25, dev.osamy, 2.7, dev.osamx, 0, dev.otransx, -458.1545+0.05, dev.oeyex, 0, dev.oeyey, -4.8) diff --git a/csaxs_bec/device_configs/omny_config.yaml b/csaxs_bec/device_configs/omny_config.yaml index 486bf2a..f48aeea 100644 --- a/csaxs_bec/device_configs/omny_config.yaml +++ b/csaxs_bec/device_configs/omny_config.yaml @@ -109,7 +109,7 @@ otransy: readoutPriority: baseline userParameter: up_position: -1.2 - gripper_sensorvoltagetarget: -2.94 + gripper_sensorvoltagetarget: -2.30 otransz: description: Transfer Z deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor diff --git a/csaxs_bec/devices/omny/galil/galil_ophyd.py b/csaxs_bec/devices/omny/galil/galil_ophyd.py index 175b3f3..e74b726 100644 --- a/csaxs_bec/devices/omny/galil/galil_ophyd.py +++ b/csaxs_bec/devices/omny/galil/galil_ophyd.py @@ -105,7 +105,7 @@ class GalilController(Controller): return True def stop_all_axes(self) -> str: - return self.socket_put_and_receive("XQ#STOP,1") + return self.socket_put_confirmed("XQ#STOP,1") def get_digital_input(self, channel): return bool(float(self.socket_put_and_receive(f"MG @IN[{channel}]").strip()))