mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Keep a standing train's direction through jitter and missing bearings
- GPS jitter under 15 m at a standing train no longer turns it, in reports and in playback; a reversal needs at least 15 m of movement. - A standing train keeps its operator's last bearing through reports that leave it out. - Playback resets its turn point at a break, so a jump to a corrected position is not a reversal. - A train bound while its line is still loading takes its direction from the movement it already made. - A vehicle in view that leaves a Transit hold goes on from its own clock instead of rewinding. - Tests cover the 15 m boundary, the late line, the hold release and the icon after Transit is turned back on; duplicate jitter tests are merged. - FOLLOW_MIN_MOVE_M is gone; comments and CURRENT-STATE match the code.
This commit is contained in:
1 parent
df4d76384c
commit
58afb169d1
10 files changed
+291
-127
No files matched your search
@@ -162,8 +162,8 @@ test('a train on a known floor at sea level reports a rail height of 0 m', async
|
||||
});
|
||||
|
||||
test('a train first seen standing takes no direction from its GPS jitter', async (t) => {
|
||||
// Neither reports 13 m apart nor the course drawn between them say which way
|
||||
// it runs; an operator's bearing does.
|
||||
// Reports 13 m apart, and the course drawn between them, do not tell which
|
||||
// way it runs; an operator's bearing does.
|
||||
const app = harness(t, { paths: { 'mbta-rail': PACK }, at: BOSTON });
|
||||
let jitterM = 0;
|
||||
app.feeds.set('mbta-rail', () => [
|
||||
@@ -184,6 +184,46 @@ test('a train first seen standing takes no direction from its GPS jitter', async
|
||||
assert.deepEqual(seen, Array(6).fill([0, -1]));
|
||||
});
|
||||
|
||||
test('a standing train keeps its operator’s bearing through reports that leave it out', async (t) => {
|
||||
const app = harness(t, { paths: { 'mbta-rail': PACK }, at: BOSTON });
|
||||
let bearing = 270;
|
||||
app.feeds.set('mbta-rail', () => [
|
||||
train('T1', LAT, LON0 + 1000 / KX, { bearing }),
|
||||
]);
|
||||
await app.enable();
|
||||
const seen = [];
|
||||
for (const next of [270, 270, 270, null, null, null]) {
|
||||
bearing = next;
|
||||
app.run(RAIL_POLL_MS);
|
||||
await app.poll();
|
||||
app.parts().selection.selectTrain(T1);
|
||||
seen.push(app.layer.getSelectedTrain().path.direction);
|
||||
}
|
||||
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, {
|
||||
|
||||
Reference in new issue
Block a user