From 8c7e1cf0600ac79b47fad393cceec05d8aca9922 Mon Sep 17 00:00:00 2001 From: x12sa Date: Thu, 12 Mar 2026 13:48:24 +0100 Subject: [PATCH] fixes during first round of testing flomni with Ana --- .../plugins/flomni/flomni.py | 19 +++++++++++++++++-- .../plugins/flomni/gui_tools.py | 15 +++++++++++---- .../plugins/flomni/x_ray_eye_align.py | 12 ++++++++++-- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py b/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py index 060e1a8..1128d87 100644 --- a/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py +++ b/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py @@ -84,6 +84,15 @@ class FlomniInitStagesMixin: else: return + + sensor_voltage_target = dev.ftransy.user_parameter.get("sensor_voltage") + sensor_voltage = float(dev.ftransy.controller.socket_put_and_receive("MG@AN[1]").strip()) + + if not np.isclose(sensor_voltage, sensor_voltage_target, 0.25): + print(f"Sensor voltage of the gripper is {sensor_voltage}, while target from config is {sensor_voltage_target}") + print("Verify that the value is acceptable and update config file. Reload config and start again.") + return + print("Starting to drive ftransy to +y limit") self.drive_axis_to_limit(dev.ftransy, "forward") dev.ftransy.limits = [-100, 0] @@ -414,6 +423,7 @@ class FlomniSampleTransferMixin: raise FlomniError("Ftray is not at the 'IN' position. Aborting.") def ftransfer_flomni_stage_in(self): + time.sleep(1) sample_in_position = dev.flomni_samples.is_sample_slot_used(0) #bool(float(dev.flomni_samples.sample_placed.sample0.get())) if not sample_in_position: @@ -428,7 +438,7 @@ class FlomniSampleTransferMixin: umv(dev.fsamx, fsamx_in) dev.fsamx.limits = [fsamx_in - 0.4, fsamx_in + 0.4] - self.flomnigui_idle() + #self.flomnigui_idle() def laser_tracker_show_all(self): dev.rtx.controller.laser_tracker_show_all() @@ -586,6 +596,8 @@ class FlomniSampleTransferMixin: if sample_in_position: raise FlomniError(f"The planned put position [{position}] already has a sample.") + self.flomnigui_show_cameras() + self.ftransfer_gripper_move(position) self.ftransfer_controller_enable_mount_mode() @@ -611,7 +623,7 @@ class FlomniSampleTransferMixin: self.ftransfer_controller_disable_mount_mode() self.ensure_gripper_up() - sample_name = dev.flomni_samples.sample_in_gripper.get() + sample_name = dev.flomni_samples.sample_in_gripper_name.get() self.flomni_modify_storage_non_interactive(100, 0, "-") self.flomni_modify_storage_non_interactive(position, 1, sample_name) @@ -1844,6 +1856,9 @@ class Flomni( ) def tomo_scan_projection(self, angle: float): + + dev.rtx.controller.laser_tracker_check_signalstrength() + scans = builtins.__dict__.get("scans") # additional_correction = self.align.compute_additional_correction(angle) diff --git a/csaxs_bec/bec_ipython_client/plugins/flomni/gui_tools.py b/csaxs_bec/bec_ipython_client/plugins/flomni/gui_tools.py index 51ad193..9727056 100644 --- a/csaxs_bec/bec_ipython_client/plugins/flomni/gui_tools.py +++ b/csaxs_bec/bec_ipython_client/plugins/flomni/gui_tools.py @@ -57,15 +57,22 @@ class flomniGuiTools: def _flomnigui_check_attribute_not_exists(self, attribute_name): if hasattr(self.gui, "flomni"): - if hasattr(self.gui.flomni, attribute_name): - return False + if attribute_name == "xeyegui": + if hasattr(self.gui.flomni, "xrayeye"): + return False + if attribute_name == "progressbar": + if hasattr(self.gui.flomni, "RingProgressBar"): + return False + if attribute_name == "cam_flomni_gripper" or attribute_name == "cam_flomni_overview": + if hasattr(self.gui.flomni, "Image") or hasattr(self.gui.flomni, "Image_0"): + return False return True def flomnigui_show_cameras(self): self.flomnigui_show_gui() if self._flomnigui_check_attribute_not_exists( - "camera_gripper" - ) or self._flomnigui_check_attribute_not_exists("camera_overview"): + "cam_flomni_gripper" + ) or self._flomnigui_check_attribute_not_exists("cam_flomni_overview"): self.flomnigui_remove_all_docks() camera_gripper_image = self.gui.flomni.new("Image") if self._flomnicam_check_device_exists(dev.cam_flomni_gripper): diff --git a/csaxs_bec/bec_ipython_client/plugins/flomni/x_ray_eye_align.py b/csaxs_bec/bec_ipython_client/plugins/flomni/x_ray_eye_align.py index 1e17ea5..1ec5465 100644 --- a/csaxs_bec/bec_ipython_client/plugins/flomni/x_ray_eye_align.py +++ b/csaxs_bec/bec_ipython_client/plugins/flomni/x_ray_eye_align.py @@ -49,6 +49,8 @@ class XrayEyeAlign: self._xray_fov_xy = [0, 0] def update_frame(self, keep_shutter_open=False): + if self.flomni._flomnigui_check_attribute_not_exists("xeyegui"): + self.flomni.flomnigui_show_xeyealign() if not dev.cam_xeye.live_mode_enabled.get(): dev.cam_xeye.live_mode_enabled.put(True) @@ -245,7 +247,13 @@ class XrayEyeAlign: ) print("Check the fit in the GUI...") - print("Then LOAD ALIGNMENT PARAMETERS by running flomni.read_alignment_offset()\n") + time.sleep(5) + + print("Automatically loading new alignment parameters from xray eye alignment.\n") + + self.flomni.read_alignment_offset() + + print("You are ready to remove the xray eye and start ptychography scans.") def write_output(self): file = os.path.expanduser("~/Data10/specES1/internal/xrayeye_alignmentvalues") @@ -266,7 +274,7 @@ class XrayEyeAlign: fovx_x = (k - 1) * 45 fovx_list.append([fovx_x, fovx_offset * 1000]) # Append the data to the list - print(f"Writing to file new alignment: number {k}, value x {fovx_offset}") + print(f"Alignment number {k}, value x {fovx_offset}") alignment_values_file.write(f"{fovx_x}\t{fovx_offset * 1000}\n") # Now build final numpy array: -- 2.52.0