diff --git a/app/kabelueberwachung/page.jsx b/app/kabelueberwachung/page.jsx index 33cb01b..34b4621 100644 --- a/app/kabelueberwachung/page.jsx +++ b/app/kabelueberwachung/page.jsx @@ -1,32 +1,122 @@ "use client"; -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import Kue705FO from "../../components/modules/Kue705FO"; function Kabelueberwachung() { - const moduleValues = { - isolationswert: ">200", - schleifenwiderstand: "0.85", + 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 [schleifenwiderstand, setSchleifenwiderstand] = useState([]); // State to store the resistance values + + // Function to handle rack change + const changeRack = (rack) => { + setActiveRack(rack); }; + // Load the external JavaScript file and fetch the isolation values + useEffect(() => { + if (window.kueIso && Array.isArray(window.kueIso)) { + setKueIso(window.kueIso); // Store the isolation values from the global variable + } + + if (window.kueRes && Array.isArray(window.kueRes)) { + setSchleifenwiderstand(window.kueRes); // Store the resistance values from the global variable + } + }, []); + + // Data for each rack, using isolation values from kueIso, kueName, and schleifenwiderstand + const racks = { + rack1: kueIso.slice(0, 8).map((value, index) => ({ + isolationswert: value, // Isolation value for this slot + schleifenwiderstand: schleifenwiderstand[index], // Resistance for this slot + modulName: kueName[index] || "Unknown", // Name for this slot + })), + rack2: kueIso.slice(8, 16).map((value, index) => ({ + isolationswert: value, + schleifenwiderstand: schleifenwiderstand[8 + index], + modulName: kueName[8 + index] || "Unknown", + })), + rack3: kueIso.slice(16, 24).map((value, index) => ({ + isolationswert: value, + schleifenwiderstand: schleifenwiderstand[16 + index], + modulName: kueName[16 + index] || "Unknown", + })), + rack4: kueIso.slice(24, 32).map((value, index) => ({ + isolationswert: value, + schleifenwiderstand: schleifenwiderstand[24 + index], + modulName: kueName[24 + index] || "Unknown", + })), + }; + + useEffect(() => { + const script = document.createElement("script"); + script.src = "CPL?Service/kueData.js"; // Path to your JavaScript file + script.async = true; + document.body.appendChild(script); + + // Once the script is loaded, get the isolation values + script.onload = () => { + if (window.kueName && Array.isArray(window.kueName)) { + setKueName(window.kueName); // Store the KUE names from the global variable + } + }; + + // Cleanup the script if the component unmounts + return () => { + document.body.removeChild(script); + }; + }, []); + return (

Kabelüberwachung

+ + {/* Tabs for Racks */} +
+ + + + +
+ + {/* Slots for the active rack */}
- {/* Hier verwenden wir die Kue705FO-Komponente */} - - - - - - - - + {racks[`rack${activeRack}`].map((slot, index) => ( + + ))}
); diff --git a/components/modules/Kue705FO.jsx b/components/modules/Kue705FO.jsx index e92df54..3562c32 100644 --- a/components/modules/Kue705FO.jsx +++ b/components/modules/Kue705FO.jsx @@ -1,7 +1,12 @@ import React from "react"; import { Icon } from "@iconify/react"; // Für Iconify Icons -function Kue705FO({ isolationswert, schleifenwiderstand, modulName, version }) { +function Kue705FO({ + isolationswert, + schleifenwiderstand, + modulName, + kueVersion, +}) { return (
{/* Hauptkörper - Linker Bereich */} @@ -21,6 +26,26 @@ function Kue705FO({ isolationswert, schleifenwiderstand, modulName, version }) { KÜ705-FO + {/* Modulname und Version */} +
+

Version: {kueVersion}

+
+ + {/* Isolationswert */} +
+

Isolationswert:

+

{isolationswert} kOhm

+
+ + {/* Kabelüberwachung-Modul-Name */} +
+

ModulName: {modulName}

+
+ {/* Schleifenwiderstand */} +
+

Schleifenwiderstand: {schleifenwiderstand} kOhm

+
+ {/* Unterer Bereich - Schleifenwiderstand und Messkurve */}
{/* Messkurve Button */} diff --git a/utils/loadWindowVariables.js b/utils/loadWindowVariables.js index 68ba0f7..0806b55 100644 --- a/utils/loadWindowVariables.js +++ b/utils/loadWindowVariables.js @@ -41,7 +41,7 @@ export async function loadWindowVariables(apiUrl) { // kueConfig.acp Variablen kueOnline: window.kueOnline, kueID: window.kueID, - kueIso: window.kueIso, + //kueIso: window.kueIso, von SERVICE/kueConfig.acp also von window.kueIso // kuedetail.acp Variablen kueValid: window.kueValid, kueAlarm1: window.kueAlarm1,