Skip to content

PI stage: connected only after a full initialize, a reset id, a wait for the controller, and fake-GCS2 tests - #73

Merged
kalidke merged 6 commits into
mainfrom
pistage-fixes
Oct 2, 2026
Merged

kalidke merged 6 commits into
mainfrom
pistage-fixes

Conversation

@kalidke

@kalidke kalidke commented Sep 29, 2026

Copy link
Copy Markdown
Member

The PI stage (PIStage, C-867) fixes from the #69 review, as one PR into main. They are for 0.2.6 and were kept out of 0.2.5.

This branch carries #72 (the 0.2.6-DEV bump) merged in, because a PR into a released main must otherwise raise the version. Until #72 merges, its one commit shows here too.

Fixed

  • shutdown could close another object's connection. id defaulted to 0, a valid GCS id, and was never reset. It now defaults to -1, and shutdown resets it; a failed close keeps the id so a later shutdown can retry.
  • initialize reported the stage connected before it was (review F2). connectionstatus was set before the connect, and a failed close after a failed reference left it true, so a retry answered "already initialized". It is now set only after the whole sequence succeeds, and every step after the connect is inside the cleanup, which closes the connection and rethrows.
  • The stage panels' initialize buttons (1D, 2D and 3D) log a failed initialize and return, instead of throwing out of the Makie click callback (review F4). They also skip the position read when initialize returned without connecting.

Changed

  • initialize waits for PI_IsControllerReady after the reference move, before polling PI_qFRF, as PI's samples do (review F3). Both waits share REFERENCE_TIMEOUT_S (60 s). Not yet run on hardware; this needs a rig check on the C-867.
  • Docstrings: initialize says what it does; referencemove is the PI_FRF start. The stale TODOs are gone, and so is the "1 mm/s" comment (review F6).

Tests (F7)

  • A seam: pi_stage/gcs2.jl wraps each of the 19 GCS2 calls PIStage makes as a function, so test/pi_stage_fake_sdk.jl (FakePIStage) replaces every one. Calls the tests don't model (PI_MOV, PI_HLT, PI_STP) throw, so no test can reach a DLL. No call's types changed.
  • test/pi_stage.jl has 8 cases:
    • the default id, and shutdown before initialize;
    • the success order FRF, then IsControllerReady, then qFRF, with connectionstatus still false during the reference;
    • a refused FRF;
    • a controller that is never ready;
    • an axis that is never referenced;
    • a throw after the reference;
    • a failed close, then a retry;
    • shutdown's id reset.
  • Local suite at this head (kitt, Julia 1.13): 1841 pass, 3 broken, 0 fail. The lab/tests record follows as a commit status.

Not yet run on hardware. MicroscopeAdapt's rig builds PIStage().

🤖 Generated with Claude Code

kalidke and others added 6 commits September 29, 2026 14:33
No behaviour change: each inline @CCall moves into pi_stage/gcs2.jl unchanged,
so a test can replace the wrappers.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Id defaults to -1 and shutdown resets it; connectionstatus is set once,
after every step past the connect; initialize waits for
PI_IsControllerReady before PI_qFRF; the stage panels' initialize buttons
log a failed initialize; stale TODOs and docstrings corrected. Adds
test/pi_stage_fake_sdk.jl and test/pi_stage.jl.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Decision 0033: after X.Y.Z, main carries X.Y.(Z+1)-DEV. TagOnMerge skips a
-DEV version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…istage-fixes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	CHANGELOG.md
#	test/runtests.jl
…e motion-stop wait, reclaim own connection on retry, one GUI initialize guard

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ze, as in 0.2.5 (#73 Q1)

gui_initialize still logs the failure. 0.2.5 opened the panel when initialize
returned without connecting (MCL_InitHandle == 0), with its callbacks refusing
while connectionstatus is false; the P5 guard's '|| return' stopped that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kalidke

kalidke commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

This ships in #76 (MicroscopeControl 0.2.6), the single 0.2.6 release PR, as a merge commit of this PR's accepted head. Please leave this PR open: GitHub marks it merged when #76 lands.

kalidke added a commit that referenced this pull request Sep 30, 2026
… PI and DCAM4 claims, drop a blank line

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kalidke
kalidke merged commit 781fa4a into main Oct 2, 2026
5 checks passed
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