Skip to content

feat(panel-lock): the panel lock also locks the joystick of a Prior stage - #832

Draft
hongquanli wants to merge 2 commits into
feat/agent-sessionfrom
feat/prior-joystick-lock
Draft

hongquanli wants to merge 2 commits into
feat/agent-sessionfrom
feat/prior-joystick-lock

Conversation

@hongquanli

Copy link
Copy Markdown
Contributor

Draft: not checked on a Prior stage yet. The list for the bench is below. Base: the branch of #823 (merge #823 first).

What this adds

The lock of the control panel also turns off the joystick of a stage controller that has a joystick of its own (a Prior ProScan controller), and turns it on again at the unlock.

Why

The panel lock is a command of the Cephla controller. A Prior stage controller has its own joystick, and nothing locked it. So on a microscope with a Prior XY stage, a person could move the stage with the joystick while an agent drives (#823), during homing, and at the loading position.

How it works

  • The stage says what it has. AbstractStage.has_own_joystick() (False by default) and AbstractStage.set_joystick_lock(locked) (does nothing by default). The Prior stage sends H (joystick off) or J (joystick on) and raises when the controller does not answer 0. A combined stage passes the call to its XY stage and its Z stage. The window does not ask which kind of stage it has.
  • One place locks and unlocks: _set_control_panel_lock in gui_hcs.py. It sends the Cephla panel lock as before, then the lock of the stage's joystick. The lock is counted by reason (agent session, homing, loading position), as in feat(agent-session): an agent session for the control server, with take over and hand back #823, so the end of one does not unlock under another.
  • For an agent session, each lock must be confirmed. When the Prior controller does not confirm, the session is refused with could not lock the joystick of the stage, and Squid turns the joystick on again. For homing and the loading position a failure is logged, as for the panel today.
  • The setting agent_session_allow_unlocked_panel stays about the Cephla panel only. With it on, the joystick of a Prior stage is still locked, and the banner says so.

The Prior commands are from the ProScan III manual (stage commands): H turns the joystick off after a joystick move in progress, J turns it on, each answers 0 in the standard mode, and the joystick is on at power-up.

Behaviour change

  • A microscope with no Prior stage: nothing changes. The stage call does nothing, and the Cephla lock commands are the same.
  • A microscope with a Prior stage: homing and the loading position now turn the Prior joystick off and on again. Before, the joystick stayed on.

Tests

  • tests/squid/test_prior_stage.py, tests/squid/test_stage.py: the lock and the unlock on a fake controller, an answer that is not 0, no answer, a stage with no joystick, a combined stage.
  • tests/control/test_stage_joystick_lock.py (new), tests/control/test_agent_session_protection.py: the lock for each reason, a failure of one device does not stop the command to the other, a session that is refused unlocks again, the banner texts, the refusal text.
  • tests/control/test_HighContentScreeningGui.py, whole, in one process: 59 passed.

For the bench (a Prior stage), before this merges

  1. The commands. Send H and J by hand: each answers 0. Check that H 0 at the start of Squid leaves the joystick on (an older firmware can take it as H). Note the firmware version.
  2. Squid's own moves while the joystick is off: click-to-move, the arrow buttons, a move_to over the control server, and homing (homing now locks the joystick).
  3. The joystick works again after each unlock: homing that ends, homing that fails, the return from the loading position, the end of an agent session (Take over, End session, Unlock anyway), a session that is refused, the close of Squid during a lock, a restart of Squid.
  4. Timing. Send H while the joystick is held to one side, and while a move of Squid runs: the answer must still come at once. A late answer refuses a session.
  5. The controller is switched off and on during a lock. The joystick is on again after power-up. Check that Squid still talks to the controller, and that the next lock works.
  6. Squid ends with no unlock (a crash): the joystick stays off until the next start of Squid or a power cycle.

Not in this pull request

  • An acquisition turns the Cephla joystick off for each time point. The Prior joystick stays on during an acquisition, as today.
  • Other open work changes squid/stage/prior.py; a merge can need a small fix there.

🤖 Generated with Claude Code

https://claude.ai/code/session_0152Tv36aY3Whyz7ATrKcZX3

hongquanli and others added 2 commits November 15, 2026 09:44
AbstractStage.has_own_joystick() says if the stage controller has a joystick
that moves the stage without Squid, and set_joystick_lock(locked) turns it off
or on. A stage with no joystick of its own does nothing (the Cephla stage, whose
joystick is on the control panel, and the PI focus stage). CombinedStage passes
both calls to its XY and Z stages.

The Prior stage has its own joystick: "H" turns it off and "J" turns it on, and
the controller answers "0" to each. Any other answer, or no answer, raises
SquidError. enable_joystick() and disable_joystick() (not called anywhere) now
use it. The start-up "H 0" is not changed: it keeps the joystick on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0152Tv36aY3Whyz7ATrKcZX3
…tage

A Prior stage controller has a joystick of its own, and nothing locked it: a
hand on it moved the stage while an agent drove, during homing and at the
loading position. The lock of the control panel now turns that joystick off
too, for each of the three reasons, and the unlock turns it on again.

_set_control_panel_lock is the one place that locks and unlocks both. For
homing, the loading position and every unlock, a failure is logged and the
other one is still sent. The agent session locks through the same place and
waits for each confirmation: when the Prior controller does not confirm, the
session is refused with "could not lock the joystick of the stage", and the
joystick is turned on again (the reason is held from before the send).

With agent_session_allow_unlocked_panel on and a control panel that cannot
lock, the joystick of a Prior stage is still locked, and the banner says so:
"The control panel is not locked: do not touch it. The joystick of the stage
is locked." On a microscope with no Prior stage nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0152Tv36aY3Whyz7ATrKcZX3
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant