fix(omny): reuse camera docks on parking/samplestage switch, GUI-confirm mount step, speed up otransx/oshield sim
CI for csaxs_bec / test (push) Successful in 1m58s

- gui_tools.py: _omnycam_parking()/_omnycam_samplestage() now share one
  _omnygui_show_omnycam_pair() helper that creates the two camera Image
  docks + console once and re-points them via Image.image(device=...)
  on later switches instead of tearing down and rebuilding the whole
  GUI every time (bec_widgets' Image.image() already supports being
  called again to swap the monitored device). Also stops live mode on
  the outgoing camera pair on a switch, and drops the dead
  _omnycam_check_device_exists no-op guard in favor of the `in dev`
  idiom already used for cam_xeye in this file.
- omny_sample_transfer_mixin.py: the two remaining blocking
  input("Ready. Press Enter...") prompts in otransfer_put_sample/
  otransfer_get_sample now go through otransfer_confirm_dialog() like
  every other transfer confirmation, so they show up in the GUI console
  instead of blocking on a terminal keypress; fixed the get_sample
  prompt's copy-pasted "mount" wording to "unmount".
- simulated_omny.yaml: otransx sim_velocity 10->100 mm/s; oshield
  gained sim_velocity: 10.0 (previously unset, defaulting to the
  Smaract sim's 1 mm/s) -- both x10 per request.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Mupip8x7Hean6E3FFvpbj
This commit is contained in:
x01dcandClaude Sonnet 5 committed 2026-09-04 16:36:14 +02:00
1 parent fbc76b4fb1
commit eef1c7eb46
4 files changed
+97 -70

No files matched your search

@@ -33,11 +33,10 @@ class OMNYGuiTools:
self.progressbar = None
self.xeyegui = None
self.idle_text_box = None
self.fig200 = None
self.fig201 = None
self.fig202 = None
self.fig203 = None
self.cam_dock_a = None
self.cam_dock_b = None
self.console = None
self._omnycam_shown_pair = None
def set_client(self, client):
self.client = client
@@ -68,14 +67,6 @@ class OMNYGuiTools:
return True
return False
def _omnycam_check_device_exists(self, device):
try:
device
except:
return False
else:
return True
def omnygui_show_xeyealign(self):
self.omnygui_show_gui()
if self._omnygui_is_missing("xeyegui"):
@@ -104,30 +95,37 @@ class OMNYGuiTools:
self._omnycam_active_pair = ("cam200", "cam203")
def omnygui_show_omnycam_parking(self):
self._omnygui_show_omnycam_pair("cam200", "cam203", num_rotation_90=3)
def _omnycam_samplestage(self):
self.omnygui_show_omnycam_samplestage()
self._omnycam_active_pair = ("cam201", "cam202")
def omnygui_show_omnycam_samplestage(self):
self._omnygui_show_omnycam_pair("cam201", "cam202", num_rotation_90=0)
def _omnygui_show_omnycam_pair(self, cam_a: str, cam_b: str, num_rotation_90: int = 0):
"""Show a live camera pair, reusing the two camera docks + console
across parking<->samplestage switches instead of tearing the whole
GUI down and rebuilding it every time.
``Image.image(device=..., signal=...)`` (bec_widgets) disconnects
the previous monitor and reconnects to the new one on an existing
widget, so switching pairs is just re-pointing ``cam_dock_a``/
``cam_dock_b`` at the new devices -- the docks and console are only
(re)created here if they don't exist yet (first camera view this
session, or after a full teardown via another GUI state such as
idle/progress/xeyealign).
"""
self.omnygui_show_gui()
if (
self._omnygui_is_missing("fig200")
or self._omnygui_is_missing("fig203")
self._omnygui_is_missing("cam_dock_a")
or self._omnygui_is_missing("cam_dock_b")
or self._omnygui_is_missing("console")
):
self.omnygui_remove_all_docks()
self.fig200 = self.gui.omny.new("Image")
if self._omnycam_check_device_exists(dev.cam200):
self.fig200.image(device="cam200", signal="preview")
self.fig200.num_rotation_90 = 3
self.fig200.lock_aspect_ratio = True
dev.cam200.start_live_mode()
else:
print("Cannot open cam200. Device does not exist.")
self.fig203 = self.gui.omny.new("Image")
if self._omnycam_check_device_exists(dev.cam203):
self.fig203.image(device="cam203", signal="preview")
self.fig203.num_rotation_90 = 3
self.fig203.lock_aspect_ratio = True
dev.cam203.start_live_mode()
else:
print("Cannot open cam203. Device does not exist.")
self.cam_dock_a = self.gui.omny.new("Image")
self.cam_dock_b = self.gui.omny.new("Image")
# Hard-stop console, docked below the cameras. otransy is the
# closest omny analog to flomni's ftransy (both the transfer-Y
# axis) -- no secondary/extra stop device wired yet.
@@ -140,41 +138,22 @@ class OMNYGuiTools:
)
self.gui.omny.set_layout_ratios(vertical=[5, 1])
def _omnycam_samplestage(self):
self.omnygui_show_omnycam_samplestage()
self._omnycam_active_pair = ("cam201", "cam202")
outgoing_pair = self._omnycam_shown_pair
if outgoing_pair and outgoing_pair != (cam_a, cam_b):
for cam_name in outgoing_pair:
if cam_name in dev:
getattr(dev, cam_name).stop_live_mode()
def omnygui_show_omnycam_samplestage(self):
self.omnygui_show_gui()
if (
self._omnygui_is_missing("fig201")
or self._omnygui_is_missing("fig202")
or self._omnygui_is_missing("console")
):
self.omnygui_remove_all_docks()
self.fig201 = self.gui.omny.new("Image")
if self._omnycam_check_device_exists(dev.cam201):
self.fig201.image(device="cam201", signal="preview")
self.fig201.lock_aspect_ratio = True
dev.cam201.start_live_mode()
for dock, cam_name in ((self.cam_dock_a, cam_a), (self.cam_dock_b, cam_b)):
if cam_name in dev:
dock.image(device=cam_name, signal="preview")
dock.num_rotation_90 = num_rotation_90
dock.lock_aspect_ratio = True
getattr(dev, cam_name).start_live_mode()
else:
print("Cannot open cam201. Device does not exist.")
self.fig202 = self.gui.omny.new("Image")
if self._omnycam_check_device_exists(dev.cam202):
self.fig202.image(device="cam202", signal="preview")
self.fig202.lock_aspect_ratio = True
dev.cam202.start_live_mode()
else:
print("Cannot open cam202. Device does not exist.")
print(f"Cannot open {cam_name}. Device does not exist.")
self.console = self.gui.omny.new(
"z_ConsoleButtonsWidget",
object_name="console",
where="bottom",
hard_stop_device_name="otransy",
hard_stop_label="OMNY Motion Stop",
)
self.gui.omny.set_layout_ratios(vertical=[5, 1])
self._omnycam_shown_pair = (cam_a, cam_b)
def omnygui_remove_all_docks(self):
if hasattr(self.gui, "omny"):
@@ -183,11 +162,10 @@ class OMNYGuiTools:
self.text_box = None
self.xeyegui = None
self.idle_text_box = None
self.fig200 = None
self.fig201 = None
self.fig202 = None
self.fig203 = None
self.cam_dock_a = None
self.cam_dock_b = None
self.console = None
self._omnycam_shown_pair = None
def omnygui_idle(self):
self.omnygui_show_gui()
@@ -779,7 +779,8 @@ class OMNYSampleTransferMixin:
self._otransfer_controller_enable_mount_mode()
dev.otransy.controller.socket_put_confirmed(f"mntaprch={_otransy_approach_height:.2f}")
input("Ready. Press Enter to start the mount process now...")
if not self.otransfer_confirm_dialog("Ready to start the mount process now?", "y"):
raise OMNYTransferError("Transfer process has been manually aborted.")
dev.otransy.controller.socket_put_confirmed("XQ#GRPUT")
print("The mount process started.")
@@ -932,7 +933,8 @@ class OMNYSampleTransferMixin:
dev.otransy.controller.socket_put_confirmed(f"getaprch={_otransy_approach_height:.2f}")
input("Ready. Press Enter to start the mount process now...")
if not self.otransfer_confirm_dialog("Ready to start the unmount process now?", "y"):
raise OMNYTransferError("Transfer process has been manually aborted.")
dev.otransy.controller.socket_put_confirmed("XQ#GRGET")
@@ -255,7 +255,7 @@ otransx:
- 0
port: 8081
sign: 1
sim_velocity: 10.0
sim_velocity: 100.0
sim_initial_position: 0
enabled: true
onFailure: buffer
@@ -709,6 +709,7 @@ oshield:
- 15.8
port: 3334
sign: 1
sim_velocity: 10.0
# Real hardware idles with the sample-stage shield closed; 15.5 is
# _oshield_ST_close()'s own umv() target (omny_sample_transfer_mixin.py).
# Starting at 0 (neither open -11.88 nor closed 15.5) always failed
@@ -122,6 +122,7 @@ def test_omnygui_show_omnycam_parking_uses_current_image_widget_api():
client.gui.omny.new.side_effect = [fig200, fig203, console]
dev_mock = mock.MagicMock()
dev_mock.__contains__ = mock.Mock(return_value=True)
with mock.patch(f"{GUI_TOOLS}.dev", dev_mock, create=True):
tools.omnygui_show_omnycam_parking()
@@ -240,6 +241,7 @@ def test_omnygui_show_omnycam_samplestage_uses_current_image_widget_api():
client.gui.omny.new.side_effect = [fig201, fig202, console]
dev_mock = mock.MagicMock()
dev_mock.__contains__ = mock.Mock(return_value=True)
with mock.patch(f"{GUI_TOOLS}.dev", dev_mock, create=True):
tools.omnygui_show_omnycam_samplestage()
@@ -250,3 +252,47 @@ def test_omnygui_show_omnycam_samplestage_uses_current_image_widget_api():
fig202.image.assert_called_once_with(device="cam202", signal="preview")
dev_mock.cam202.start_live_mode.assert_called_once()
assert tools.console is console
def test_omnycam_switch_repoints_existing_docks_instead_of_recreating():
"""Switching parking<->samplestage while the camera view is already open
must not tear down and rebuild the GUI (visible flicker) -- it should
reuse the same two Image docks + console and just re-point them at the
new camera pair via Image.image(), per bec_widgets' current API."""
tools, client = _make_gui_tools()
client.gui.windows = {"omny": mock.MagicMock()}
dock_a = mock.MagicMock()
dock_a._is_deleted.return_value = False
dock_b = mock.MagicMock()
dock_b._is_deleted.return_value = False
console = mock.MagicMock()
console._is_deleted.return_value = False
client.gui.omny.new.side_effect = [dock_a, dock_b, console]
dev_mock = mock.MagicMock()
dev_mock.__contains__ = mock.Mock(return_value=True)
with mock.patch(f"{GUI_TOOLS}.dev", dev_mock, create=True):
tools.omnygui_show_omnycam_parking()
client.gui.omny.new.reset_mock()
dock_a.image.reset_mock()
dock_b.image.reset_mock()
tools.omnygui_show_omnycam_samplestage()
# no new docks/console created on the switch
client.gui.omny.new.assert_not_called()
assert tools.cam_dock_a is dock_a
assert tools.cam_dock_b is dock_b
assert tools.console is console
# the same two docks were re-pointed at the new devices
dock_a.image.assert_called_once_with(device="cam201", signal="preview")
assert dock_a.num_rotation_90 == 0
dock_b.image.assert_called_once_with(device="cam202", signal="preview")
# the outgoing pair's live mode was stopped, the incoming pair's started
dev_mock.cam200.stop_live_mode.assert_called_once()
dev_mock.cam203.stop_live_mode.assert_called_once()
dev_mock.cam201.start_live_mode.assert_called_once()
dev_mock.cam202.start_live_mode.assert_called_once()