From 446b20130232f3140b079fea9f7723e434004e8e Mon Sep 17 00:00:00 2001 From: x01dc Date: Tue, 1 Sep 2026 14:17:38 +0200 Subject: [PATCH] fix(omny): realistic sim motor temperatures, rotation heads-up, and corr_pos_x crash - sim_galil.py: default unseeded analog-input channels to a voltage that reads back as a realistic ~30 degC motor temperature instead of the previous 0.0V/150 degC default (real motors run well under 60 degC). - rt_omny_ophyd.py: feedback_enable_with_reset() now tells the user the current angle and warns it might take a while when osamroy has more than 5 deg to rotate back to zero, matching flomni's style of heads-up. - omny_sample_transfer_mixin.py: otransfer_put_sample() now calls reset_correction()/reset_tomo_alignment_fit() when mounting into the sample stage (pin_position == 0), mirroring flomni's ftransfer_put_sample() -> ftransfer_flomni_stage_in() pattern. Fixes an AttributeError ('OMNY' object has no attribute 'corr_pos_x') hit when calling tomo_scan_projection() after a sample transfer. --- .../plugins/omny/omny_sample_transfer_mixin.py | 8 ++++++++ csaxs_bec/devices/omny/rt/rt_omny_ophyd.py | 13 ++++++++++--- csaxs_bec/devices/sim/sim_galil.py | 10 ++++++++-- 3 files changed, 26 insertions(+), 5 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 3cb19d27..b0f59611 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 @@ -764,6 +764,14 @@ 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) + + if pin_position == 0: + # sample is now in the sample stage (scanning position): any alignment + # correction data belongs to the previous sample, discard it -- matches + # flomni's ftransfer_put_sample()/ftransfer_flomni_stage_in() + self.reset_correction() + self.reset_tomo_alignment_fit() + # 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 diff --git a/csaxs_bec/devices/omny/rt/rt_omny_ophyd.py b/csaxs_bec/devices/omny/rt/rt_omny_ophyd.py index f2566f25..70c905b1 100644 --- a/csaxs_bec/devices/omny/rt/rt_omny_ophyd.py +++ b/csaxs_bec/devices/omny/rt/rt_omny_ophyd.py @@ -527,9 +527,16 @@ class RtOMNYController(Controller): # the following read will also upate the angle in rt during readout readback = osamroy.obj.readback.get() if np.fabs(readback) > 0.1: - self.device_manager.connector.send_client_info( - f"Rotating to zero", scope="feedback enable", show_asap=True - ) + if np.fabs(readback) > 5: + self.device_manager.connector.send_client_info( + f"Rotating from {readback:.1f} deg to zero. This might take a while.", + scope="feedback enable", + show_asap=True, + ) + else: + self.device_manager.connector.send_client_info( + f"Rotating to zero", scope="feedback enable", show_asap=True + ) osamroy.obj.move(0, wait=True) osamx = self.device_manager.devices.osamx diff --git a/csaxs_bec/devices/sim/sim_galil.py b/csaxs_bec/devices/sim/sim_galil.py index c7df6f74..d6a21fc3 100644 --- a/csaxs_bec/devices/sim/sim_galil.py +++ b/csaxs_bec/devices/sim/sim_galil.py @@ -40,6 +40,12 @@ _STPPERMM_EXPR_RE = re.compile(r"^([0-9.]+)\s*\*\s*stppermm\[(\d+)\]$") _OMNY_ROTATION_PORT = 8083 _OMNY_ROTATION_AXIS = 2 +# Default analog input voltage for unseeded channels, used by GalilController. +# motor_temperature() (@AN[axis+1], converted via (V+10)/20*300 to degC). -8.0V -> 30 +# degC, a realistic idle motor temperature; the previous 0.0V default read back as +# 150 degC on every axis without an explicit sim_analog_inputs override. +_DEFAULT_ANALOG_INPUT_V = -8.0 + class _SimGalilAxis: """State of a single simulated Galil axis (positions in microsteps).""" @@ -144,7 +150,7 @@ class SimGalilState: } self.digital_inputs = {14: 1.0} # light curtain reads triggered by default self.digital_outputs = {9: 0.0, 15: 1.0} # gripper closed, lights on - self.analog_inputs = {1: -1.6} + self.analog_inputs = {} self._thread_deadlines = {} # thread_id -> unix time until which thread is active self._transfer_thread = None self._transfer_abort = threading.Event() @@ -494,7 +500,7 @@ class SimGalilSocket(SimSocketBase): return f"{state.digital_outputs.get(channel, 0.0):.4f}" if arg.startswith("@AN["): channel = int(arg[4:].split("]")[0]) - return f"{state.analog_inputs.get(channel, 0.0):.4f}" + return f"{state.analog_inputs.get(channel, _DEFAULT_ANALOG_INPUT_V):.4f}" if arg in ("allaxref", "axisref"): return f"{1.0 if state.all_axes_referenced() else 0.0:.4f}" if arg.startswith("axisref["):