Add multi-decoder split and pit timing support

This commit is contained in:
larssand
2026-08-25 19:45:40 +02:00
parent 6f02e955a5
commit 8ea8b3a84e
20 changed files with 876 additions and 147 deletions

View File

@@ -4,14 +4,24 @@ export function createDefaultAmmcConfigHelper() {
autoStart: false,
decoderHost: "",
wsPort: 9000,
splitEnabled: false,
splitDecoderHost: "",
splitWsPort: 9001,
pitEnabled: false,
pitEntryDecoderHost: "",
pitEntryWsPort: 9002,
pitExitDecoderHost: "",
pitExitWsPort: 9003,
executablePath: "",
workingDirectory: "",
extraArgs: "",
};
}
export function getManagedWsUrlHelper({ ammc, getBackendUrl }) {
const port = Number(ammc.config?.wsPort || 9000);
export function getManagedWsUrlHelper({ ammc, getBackendUrl }, role = "main") {
const portKey = role === "split" ? "splitWsPort" : role === "pit_entry" ? "pitEntryWsPort" : role === "pit_exit" ? "pitExitWsPort" : "wsPort";
const defaultPort = role === "split" ? 9001 : role === "pit_entry" ? 9002 : role === "pit_exit" ? 9003 : 9000;
const port = Number(ammc.config?.[portKey] || defaultPort);
try {
const backendUrl = new URL(getBackendUrl());
return `ws://${backendUrl.hostname}:${port}`;
@@ -97,6 +107,11 @@ export function applyPersistedStateHelper(persisted, deps) {
state.activeSessionId = persisted.activeSessionId || null;
state.settings = {
wsUrl: persisted.settings?.wsUrl || state.settings.wsUrl || "ws://127.0.0.1:9000",
splitDecoderEnabled: persisted.settings?.splitDecoderEnabled === true,
splitWsUrl: String(persisted.settings?.splitWsUrl || state.settings.splitWsUrl || "ws://127.0.0.1:9001"),
pitDecoderEnabled: persisted.settings?.pitDecoderEnabled === true,
pitEntryWsUrl: String(persisted.settings?.pitEntryWsUrl || state.settings.pitEntryWsUrl || "ws://127.0.0.1:9002"),
pitExitWsUrl: String(persisted.settings?.pitExitWsUrl || state.settings.pitExitWsUrl || "ws://127.0.0.1:9003"),
backendUrl: persisted.settings?.backendUrl || state.settings.backendUrl || getDefaultBackendUrl(),
language: persisted.settings?.language || state.settings.language || DEFAULT_LANGUAGE,
theme: AVAILABLE_THEMES.includes(String(persisted.settings?.theme || state.settings.theme || DEFAULT_THEME).toLowerCase()) ? String(persisted.settings?.theme || state.settings.theme || DEFAULT_THEME).toLowerCase() : DEFAULT_THEME,