Split- och depåstatistik är implementerad

This commit is contained in:
larssand
2026-08-25 20:00:55 +02:00
parent 8ea8b3a84e
commit abf887dccd
16 changed files with 564 additions and 46 deletions

View File

@@ -319,6 +319,11 @@ export function processDecoderMessageHelper(msg, deps, decoderRole = "main") {
if (entry.pitActive) return;
entry.pitEnteredAt = timestamp;
entry.pitActive = true;
entry.pitEntryDriverId = entry.driverId || null;
entry.pitEntryDriverName = entry.driverName || "";
entry.pitEntryCarId = entry.carId || null;
entry.pitEntryCarName = entry.carName || "";
entry.pitEntryTransponder = transponder;
if (!Array.isArray(result.pitEvents)) result.pitEvents = [];
result.pitEvents.push({ timestamp, type: "entry", transponder, competitorKey: key, driverId: entry.driverId, carId: entry.carId });
pushOverlayEvent("pit", `${entry.displayName || entry.driverName} • PIT IN`);
@@ -330,6 +335,11 @@ export function processDecoderMessageHelper(msg, deps, decoderRole = "main") {
const enteredAt = Number(entry.pitEnteredAt || 0);
if (!enteredAt || timestamp <= enteredAt) return;
const pitStopMs = timestamp - enteredAt;
const pitDriverId = entry.pitEntryDriverId ?? entry.driverId ?? null;
const pitDriverName = entry.pitEntryDriverName || entry.driverName || "";
const pitCarId = entry.pitEntryCarId ?? entry.carId ?? null;
const pitCarName = entry.pitEntryCarName || entry.carName || "";
const pitTransponder = entry.pitEntryTransponder || transponder;
entry.pitActive = false;
entry.pitEnteredAt = null;
entry.pitStops = Math.max(0, Number(entry.pitStops || 0)) + 1;
@@ -338,8 +348,13 @@ export function processDecoderMessageHelper(msg, deps, decoderRole = "main") {
if (!entry.bestPitStopMs || pitStopMs < entry.bestPitStopMs) entry.bestPitStopMs = pitStopMs;
if (!Array.isArray(result.pitEvents)) result.pitEvents = [];
if (!Array.isArray(result.pitStops)) result.pitStops = [];
result.pitEvents.push({ timestamp, type: "exit", transponder, competitorKey: key, driverId: entry.driverId, carId: entry.carId, pitStopMs });
result.pitStops.push({ enteredAt, exitedAt: timestamp, pitStopMs, transponder, competitorKey: key, driverId: entry.driverId, carId: entry.carId });
result.pitEvents.push({ timestamp, type: "exit", transponder, competitorKey: key, driverId: pitDriverId, driverName: pitDriverName, carId: pitCarId, carName: pitCarName, pitStopMs });
result.pitStops.push({ enteredAt, exitedAt: timestamp, pitStopMs, transponder: pitTransponder, exitTransponder: transponder, competitorKey: key, driverId: pitDriverId, driverName: pitDriverName, carId: pitCarId, carName: pitCarName });
entry.pitEntryDriverId = null;
entry.pitEntryDriverName = "";
entry.pitEntryCarId = null;
entry.pitEntryCarName = "";
entry.pitEntryTransponder = "";
pushOverlayEvent("pit", `${entry.displayName || entry.driverName} • PIT ${formatLap(pitStopMs)}`);
saveState();
return;