Expose STARBackend.channel_request_cycle_counts()#909
Expose STARBackend.channel_request_cycle_counts()#909BioCam wants to merge 5 commits intoPyLabRobot:mainfrom
STARBackend.channel_request_cycle_counts()#909Conversation
There was a problem hiding this comment.
Pull request overview
This PR exposes a new STAR backend query API for retrieving per-channel cycle counters (tip pick-up/discard, aspiration, dispensing), plus a convenience method to fetch the counters for all channels.
Changes:
- Add
STARBackend.channel_request_cycle_counts()to query cycle counters for a single channel via firmware commandRV. - Add
STARBackend.channels_request_cycle_counts()to iterate over all channels and return per-channel cycle counter dictionaries.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "Robots with more than 8 channels have limited Y-axis reach per channel; they don't have random access to the full deck area.\n" | ||
| "Try the operation with different channels or a different target position (i.e. different labware placement)." | ||
| ) | ||
|
|
There was a problem hiding this comment.
Line contains trailing whitespace on an otherwise blank line. Please remove the extra spaces to satisfy linters and avoid noisy diffs.
| "Try the operation with different channels or a different target position (i.e. different labware placement)." | ||
| ) | ||
|
|
||
| async def channel_request_cycle_counts(self, channel_idx: int) -> dict: |
There was a problem hiding this comment.
The return type annotation -> dict is very generic and loses the information that this method returns a fixed set of integer counters. Consider using a more specific type (e.g., Dict[str, int] or a TypedDict) so callers and type-checkers can rely on the exact keys and value types.
| resp = await self.send_command( | ||
| module=STARBackend.channel_id(channel_idx), | ||
| command="RV", | ||
| fmt="na##########nb##########nc##########nd##########", | ||
| ) | ||
| return { | ||
| "tip_pick_up_cycles": resp["na"], | ||
| "tip_discard_cycles": resp["nb"], | ||
| "aspiration_cycles": resp["nc"], | ||
| "dispensing_cycles": resp["nd"], | ||
| } |
There was a problem hiding this comment.
New firmware query methods are added here, but there’s no corresponding test coverage. STAR_tests.py already has patterns for mocking _write_and_read_command/send_command; adding a test that validates the assembled RV command and parsed counters would help prevent regressions in the format string and key mapping.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…channel Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
No description provided.