diff --git a/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py b/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py index 86c2499c..3c1fe4dc 100644 --- a/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py +++ b/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py @@ -305,7 +305,7 @@ class FlomniInitStagesMixin: dev.ftransx.limits = [0, 50] dev.ftray.limits = [-200, 0] dev.fsamy.limits = [2, 3.5] - dev.foptz.limits = [22.5, 28] + dev.foptz.limits = [17 - 0.1, 17 + 0.1] dev.foptx.limits = [-17, -12] dev.fheater.limits = [-15, 0] dev.feyex.limits = [-18, -1] @@ -333,7 +333,8 @@ class FlomniInitStagesMixin: # the fopty 3.87 should put us in place for a lower FZP on the lower FZP chip - umv(dev.foptz, 23) + umv(dev.foptz, 17) + dev.foptz.limits = [17 - 0.1, 17 + 0.1] flomni_samx_in = dev.fsamx.user_parameter.get("in") if flomni_samx_in is None: @@ -1090,17 +1091,18 @@ class FlomniSampleTransferMixin: if position == 0 and fsamx_pos > -160: print("Use GUI interface.") - if self.ftransfer_confirm_dialog("May the flomni stage be moved out for the sample change? Feedback will be disabled and alignment will be lost!", "y"): - - # if self.OMNYTools.yesno( - # "May the flomni stage be moved out for the sample change? Feedback will be disabled and alignment will be lost!", - # "y", - # ): + if self.ftransfer_confirm_dialog( + "May the flomni stage be moved out for the sample change? " + "Feedback will be disabled and alignment will be lost!", + "y", + ): print("OK. continue.") self.ftransfer_flomni_stage_out() else: - print("Stopping.") - return + raise FlomniError( + "Stage-out declined by user. Aborting sample transfer before any " + "gripper motion." + ) self.ensure_gripper_up() self.check_tray_in() diff --git a/csaxs_bec/bec_ipython_client/plugins/flomni/flomni_optics_mixin.py b/csaxs_bec/bec_ipython_client/plugins/flomni/flomni_optics_mixin.py index bd309f4b..20004b63 100644 --- a/csaxs_bec/bec_ipython_client/plugins/flomni/flomni_optics_mixin.py +++ b/csaxs_bec/bec_ipython_client/plugins/flomni/flomni_optics_mixin.py @@ -5,6 +5,10 @@ from rich.console import Console from rich.table import Table +class FlomniOpticsError(Exception): + pass + + class FlomniOpticsMixin: @staticmethod def _get_user_param_safe(device, var): @@ -13,6 +17,12 @@ class FlomniOpticsMixin: raise ValueError(f"Device {device} has no user parameter definition for {var}.") return param.get(var) + def _osa_remaining_space(self, fosaz_target: float) -> float: + """Clearance (mm) between the OSA and a normal OMNY pin if fosaz were + at `fosaz_target`, at the *current* foptz reading. <=0 means collision.""" + foptz_val = dev.foptz.readback.get() + return -fosaz_target + (33 - foptz_val) + def feye_out(self): dev.fsh.fshclose() self.foptics_in() @@ -188,6 +198,16 @@ class FlomniOpticsMixin: ) if need_move_osa: + remaining = self._osa_remaining_space(fosaz_in) + if remaining <= 0: + foptz_val = dev.foptz.readback.get() + raise FlomniOpticsError( + f"Refusing to move OSA to its IN position: at the current foptz " + f"({foptz_val:.2f}), fosaz IN ({fosaz_in:.4f}) would leave " + f"{remaining:.2f} mm of clearance to a normal OMNY pin -- a " + "collision. Check/recalibrate the fosaz 'in' user parameter for " + "the current foptz before proceeding (see ffzp_info())." + ) umv(dev.fosax, fosax_in, dev.fosay, fosay_in) umv(dev.fosaz, fosaz_in) else: @@ -311,13 +331,12 @@ class FlomniOpticsMixin: console.print(table) fosaz_val = dev.fosaz.readback.get() - foptz_val = dev.foptz.readback.get() fosaz_in = self._get_user_param_safe("fosaz", "in") tol_osa = 0.010 # mm, 10 microns - remaining_current = -fosaz_val + (33 - foptz_val) - remaining_at_in = -fosaz_in + (33 - foptz_val) + remaining_current = self._osa_remaining_space(fosaz_val) + remaining_at_in = self._osa_remaining_space(fosaz_in) print("\nOSA Information:") print(f" Current fosaz {fosaz_val:.1f}") diff --git a/csaxs_bec/device_configs/ptycho_flomni.yaml b/csaxs_bec/device_configs/ptycho_flomni.yaml index e0c9e663..e6b0b8e4 100644 --- a/csaxs_bec/device_configs/ptycho_flomni.yaml +++ b/csaxs_bec/device_configs/ptycho_flomni.yaml @@ -144,7 +144,7 @@ foptz: readoutPriority: baseline connectionTimeout: 20 userParameter: - in: 23 + in: 17 deviceTags: - ptycho_flomni