Rewrite Mettler Toledo SICS scale backend with I0 command discovery, protocol simulator, and tests#979
Open
BioCam wants to merge 49 commits intoPyLabRobot:mainfrom
Open
Conversation
… validation, device discovery, and chatterbox simulator
A valid response arriving just past the timeout threshold was being discarded because the timeout check preceded the non-empty check. Sleep moved to only occur between empty reads. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…n, gate execution-only code; round chatterbox to 0.01mg
…e and MT-SICS response parsing
…G_LEVEL_IO logging
… (matching STAR pattern)
…entation, notebook logging before setup
…backend and chatterbox tests
…MT-SICS chatterbox and parsing tests
… measure_temperature, robust stop, rename chatterbox to simulator, remove deprecated methods
…e name, update notebooks
…quires_mt_sics_command gating to all commands
Collaborator
Author
|
Note: I would like to rename the backend to |
…ub.com/BioCam/pylabrobot into create-mettler-toledo-SICS-scale-sytem
- Delete MettlerToledoSICSSimulator and its tests (keep generic ScaleSimulator) - Update tutorial notebook to use MettlerToledoWXS205SDUBackend directly - Remove simulation/execution toggle and all simulator conditionals - Clean up simulator references in docs and mt_sics_commands.md - Change deprecation dates to "remove in v1" Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…mand Move the supported-command gate into send_command itself. Delete the decorator, the registry, request_supported_methods, and all hasattr checks. _supported_commands is initialized as an empty set in __init__ so the check is skipped during setup() and enforced after I0 discovery. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0613d5a to
1fdeef0
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The chatterbox module re-exports ScaleSimulator as ScaleChatterboxBackend, which causes a docutils warning when autosummary processes it with :recursive:. Reference simulator.ScaleSimulator directly instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi everyone,
PyLabRobot currently only has one programmatically controllable scale integrated - the "Mettler Toledo scale".
But in reality this is an oversimplification: Mettler Toledo manufactures a whole array of programmable scales, known as "Automated Precision Weighing Modules". The one we typically refer to is the WX series APW Module, which is the one sold in Hamilton's Liquid Verification Kit.
However, this scale is only one of many that uses the Mettler Toledo Standard Interface Command Set (MT-SICS), a serial protocol shared across Mettler Toledo's Automated Precision Weigh Modules (WXS, WMS, WX series). These devices range from 0.1 mg analytical balances to multi-kilogram industrial weigh modules, but they all speak the same serial command protocol.
This PR rewrites the PLR backend based on the MT-SICS spec and hardware validation on a physical WXS205SDU WXA-Bridge (firmware: 1.10). A single backend now handles any MT-SICS device - during
.setup(), it queries the device to discover exactly which commands that specific model supports, and gates methods accordingly. No hardcoded model assumptions.The Problems
ZCandTCwere sent to devices that don't support them, causing silent failures (ESsyntax errors with a mystery comment "For some reason, this will always return a syntax error").I2response).DAT/TIMreturned only the first field.send_commandreturned a single line. Multi-line commands (I0,I50,M27) could not be used.ScaleChatterboxBackendreturned a fixed dummy weight with no physics.PR Content / Solutions
Core architecture:
@requires_mt_sics_commandare gated at runtime against the device's actual command list.shlex.splitparsing withMettlerToledoResponsedataclass replacing rawList[str].send_commandreads until statusA, handlingB-status continuation lines.C(cancel) if available, flushes the buffer. Never clears zero/tare state.confirmed_firmware_versions.pywith setup-time warnings for untested versions.Simulator (evolution of the Chatterbox pattern):
MettlerToledoSICSSimulatorinherits from the backend, overridessend_commandwith mock responses. Where a Chatterbox returns fixed dummy values, the Simulator maintains physics state (weight, tare, temperature) as settable instance variables. All 55 commands handled.Coverage:
protocol.md) and full 194-command reference (mt_sics_commands.md).request_supported_methods()discovery.Future Work for MT-SICS
This PR covers the WXS205SDU thoroughly. For other MT-SICS devices:
mt_sics_commands.md.Happy to discuss any of the design decisions - especially around the Simulator pattern and interrupt safety, as those could be useful templates for other PLR device drivers.