From 47cbb08c13f3c3a290754bf314bd61edd7930561 Mon Sep 17 00:00:00 2001 From: x01dc Date: Thu, 1 Oct 2026 15:52:16 +0200 Subject: [PATCH] fix(flomni): check OSA collision warning against fosaz's defined IN position The foptz-target OSA-collision warning was checking fosaz's current live readback, but fosaz is normally parked safely OUT except when actually in use -- so the warning would almost never fire in practice. Check against fosaz's "in" user_parameter instead (the same nominal position FlomniOpticsMixin.fosa_in() itself checks before refusing a fosaz move), since that's the real question: would this foptz target collide with the OSA if it were swapped in. Live-verified against the running simulated flomni session: fosaz's defined IN position is 13.1mm; the warning now correctly engages right at the real physical crossover (foptz=19 -> +0.90mm clearance, safe; foptz=20 -> -0.10mm, warns), matching compute_osa_remaining_space() exactly through the real dialog/client/device-RPC code path. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01NPZ9gzN2rt3wgiMnTKyrug --- .../widgets/tomo_params/tomo_params.py | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/csaxs_bec/bec_widgets/widgets/tomo_params/tomo_params.py b/csaxs_bec/bec_widgets/widgets/tomo_params/tomo_params.py index b25b1aea..f9ccffc0 100644 --- a/csaxs_bec/bec_widgets/widgets/tomo_params/tomo_params.py +++ b/csaxs_bec/bec_widgets/widgets/tomo_params/tomo_params.py @@ -2193,12 +2193,19 @@ class CommandJobBuilderDialog(QDialog): """Live, advisory-only OSA-collision warning for move_foptz_with_shift's foptz_target field. + Checked against fosaz's *defined* IN position (its "in" + user_parameter), not wherever fosaz happens to be reading right + now -- fosaz is normally parked safely OUT except when actually in + use, so checking the live position would almost never warn. The + real question is "if the OSA were swapped in at its nominal + position while foptz is at this target, would it collide", which + is also exactly what FlomniOpticsMixin.fosa_in() itself checks + (and refuses on) for fosaz moves -- this surfaces the same check + here, at data-entry time, for foptz instead. + The move itself stays a plain absolute move (see - _queue_action_move_foptz_with_shift's docstring) -- this just - surfaces, at data-entry time, the same clearance check - FlomniOpticsMixin.fosa_in() enforces (by refusing) for fosaz moves, - so an operator can see a likely OSA collision before queuing a - foptz target, without the queue action itself blocking on it. + _queue_action_move_foptz_with_shift's docstring) -- this is + advisory only, the queue action itself doesn't block on it. """ from csaxs_bec.bec_ipython_client.plugins.flomni.flomni_optics_mixin import ( compute_osa_remaining_space, @@ -2217,14 +2224,17 @@ class CommandJobBuilderDialog(QDialog): if fosaz is None: return try: - fosaz_val = fosaz.readback.get() + fosaz_in = (fosaz.user_parameter or {}).get("in") except Exception: return - clearance = compute_osa_remaining_space(foptz_widget.value(), fosaz_val) + if fosaz_in is None: + return + clearance = compute_osa_remaining_space(foptz_widget.value(), fosaz_in) if clearance <= 0: lbl.setText( - f"Warning: at this foptz target, OSA clearance would be " - f"{clearance:.2f} mm (<=0 = collision risk with a normal OMNY pin)." + f"Warning: at this foptz target, OSA clearance at its defined " + f"IN position ({fosaz_in:.2f} mm) would be {clearance:.2f} mm " + "(<=0 = collision risk with a normal OMNY pin)." ) lbl.setVisible(True) else: