feat(decoder): warn when the decoder's clock is off (1.42.4)
The decoder's time is never changed. Passings (also during warm-up) measure it against the computer's clock, and Race Day's preflight and the decoder diagnostics warn when it is over a minute off, e.g. after the switch to winter time.
This commit is contained in:
1 parent
ca88fd9ecc
commit
35eb3eb059
14 files changed
+180
-5
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { createDecoderClockCheck, describeDecoderClockSkew } from "../src/decoder_clock_check.js";
|
||||
|
||||
const HOUR = 3600000;
|
||||
|
||||
test("a decoder still on summer time shows as one hour ahead; one in step shows nothing", () => {
|
||||
const check = createDecoderClockCheck();
|
||||
const now = Date.UTC(2026, 9, 25, 17, 21, 0);
|
||||
check.record("main", now + HOUR + 40, now); // decoder says 19:21, the computer 18:21
|
||||
assert.deepEqual(describeDecoderClockSkew(check.skewMs("main")), { ahead: true, hours: 1, minutes: 0 });
|
||||
const inStep = createDecoderClockCheck();
|
||||
inStep.record("main", now - 30, now); // 30 ms on the network
|
||||
assert.equal(describeDecoderClockSkew(inStep.skewMs("main")), null);
|
||||
assert.equal(describeDecoderClockSkew(null), null, "nothing before the first passing");
|
||||
});
|
||||
|
||||
test("a passing delivered late doesn't make the clock look wrong", () => {
|
||||
const check = createDecoderClockCheck();
|
||||
const now = 10 * HOUR;
|
||||
check.record("main", now - 20, now);
|
||||
check.record("main", now - 10 * 60000, now + 50); // resent after a reconnect, 10 minutes old
|
||||
assert.equal(describeDecoderClockSkew(check.skewMs("main")), null);
|
||||
});
|
||||
|
||||
test("minutes off are reported as minutes, behind as not ahead", () => {
|
||||
const check = createDecoderClockCheck();
|
||||
check.record("main", 1_000_000, 1_000_000 + 12 * 60000);
|
||||
assert.deepEqual(describeDecoderClockSkew(check.skewMs("main")), { ahead: false, hours: 0, minutes: 12 });
|
||||
assert.equal(check.skewMs("split"), null, "each decoder is measured on its own");
|
||||
});
|
||||
Reference in new issue
Block a user