feat(race-day): call the next heat - asked by hand, automatic with the autopilot (1.51.0)

This commit is contained in:
larssand committed 2026-11-01 22:25:43 +01:00
1 parent fdc6c179dc
commit b2e08db3d8
15 files changed
+178 -31

No files matched your search

+66 -8
View File
@@ -8,8 +8,8 @@ import { buildRaceDayQueue, buildRaceDayPreflight, getRaceDriverIds } from "./ra
import { recordTransponderSighting, buildWarmupCheck, createPrologue, getPrologueRemainingMs, holdPrologue, resumePrologue, setPrologueRemaining, takeDuePrologueCall, formatPrologueTime, getPrologueHandoverMs, normalizePrologueSec } from "./prologue_logic.js";
import { findTransponderConflict, getDriverProfileId } from "./driver_profile_logic.js";
import { renderRaceDayView, refreshRaceDayWarmup, refreshRaceDayPrologueClock, updateRaceDayStartDisplay, refreshRaceDayLive } from "./race_day_view.js";
import { normalizeRaceDays, getRaceDay, upsertRaceDay, orderDaySessions, buildDaySchedule, getAutopilotAction, moveInDayOrder, pickBoardDate } from "./day_schedule_logic.js";
import { renderDaySchedulePanel, bindDaySchedulePanel, buildDaySchedulePrintHtml, renderDriverBoard, formatClockTime } from "./day_schedule_view.js";
import { normalizeRaceDays, getRaceDay, upsertRaceDay, orderDaySessions, buildDaySchedule, getAutopilotAction, moveInDayOrder, pickBoardDate, getDueCall } from "./day_schedule_logic.js";
import { renderDaySchedulePanel, bindDaySchedulePanel, buildDaySchedulePrintHtml, renderDriverBoard, formatClockTime, renderDayCallBanner, bindDayCallBanner } from "./day_schedule_view.js";
import { beginSession as beginSessionControl, finishSession as finishSessionControl, pauseSession as pauseSessionControl, resumeSession as resumeSessionControl } from "./session_control.js";
import { normalizeSeries, buildSeriesStandings, getSeriesRoundStatus, getSeriesRoundNextStep, getSeriesDayResult } from "./series_logic.js";
import { renderSeriesView } from "./series_view.js";
@@ -237,6 +237,7 @@ const startSessionWithAudio = (session, callbacks) => {
const tickClock = () => {
tickClockHelper({ dom, currentLanguage, handleSessionTimerTick, getActiveSession, getCurrentView: () => currentView, getOverlayMode: () => overlayMode, renderView, refreshTimingDynamics, updateHeaderState });
tickAutopilot();
tickDayCalls();
// The drivers' board counts down to each heat.
if (overlayMode && overlayViewMode === "schedule") renderView();
};
@@ -428,6 +429,52 @@ function tickAutopilot() {
}
void startOperationalSession(session, { requirePreflight: true }).finally(() => { autopilotLaunchingId = null; renderView(); });
}
// Calling a heat: the speaker says who drives it and the drivers' board highlights it. With the
// autopilot on it happens on its own; otherwise Race Day asks the race controller.
const callSnoozes = new Map();
let shownCallId = null;
function callHeat(sessionId) {
const session = state.sessions.find((item) => item.id === sessionId);
if (!session || session.calledAt) return;
const event = state.events.find((item) => item.id === session.eventId);
const row = event ? buildDayRows(event.date).find((item) => item.session.id === sessionId) : null;
session.calledAt = Date.now();
saveState();
triggerRaceAudio("heat_call", {
force: true,
variables: {
heat: `${getDayClassLabel(session)} ${session.name}`.trim(),
minutes: Math.max(1, Math.round(((row?.start || Date.now()) - Date.now()) / 60000)),
drivers: getSessionGridEntries(session).map((entry) => entry.name).join(", "),
},
logData: { raceId: session.eventId, sessionId: session.id },
});
renderView();
}
function getDueCallFor(date) {
return getDueCall(buildDayRows(date), { day: getDayPlan(date), snoozedUntil: (id) => callSnoozes.get(id) || 0 });
}
function tickDayCalls() {
if (overlayMode) return;
if (autopilotDate) {
const due = getDueCallFor(autopilotDate);
if (due) callHeat(due.session.id);
return;
}
if (currentView !== "race_day") return;
const due = getDueCallFor(getRaceDayDate());
if ((due?.session.id || null) !== shownCallId) renderView();
}
const renderDayCall = () => {
const date = getRaceDayDate();
const row = autopilotDate ? null : getDueCallFor(date);
shownCallId = row?.session.id || null;
return renderDayCallBanner({ t, escapeHtml, row, getClassLabel: getDayClassLabel, driverNames: row ? getSessionGridEntries(row.session).map((entry) => entry.name) : [] });
};
const bindDayCall = (root) => bindDayCallBanner(root, {
onCall: (sessionId) => callHeat(sessionId),
onLater: (sessionId) => { callSnoozes.set(sessionId, Date.now() + 2 * 60000); renderView(); },
});
// Pausing the day stops the autopilot and pauses whatever is on track (or holds the count-down).
function pauseRaceDay(date) {
saveDayPlan({ ...getDayPlan(date), pausedAt: Date.now() });
@@ -458,7 +505,7 @@ const bindDaySchedule = (root) => {
const date = getRaceDayDate();
bindDaySchedulePanel(root, {
date,
onSavePlan: ({ startAt, gapMin }) => { saveDayPlan({ ...getDayPlan(date), startAt, gapMin }); renderView(); },
onSavePlan: ({ startAt, gapMin, callMin }) => { saveDayPlan({ ...getDayPlan(date), startAt, gapMin, callMin }); renderView(); },
onMove: (sessionId, step) => moveDaySession(date, sessionId, step),
onPrint: () => openPrintWindow(t("day.print_title", { date }), buildDaySchedulePrintHtml({ t, escapeHtml, date, rows: buildDayRows(date), getClassLabel: getDayClassLabel, getSessionGridEntries })),
onBoard: () => window.open(buildOverlayUrl("schedule", { public: true }), "_blank"),
@@ -487,6 +534,7 @@ function resetSessionData(session) {
session.resultsResetAt = Date.now();
delete state.resultsBySession[session.id];
session.followUpStartedAt = null;
session.calledAt = null;
// A heat (anything but an Open/Free Practice that runs all evening) goes back to "ready":
// the clock is back at zero and it can be started again.
const rerunHeat = !isPracticeSessionType(session.type) && session.status !== "running";
@@ -619,7 +667,7 @@ const renderRaceDay = () => renderRaceDayView({
getLiveSession,
renderSuspectLapsPanel: (session) => renderSuspectLapsPanelWithRelease(session),
buildLeaderboard, getSessionTargetMs, formatRaceClock,
renderDaySchedule, bindDaySchedule,
renderDaySchedule, bindDaySchedule, renderDayCall, bindDayCall,
setCompetitorLapStatus,
addTrackLayout, renderView, state, dom, t, escapeHtml, formatLap, formatCountdown, formatElapsedClock,
getEventName, getSessionTypeLabel, getStatusLabel, getStartModeLabel,
@@ -2743,7 +2791,7 @@ const TRANSLATIONS = {
"guide.race_day_8": "8. Redan när du registrerar eller ändrar en förare under Förare varnar systemet om transpondern redan används av en annan förare (t.ex. i fel klass) och namnger vem - ett komplement till förkontrollens kontroll av dubbla transpondrar inom samma heat. Samma person som kör flera klasser med sin egen transponder flaggas aldrig.",
"guide.race_day_9": "9. Kör ni på ett nät där fler har åtkomst (t.ex. arenans WiFi)? Slå på Admin-PIN under Inställningar -> System & backup. Då kräver alla ändringar PIN - resultat, inställningar och uppdatering - medan visning och publika overlay-/träningslänkar fungerar som vanligt. Varje webbläsare loggar in en gång och kommer ihåg det i 30 dagar.",
"guide.race_day_10": "10. Start med nedräkning (som EFRA/IFMAR): välj längd (Go, 30 s, 1, 1:30, 2, 3 eller 5 min - standard per tävling under Race Setup) och tryck Starta. Banan är öppen, speakern ropar ut tiden (varje minut, 30 s, 10 s; vid gridstart även \"bilarna till startplatsen\" vid 30 s och 9..3). Pausa medan bilarna ställs upp, +1 min, Till 30 s (omstart av gridet), Till 10 s, Go nu eller Avbryt. När tiden går ut startar heatet av sig själv: gridstart får startljus och slumpad signal, flygande start ger signalen och \"Klockan går\". Transponderkontrollen visar grön bock för alla som passerat sedan nedräkningen började - saknas någon, byt transponder direkt i panelen eller välj en okänd transponder som passerat. Go nu varnar om någon inte setts.",
"guide.race_day_11": "11. Dagens schema (längst ned på Race Day) visar alla klasser den dagen i en körordning med tider. Ange första start och paus mellan heaten; ▲▼ ändrar ordningen. Ett heat som startar sent eller pausas flyttar resten av dagen. 🖨 Skriv ut körordning ger en lista med tider och förare att sätta upp på tavlan, och 📺 Förarvy (/public-overlay/schedule) visar förarna nästa heat med vilka som kör och en påminnelse när det är 10 minuter kvar. ▶ Kör dagen automatiskt startar varje heats nedräkning själv när det är dags (den här webbläsaren måste vara öppen); ⏸ Pausa dagen pausar heatet på banan och automatiken tills du fortsätter.",
"guide.race_day_11": "11. Dagens schema (längst ned på Race Day) visar alla klasser den dagen i en körordning med tider. Ange första start och paus mellan heaten; ▲▼ ändrar ordningen. Ett heat som startar sent eller pausas flyttar resten av dagen. 🖨 Skriv ut körordning ger en lista med tider och förare att sätta upp på tavlan, och 📺 Förarvy (/public-overlay/schedule) visar förarna nästa heat och vilka som kör. Upprop: när ett heat har 10 minuter kvar (ändras under Upprop) frågar Race Day om du vill ropa upp det – 📢 Ropa ut läser upp heatet och förarna i högtalarna och markerar det Uppropad i förarvyn; Senare frågar igen om 2 minuter. ▶ Kör dagen automatiskt startar varje heats nedräkning själv när det är dags och ropar då upp heaten själv (den här webbläsaren måste vara öppen); ■ Stoppa automatiken låter dig köra för hand och sedan slå på den igen; ⏸ Pausa dagen pausar heatet på banan och automatiken tills du fortsätter.",
"guide.dashboard_title": "Schemaavvikelse på Översikt",
"guide.dashboard_1": "Översikt visar nu skillnaden mellan planerad tid och faktisk körtid för alla startade sessioner.",
"guide.dashboard_2": "Planerad tid räknar sessionstid plus follow-up. Faktisk tid räknar verklig tid från start till stopp eller nuvarande tid om heatet fortfarande kör.",
@@ -2806,6 +2854,11 @@ const TRANSLATIONS = {
"day.board": "Förarvy",
"day.start_time": "Första start",
"day.gap": "Paus mellan heat (min)",
"day.call_min": "Upprop (min innan)",
"day.call_title": "{name} startar {time} (om {min} min) – dags att ropa upp",
"day.call_now": "Ropa ut",
"day.call_later": "Senare",
"day.called_at": "Uppropad {time}",
"day.autopilot_on": "Kör dagen automatiskt",
"day.autopilot_off": "Stoppa automatiken",
"day.autopilot_confirm": "Kör dagen automatiskt? Varje heat startar sin nedräkning själv när det är dags enligt schemat. Du kan pausa dagen eller ta över när som helst. Låt den här webbläsaren vara öppen.",
@@ -2829,7 +2882,7 @@ const TRANSLATIONS = {
"day.print_hint": "Tiderna är planerade och kan flyttas om något drar ut på tiden. Följ förarvyn för aktuella tider.",
"day.board_title": "Dagens schema {date}",
"day.board_now": "startar nu",
"day.board_heads_up": "Gör dig redo – snart dags!",
"day.board_heads_up": "Uppropad – gör dig redo!",
"day.board_on_track": "På banan",
"day.board_all_done": "Alla heat är körda för idag.",
"day.board_none": "Inget schema för idag.",
@@ -4675,7 +4728,7 @@ const TRANSLATIONS = {
"guide.race_day_8": "8. Already when you register or edit a driver under Drivers, the system warns if the transponder is already used by a different driver (e.g. in the wrong class) and names who - a complement to the preflight's duplicate-transponder check within a single heat. The same person racing multiple classes on their own transponder is never flagged.",
"guide.race_day_9": "9. Running on a network others can reach (e.g. the venue WiFi)? Turn on the Admin PIN under Settings -> System & backup. Every change then needs the PIN - results, settings and updates - while viewing and public overlay/training links work as usual. Each browser logs in once and is remembered for 30 days.",
"guide.race_day_10": "10. Start with a count-down (as EFRA/IFMAR): pick a length (Go, 30 s, 1, 1:30, 2, 3 or 5 min - the default per event is set in Race Setup) and press Start. The track is open and the announcer calls the time (every minute, 30 s, 10 s; for a grid start also \"cars to the grid\" at 30 s and 9..3). Hold while cars are placed on the grid, +1 min, To 30 s (grid restart), To 10 s, Go now or Cancel. When the time runs out the heat starts by itself: a grid start gets the start lights and a random signal, a flying start gets the signal and \"Clock is running\". The transponder check shows a green tick for everyone who has crossed since the count-down began - if someone is missing, change their transponder right in the panel or pick an unknown transponder that crossed. Go now warns if someone wasn't seen.",
"guide.race_day_11": "11. Today's schedule (at the bottom of Race Day) shows every class that day in one running order with times. Set the first start and the break between heats; ▲▼ change the order. A heat that starts late or is paused moves the rest of the day. 🖨 Print running order gives a list with times and drivers for the board in the pits, and 📺 Drivers' board (/public-overlay/schedule) shows drivers the next heats, who drives them and a heads-up 10 minutes before. ▶ Run the day automatically starts each heat's count-down on its own when it is due (keep this browser open); ⏸ Pause the day pauses the heat on track and the autopilot until you resume.",
"guide.race_day_11": "11. Today's schedule (at the bottom of Race Day) shows every class that day in one running order with times. Set the first start and the break between heats; ▲▼ change the order. A heat that starts late or is paused moves the rest of the day. 🖨 Print running order gives a list with times and drivers for the board in the pits, and 📺 Drivers' board (/public-overlay/schedule) shows drivers the next heats and who drives them. Calls: when a heat is 10 minutes away (set under Call), Race Day asks whether to call it – 📢 Call now reads the heat and its drivers over the speakers and marks it Called on the drivers' board; Later asks again in 2 minutes. ▶ Run the day automatically starts each heat's count-down on its own when it is due and then calls the heats itself (keep this browser open); ■ Stop autopilot lets you run heats by hand and turn it back on later; ⏸ Pause the day pauses the heat on track and the autopilot until you resume.",
"guide.dashboard_title": "Schedule drift on overview",
"guide.dashboard_1": "Overview now shows the difference between planned time and actual elapsed time for all started sessions.",
"guide.dashboard_2": "Planned time includes session duration plus follow-up. Actual time uses real time from start to stop, or the current time if the heat is still running.",
@@ -4738,6 +4791,11 @@ const TRANSLATIONS = {
"day.board": "Drivers' board",
"day.start_time": "First start",
"day.gap": "Break between heats (min)",
"day.call_min": "Call (min before)",
"day.call_title": "{name} starts at {time} (in {min} min) – time to call it",
"day.call_now": "Call now",
"day.call_later": "Later",
"day.called_at": "Called {time}",
"day.autopilot_on": "Run the day automatically",
"day.autopilot_off": "Stop autopilot",
"day.autopilot_confirm": "Run the day automatically? Each heat starts its own count-down when the schedule says so. You can pause the day or take over at any time. Keep this browser open.",
@@ -4761,7 +4819,7 @@ const TRANSLATIONS = {
"day.print_hint": "Times are planned and can move if something runs long. Follow the drivers' board for current times.",
"day.board_title": "Today's schedule {date}",
"day.board_now": "starting now",
"day.board_heads_up": "Get ready – almost time!",
"day.board_heads_up": "Called – get ready!",
"day.board_on_track": "On track",
"day.board_all_done": "Every heat has been run today.",
"day.board_none": "No schedule for today.",