Skip to content

fix: Stage controller objects that batch repeated relative/absolute calls and emit moveFinished when done #423

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 10 commits into from
May 6, 2025

Conversation

tlambert03
Copy link
Member

This is an attempt to fix #410 ... it's still a WIP, but it introduces a _ValueBatcher object, a generic object that knows how to get/set and add values, and check device busy state. It manages repeated calls to add_relative and/or set_absolute, and, maintains an internal awareness of whether we're "done" or not.

That all sounds rather abstract, and it is, but the goal is to have one object that we can share (across, say, the stage controller widget, and the stage explorer widget #400 ... that coordinates all of the attempts to control and move the stage, and, importantly, lets them all know when the job is done so they can, for example, snap an image.

The value batcher itself doesn't manage an event loop, and could be moved into pymmcore-plus. It is wrapped here with a small QObject that does have the timer, polls the controller, and emits the signal when needed.

Here is a concrete example of what it enables (there's still one little glitch that can be seen in the movie... and I'm not yet sure if that's a bug in this code, or the demo stage device adapter). Note that you can press the relative move button twice (before it's done) and it still makes a 2x movement.

Untitled.mov

@tlambert03 tlambert03 changed the title Stage controller objects that batch repeated relative/absolute calls and emit moveFinished when done Stage controller objects that batch repeated relative/absolute calls and emit moveFinished when done [WIP] May 4, 2025
@tlambert03 tlambert03 marked this pull request as draft May 4, 2025 21:22
@tlambert03 tlambert03 changed the title Stage controller objects that batch repeated relative/absolute calls and emit moveFinished when done [WIP] fix: Stage controller objects that batch repeated relative/absolute calls and emit moveFinished when done [WIP] May 4, 2025
@tlambert03
Copy link
Member Author

hey @fdrgsp, would you mind banging on this for a little bit and trying to break it?

@tlambert03 tlambert03 requested a review from fdrgsp May 4, 2025 23:58
@tlambert03
Copy link
Member Author

this now uses pymmcore-plus v0.14 with pymmcore-plus/pymmcore-plus#462

@tlambert03 tlambert03 changed the title fix: Stage controller objects that batch repeated relative/absolute calls and emit moveFinished when done [WIP] fix: Stage controller objects that batch repeated relative/absolute calls and emit moveFinished when done May 5, 2025
@tlambert03 tlambert03 marked this pull request as ready for review May 5, 2025 22:21
Copy link

codecov bot commented May 5, 2025

Codecov Report

Attention: Patch coverage is 96.96970% with 2 lines in your changes missing coverage. Please review.

Project coverage is 90.47%. Comparing base (1175bba) to head (14132c3).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rc/pymmcore_widgets/control/_q_stage_controller.py 95.55% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #423      +/-   ##
==========================================
- Coverage   90.52%   90.47%   -0.05%     
==========================================
  Files          89       90       +1     
  Lines        9791     9816      +25     
==========================================
+ Hits         8863     8881      +18     
- Misses        928      935       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tlambert03
Copy link
Member Author

this is looking pretty good. here's a real scope (it's a bit extra laggy, because this was also over remove desktop):

Untitled.mov

@tlambert03 tlambert03 merged commit 31116b4 into pymmcore-plus:main May 6, 2025
20 checks passed
@tlambert03 tlambert03 deleted the async-stage branch May 6, 2025 20:21
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stage Widget "Snap on Click" -> "Snap after Move"
1 participant