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.
This PR adds some stability improvements to physical ball locks and multi balls.
Graceful Lost Ball Handling
This PR extends the ball count handler for ejecting physical balls to double-check the ball counts after an eject attempt, in case more balls were ejected than expected. If this occurs, the changes in this PR will post that the device has lost balls, and will update the device count to reflect the new physical count.
For situations where multiple balls were intended to be ejected and some eject together, this PR also gracefully cancels the eject queue for the lost balls.
This change does not apply to ball devices tagged as
trough
, because troughs can jam and "lose" many balls simultaneously and those balls should not be removed from the trough count yet. This change also does not apply to manual eject devices (which really shouldn't have multiple balls anyway) because there is no way to objectively measure how many eject attempts were made relative to how many balls were ejected.Improved Ball Count Handling
This PR changes the logic for counting physical balls in a ball device, tracking the expected new number of balls instead of the known physical ball count. This change allows the ball device to identify when the ball counts mismatch (e.g. a ball slipped out or multiple balls entered simultaneously) and avoids race conditions. There is no change in the happy path behavior, just a reduced chance of error.