You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
F-20: Orchestrator: taking over a moving loco starts from speed 0 #23
Severity: HIGH · Effort: Medium · Batch: 1 · Status: Code done in #21 (7c980f9), awaiting bench verification
Found in the second full review of the firmware. Recorded with the rest of the pass (F-19…F-44) in docs/REVIEW_REMEDIATION_PLAN_2.md, which is where its status is kept.
Description
On acquire, Throttle::assignLocomotive zeroes the model and OrchestratorBackend::acquireLocomotive zeroes its shadow. The loco's actual state arrived in
the opening STATE_SNAPSHOT (and in every LOCO_STATE since), but onLocoState only routes
addresses that are already assigned, so it was discarded. Taking over a loco another operator
or an automation run has at speed 60, one click clockwise commands speed 4; one click
anticlockwise commands reverse 4.
WiThrottle does not have this problem: JMRI restates speed and direction after M…+.
Plan
OrchestratorClient keeps a compact cache of the latest state per address, filled from STATE_SNAPSHOT (which replaces it wholesale) and LOCO_STATE, cleared when the link goes
down. Bounded in size.
OrchestratorBackend::acquireLocomotive seeds its shadow from the cache and replays the
cached state through the throttle-state callback, exactly as a LOCO_STATE would arrive.
This is display-side use of layout state: nothing is sent outward, so the "a snapshot is
never replayed as commands" rule stands.
Unit test: snapshot, then acquire, then assert the update carried the snapshot's speed and
direction.
Acquiring a loco the orchestrator already reports as moving shows its speed and
direction immediately (replayed through the throttle-state callback).
The next knob click moves from that speed, not from 0 — the controller's model and
the backend's shadow are both seeded.
Nothing is sent to the orchestrator on acquire.
Unit tests test_orch_backend_acquire_seeds_from_layout_state, test_orch_backend_acquire_of_unreported_loco_shows_nothing and test_orch_snapshot_replaces_cached_state pass on the board (they compile).
Bench: drive a loco from the web UI, take it over on the device, click once each way.
Activity