Digitale Ausgänge nicht erforderlich
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
export const fetchDigitalOutputs = async () => {
|
||||
if (typeof window === "undefined") return [];
|
||||
|
||||
// ✅ da.js nur bei Bedarf nachladen (Pfad abhängig von Umgebung)
|
||||
const scriptSrc =
|
||||
process.env.NEXT_PUBLIC_NODE_ENV === "production"
|
||||
? "/CPL?/CPL/SERVICE/da.js"
|
||||
@@ -19,25 +18,24 @@ export const fetchDigitalOutputs = async () => {
|
||||
});
|
||||
|
||||
const win = window as any;
|
||||
|
||||
const state = win.win_da_state;
|
||||
const labels = win.win_da_bezeichnung;
|
||||
|
||||
if (
|
||||
Array.isArray(state) &&
|
||||
Array.isArray(labels) &&
|
||||
state.length === labels.length
|
||||
) {
|
||||
return state.map((status: number, index: number) => ({
|
||||
id: index + 1,
|
||||
label: labels[index] || `Ausgang ${index + 1}`,
|
||||
status: status === 1,
|
||||
}));
|
||||
} else {
|
||||
console.warn("⚠️ Digitale Ausgänge unvollständig oder inkonsistent:", {
|
||||
state,
|
||||
labels,
|
||||
});
|
||||
if (!Array.isArray(state)) {
|
||||
console.warn("⚠️ win_da_state fehlt oder ist ungültig:", state);
|
||||
return [];
|
||||
}
|
||||
|
||||
const outputs = state
|
||||
.slice(0, 4) // ✅ Nur die 4 Ausgänge verwenden
|
||||
.map((status: number, index: number) => ({
|
||||
id: index + 1,
|
||||
label:
|
||||
Array.isArray(labels) && labels[index]
|
||||
? labels[index]
|
||||
: `Ausgang ${index + 1}`,
|
||||
status: status === 1,
|
||||
}));
|
||||
|
||||
return outputs;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user