feat: digitalOutputs separate jsSimulatedProd mode
This commit is contained in:
@@ -33,7 +33,7 @@ export const fetchDigitalOutputsService = async () => {
|
||||
status: status === 1,
|
||||
}));
|
||||
}
|
||||
} else if (mode === "json" || mode === "jsSimulatedProd") {
|
||||
} else if (mode === "json") {
|
||||
const res = await fetch("/api/cpl/getDigitalOutputsHandler");
|
||||
|
||||
if (!res.ok) {
|
||||
@@ -57,6 +57,24 @@ export const fetchDigitalOutputsService = async () => {
|
||||
}));
|
||||
}
|
||||
}
|
||||
} else if (mode === "jsSimulatedProd") {
|
||||
console.log("🔄 Lade simulierte analoge Eingänge im Produktionsmodus...");
|
||||
const scriptUrl = "/api/cpl/getDigitalOutputsHandler"; // gibt JavaScript zurück
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const script = document.createElement("script");
|
||||
script.src = scriptUrl;
|
||||
script.async = true;
|
||||
script.onload = () => resolve();
|
||||
script.onerror = () =>
|
||||
reject("❌ Fehler beim Laden des simulierten Scripts");
|
||||
document.body.appendChild(script);
|
||||
});
|
||||
const win = window as any;
|
||||
return Array.from({ length: 4 }, (_, i) => ({
|
||||
id: i + 1,
|
||||
label: win.win_da_bezeichnung[i] || `Ausgang ${i + 1}`,
|
||||
status: win.win_da_state[i] === 1,
|
||||
}));
|
||||
} else {
|
||||
console.warn(`⚠️ Unbekannter Modus: ${mode}`);
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user