Kabelüberwachung liest aus Redux

This commit is contained in:
ISA
2024-11-05 08:25:18 +01:00
parent 228d8d7a1b
commit 1cdd77be09
8 changed files with 277 additions and 582 deletions

View File

@@ -2,6 +2,7 @@
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import ReactModal from "react-modal"; import ReactModal from "react-modal";
import Chart from "chart.js/auto"; import Chart from "chart.js/auto";
import { useSelector } from "react-redux";
import KueModal from "../modales/KueModal"; import KueModal from "../modales/KueModal";
import "bootstrap-icons/font/bootstrap-icons.css"; // Import Bootstrap Icons import "bootstrap-icons/font/bootstrap-icons.css"; // Import Bootstrap Icons
@@ -35,107 +36,110 @@ function Kue705FO({
schleifenwiderstand || "0" schleifenwiderstand || "0"
); );
const [showModal, setShowModal] = useState(false); const [showModal, setShowModal] = useState(false);
const [showChartModal, setShowChartModal] = useState(false); // Modal für die Messkurve const [showChartModal, setShowChartModal] = useState(false);
const [chartData, setChartData] = useState(null); // State für die geladene Chart-Daten const [chartData, setChartData] = useState(null);
const handleOpenModal = () => { // Redux-Variablen abrufen
setShowModal(true); const {
}; kuePSTmMinus96V,
kueCableBreak,
kueGroundFault,
kueAlarm1,
kueAlarm2,
kueOverflow,
kueVersion: reduxKueVersion,
tdrActive,
} = useSelector((state) => state.variables);
const handleCloseModal = () => { const handleOpenModal = () => setShowModal(true);
setShowModal(false); const handleCloseModal = () => setShowModal(false);
};
// Funktion zum Anzeigen des Chart-Modals
const handleOpenChartModal = () => { const handleOpenChartModal = () => {
setShowChartModal(true); setShowChartModal(true);
if (activeButton === "TDR") { if (activeButton === "TDR") {
loadTDRChartData(); // Lade TDR-Daten, wenn der TDR-Button aktiv ist loadTDRChartData();
} else { } else {
loadLoopChartData(); // Andernfalls lade die Schleifenmessdaten loadLoopChartData();
}
};
const handleButtonClick = (button) => {
if (button === "Schleife") {
setActiveButton("Schleife");
setloopTitleText("Schleifenwiderstand [kOhm]");
setCurrentDisplayValue(schleifenwiderstand || "0");
} else if (button === "TDR") {
setActiveButton("TDR");
setloopTitleText("Entfernung [Km]");
setCurrentDisplayValue(tdrLocation || "0");
}
};
// Bestimme, welche Funktion ausgeführt wird, basierend auf dem aktiven Button
const handleRefreshClick = () => {
if (activeButton === "Schleife") {
goLoop(); // Wenn Schleife aktiv ist, starte goLoop
} else if (activeButton === "TDR") {
goTDR(); // Wenn TDR aktiv ist, starte goTDR
} }
}; };
const handleCloseChartModal = () => { const handleCloseChartModal = () => setShowChartModal(false);
setShowChartModal(false);
};
const environment = process.env.NODE_ENV || "production";
let fileData;
// Daten laden und den TDR-Chart erstellen
const loadTDRChartData = () => { const loadTDRChartData = () => {
const slot = slotIndex; const slot = slotIndex;
//const fileData = `../cpl?lastTDR/slot${slot}.json`; // TDR-Daten je nach Slot laden const environment = process.env.NODE_ENV || "production";
if (environment === "production") { const fileData =
fileData = `/CPL?/CPL/lastTDR/slot${slot}.json`; // Produktions-Pfad environment === "production"
} else { ? `/CPL?/CPL/lastTDR/slot${slot}.json`
fileData = `/CPLmockData/lastTDR/slot${slot}.json`; // Mock-Daten-Pfad für Entwicklung : `/CPLmockData/lastTDR/slot${slot}.json`;
}
fetch(fileData) fetch(fileData)
.then((response) => response.json()) .then((response) => response.json())
.then((data) => { .then((data) => {
setChartData(data); // Daten setzen setChartData(data);
createTDRChart(data); // Chart für TDR-Messung erstellen createTDRChart(data);
}) })
.catch((error) => { .catch((error) =>
console.error("Fehler beim Laden der TDR-Messkurvendaten:", error); console.error("Fehler beim Laden der TDR-Messkurvendaten:", error)
}); );
}; };
// Daten laden und den Schleifenmessungs-Chart erstellen
const loadLoopChartData = () => { const loadLoopChartData = () => {
const slot = slotIndex; const slot = slotIndex;
//const fileData = `../cpl?4000values/slot${slot}.json`; // Schleifenmessdaten je nach Slot laden const environment = process.env.NODE_ENV || "production";
if (environment === "production") { const fileData =
fileData = `/CPL?/CPL/4000values/slot${slot}.json`; // Produktions-Pfad environment === "production"
} else { ? `/CPL?/CPL/4000values/slot${slot}.json`
fileData = `/CPLmockData/4000values/slot${slot}.json`; // Mock-Daten-Pfad für Entwicklung : `/CPLmockData/4000values/slot${slot}.json`;
}
fetch(fileData) fetch(fileData)
.then((response) => response.json()) .then((response) => response.json())
.then((data) => { .then((data) => {
setChartData(data); // Daten setzen setChartData(data);
createChart(data, "Schleifenmesskurve"); // Chart für Schleifenmessung erstellen createChart(data, "Schleifenmesskurve");
}) })
.catch((error) => { .catch((error) =>
console.error("Fehler beim Laden der Schleifenmesskurvendaten:", error); console.error("Fehler beim Laden der Schleifenmesskurvendaten:", error)
}); );
}; };
// Funktion zum Erstellen des Charts
// Funktion zum Erstellen des Charts
const createChart = (data) => { const createChart = (data) => {
const ctx = document.getElementById("myChart").getContext("2d"); const ctx = document.getElementById("myChart").getContext("2d");
// Funktion zur Umwandlung des Datums in das deutsche Format
const formatToGermanDate = (timestamp) => {
const date = new Date(timestamp);
return new Intl.DateTimeFormat("de-DE", {
day: "2-digit",
month: "2-digit",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
}).format(date);
};
// Ausgabe der Chart-Daten in der Konsole mit Slot-Informationen
console.log(`Chart-Daten für Slot ${slotIndex + 1}:`, data);
new Chart(ctx, { new Chart(ctx, {
type: "line", type: "line",
data: { data: {
labels: data.map((row) => formatToGermanDate(row.t)).reverse(), // Zeitwerte ins deutsche Format umwandeln und umkehren labels: data
.map((row) => new Date(row.t).toLocaleString("de-DE"))
.reverse(),
datasets: [ datasets: [
{ {
label: "Isolationswiderstand (MOhm)", // Einheit hinzugefügt label: "Isolationswiderstand (MOhm)",
data: data.map((row) => row.m).reverse(), data: data.map((row) => row.m).reverse(),
borderColor: "#00AEEF", borderColor: "#00AEEF",
fill: false, fill: false,
yAxisID: "y", yAxisID: "y",
}, },
{ {
label: "Schleifenwiderstand (kOhm)", // Einheit hinzugefügt label: "Schleifenwiderstand (kOhm)",
data: data.map((row) => row.n).reverse(), data: data.map((row) => row.n).reverse(),
borderColor: "black", borderColor: "black",
fill: false, fill: false,
@@ -148,272 +152,82 @@ function Kue705FO({
y: { y: {
type: "linear", type: "linear",
position: "left", position: "left",
title: { title: { display: true, text: "MOhm" },
display: true,
text: "MOhm", // Einheit für linke Achse hinzugefügt
},
}, },
y1: { y1: {
type: "linear", type: "linear",
position: "right", position: "right",
title: { title: { display: true, text: "kOhm" },
display: true,
text: "kOhm", // Einheit für rechte Achse hinzugefügt
},
}, },
}, },
}, },
}); });
}; };
// Funktion zum Erstellen des TDR-Charts
const createTDRChart = (dataTDR) => {
const ctx = document.getElementById("myChart").getContext("2d");
console.log(`TDR-Daten für Slot ${slotIndex + 1}:`, dataTDR);
new Chart(ctx, {
type: "line",
data: {
labels: dataTDR.map((row) => row.t), // Entfernung oder Zeit auf der x-Achse
datasets: [
{
label: "Pegel",
data: dataTDR.map((row) => row.m), // Nur Pegel auf der y-Achse
borderColor: "#00AEEF",
borderWidth: 1,
pointBorderWidth: 0,
pointStyle: false,
fill: false,
},
],
},
options: {
scales: {
y: {
type: "linear",
position: "left",
},
},
},
});
};
// Funktion für die TDR-Messung
const goTDR = () => {
//-------------------------------------------------
/* const [isClient, setIsClient] = useState(false);
useEffect(() => {
// This will only run in the client/browser, not on the server
setIsClient(true);
}, []);
if (!isClient) {
return null; // or a loading spinner
} */
//-------------------------------------------------
let slot = slotIndex;
if (slot >= 32) {
return;
}
let slotFormat = slot < 10 ? `0${slot}` : `${slot}`;
setLoading(true);
alert(`TDR wird für Slot ${slot + 1} gestartet...`);
fetch(`/CPL?Service/KUEdetailTDR.ACP&KTT${slotFormat}=1&slot=${slot}`, {
method: "GET",
})
.then((response) => {
if (response.ok) {
alert(`TDR erfolgreich gestartet für Slot ${slot + 1}`);
console.log("TDR erfolgreich gestartet für Slot", slot + 1);
} else {
console.error("Fehler beim Senden der TDR-Anfrage");
}
})
.catch((error) => {
console.error("Fehler:", error);
})
.finally(() => setLoading(false));
};
// Funktion für die Schleifenmessung
const goLoop = () => {
let slot = slotIndex;
if (slot >= 32) {
return;
}
let slotFormat = slot < 10 ? `0${slot}` : `${slot}`;
setLoading(true); // Setze den Ladezustand auf true
alert(`Schleifenmessung wird für Slot ${slot} gestartet...`);
fetch(`/CPL?Service/KUEdetail.HTML&KS_${slotFormat}=1&slot=${slot}`, {
method: "GET",
})
.then((response) => {
if (response.ok) {
alert(`Schleifenmessung erfolgreich gestartet für Slot ${slot}`);
console.log("Schleifenmessung erfolgreich gestartet für Slot", slot);
} else {
alert("Fehler beim Starten der Schleifenmessung.");
console.error("Fehler beim Senden der Schleifen-Anfrage");
}
})
.catch((error) => {
alert("Ein Fehler ist aufgetreten.");
console.error("Fehler:", error);
})
.finally(() => setLoading(false)); // Ladezustand zurücksetzen
};
const handleModulNameChange = (newName) => {
setCurrentModulName(newName);
};
// Überprüfe, ob ein Modul im Slot vorhanden ist
const isModulPresent = kueOnline === 1; // Since you're passing the status directly now
const handleButtonClick = (button) => {
if (button === "Schleife") {
setActiveButton("Schleife");
setloopTitleText("Schleifenwiderstand [kOhm]");
setCurrentDisplayValue(schleifenwiderstand || "0");
} else if (button === "TDR") {
setActiveButton("TDR");
setloopTitleText("Entfernung [Km]");
setCurrentDisplayValue(tdrLocation || "0");
}
};
// Bestimme, welche Funktion ausgeführt wird, basierend auf dem aktiven Button
const handleRefreshClick = () => {
if (activeButton === "Schleife") {
goLoop(); // Wenn Schleife aktiv ist, starte goLoop
} else if (activeButton === "TDR") {
goTDR(); // Wenn TDR aktiv ist, starte goTDR
}
};
useEffect(() => {
setCurrentModulName(modulName);
}, [modulName]);
useEffect(() => {
setCurrentDisplayValue(schleifenwiderstand);
}, [schleifenwiderstand]);
useEffect(() => { useEffect(() => {
const updateAlarmStatus = () => { const updateAlarmStatus = () => {
const alarmStatus = const alarmStatus =
(window.kueAlarm1 && window.kueAlarm1[slotIndex]) || (kueAlarm1 && kueAlarm1[slotIndex]) ||
(window.kueAlarm2 && window.kueAlarm2[slotIndex]) || (kueAlarm2 && kueAlarm2[slotIndex]) ||
(window.kueCableBreak && window.kueCableBreak[slotIndex]) || (kueCableBreak && kueCableBreak[slotIndex]) ||
(window.kueGroundFault && window.kueGroundFault[slotIndex]); (kueGroundFault && kueGroundFault[slotIndex]);
setCurrentAlarmStatus(alarmStatus); // Aktualisiere den Alarmstatus setCurrentAlarmStatus(alarmStatus);
}; };
// Aktualisierung sofort und alle 5 Sekunden
updateAlarmStatus(); updateAlarmStatus();
const interval = setInterval(updateAlarmStatus, 10000); const interval = setInterval(updateAlarmStatus, 10000);
return () => clearInterval(interval);
}, [slotIndex, kueAlarm1, kueAlarm2, kueCableBreak, kueGroundFault]);
return () => clearInterval(interval); // Bereinigung bei Entladen der Komponente
}, [slotIndex]);
//------------------------------------------------
// Dynamischer Abruf des kueVersion-Werts für jeden Slot in Intervallen
useEffect(() => {
const intervalId = setInterval(() => {
if (window.kueVersion && window.kueVersion[slotIndex]) {
setKueVersion("V" + window.kueVersion[slotIndex] / 100);
}
}, 10000); // 10000 ms = 10 Sekunden
// Bereinigung der Intervalle beim Entfernen der Komponente
return () => clearInterval(intervalId);
}, [slotIndex]);
//-------------------------------------------------
//-------------------------------------------------
// Priority: Aderbruch - Erdschluss - Isolationsfehler - Schleifenfehler - Overflow (>200 MOhm) - Messwert
// Prioritätsprüfung in updateDisplay
useEffect(() => { useEffect(() => {
const updateDisplay = () => { const updateDisplay = () => {
if ( if (kuePSTmMinus96V?.[slotIndex] === 1) {
!window.kuePSTmMinus96V ||
!window.kueCableBreak ||
!window.kueGroundFault ||
!window.kueAlarm1 ||
!window.kueAlarm2 ||
!window.kueOverflow
) {
// console.log("Warten auf window Variablen...");
setTimeout(updateDisplay, 1000); // Warte 1 Sekunde und versuche es erneut
return;
}
/* console.log(
"Alle window-Variablen sind verfügbar. Beginne mit den Prioritätsprüfungen..."
); */
// PST-M Ausfall
if (window.kuePSTmMinus96V[slotIndex] === 1) {
setCurrentDisplayValue("PST-M prüfen"); setCurrentDisplayValue("PST-M prüfen");
return; return;
} }
// Aderbruch if (kueCableBreak?.[slotIndex] === 1) {
if (window.kueCableBreak[slotIndex] === 1) {
// console.log("Aderbruch erkannt für Slot", slotIndex);
setCurrentDisplayValue(isoDisplayText); setCurrentDisplayValue(isoDisplayText);
return; return;
} }
// Erdschluss if (kueGroundFault?.[slotIndex] === 1) {
else if (window.kueGroundFault[slotIndex] === 1) {
// console.log("Erdschluss erkannt für Slot", slotIndex);
setCurrentDisplayValue(groundFaultDisplayText); setCurrentDisplayValue(groundFaultDisplayText);
return; return;
} }
// Isolationsfehler if (kueAlarm1?.[slotIndex] === 1) {
else if (window.kueAlarm1[slotIndex] === 1) {
// console.log("Isolationsfehler erkannt für Slot", slotIndex);
setCurrentDisplayValue(isoFaultDisplayText); setCurrentDisplayValue(isoFaultDisplayText);
return; return;
} }
// Schleifenfehler if (kueAlarm2?.[slotIndex] === 1) {
else if (window.kueAlarm2[slotIndex] === 1) {
// console.log("Schleifenfehler erkannt für Slot", slotIndex);
setCurrentDisplayValue(loopFaultDisplayText); setCurrentDisplayValue(loopFaultDisplayText);
return; return;
} }
// Overflow (>200 MOhm) if (kueOverflow?.[slotIndex] === 1) {
else if (window.kueOverflow[slotIndex] === 1) {
/* console.log(
"Overflow erkannt für Slot",
slotIndex,
"- Anzeige: '>200'"
); */
setCurrentDisplayValue(isoGreaterThan200); setCurrentDisplayValue(isoGreaterThan200);
return; return;
} }
// Kein Fehler setCurrentDisplayValue(isolationswert);
else {
/* console.log(
"Kein Fehler erkannt, zeige Standardisolationswert an für Slot",
slotIndex
); */
setCurrentDisplayValue(isolationswert); // Nur Isolationswert ohne ">200" als Fallback
}
}; };
updateDisplay(); // Initialer Aufruf updateDisplay();
const interval = setInterval(updateDisplay, 5000); // Regelmäßige Überprüfung const interval = setInterval(updateDisplay, 5000);
return () => clearInterval(interval);
}, [
slotIndex,
isolationswert,
kuePSTmMinus96V,
kueCableBreak,
kueGroundFault,
kueAlarm1,
kueAlarm2,
kueOverflow,
]);
return () => clearInterval(interval); // Bereinigung bei Entladen der Komponente useEffect(() => {
}, [slotIndex, isolationswert]); if (reduxKueVersion?.[slotIndex]) {
setKueVersion("V" + reduxKueVersion[slotIndex] / 100);
//------------------------------------------------- }
}, [slotIndex, reduxKueVersion]);
return ( return (
<div className="relative bg-gray-300 w-[116px] h-[390px] border border-gray-400 scale-110 top-3"> <div className="relative bg-gray-300 w-[116px] h-[390px] border border-gray-400 scale-110 top-3">
@@ -439,11 +253,8 @@ function Kue705FO({
showModal={showModal} showModal={showModal}
onClose={handleCloseModal} onClose={handleCloseModal}
slot={slotIndex} slot={slotIndex}
onModulNameChange={handleModulNameChange} onModulNameChange={setCurrentModulName}
/> />
{/*
Bei Kabelbruch (cableBreak), Erdschluss (groundFault), Isolationsfehler (measure1Alarm) oder Schleifenfehler (measure2Alarm)
*/}
<div className="flex flex-col mt-[10px] ml-[10px]"> <div className="flex flex-col mt-[10px] ml-[10px]">
<div className="flex items-center"> <div className="flex items-center">
<div className="w-[10px] h-[10px] bg-green-500 rounded-full mr-2"></div> <div className="w-[10px] h-[10px] bg-green-500 rounded-full mr-2"></div>
@@ -452,37 +263,37 @@ function Kue705FO({
<div className="flex items-center mt-1"> <div className="flex items-center mt-1">
<div <div
className={`w-[10px] h-[10px] rounded-full mr-2 ${ className={`w-[10px] h-[10px] rounded-full mr-2 ${
alarmStatus ? "bg-red-500" : "bg-gray-300" currentAlarmStatus ? "bg-red-500" : "bg-gray-300"
}`} }`}
></div> ></div>
<span className="text-white text-[10px]">Alarm</span> <span className="text-white text-[10px]">Alarm</span>
</div> </div>
</div> </div>
{/* Display für Isolationsfehler, Aderbruch, Erdschluss oder Schleifenfehler */}
<div className="relative mt-[50px] mx-auto bg-black text-white w-[100px] h-[40px] flex items-center justify-center text-[18px] z-10"> <div className="relative mt-[50px] mx-auto bg-black text-white w-[100px] h-[40px] flex items-center justify-center text-[18px] z-10">
<div className="text-center"> <div className="text-center">
<span <span
className={ className={
window.kuePSTmMinus96V[slotIndex] === 1 || kuePSTmMinus96V?.[slotIndex] === 1 ||
window.kueCableBreak[slotIndex] === 1 || kueCableBreak?.[slotIndex] === 1 ||
window.kueGroundFault[slotIndex] === 1 || kueGroundFault?.[slotIndex] === 1 ||
window.kueAlarm1[slotIndex] === 1 || kueAlarm1?.[slotIndex] === 1 ||
window.kueAlarm2[slotIndex] === 1 kueAlarm2?.[slotIndex] === 1
? "text-red-500 text-[14px]" // Rot und kleinere Schrift für Alarme ? "text-red-500 text-[14px]"
: window.kueOverflow[slotIndex] === 1 //Sehr hoher Isolationswiderstand , ein sehr gutes Kabel : kueOverflow?.[slotIndex] === 1
? "text-white text-[14px]" // Neutrale Farbe für >200 MOhm-Anzeige ? "text-white text-[14px]"
: "" : ""
} }
> >
{currentDisplayValue} {currentDisplayValue}
</span> </span>
{window.kuePSTmMinus96V[slotIndex] !== 1 && {kuePSTmMinus96V?.[slotIndex] !== 1 &&
window.kueCableBreak[slotIndex] !== 1 && kueCableBreak?.[slotIndex] !== 1 &&
window.kueGroundFault[slotIndex] !== 1 && kueGroundFault?.[slotIndex] !== 1 &&
window.kueAlarm1[slotIndex] !== 1 && kueAlarm1?.[slotIndex] !== 1 &&
window.kueAlarm2[slotIndex] !== 1 && kueAlarm2?.[slotIndex] !== 1 &&
window.kueOverflow[slotIndex] !== 1 && ( kueOverflow?.[slotIndex] !== 1 && (
<div className="text-[8px]">ISO MOhm</div> <div className="text-[8px]">ISO MOhm</div>
)} )}
</div> </div>
@@ -536,13 +347,13 @@ function Kue705FO({
<button <button
onClick={() => handleButtonClick("TDR")} onClick={() => handleButtonClick("TDR")}
className={`w-[50%] h-[25px] text-white text-[10px] flex items-center justify-center ${ className={`w-[50%] h-[25px] text-white text-[10px] flex items-center justify-center ${
window.tdrActive[slotIndex] === 0 tdrActive[slotIndex] === 0
? "bg-gray-200 cursor-not-allowed" // Deaktiviert: Hellgrau ? "bg-gray-200 cursor-not-allowed" // Deaktiviert: Hellgrau
: activeButton === "TDR" : activeButton === "TDR"
? "bg-littwin-blue" // Aktiviert: Littwin Blau ? "bg-littwin-blue" // Aktiviert: Littwin Blau
: "bg-gray-400" // Nicht geklickt: Dunkelgrau : "bg-gray-400" // Nicht geklickt: Dunkelgrau
}`} }`}
disabled={window.tdrActive[slotIndex] === 0} // Button deaktiviert, wenn TDR für diesen Slot nicht aktiv ist disabled={tdrActive[slotIndex] === 0} // Button deaktiviert, wenn TDR für diesen Slot nicht aktiv ist
> >
TDR TDR
</button> </button>

View File

@@ -2,232 +2,108 @@
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import Kue705FO from "../components/modules/Kue705FO"; import Kue705FO from "../components/modules/Kue705FO";
import { loadWindowVariables } from "../utils/loadWindowVariables"; import { useDispatch, useSelector } from "react-redux";
import { setVariables } from "../store/variablesSlice";
//import { loadWindowVariables } from "../utils/loadWindowVariables";
function Kabelueberwachung() { function Kabelueberwachung() {
const router = useRouter(); const router = useRouter();
const [activeRack, setActiveRack] = useState(1); // Track the active rack const dispatch = useDispatch();
const [kueIso, setKueIso] = useState([]); // State to store isolation values const [activeRack, setActiveRack] = useState(1); // Aktives Rack
const [kueID, setKueID] = useState([]); // State to store the KUE names const [alarmStatus, setAlarmStatus] = useState([]); // Alarmstatus
const [schleifenwiderstand, setSchleifenwiderstand] = useState([]); // State to store the resistance values
const [kueOnline, setKueOnline] = useState([]); // State to store the module status
const [alarmStatus, setAlarmStatus] = useState([]); // State to store the alarm status
// Verwende den useRouter Hook, um den Rack-Parameter zu extrahieren // Redux-Variablen aus dem Store abrufen
const {
kueOnline,
kueID,
kueIso,
kueAlarm1,
kueAlarm2,
kueRes,
kueCableBreak,
kueGroundFault,
} = useSelector((state) => state.variables);
// URL-Parameter 'rack' abfragen und setzen
useEffect(() => { useEffect(() => {
const query = new URLSearchParams(window.location.search); const query = new URLSearchParams(window.location.search);
const rackParam = query.get("rack"); const rackParam = query.get("rack");
if (rackParam) { if (rackParam) {
setActiveRack(parseInt(rackParam)); // Setze das aktive Rack basierend auf dem URL-Parameter setActiveRack(parseInt(rackParam));
} }
}, [router.query]); }, [router.query]);
// Load the external JavaScript file and fetch the isolation values // Laden der `window`-Variablen und Speichern in Redux
useEffect(() => { /* useEffect(() => {
const fetchData = () => { const fetchData = async () => {
loadWindowVariables() const variables = await loadWindowVariables();
.then(() => { dispatch(setVariables(variables));
if (window.kueIso && Array.isArray(window.kueIso)) {
setKueIso(window.kueIso);
}
if (window.kueRes && Array.isArray(window.kueRes)) {
setSchleifenwiderstand(window.kueRes);
}
if (window.kueOnline && Array.isArray(window.kueOnline)) {
setKueOnline(window.kueOnline);
}
if (window.kueID && Array.isArray(window.kueID)) {
setKueID(window.kueID);
}
updateAlarmStatus(); // Alarmstatus sofort aktualisieren
})
.catch((error) => {
console.error("Fehler beim Laden der Variablen:", error);
});
}; };
const updateAlarmStatus = () => {
const updatedAlarmStatus = kueIso.map((_, index) => {
return (
(window.kueAlarm1 && window.kueAlarm1[index]) ||
(window.kueAlarm2 && window.kueAlarm2[index]) ||
(window.kueCableBreak && window.kueCableBreak[index]) ||
(window.kueGroundFault && window.kueGroundFault[index])
);
});
// console.log("Aktualisierter alarmStatus:", updatedAlarmStatus);
setAlarmStatus(updatedAlarmStatus); // State für Alarmstatus aktualisieren
};
fetchData(); fetchData();
const interval = setInterval(fetchData, 10000); // alle 5 Sekunden }, [dispatch]);
*/
// Alarmstatus basierend auf Redux-Variablen berechnen
const updateAlarmStatus = () => {
const updatedAlarmStatus = kueIso.map((_, index) => {
return (
(kueAlarm1 && kueAlarm1[index]) ||
(kueAlarm2 && kueAlarm2[index]) ||
(kueCableBreak && kueCableBreak[index]) ||
(kueGroundFault && kueGroundFault[index])
);
});
setAlarmStatus(updatedAlarmStatus);
};
// Alarmstatus initial berechnen und alle 10 Sekunden aktualisieren
useEffect(() => {
updateAlarmStatus();
const interval = setInterval(updateAlarmStatus, 10000);
return () => clearInterval(interval); return () => clearInterval(interval);
}, []); }, [kueIso, kueAlarm1, kueAlarm2, kueCableBreak, kueGroundFault]);
// Zuerst alle Werte der Arrays speichern // Modul- und Rack-Daten aufbereiten
const allModules = kueIso.map((iso, index) => ({ const allModules = kueIso.map((iso, index) => ({
isolationswert: iso, isolationswert: iso,
schleifenwiderstand: schleifenwiderstand[index], schleifenwiderstand: kueRes[index],
modulName: kueID[index] || "Unknown", modulName: kueID[index] || "Unknown",
kueOnlineStatus: kueOnline[index], kueOnlineStatus: kueOnline[index],
alarmStatus: alarmStatus[index],
})); }));
// Dann die Module für jedes Rack in 8er-Gruppen aufteilen
const racks = { const racks = {
rack1: allModules.slice(0, 8), rack1: allModules.slice(0, 8),
rack2: allModules.slice(8, 16), rack2: allModules.slice(8, 16),
rack3: allModules.slice(16, 24), rack3: allModules.slice(16, 24),
rack4: allModules.slice(24, 32), rack4: allModules.slice(24, 32),
}; };
// Log the racks in the console for debugging
/* console.log("Rack 1:", racks.rack1);
console.log("Rack 2:", racks.rack2);
console.log("Rack 3:", racks.rack3);
console.log("Rack 4:", racks.rack4); */
// Function to handle rack change // Funktion zum Wechseln des Racks
const changeRack = (rack) => { const changeRack = (rack) => setActiveRack(rack);
setActiveRack(rack);
};
useEffect(() => {
const script = document.createElement("script");
const environment = process.env.NEXT_PUBLIC_NODE_ENV || "production";
script.src =
environment === "production"
? "CPL?/CPL/SERVICE/kueData.js"
: "/CPLmockData/SERVICE/kueData.js";
script.async = true;
document.body.appendChild(script);
// Cleanup function mit Überprüfung
return () => {
if (script.parentNode === document.body) {
document.body.removeChild(script);
}
};
}, []);
//----------------------------------------------
useEffect(() => {
const fetchData = () => {
const existingScript = document.querySelector(
"script[src*='kueData.js']"
);
// Stelle sicher, dass das Element existiert und ein Kind von `document.body` ist, bevor du es entfernst
if (existingScript && existingScript.parentNode === document.body) {
document.body.removeChild(existingScript);
}
// Füge das Skript erneut hinzu
const script = document.createElement("script");
script.src =
process.env.NODE_ENV === "production"
? "CPL?/CPL/SERVICE/kueData.js" // Produktionspfad
: "/CPLmockData/SERVICE/kueData.js"; // Entwicklungs-Pfad für Mock-Daten
script.async = true;
script.onload = () => {
// Aktualisiere die Variablen nach kurzer Verzögerung, um sicherzustellen, dass sie geladen sind
setTimeout(() => {
if (window.kueIso && Array.isArray(window.kueIso)) {
setKueIso(window.kueIso);
}
if (window.kueRes && Array.isArray(window.kueRes)) {
setSchleifenwiderstand(window.kueRes);
}
if (window.kueOnline && Array.isArray(window.kueOnline)) {
setKueOnline(window.kueOnline);
}
if (window.kueID && Array.isArray(window.kueID)) {
setKueID(window.kueID);
}
updateAlarmStatus(); // Aktualisiere den Alarmstatus
}, 500); // 500 ms Verzögerung, um sicherzustellen, dass die Daten geladen sind
};
document.body.appendChild(script);
};
const updateAlarmStatus = () => {
const updatedAlarmStatus = window.kueIso.map((_, index) => {
return (
(window.kueAlarm1 && window.kueAlarm1[index]) ||
(window.kueAlarm2 && window.kueAlarm2[index]) ||
(window.kueCableBreak && window.kueCableBreak[index]) ||
(window.kueGroundFault && window.kueGroundFault[index])
);
});
// console.log("Aktualisierter alarmStatus:", updatedAlarmStatus);
setAlarmStatus(updatedAlarmStatus); // Setze den aktualisierten Alarmstatus
};
// Lade die Daten sofort und alle 5 Sekunden neu
fetchData();
const interval = setInterval(fetchData, 10000);
return () => clearInterval(interval); // Bereinige das Intervall beim Entladen der Komponente
}, []);
//----------------------------------------------
return ( return (
<div className="bg-gray-100 flex-1 p-6 text-black"> <div className="bg-gray-100 flex-1 p-6 text-black">
<h1 className="text-2xl mb-4">Kabelüberwachung</h1> <h1 className="text-2xl mb-4">Kabelüberwachung</h1>
<div className="mb-4"> <div className="mb-4">
<button {[1, 2, 3, 4].map((rack) => (
onClick={() => changeRack(1)} <button
className={`mr-1 ${ key={rack}
activeRack === 1 onClick={() => changeRack(rack)}
? "bg-littwin-blue text-white p-1 rounded-sm " className={`mr-2 ${
: "bg-gray-300 p-1 text-sm" activeRack === rack
}`} ? "bg-littwin-blue text-white p-1 rounded-sm"
> : "bg-gray-300 p-1 text-sm"
Rack 1 }`}
</button> >
<button Rack {rack}
onClick={() => changeRack(2)} </button>
className={`mr-2 ${ ))}
activeRack === 2
? "bg-littwin-blue text-white p-1 rounded-sm"
: "bg-gray-300 p-1 text-sm"
}`}
>
Rack 2
</button>
<button
onClick={() => changeRack(3)}
className={`mr-2 ${
activeRack === 3
? "bg-littwin-blue text-white p-1 rounded-sm"
: "bg-gray-300 p-1 text-sm"
}`}
>
Rack 3
</button>
<button
onClick={() => changeRack(4)}
className={`mr-2 ${
activeRack === 4
? "bg-littwin-blue text-white p-1 rounded-sm"
: "bg-gray-300 p-1 text-sm"
}`}
>
Rack 4
</button>
</div> </div>
<div className="flex flex-row space-x-4 scale-110 ml-[5%] mt-[5%]"> <div className="flex flex-row space-x-4 scale-110 ml-[5%] mt-[5%]">
{racks[`rack${activeRack}`].map((slot, index) => { {racks[`rack${activeRack}`].map((slot, index) => {
const slotIndex = index + (activeRack - 1) * 8; const slotIndex = index + (activeRack - 1) * 8;
const alarmStatus =
(window.kueAlarm1 && window.kueAlarm1[slotIndex]) ||
(window.kueAlarm2 && window.kueAlarm2[slotIndex]) ||
(window.kueCableBreak && window.kueCableBreak[slotIndex]) ||
(window.kueGroundFault && window.kueGroundFault[slotIndex]);
return ( return (
<div key={index} className="flex"> <div key={index} className="flex">
<Kue705FO <Kue705FO
@@ -235,12 +111,9 @@ function Kabelueberwachung() {
schleifenwiderstand={slot.schleifenwiderstand} schleifenwiderstand={slot.schleifenwiderstand}
modulName={slot.modulName} modulName={slot.modulName}
kueOnline={slot.kueOnlineStatus} kueOnline={slot.kueOnlineStatus}
alarmStatus={alarmStatus} // Pass the calculated alarm status alarmStatus={slot.alarmStatus}
slotIndex={slotIndex} slotIndex={slotIndex}
/> />
{/*
console.log(`Module Data (Rack ${activeRack}, Slot ${index + 1}):`,slot);
*/}
</div> </div>
); );
})} })}

View File

@@ -1,4 +1,4 @@
var last20Messages = ` var win_last20Messages = `
<tr><td>16750</td><td>03501</td><td>2024-10-23 15:08:58:000</td><td>Modul 26 Isofehler kommend</td><td>1</td></tr> <tr><td>16750</td><td>03501</td><td>2024-10-23 15:08:58:000</td><td>Modul 26 Isofehler kommend</td><td>1</td></tr>
<tr><td>16749</td><td>03201</td><td>2024-10-23 15:07:24:000</td><td>Modul 23 Isofehler gehend</td><td>0</td></tr> <tr><td>16749</td><td>03201</td><td>2024-10-23 15:07:24:000</td><td>Modul 23 Isofehler gehend</td><td>0</td></tr>
<tr><td>16748</td><td>03501</td><td>2024-10-23 15:01:52:000</td><td>Modul 26 Isofehler gehend</td><td>0</td></tr> <tr><td>16748</td><td>03501</td><td>2024-10-23 15:01:52:000</td><td>Modul 26 Isofehler gehend</td><td>0</td></tr>

View File

@@ -1,17 +1,17 @@
var appVersion = "0.02"; var win_appVersion = "0.02";
var deviceName = "CPLV4_Maschen"; var win_deviceName = "CPLV4_Maschen";
var mac1 = "0 48 86 81 46 143"; var win_mac1 = "0 48 86 81 46 143";
var mac2 = "0 48 86 81 46 144"; var win_mac2 = "0 48 86 81 46 144";
var ip = "10.10.0.243"; var win_ip = "10.10.0.243";
var subnet = "255.255.255.0"; var win_subnet = "255.255.255.0";
var gateway = "10.10.0.1"; var win_gateway = "10.10.0.1";
var datetime = "23.10.24 15:10:28 Uhr"; var win_datetime = "23.10.24 15:10:28 Uhr";
var opcState = "1"; var win_opcState = "1";
var opcSessions = "0"; var win_opcSessions = "0";
//var opcName="CPL V4 OPC UA Application Deutsche Bahne']'])"; //var opcName="CPL V4 OPC UA Application Deutsche Bahne']'])";
var opcName = "CPL V4 OPC UA Application Deutsche Bahne"; var win_opcName = "CPL V4 OPC UA Application Deutsche Bahne";
var ntp1 = "192.53.103.108"; var win_ntp1 = "192.53.103.108";
var ntp2 = "0.0.0.0"; var win_ntp2 = "0.0.0.0";
var ntp3 = "0.0.0.0"; var win_ntp3 = "0.0.0.0";
var ntpTimezone = "2"; var win_ntpTimezone = "2";
var ntpActive = "1"; var win_ntpActive = "1";

View File

@@ -1,3 +1,13 @@
var de=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; var win_de = [
var counter=[0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000]; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
var flutter=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; 0, 0, 0, 0, 0, 0,
];
var win_counter = [
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0,
];
var win_flutter = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
];

View File

@@ -1,5 +1,5 @@
//Modul vorhanden 1 = vorhanden, 0 = nicht vorhanden //Modul vorhanden 1 = vorhanden, 0 = nicht vorhanden
var kueOnline = [ var win_kueOnline = [
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
]; ];
@@ -8,44 +8,44 @@ var kueOnline = [
/* /*
Das kann sein, muss aber nicht. Hier unten im Testaufbau haben wir nur eine PST-M für alle 32 Kabelüberwachungen. Es kann aber sein das beim Kunden auch für jeden BGT eine PST-M vorhanden ist, also insgesamt 4 Stück. Das kann sein, muss aber nicht. Hier unten im Testaufbau haben wir nur eine PST-M für alle 32 Kabelüberwachungen. Es kann aber sein das beim Kunden auch für jeden BGT eine PST-M vorhanden ist, also insgesamt 4 Stück.
*/ */
var kuePSTmMinus96V = [ var win_kuePSTmMinus96V = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]; ];
//Aderbruch 1 = Fehler, 0 = kein Fehler //Aderbruch 1 = Fehler, 0 = kein Fehler
var kueCableBreak = [ var win_kueCableBreak = [
1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 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, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1,
]; ];
//Erdschluss 1 = Fehler, 0 = kein Fehler //Erdschluss 1 = Fehler, 0 = kein Fehler
var kueGroundFault = [ var win_kueGroundFault = [
1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]; ];
//Isolationsfehler 1 = Fehler, 0 = kein Fehler, Alarm kommt wenn kueIso < kueLimit1 //Isolationsfehler 1 = Fehler, 0 = kein Fehler, Alarm kommt wenn kueIso < kueLimit1
var kueAlarm1 = [ var win_kueAlarm1 = [
1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]; ];
//Schleifenfehler 1 = Fehler, 0 = kein Fehler //Schleifenfehler 1 = Fehler, 0 = kein Fehler
var kueAlarm2 = [ var win_kueAlarm2 = [
1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]; ];
//Überlauf 1 = Fehler, 0 = kein Fehler , hier wird in Display ">200 MOhm" angezeigt //Überlauf 1 = Fehler, 0 = kein Fehler , hier wird in Display ">200 MOhm" angezeigt
var kueOverflow = [ var win_kueOverflow = [
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, 0, 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, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]; ];
//--------------------------------------------------- //---------------------------------------------------
//Isolationswerte in Display (isoDisplay) Einheit: MOhm //Isolationswerte in Display (isoDisplay) Einheit: MOhm
var kueIso = [ var win_kueIso = [
10.0, 10.0, 10.0, 10.5, 10.0, 10.0, 10.0, 10.0, 10.5, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.5, 10.0, 10.0, 10.0, 10.0, 10.5, 10.0, 10.0, 10.0, 10.0,
10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.5, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.5, 10.0, 10.0, 10.0, 10.0, 10.0,
10.5, 10.0, 200.0, 200.0, 200.0, 200.0, 10.5, 10.0, 200.0, 200.0, 200.0, 200.0,
]; ];
//Grenzwert (MOhm) für Isolationswiderstand //Grenzwert (MOhm) für Isolationswiderstand
var kueLimit1 = [ var win_kueLimit1 = [
9, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 9, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0,
10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0,
10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0,
@@ -60,40 +60,40 @@ Wenn der Widerstand innerhalb dieser 420 Sekunden wieder über den Grenzwert ste
die Filterzeit startet beim nächsten Unterschreiten des Grenzwerts neu. Die Filterzeit verhindert also, dass die Filterzeit startet beim nächsten Unterschreiten des Grenzwerts neu. Die Filterzeit verhindert also, dass
kurzfristige Schwankungen oder Störungen fälschlicherweise als Fehler gemeldet werden. kurzfristige Schwankungen oder Störungen fälschlicherweise als Fehler gemeldet werden.
*/ */
var kueDelay1 = [ var win_kueDelay1 = [
10, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 10, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420,
420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, 420,
420, 420,
]; ];
//--------------------------------------------------- //---------------------------------------------------
//Schleifenwiderstand in Display (resDisplay) Einheit: KOhm //Schleifenwiderstand in Display (resDisplay) Einheit: KOhm
var kueRes = [ var win_kueRes = [
0.0, 0.612, 0.0, 0.645, 0.822, 0.97, 0.0, 0.0, 1.452, 0.0, 0.734, 0.37, 0.566, 0.0, 0.612, 0.0, 0.645, 0.822, 0.97, 0.0, 0.0, 1.452, 0.0, 0.734, 0.37, 0.566,
0.0, 0.738, 0.684, 1.166, 0.595, 0.0, 1.651, 1.18, 1.387, 1.214, 0.0, 1.475, 0.0, 0.738, 0.684, 1.166, 0.595, 0.0, 1.651, 1.18, 1.387, 1.214, 0.0, 1.475,
0.615, 0.494, 1.217, 65.0, 65.0, 65.0, 65.0, 0.615, 0.494, 1.217, 65.0, 65.0, 65.0, 65.0,
]; ];
//Schleifenmessung Unterer Grenzwert (KOhm) //Schleifenmessung Unterer Grenzwert (KOhm)
var kueLimit2Low = [ var win_kueLimit2Low = [
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1,
]; ];
//Schleifenintervall (h) für Schleifenmessung //Schleifenintervall (h) für Schleifenmessung
var kueLoopInterval = [ var win_kueLoopInterval = [
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
]; ];
//--------------------------------------------------- //---------------------------------------------------
//KÜ Modul Version soll /100 und davor V angezeigt werden z.B. 4.19V //KÜ Modul Version soll /100 und davor V angezeigt werden z.B. 4.19V
var kueVersion = [ var win_kueVersion = [
419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419,
419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, 419,
419, 419, 419, 419,
]; ];
//Modulname in Komponente und auf der Anzeige //Modulname in Komponente und auf der Anzeige
var kueID = [ var win_kueID = [
"FTZ_2", "FTZ_2",
"B23", "B23",
"Kabel 3", "Kabel 3",
@@ -130,43 +130,43 @@ var kueID = [
//--------------------------------------------------- //---------------------------------------------------
var kueResidence = [ var win_kueResidence = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]; ];
//TDR--------------------------------------------------- //TDR---------------------------------------------------
var tdrAtten = [ var win_tdrAtten = [
2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0,
2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0,
2.0, 2.0, 2.0, 2.0,
]; ];
var tdrPulse = [ var win_tdrPulse = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]; ];
var tdrSpeed = [ var win_tdrSpeed = [
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100,
]; ];
var tdrAmp = [ var win_tdrAmp = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]; ];
var tdrTrigger = [ var win_tdrTrigger = [
80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
]; ];
var tdrLocation = [ var win_tdrLocation = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]; ];
var tdrActive = [ var win_tdrActive = [
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, 0, 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, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]; ];
var tdrLast = [ var win_tdrLast = [
"2024-10-17 07:51:54:000", "2024-10-17 07:51:54:000",
"2024-09-30 08:38:50:000", "2024-09-30 08:38:50:000",
"?", "?",

View File

@@ -13,7 +13,7 @@ const initialState = {
ntp1: null, ntp1: null,
ntp2: null, ntp2: null,
ntp3: null, ntp3: null,
zeitzone: null, ntpTimezone: null,
ntpActive: null, ntpActive: null,
de: null, de: null,
counter: null, counter: null,

View File

@@ -2,46 +2,47 @@
export async function loadWindowVariables() { export async function loadWindowVariables() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const requiredVars = [ const requiredVars = [
"last20Messages", "win_last20Messages",
"deviceName", "win_deviceName",
"mac1", "win_mac1",
"mac2", "win_mac2",
"ip", "win_ip",
"subnet", "win_subnet",
"gateway", "win_gateway",
"datetime", "win_datetime",
"ntp1", "win_ntp1",
"ntp2", "win_ntp2",
"ntp3", "win_ntp3",
"systemZeit", "win_systemZeit",
"ntpTimezone", "win_ntpTimezone",
"ntpActive", "win_ntpActive",
"de", "win_de",
"counter", "win_counter",
"flutter", "win_flutter",
"kueOnline", "win_kueOnline",
"kueID", "win_kueID",
"kueAlarm1", "win_kueAlarm1",
"kueAlarm2", "win_kueAlarm2",
"kueRes", "win_kueIso",
"kueCableBreak", "win_kueRes",
"kueGroundFault", "win_kueCableBreak",
"kueLimit1", "win_kueGroundFault",
"kueLimit2Low", "win_kueLimit1",
"kueDelay1", "win_kueLimit2Low",
"kueLoopInterval", "win_kueDelay1",
"kueVersion", "win_kueLoopInterval",
"tdrAtten", "win_kueVersion",
"tdrPulse", "win_tdrAtten",
"tdrSpeed", "win_tdrPulse",
"tdrAmp", "win_tdrSpeed",
"tdrTrigger", "win_tdrAmp",
"tdrLocation", "win_tdrTrigger",
"tdrActive", "win_tdrLocation",
"kueOverflow", "win_tdrActive",
"kueResidence", "win_kueOverflow",
"tdrLast", "win_kueResidence",
"appVersion", "win_tdrLast",
"win_appVersion",
]; ];
const loadScript = (src) => { const loadScript = (src) => {
@@ -69,7 +70,7 @@ export async function loadWindowVariables() {
.then(() => { .then(() => {
const variablesObj = requiredVars.reduce((acc, variable) => { const variablesObj = requiredVars.reduce((acc, variable) => {
if (window[variable] !== undefined) { if (window[variable] !== undefined) {
acc[variable] = window[variable]; acc[variable.replace("win_", "")] = window[variable]; // Entferne "win_" beim Speichern in Redux
} }
return acc; return acc;
}, {}); }, {});