fix: Darstellung der Isolationsanzeige angepasst

- ">200 MOhm" wird nun als neutraler Wert angezeigt und nicht in Rot, da es auf eine gute Kabelisolation hinweist.
- Rote Textfarbe bleibt auf Fehlerbeschränkungen wie Aderbruch, Erdschluss, Isolations- und Schleifenfehler begrenzt.
- Code-Bedingungen für die Prioritätsanzeige optimiert, um korrekte Farbzuordnung und Alarmauslösung sicherzustellen.
This commit is contained in:
ISA
2024-10-29 13:25:13 +01:00
parent 580452574d
commit b1a24a3f4e
8 changed files with 139 additions and 181 deletions

View File

@@ -3,7 +3,6 @@
import React, { useEffect, useState } from "react";
import Image from "next/image";
import "bootstrap-icons/font/bootstrap-icons.css";
//import { loadWindowVariables } from "../utils/loadWindowVariables";
import SettingsModal from "./modales/SettingsModal";
function Header() {
@@ -13,14 +12,17 @@ function Header() {
// Flag außerhalb des State-Managements, um die Ausgabe nur einmal zu loggen
let variablesLogged = false;
useEffect(() => {
if (!variablesLogged) {
variablesLogged = true; // Setze das Flag, um das erneute Loggen zu verhindern
}
const interval = setInterval(() => {
if (localStorage.getItem("variablesLoaded") === "true") {
// Lade die Werte nur, wenn die Variablen tatsächlich geladen wurden
setStationsname(window.deviceName || "Unbekannt");
setCplStatus(window.hardware_version || "Unbekannt");
clearInterval(interval); // Beende das Intervall, sobald die Werte gesetzt sind
}
}, 500); // Prüfe das Flag alle 500 ms
setStationsname(window.deviceName || "Unbekannt");
setCplStatus(window.hardware_version || "Unbekannt");
return () => clearInterval(interval);
}, []);
const handleSettingsClick = () => setShowSettingsModal(true);

View File

@@ -272,7 +272,7 @@ function KueModal({ showModal, onClose, slot, onModulNameChange }) {
<thead className="bg-gray-100">
<tr>
<th className="p-2 border text-sm text-center">
Unterer Grenzwert (kOhm)
Grenzwert (kOhm)
</th>
<th className="p-2 border text-sm text-center">

View File

@@ -28,6 +28,7 @@ function Kue705FO({
useState("Schleifenfehler");
const [isoFaultDisplayText, setIsoFaultDisplayText] =
useState("Isolationsfehler");
const [isoGreaterThan200, setIsoGreaterThan200] = useState(">200 MOhm");
const [loading, setLoading] = useState(false);
const [currentDisplayValue, setCurrentDisplayValue] = useState(
@@ -320,122 +321,8 @@ function Kue705FO({
return () => clearInterval(interval); // Bereinigung bei Entladen der Komponente
}, [slotIndex]);
//-------------------------------------------------
// Intervall für den Wechsel der Anzeige zwischen "Aderbruch" und dem Icon
useEffect(() => {
if (window.kueCableBreak[slotIndex] === 1) {
const intervalId = setInterval(() => {
setIsoDisplayText((prevText) =>
prevText === "Aderbruch" ? (
<i
className="bi bi-exclamation-triangle"
style={{ fontSize: "24px" }}
></i>
) : (
"Aderbruch"
)
);
}, 2000); // Wechselt alle 2 Sekunden zwischen Text und Icon
// Setze den Isolationswert auf einen leeren String bei Aderbruch
setCurrentDisplayValue("");
return () => clearInterval(intervalId);
} else {
// Zeigt den tatsächlichen Isolationswert, wenn kein Aderbruch vorliegt
setCurrentDisplayValue(isolationswert || ">200");
setIsoDisplayText("");
}
}, [slotIndex, isolationswert]);
//-------------------------------------------------
// Intervall für den Wechsel der Anzeige zwischen "Erdschluss" und dem Icon
useEffect(() => {
if (window.kueGroundFault[slotIndex] === 1) {
const intervalId = setInterval(() => {
setGroundFaultDisplayText((prevText) =>
prevText === "Erdschluss" ? (
<i
className="bi bi-exclamation-triangle"
style={{ fontSize: "24px" }}
></i>
) : (
"Erdschluss"
)
);
}, 2000); // Wechselt alle 2 Sekunden zwischen Text und Icon
// Setze den Isolationswert auf einen leeren String bei Erdschluss
setCurrentDisplayValue("");
return () => clearInterval(intervalId);
} else {
// Zeigt den tatsächlichen Isolationswert, wenn kein Erdschluss vorliegt
setCurrentDisplayValue(isolationswert || ">200");
setGroundFaultDisplayText("");
}
}, [slotIndex, isolationswert]);
//-------------------------------------------------
// Intervall für den Wechsel der Anzeige zwischen "Schleifenfehler" und dem Icon
useEffect(() => {
if (window.kueAlarm2[slotIndex] === 1) {
const intervalId = setInterval(() => {
setLoopFaultDisplayText((prevText) =>
prevText === "Schleifenfehler" ? (
<i
className="bi bi-exclamation-triangle"
style={{ fontSize: "24px" }}
></i>
) : (
"Schleifenfehler"
)
);
}, 2000); // Wechselt alle 2 Sekunden zwischen Text und Icon
// Setze den schleifenwiderstand auf einen leeren String bei Alarm
setCurrentDisplayValue("");
return () => clearInterval(intervalId);
} else {
// Zeigt den tatsächlichen schleifenwiderstand, wenn kein Alarm vorliegt
setCurrentDisplayValue(schleifenwiderstand || "0");
setLoopFaultDisplayText("");
}
}, [slotIndex, schleifenwiderstand]);
//------------------------------------------------
// Intervall für den Wechsel der Anzeige zwischen "Isolationsfehler" und dem Icon
useEffect(() => {
if (window.kueAlarm1[slotIndex] === 1) {
const intervalId = setInterval(() => {
setIsoFaultDisplayText((prevText) =>
prevText === "Isolationsfehler" ? (
<i
className="bi bi-exclamation-triangle"
style={{ fontSize: "24px" }}
></i>
) : (
"Isolationsfehler"
)
);
}, 2000); // Wechselt alle 2 Sekunden zwischen Text und Icon
// Setze den isolationswert auf einen leeren String bei Alarm
setCurrentDisplayValue("");
return () => clearInterval(intervalId);
} else {
// Zeigt den tatsächlichen isolationswert, wenn kein Alarm vorliegt
setCurrentDisplayValue(isolationswert || ">200");
setIsoFaultDisplayText("");
}
}, [slotIndex, isolationswert]);
//------------------------------------------------
// Dynamischer Abruf des kueVersion-Werts für jeden Slot
// Dynamischer Abruf des kueVersion-Werts für jeden Slot in Intervallen
useEffect(() => {
const intervalId = setInterval(() => {
@@ -448,11 +335,90 @@ function Kue705FO({
return () => clearInterval(intervalId);
}, [slotIndex]);
//-------------------------------------------------
//-------------------------------------------------
// Priority: Aderbruch - Erdschluss - Isolationsfehler - Schleifenfehler - Overflow (>200 MOhm) - Messwert
// Prioritätsprüfung in updateDisplay
useEffect(() => {
const updateDisplay = () => {
console.log("Prüfen der window-Variablen:");
console.log("kueCableBreak:", window.kueCableBreak);
console.log("kueGroundFault:", window.kueGroundFault);
console.log("kueAlarm1:", window.kueAlarm1);
console.log("kueAlarm2:", window.kueAlarm2);
console.log("kueOverflow:", window.kueOverflow);
if (
!window.kueCableBreak ||
!window.kueGroundFault ||
!window.kueAlarm1 ||
!window.kueAlarm2 ||
!window.kueOverflow
) {
console.log("Warten auf window Variablen...");
setTimeout(updateDisplay, 100);
return;
}
console.log(
"Alle window-Variablen sind verfügbar. Beginne mit den Prioritätsprüfungen..."
);
// Aderbruch
if (window.kueCableBreak[slotIndex] === 1) {
console.log("Aderbruch erkannt für Slot", slotIndex);
setCurrentDisplayValue(isoDisplayText);
return;
}
// Erdschluss
else if (window.kueGroundFault[slotIndex] === 1) {
console.log("Erdschluss erkannt für Slot", slotIndex);
setCurrentDisplayValue(groundFaultDisplayText);
return;
}
// Isolationsfehler
else if (window.kueAlarm1[slotIndex] === 1) {
console.log("Isolationsfehler erkannt für Slot", slotIndex);
setCurrentDisplayValue(isoFaultDisplayText);
return;
}
// Schleifenfehler
else if (window.kueAlarm2[slotIndex] === 1) {
console.log("Schleifenfehler erkannt für Slot", slotIndex);
setCurrentDisplayValue(loopFaultDisplayText);
return;
}
// Overflow (>200 MOhm)
else if (window.kueOverflow[slotIndex] === 1) {
console.log(
"Overflow erkannt für Slot",
slotIndex,
"- Anzeige: '>200'"
);
setCurrentDisplayValue(isoGreaterThan200);
return;
}
// Kein Fehler
else {
console.log(
"Kein Fehler erkannt, zeige Standardisolationswert an für Slot",
slotIndex
);
setCurrentDisplayValue(isolationswert); // Nur Isolationswert ohne ">200" als Fallback
}
};
updateDisplay(); // Initialer Aufruf
const interval = setInterval(updateDisplay, 5000); // Regelmäßige Überprüfung
return () => clearInterval(interval); // Bereinigung bei Entladen der Komponente
}, [slotIndex, isolationswert]);
//-------------------------------------------------
return (
<div className="relative bg-gray-300 w-[116px] h-[390px] border border-gray-400 scale-110 top-3">
{isModulPresent ? (
{kueOnline === 1 ? (
<>
<div className="relative w-[113.202px] h-[242.492px] bg-littwin-blue border-[1.5px] border-gray-400 z-0">
<div className="flex items-start justify-between h-[30px]">
@@ -493,7 +459,7 @@ function Kue705FO({
<span className="text-white text-[10px]">Alarm</span>
</div>
</div>
{/* Anzeige für Isolationsfehler, Aderbruch, Erdschluss oder Schleifenfehler */}
{/* 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="text-center">
<span
@@ -503,24 +469,19 @@ function Kue705FO({
window.kueAlarm1[slotIndex] === 1 ||
window.kueAlarm2[slotIndex] === 1
? "text-red-500 text-[14px]" // Rot und kleinere Schrift für Alarme
: window.kueOverflow[slotIndex] === 1 //Sehr hoher Isolationswiderstand , ein sehr gutes Kabel
? "text-white text-[14px]" // Neutrale Farbe für >200 MOhm-Anzeige
: ""
}
>
{/* Zeigt den entsprechenden Fehler oder den Isolationswert */}
{window.kueCableBreak[slotIndex] === 1
? isoDisplayText // Aderbruch-Anzeige
: window.kueGroundFault[slotIndex] === 1
? groundFaultDisplayText // Erdschluss-Anzeige
: window.kueAlarm1[slotIndex] === 1
? isoFaultDisplayText // Isolationsfehler-Anzeige mit Icon
: window.kueAlarm2[slotIndex] === 1
? loopFaultDisplayText // Schleifenfehler-Anzeige mit Icon
: isolationswert || ">200"}{" "}
{currentDisplayValue}
</span>
{window.kueCableBreak[slotIndex] !== 1 &&
window.kueGroundFault[slotIndex] !== 1 &&
window.kueAlarm1[slotIndex] !== 1 &&
window.kueAlarm2[slotIndex] !== 1 && (
window.kueAlarm2[slotIndex] !== 1 &&
window.kueOverflow[slotIndex] !== 1 && (
<div className="text-[8px]">ISO MOhm</div>
)}
</div>
@@ -537,6 +498,7 @@ function Kue705FO({
{kueVersion}
</div>
</div>
{/* loopDisplay: Zeigt Schleifenwiderstand oder TDR-Distanz an, je nach Modus */}
<div className="absolute bottom-1 left-[1.095px] w-[113.182px] h-[130px] bg-gray-300 border-[1.5px] border-gray-400 p-1">
<span className="text-black text-[7px] absolute top-[2px] left-1 mt-1">

View File

@@ -22,7 +22,6 @@ function MyApp({ Component, pageProps }) {
datetime: window.datetime,
kueOnline: window.kueOnline,
kueIso: window.kueIso,
kueValid: window.kueValid,
kueAlarm1: window.kueAlarm1,
kueAlarm2: window.kueAlarm2,
kueRes: window.kueRes,
@@ -30,16 +29,12 @@ function MyApp({ Component, pageProps }) {
kueGroundFault: window.kueGroundFault,
kueLimit1: window.kueLimit1,
kueLimit2Low: window.kueLimit2Low,
kueLimit2High: window.kueLimit2High,
kueDelay1: window.kueDelay1,
kueLoopInterval: window.kueLoopInterval,
kueID: window.kueID,
kueName: window.kueName,
kueVersion: window.kueVersion,
kueOverflow: window.kueOverflow,
kue100V: window.kue100V,
kueResidence: window.kueResidence,
kueBooting: window.kueBooting,
tdrAtten: window.tdrAtten,
tdrPulse: window.tdrPulse,
tdrSpeed: window.tdrSpeed,
@@ -49,6 +44,7 @@ function MyApp({ Component, pageProps }) {
tdrActive: window.tdrActive,
tdrLast: window.tdrLast,
});
localStorage.setItem("variablesLoaded", "true");
})
.catch((error) => {
console.error("Error loading window variables:", error);

View File

@@ -148,19 +148,19 @@ function Dashboard() {
<table className="min-w-full border border-gray-200 text-left">
<thead className="bg-gray-100 border-b border-gray-300">
<tr>
<th className="py-3 px-4 text-gray-700 text-sm font-medium">
<th className="py-1 px-4 text-gray-700 text-sm font-medium">
ID
</th>
<th className="py-3 px-4 text-gray-700 text-sm font-medium">
<th className="py-1 px-4 text-gray-700 text-sm font-medium">
Modul
</th>
<th className="py-3 px-4 text-gray-700 text-sm font-medium">
<th className="py-1 px-4 text-gray-700 text-sm font-medium">
Zeitstempel
</th>
<th className="py-3 px-4 text-gray-700 text-sm font-medium w-2/3">
<th className="py-1 px-4 text-gray-700 text-sm font-medium w-2/3">
Meldung
</th>
<th className="py-3 px-4 text-gray-700 text-sm font-medium">
<th className="py-1 px-4 text-gray-700 text-sm font-medium">
Status
</th>
</tr>
@@ -172,21 +172,21 @@ function Dashboard() {
key={index}
className="border-b border-gray-200 hover:bg-gray-50"
>
<td className="py-1 px-4 w-1/7">{columns[0]}</td>
<td className="py-1 px-4 w-1/7">{columns[1]}</td>
<td className="py-1 px-4 w-3/7 whitespace-nowrap">
<td className="px-4 w-1/7">{columns[0]}</td>
<td className="px-4 w-1/7">{columns[1]}</td>
<td className="px-4 w-3/7 whitespace-nowrap">
<div className="flex flex-row space-x-2">
<span>{columns[2].split(" ")[0]}</span>
<span>{columns[2].split(" ")[1]}</span>
</div>
</td>
<td className="py-1 px-4 w-2/7">{columns[3]}</td>
<td className="py-1 px-4 w-1/7">{columns[4]}</td>
<td className="px-4 w-2/7">{columns[3]}</td>
<td className="px-4 w-1/7">{columns[4]}</td>
</tr>
))
) : (
<tr>
<td className="py-3 px-4 text-center" colSpan="5">
<td className="px-4 text-center" colSpan="5">
Keine Meldungen verfügbar.
</td>
</tr>

View File

@@ -94,21 +94,22 @@ function Kabelueberwachung() {
useEffect(() => {
const script = document.createElement("script");
// Dynamischer Pfad basierend auf der Umgebung
const environment = process.env.NEXT_PUBLIC_NODE_ENV || "production";
if (environment === "production") {
script.src = `CPL?/CPL/SERVICE/kueData.js`; // Produktions-Pfad
} else {
script.src = `/CPLmockData/SERVICE/kueData.js`; // Mock-Daten-Pfad
}
script.src =
environment === "production"
? "CPL?/CPL/SERVICE/kueData.js"
: "/CPLmockData/SERVICE/kueData.js";
script.async = true;
document.body.appendChild(script);
// Cleanup the script if the component unmounts
// Cleanup function mit Überprüfung
return () => {
document.body.removeChild(script);
if (script.parentNode === document.body) {
document.body.removeChild(script);
}
};
}, []);
//----------------------------------------------
useEffect(() => {
const fetchData = () => {

View File

@@ -14,6 +14,21 @@ var kueGroundFault = [
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,
];
//Isolationsfehler 1 = Fehler, 0 = kein Fehler, Alarm kommt wenn kueIso < kueLimit1
var kueAlarm1 = [
0, 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,
];
//Schleifenfehler 1 = Fehler, 0 = kein Fehler
var kueAlarm2 = [
0, 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,
];
//Überlauf 1 = Fehler, 0 = kein Fehler , hier wird in Display ">200 MOhm" angezeigt
var kueOverflow = [
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,
0, 0, 0, 0, 0, 0,
];
//---------------------------------------------------
//Isolationswerte in Display (isoDisplay) Einheit: MOhm
var kueIso = [
@@ -23,15 +38,11 @@ var kueIso = [
];
//Grenzwert (MOhm) für Isolationswiderstand
var kueLimit1 = [
13.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,
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,
];
//Isolationsfehler 1 = Fehler, 0 = kein Fehler, Alarm kommt wenn kueIso < kueLimit1
var kueAlarm1 = [
0, 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,
];
/*
Verzögerung/Filterzeit 420 Sekunden Standardeinstellung
In dem Beispiel muss der Isolationswiderstand für die gesamte Filterzeit von 420 Sekunden
@@ -42,9 +53,9 @@ die Filterzeit startet beim nächsten Unterschreiten des Grenzwerts neu. Die Fil
kurzfristige Schwankungen oder Störungen fälschlicherweise als Fehler gemeldet werden.
*/
var kueDelay1 = [
410, 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,
];
//---------------------------------------------------
//Schleifenwiderstand in Display (resDisplay) Einheit: KOhm
@@ -60,11 +71,6 @@ var kueLimit2Low = [
0.1, 0.1,
];
//Schleifenfehler 1 = Fehler, 0 = kein Fehler
var 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,
0, 0, 0, 0, 0, 0,
];
//Schleifenintervall (h) für Schleifenmessung
var 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,
@@ -116,11 +122,6 @@ var kueID = [
//---------------------------------------------------
var kueOverflow = [
0, 0, 0, 0, 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,
];
var 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,

View File

@@ -16,7 +16,6 @@ export async function loadWindowVariables() {
"flutter",
"kueOnline",
"kueID",
"kueValid",
"kueAlarm1",
"kueAlarm2",
"kueRes",
@@ -24,7 +23,6 @@ export async function loadWindowVariables() {
"kueGroundFault",
"kueLimit1",
"kueLimit2Low",
"kueLimit2High",
"kueDelay1",
"kueLoopInterval",
"kueVersion",
@@ -36,10 +34,8 @@ export async function loadWindowVariables() {
"tdrLocation",
"tdrActive",
"kueOverflow",
"kue100V",
"kueResidence",
"tdrLast",
"kueBooting",
"appVersion",
];