Reset a train's turn point on a new playback epoch

- A clock correction starts a new epoch, and playback may first draw its
  second report. The turn point now resets on a new epoch as well as on a
  break, so a standing train no longer turns around after a correction.
- recallDirection and earlierFixes are gone: comparing each earlier report
  with the newest turned a standing train on GPS jitter. A train bound when
  its line arrives late shows no direction until it has moved 15 m.
- Tests share reportDirections, iconOf and the playback helper.
- Comments and CURRENT-STATE match the code.
This commit is contained in:
German Khokhlov committed 2026-11-19 00:26:57 +04:00
1 parent 58afb169d1
commit e8ef4d1293
8 files changed
+108 -131

No files matched your search

-22
View File
@@ -202,28 +202,6 @@ test('a standing train keeps its operator’s bearing through reports that leave
assert.deepEqual(seen, Array(6).fill(-1));
});
test('a train bound standing, its line late, runs the way its earlier reports went', async (t) => {
t.mock.method(console, 'warn', () => {});
const paths = { 'mbta-rail': 503 };
const app = harness(t, { paths, at: BOSTON });
let eastM = 1600;
app.feeds.set('mbta-rail', () => [train('T1', LAT, LON0 + eastM / KX)]);
await app.enable();
// No line yet: it runs 300 m west, with no bearing, and stands.
for (const next of [1500, 1400, 1300, 1300, 1300, 1300, 1300, 1300]) {
eastM = next;
app.run(RAIL_POLL_MS);
await app.poll();
}
assert.equal(app.entry(T1).path, null, 'not bound yet');
paths['mbta-rail'] = PACK;
const slot = app.state()._pathPacks.get('mbta-rail');
app.run(Math.max(0, slot.retryAt - Date.now()));
await app.poll();
app.parts().selection.selectTrain(T1);
assert.equal(app.layer.getSelectedTrain().path.direction, -1);
});
test('a snapshot read again while nothing changed is the one read before', async (t) => {
let list = stopList('Alpha', 'Bravo', 'Charlie');
const app = await onTheLine(t, {