mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Aircraft drawn as far behind real time as their feed is late, along one curve their trail follows
Civil and military aircraft were drawn a fixed 30 s (15 s) behind real time while anonymous feed reports arrive about 90 s old every 30 s, so every contact dead reckoned about a minute past its newest report and snapped when the next one landed (several km on a turn), and the tracked trail, recorded from those drawn positions and patched as reports arrived, kinked. - The display delay (data/displayDelay.js) is the 90th percentile of the newest 256 report lags plus 5 s, between the layer's floor (30 s, 15 s) and five minutes, slewed at most 0.2 s/s up and 0.05 s/s down. Icons, the renderer's live motion clock, labels, HUD, detection, the tracked camera and the trail read the one delay; following the world clock draws with none and deliveries leave it alone. - Between two reports an aircraft flies a biarc (data/fixCurve.js) that passes through both and leaves each along its track, sent as contract arc segments; the trail is the reports joined along the same curve, so the icon sits on it. Nothing drawn between reports is kept. - A report a coasting contact missed is eased onto from where it would have been that frame (at least 3 s, at most 30% over its speed, within 20 s); over 5 km it jumps. Past its newest report a contact coasts straight on: a turn rate averaged over earlier reports outlived the turn. - Forward synthetic fixes no longer block real reports older than them, and a history keeps 24 fixes. - A feed simulation (testSupport/aircraftFeedSim.mjs) checks both layers against a 90 s late feed, a fallback switch, repeated reports, outages and the world clock.
This commit is contained in:
1 parent
c57eb74506
commit
5f98f8bdf3
40 files changed
+2606
-1238
No files matched your search
@@ -0,0 +1,170 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
createDisplayDelay,
|
||||
DISPLAY_DELAY_CAP_MS,
|
||||
DISPLAY_DELAY_DEADBAND_MS,
|
||||
DISPLAY_DELAY_FALL,
|
||||
DISPLAY_DELAY_LAGS,
|
||||
DISPLAY_DELAY_MARGIN_MS,
|
||||
DISPLAY_DELAY_MIN_LAGS,
|
||||
DISPLAY_DELAY_RISE,
|
||||
} from './displayDelay.js';
|
||||
|
||||
// A live feed is drawn far enough behind real time that every contact has a
|
||||
// report on both sides of the time drawn.
|
||||
|
||||
const SEC = 1000;
|
||||
const FLOOR = 30 * SEC;
|
||||
const POLL = 30 * SEC;
|
||||
|
||||
/**
|
||||
* A feed polled every 30 s whose reports arrive `ageMs` old, one new report
|
||||
* per contact per poll: each lag is the age plus the poll interval.
|
||||
*/
|
||||
function feed(delay, { contacts = 20, polls = 4, ageMs, startMs = 0 }) {
|
||||
let now = startMs;
|
||||
for (let p = 0; p < polls; p++) {
|
||||
now += POLL;
|
||||
for (let c = 0; c < contacts; c++) {
|
||||
const reportMs = now - ageMs - c * 10;
|
||||
delay.noteReport(now, reportMs, reportMs - POLL);
|
||||
}
|
||||
}
|
||||
return now;
|
||||
}
|
||||
|
||||
test('the aim is the 90th percentile of recent lags plus the margin', () => {
|
||||
const delay = createDisplayDelay({ floorMs: FLOOR, pollMs: POLL });
|
||||
const now = feed(delay, { ageMs: 90 * SEC });
|
||||
assert.ok(delay.lagCount >= DISPLAY_DELAY_MIN_LAGS);
|
||||
delay.settle(now, { jump: true });
|
||||
// Lags 120 s (plus the spread of 0–190 ms): 125 s and a little.
|
||||
assert.ok(
|
||||
Math.abs(delay.currentMs - (120 * SEC + DISPLAY_DELAY_MARGIN_MS)) < 300,
|
||||
`${delay.currentMs}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('a fresh feed stays at the floor', () => {
|
||||
// Polled every 10 s, reports 2 s old: lags of 12 s, aim 17 s, under the floor.
|
||||
const delay = createDisplayDelay({ floorMs: FLOOR, pollMs: 10 * SEC });
|
||||
for (let i = 1; i <= 40; i++)
|
||||
delay.noteReport(
|
||||
i * 10 * SEC,
|
||||
i * 10 * SEC - 2 * SEC,
|
||||
(i - 1) * 10 * SEC - 2 * SEC,
|
||||
);
|
||||
assert.equal(delay.settle(400 * SEC, { jump: true }), FLOOR);
|
||||
});
|
||||
|
||||
test('the delay never passes the cap', () => {
|
||||
const delay = createDisplayDelay({ floorMs: FLOOR, pollMs: POLL });
|
||||
const now = feed(delay, { ageMs: 20 * 60 * SEC });
|
||||
assert.equal(delay.settle(now, { jump: true }), DISPLAY_DELAY_CAP_MS);
|
||||
});
|
||||
|
||||
test('before enough lags, first reports stand in: their age plus a poll', () => {
|
||||
const delay = createDisplayDelay({ floorMs: FLOOR, pollMs: POLL });
|
||||
for (let c = 0; c < 10; c++)
|
||||
delay.noteReport(1_000 * SEC, 1_000 * SEC - 90 * SEC);
|
||||
assert.equal(delay.lagCount, 0);
|
||||
assert.equal(
|
||||
delay.settle(1_000 * SEC, { jump: true }),
|
||||
90 * SEC + POLL + DISPLAY_DELAY_MARGIN_MS,
|
||||
);
|
||||
});
|
||||
|
||||
test('a report that did not move on gives no lag', () => {
|
||||
const delay = createDisplayDelay({ floorMs: FLOOR, pollMs: POLL });
|
||||
delay.noteReport(100 * SEC, 50 * SEC, 50 * SEC);
|
||||
delay.noteReport(100 * SEC, 40 * SEC, 50 * SEC);
|
||||
assert.equal(delay.lagCount, 0);
|
||||
});
|
||||
|
||||
test('only the newest lags count', () => {
|
||||
const delay = createDisplayDelay({ floorMs: FLOOR, pollMs: POLL });
|
||||
let now = feed(delay, {
|
||||
ageMs: 200 * SEC,
|
||||
contacts: DISPLAY_DELAY_LAGS,
|
||||
polls: 1,
|
||||
});
|
||||
now = feed(delay, {
|
||||
ageMs: 10 * SEC,
|
||||
contacts: DISPLAY_DELAY_LAGS,
|
||||
polls: 1,
|
||||
startMs: now,
|
||||
});
|
||||
assert.ok(delay.settle(now, { jump: true }) < 50 * SEC);
|
||||
});
|
||||
|
||||
test('the delay rises toward its aim at most 0.2 s per second, then holds there', () => {
|
||||
const delay = createDisplayDelay({ floorMs: FLOOR, pollMs: POLL });
|
||||
const now = feed(delay, { ageMs: 90 * SEC });
|
||||
assert.equal(delay.settle(now), FLOOR, 'not jumped once drawing');
|
||||
const aim = delay.aimMs;
|
||||
let prev = delay.currentMs;
|
||||
for (let s = 1; s <= 600; s++) {
|
||||
const d = delay.step(now + s * SEC);
|
||||
assert.ok(d - prev <= DISPLAY_DELAY_RISE * SEC + 1, `rose ${d - prev} ms`);
|
||||
assert.ok(d >= prev);
|
||||
prev = d;
|
||||
}
|
||||
assert.equal(prev, aim);
|
||||
// Rising by 0.2 s a second, the time drawn still moves forward at 0.8×.
|
||||
assert.ok(DISPLAY_DELAY_RISE < 1);
|
||||
});
|
||||
|
||||
test('the delay falls at most 0.05 s per second', () => {
|
||||
const delay = createDisplayDelay({ floorMs: FLOOR, pollMs: POLL });
|
||||
let now = feed(delay, { ageMs: 90 * SEC });
|
||||
delay.settle(now, { jump: true });
|
||||
const high = delay.currentMs;
|
||||
now = feed(delay, {
|
||||
ageMs: 0,
|
||||
polls: 13,
|
||||
startMs: now,
|
||||
});
|
||||
delay.settle(now);
|
||||
assert.ok(Math.abs(delay.aimMs - 35 * SEC) < 300, `${delay.aimMs}`);
|
||||
const later = delay.step(now + 100 * SEC);
|
||||
assert.equal(high - later, DISPLAY_DELAY_FALL * 100 * SEC);
|
||||
});
|
||||
|
||||
test('an aim within the deadband leaves the delay where it is', () => {
|
||||
const delay = createDisplayDelay({ floorMs: FLOOR, pollMs: POLL });
|
||||
let now = feed(delay, { ageMs: 90 * SEC });
|
||||
delay.settle(now, { jump: true });
|
||||
const was = delay.currentMs;
|
||||
now = feed(delay, {
|
||||
ageMs: 90 * SEC + DISPLAY_DELAY_DEADBAND_MS / 2,
|
||||
polls: 13,
|
||||
startMs: now,
|
||||
});
|
||||
delay.settle(now);
|
||||
assert.equal(delay.aimMs, was);
|
||||
assert.equal(delay.step(now + 60 * SEC), was);
|
||||
});
|
||||
|
||||
test('a delivery mid-slew carries on from where the delay is', () => {
|
||||
const delay = createDisplayDelay({ floorMs: FLOOR, pollMs: POLL });
|
||||
let now = feed(delay, { ageMs: 90 * SEC });
|
||||
delay.settle(now);
|
||||
const mid = delay.step(now + 100 * SEC);
|
||||
now = feed(delay, {
|
||||
ageMs: 90 * SEC,
|
||||
polls: 1,
|
||||
startMs: now + 100 * SEC - POLL,
|
||||
});
|
||||
assert.equal(delay.settle(now), mid);
|
||||
});
|
||||
|
||||
test('reset forgets the feed', () => {
|
||||
const delay = createDisplayDelay({ floorMs: FLOOR, pollMs: POLL });
|
||||
const now = feed(delay, { ageMs: 90 * SEC });
|
||||
delay.settle(now, { jump: true });
|
||||
delay.reset();
|
||||
assert.equal(delay.currentMs, FLOOR);
|
||||
assert.equal(delay.lagCount, 0);
|
||||
assert.equal(delay.settle(now, { jump: true }), FLOOR);
|
||||
});
|
||||
Reference in new issue
Block a user