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
@@ -1,4 +1,5 @@
|
||||
import { decoderDiagnostics, DIAGNOSTIC_ROLES } from "./decoder_diagnostics.js";
|
||||
import { decoderClockCheck, describeDecoderClockSkew } from "./decoder_clock_check.js";
|
||||
|
||||
let stopPrevious = () => {};
|
||||
export function decoderDiagnosticsMarkup(language) {
|
||||
@@ -63,9 +64,18 @@ export function mountDecoderDiagnostics(root, getSettings) {
|
||||
if (!force && (paused || !root.open)) return;
|
||||
const settings = getSettings();
|
||||
const entries = decoderDiagnostics.snapshot();
|
||||
// The decoder's clock against the computer's, measured on passings (decoder_clock_check.js).
|
||||
const clockLine = (role) => {
|
||||
const skew = decoderClockCheck.skewMs(role);
|
||||
if (skew == null) return `${tr("Decoderklocka", "Decoder clock")}: -`;
|
||||
const off = describeDecoderClockSkew(skew);
|
||||
if (!off) return `${tr("Decoderklocka", "Decoder clock")}: ${tr("stämmer med datorn", "matches the computer")}`;
|
||||
const amount = `${off.hours ? `${off.hours} h ` : ""}${off.minutes ? `${off.minutes} min` : ""}`.trim();
|
||||
return `${tr("Decoderklocka", "Decoder clock")}: ${amount} ${off.ahead ? tr("före", "ahead of") : tr("efter", "behind")} ${tr("datorn – ställ in rätt tid i decodern", "the computer – set the right time in the decoder")}`;
|
||||
};
|
||||
entries.forEach((entry, i) => {
|
||||
const enabled = i === 0 || (i === 1 ? settings.splitDecoderEnabled : settings.pitDecoderEnabled);
|
||||
nodes[i].textContent = `${names[i]}: ${enabled ? statuses[entry.status] || entry.status : tr("Avstängd", "Disabled")}\n${tr("Konfigurerad", "Configured")}: ${settings[urlKeys[i]] || "-"}\n${tr("Socket-adress", "Socket address")}: ${entry.url || "-"}\n${tr("Senast ansluten", "Last connected")}: ${date(entry.connectedAt)}\n${tr("Senast mottaget", "Last received")}: ${date(entry.lastReceivedAt)} (${entry.lastReceivedAt == null ? "-" : Math.max(0, Math.floor((Date.now() - entry.lastReceivedAt) / 1000))} s)\nFrames: ${entry.frames} | PASSING: ${entry.passings}\n${tr("Hanterade", "Handled")}: ${entry.handled} | ${tr("Ignorerade", "Ignored")}: ${entry.ignored}\n${tr("Ogiltiga varv", "Invalid laps")}: ${entry.invalid} | JSON ${tr("fel", "errors")}: ${entry.parseErrors}`;
|
||||
nodes[i].textContent = `${names[i]}: ${enabled ? statuses[entry.status] || entry.status : tr("Avstängd", "Disabled")}\n${tr("Konfigurerad", "Configured")}: ${settings[urlKeys[i]] || "-"}\n${tr("Socket-adress", "Socket address")}: ${entry.url || "-"}\n${tr("Senast ansluten", "Last connected")}: ${date(entry.connectedAt)}\n${tr("Senast mottaget", "Last received")}: ${date(entry.lastReceivedAt)} (${entry.lastReceivedAt == null ? "-" : Math.max(0, Math.floor((Date.now() - entry.lastReceivedAt) / 1000))} s)\nFrames: ${entry.frames} | PASSING: ${entry.passings}\n${tr("Hanterade", "Handled")}: ${entry.handled} | ${tr("Ignorerade", "Ignored")}: ${entry.ignored}\n${tr("Ogiltiga varv", "Invalid laps")}: ${entry.invalid} | JSON ${tr("fel", "errors")}: ${entry.parseErrors}\n${clockLine(entry.role)}`;
|
||||
});
|
||||
const entry = entries.find(item => item.role === select.value);
|
||||
log.textContent = `${tr("Senaste råmeddelande (max 512 tecken)", "Latest raw frame (max 512 characters)")}:\n${entry.lastFrame || "-"}\n\n${tr("Senaste 50 händelser; orsakskoder", "Latest 50 events; reason codes")}:\n${entry.log.map(item => `${date(item.at)} ${item.reason} ${item.sample}`).join("\n")}`;
|
||||
|
||||
Reference in new issue
Block a user