Skip to content

feat(worker): log actual z after each per-channel z-offset move - #573

Merged
Alpaca233 merged 3 commits into
masterfrom
feat/log-actual-z-after-offset-move
Jul 1, 2026
Merged

feat(worker): log actual z after each per-channel z-offset move#573
Alpaca233 merged 3 commits into
masterfrom
feat/log-actual-z-after-offset-move

Conversation

@Alpaca233

Copy link
Copy Markdown
Collaborator

Summary

Adds an info-level log line reporting the actual z position after each per-channel
z-offset move
during multi-point acquisition. The log is emitted from
_move_z_for_offset, so it covers both the apply path (_apply_channel_z_offset)
and the reset/undo path (_reset_channel_z_offset).

Each log records the delta moved and where z landed:

  • Stage path: [z-offset] moved +1.50 µm via stage; actual z = 3.2000 mm
  • Piezo path: [z-offset] moved +1.50 µm via piezo; piezo at 101.50 µm, actual stage z = 3.2000 mm

The stage z is read back with stage.get_pos() (the real, measured position) so it can be
used to confirm each channel offset actually landed where expected.

Why

When diagnosing per-channel z-offset behavior (PR #551), it's useful to see the resulting
z after each offset move rather than only the requested delta.

Test plan

  • pytest tests/control/test_MultiPointWorker_offsets.py — 25 passed, 1 skipped
  • black --config pyproject.toml --check — clean

Test stub's stage.get_pos() was given a numeric z_mm so the new log f-string formats
under the mock.

🤖 Generated with Claude Code

Add an info log in _move_z_for_offset (covers both the apply and reset
paths) reporting the delta moved and the resulting position: the measured
stage z, plus the piezo position on the piezo path. Makes it easy to
confirm from the log where z actually landed after each channel offset.

Give the offset test stub's stage.get_pos() a numeric z_mm so the new log
f-string formats under the mock.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds info-level telemetry to MultiPointWorker so each per-channel z-offset adjustment logs the requested/achieved delta and the resulting measured stage z position (read back via stage.get_pos()), covering both apply and reset paths through _move_z_for_offset.

Changes:

  • Emit an info log after each z-offset move in _move_z_for_offset, for both piezo and stage paths, including a stage z readback.
  • Update the MultiPointWorker offset unit test stub to return a numeric z_mm from stage.get_pos() so the new formatted log line doesn’t raise under mocks.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
software/control/core/multi_point_worker.py Adds info logs that include post-move measured stage z after each per-channel z-offset move (piezo and stage paths).
software/tests/control/test_MultiPointWorker_offsets.py Adjusts the stage mock to provide numeric z_mm to support the new formatted logging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Alpaca233 and others added 2 commits July 1, 2026 10:26
_update_apply_channel_offset_enable_state force-unchecked the checkbox when
laser AF turned off but never re-checked it when AF came back on, so a laser-AF
off->on cycle silently dropped the user's opt-in — the visible checkbox no
longer matched whether offsets were actually applied.

Make the handler visibility-only: the checked state is now changed solely by the
user, so it always reflects the apply_channel_offset flag. This is safe because
offset application is already double-gated on reflection AF in the worker
(_apply_channel_z_offset), so a retained opt-in stays inert while AF is off.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The per-channel z-offset move log rounded stage z to %.4f mm (0.1 µm), which
sat right at the size of the deviations one wants to inspect — making measured
movement look quantized. Bump to %.5f mm (10 nm) so actual moves can be checked
below the 0.1 µm grid.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Alpaca233
Alpaca233 merged commit ecd8492 into master Jul 1, 2026
3 checks passed
hongquanli added a commit that referenced this pull request Jul 4, 2026
Conflict resolution notes (software/control/core/multi_point_worker.py):
this branch MOVED the shared capture mechanics (_image_callback,
acquire_camera_image, _wait_for_outstanding_callback_images, _sleep)
into MultiPointWorkerBase, while master MODIFIED them in place
(acquisition watchdog #565, per-channel z-offset logging #573,
error-vs-user-abort classification). Resolution keeps the refactored
layout and ports master's edits into the base-class copies:

- _abort_due_to_error and a no-op _run_state_beat live on the base
  (MultiPointWorker overrides the beat with the real watchdog one), so
  every request_abort_fn() error site in the moved methods now tags
  _abort_cause = "error" exactly as on master.
- _abort_cause initialized in the base __init__; MultiPointWorker keeps
  run_state_writer/_run_state and _compute_end_reason.
- Per-image _run_state_beat() call added in the base _image_callback,
  matching master's placement after the image counters.
- Master's z-offset move logging auto-merged (methods not moved).

Verified: record-zstack suites + master's watchdog/worker-reason tests
(127 passed).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

2 participants