Bei Kabelbruch (cableBreak), Erdschluss (groundFault), Isolationsfehler (measure1Alarm) oder Schleifenfehler (measure2Alarm) wird der Status rot angezeigt. Ansonsten grün.

This commit is contained in:
ISA
2024-10-23 10:50:55 +02:00
parent 94e749efc1
commit 85bda4323c
17 changed files with 88 additions and 2725 deletions

View File

@@ -1,15 +1,14 @@
"use client";
"use client"; // app/kabelueberwachung/page.jsx
import React, { useState, useEffect } from "react";
import Kue705FO from "../../components/modules/Kue705FO";
function Kabelueberwachung() {
//const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
const [isClient, setIsClient] = useState(false);
const [apiUrl, setApiUrl] = useState("");
const [activeRack, setActiveRack] = useState(1); // Track the active rack
const [kueIso, setKueIso] = useState([]); // State to store isolation values
const [kueName, setKueName] = useState([]); // State to store the KUE names
const [kueID, setKueID] = useState([]); // State to store the KUE IDs
const [schleifenwiderstand, setSchleifenwiderstand] = useState([]); // State to store the resistance values
//const [kueOnline, setKueOnline] = useState([ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]); // Example array for module status
const [kueOnline, setKueOnline] = useState([]); // State to store the module status
@@ -18,12 +17,7 @@ function Kabelueberwachung() {
const changeRack = (rack) => {
setActiveRack(rack);
};
useEffect(() => {
setIsClient(true);
if (typeof window !== "undefined") {
setApiUrl(`https://${window.ip}:443`);
}
}, []);
/* if (!isClient) {
return null; // or a loading spinner
}*/
@@ -40,8 +34,8 @@ function Kabelueberwachung() {
if (window.kueOnline && Array.isArray(window.kueOnline)) {
setKueOnline(window.kueOnline); // Store the module status from the global variable
}
if (window.kueName && Array.isArray(window.kueName)) {
setKueName(window.kueName); // Store the KUE names from the global variable
if (window.kueID && Array.isArray(window.kueID)) {
setKueName(window.kueID); // Store the KUE names from the global variable
}
}, []);
@@ -56,26 +50,26 @@ function Kabelueberwachung() {
rack2: kueIso.slice(8, 16).map((value, index) => ({
isolationswert: value,
schleifenwiderstand: schleifenwiderstand[8 + index],
modulName: kueName[8 + index] || "Unknown",
modulName: kueID[8 + index] || "Unknown",
kueOnlineStatus: kueOnline[8 + index], // Online status for this slot
})),
rack3: kueIso.slice(16, 24).map((value, index) => ({
isolationswert: value,
schleifenwiderstand: schleifenwiderstand[16 + index],
modulName: kueName[16 + index] || "Unknown",
modulName: kueID[16 + index] || "Unknown",
kueOnlineStatus: kueOnline[16 + index], // Online status for this slot
})),
rack4: kueIso.slice(24, 32).map((value, index) => ({
isolationswert: value,
schleifenwiderstand: schleifenwiderstand[24 + index],
modulName: kueName[24 + index] || "Unknown",
modulName: kueID[24 + index] || "Unknown",
kueOnlineStatus: kueOnline[24 + index], // Online status for this slot
})),
};
useEffect(() => {
const script = document.createElement("script");
script.src = `${apiUrl}CPL?Service/kueData.js`; // Path to your JavaScript file
script.src = `CPL?Service/kueData.js`; // Path to your JavaScript file
script.async = true;
document.body.appendChild(script);