diff --git a/app/json/page.jsx b/app/json/page.jsx
new file mode 100644
index 0000000..ffc0dca
--- /dev/null
+++ b/app/json/page.jsx
@@ -0,0 +1,20 @@
+"use client"; // Wichtiger Hinweis, wenn du Next.js App Router verwendest
+
+import { useEffect } from "react";
+
+export default function Json() {
+ // Beispielvariable
+ const myVariable = "<%=KIZ0%>";
+
+ // useEffect, um sicherzustellen, dass die Konsole nach dem Laden der Seite ausgeführt wird
+ useEffect(() => {
+ console.log("Die Variable ist: ", myVariable);
+ }, []); // Der leere Array sorgt dafür, dass es nur einmal beim Laden der Komponente ausgeführt wird
+
+ return (
+
+
Json Page
+
Überprüfe die Konsole, um die Variable zu sehen.
+
+ );
+}
diff --git a/components/modules/Kue705FO.jsx b/components/modules/Kue705FO.jsx
index c3755cb..d2ff9bc 100644
--- a/components/modules/Kue705FO.jsx
+++ b/components/modules/Kue705FO.jsx
@@ -1,14 +1,16 @@
-import React, { useState } from "react";
+import React, { useState, useEffect } from "react";
+import ReactModal from "react-modal";
+import Chart from "chart.js/auto";
import KueModal from "../modales/KueModal";
function Kue705FO({
- isolationswert, // Übergabeparameter für den Isolationswert
- schleifenwiderstand, // Übergabeparameter für den Schleifenwiderstand
- modulName, // Übergabeparameter für den Modulnamen
- kueVersion = "V4.19", // Optionaler Parameter für die Version (Standardwert)
- kueOnline, // Array für den Modulstatus (1: Modul vorhanden, 0: kein Modul)
- slotIndex, // Der Index des Slots, für den die Anzeige gilt
- tdrLocation, // Wert für die TDR-Entfernung
+ isolationswert,
+ schleifenwiderstand,
+ modulName,
+ kueVersion = "V4.19",
+ kueOnline,
+ slotIndex,
+ tdrLocation,
}) {
const [currentModulName, setCurrentModulName] = useState(modulName);
const [activeButton, setActiveButton] = useState("Schleife");
@@ -16,9 +18,11 @@ function Kue705FO({
const [loading, setLoading] = useState(false);
const [currentDisplayValue, setCurrentDisplayValue] = useState(
schleifenwiderstand || "0"
- ); // Wert, der im unteren Display angezeigt wird
- //--Modales Fenster
+ );
const [showModal, setShowModal] = useState(false);
+ const [showChartModal, setShowChartModal] = useState(false); // Modal für die Messkurve
+ const [chartData, setChartData] = useState(null); // State für die geladene Chart-Daten
+
const handleOpenModal = () => {
setShowModal(true);
};
@@ -26,23 +30,83 @@ function Kue705FO({
const handleCloseModal = () => {
setShowModal(false);
};
- //----
- // Funktion zum Wechseln der Buttons und Anpassen des Anzeigewerts
- const handleButtonClick = (button) => {
- if (button === "Schleife") {
- setActiveButton("Schleife");
- setDisplayText("Schleifenwiderstand [kOhm]");
- setCurrentDisplayValue(schleifenwiderstand || "0");
- } else if (button === "TDR") {
- setActiveButton("TDR");
- setDisplayText("Entfernung [Km]");
- setCurrentDisplayValue(tdrLocation || "0");
- }
+
+ // Funktion zum Anzeigen des Chart-Modals
+ const handleOpenChartModal = () => {
+ setShowChartModal(true);
+ loadChartData(); // Lade die Daten, wenn das Modal geöffnet wird
+ };
+
+ const handleCloseChartModal = () => {
+ setShowChartModal(false);
+ };
+
+ // Daten laden und den Chart erstellen
+ const loadChartData = () => {
+ const slot = slotIndex;
+ const fileData = `../cpl?4000values/slot${slot}.json`; // Je nach Slot wird die entsprechende Datei geladen
+
+ fetch(fileData)
+ .then((response) => response.json())
+ .then((data) => {
+ setChartData(data); // Daten setzen
+ createChart(data);
+ })
+ .catch((error) => {
+ console.error("Fehler beim Laden der Messkurvendaten:", error);
+ });
+ };
+
+ // Funktion zum Erstellen des Charts
+ const createChart = (data) => {
+ const ctx = document.getElementById("myChart").getContext("2d");
+
+ new Chart(ctx, {
+ type: "line",
+ data: {
+ labels: data.map((row) => row.t), // Zeitwerte
+ datasets: [
+ {
+ label: "Isolationswiderstand",
+ data: data.map((row) => row.m),
+ borderColor: "#00AEEF",
+ fill: false,
+ yAxisID: "y",
+ },
+ {
+ label: "Schleifenwiderstand",
+ data: data.map((row) => row.n),
+ borderColor: "black",
+ fill: false,
+ yAxisID: "y1",
+ },
+ {
+ label: "Messung gültig",
+ data: data.map((row) => row.v),
+ borderColor: "gray",
+ fill: false,
+ yAxisID: "y1",
+ },
+ ],
+ },
+ options: {
+ scales: {
+ y: {
+ type: "linear",
+ position: "left",
+ },
+ y1: {
+ type: "linear",
+ position: "right",
+ },
+ },
+ },
+ });
};
// Funktion für die TDR-Messung
const goTDR = () => {
- let slot = slotIndex; // Verwende direkt slotIndex, da Slot 0 der erste Slot ist
+ let slot = slotIndex;
if (slot >= 32) {
return;
@@ -51,7 +115,7 @@ function Kue705FO({
let slotFormat = slot < 10 ? `0${slot}` : `${slot}`;
const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
- setLoading(true); // Ladezustand setzen
+ setLoading(true);
fetch(
`${apiUrl}/CPL?Service/KUEdetailTDR.ACP&KTT${slotFormat}=1&slot=${slot}`,
{
@@ -68,12 +132,12 @@ function Kue705FO({
.catch((error) => {
console.error("Fehler:", error);
})
- .finally(() => setLoading(false)); // Ladezustand wieder deaktivieren
+ .finally(() => setLoading(false));
};
// Funktion für die Schleifenmessung
const goLoop = () => {
- let slot = slotIndex; // Verwende direkt slotIndex
+ let slot = slotIndex;
if (slot >= 32) {
return;
@@ -82,7 +146,7 @@ function Kue705FO({
let slotFormat = slot < 10 ? `0${slot}` : `${slot}`;
const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
- setLoading(true); // Ladezustand setzen
+ setLoading(true);
fetch(
`${apiUrl}/CPL?Service/KUEdetail.HTML&KS_${slotFormat}=1&slot=${slot}`,
{
@@ -99,31 +163,34 @@ function Kue705FO({
.catch((error) => {
console.error("Fehler:", error);
})
- .finally(() => setLoading(false)); // Ladezustand wieder deaktivieren
+ .finally(() => setLoading(false));
+ };
+
+ const handleModulNameChange = (newName) => {
+ setCurrentModulName(newName);
};
// Überprüfe, ob ein Modul im Slot vorhanden ist
const isModulPresent = kueOnline[slotIndex] === 1;
- // 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 handleButtonClick = (button) => {
+ if (button === "Schleife") {
+ setActiveButton("Schleife");
+ setDisplayText("Schleifenwiderstand [kOhm]");
+ setCurrentDisplayValue(schleifenwiderstand || "0");
+ } else if (button === "TDR") {
+ setActiveButton("TDR");
+ setDisplayText("Entfernung [Km]");
+ setCurrentDisplayValue(tdrLocation || "0");
}
};
- const handleModulNameChange = (newName) => {
- setCurrentModulName(newName); // Aktualisiere den Namen direkt in Kue705FO
- };
-
return (
{isModulPresent ? (
<>
-
+
{slotIndex + 1}
@@ -137,16 +204,13 @@ function Kue705FO({
⚙
- {/* Modal */}
+
-
Modul Einstellungen
-
Hier kannst du Einstellungen für {modulName} vornehmen.
-
+ />
@@ -169,15 +233,6 @@ function Kue705FO({
- {/* Modal zum Ändern des Modulnamens */}
-
-
- {/* Modulname */}
{currentModulName || "Test1"}
@@ -192,12 +247,10 @@ function Kue705FO({
{displayText}
- {/* Unterer Bereich, der den dynamischen Wert anzeigt */}