From 597b0a260de8b22d0d8a9855a4366843340b56ea Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 16 Oct 2024 09:26:05 +0200 Subject: [PATCH] Schleifenmessung starten mit goLoop Funktion --- components/modules/Kue705FO.jsx | 75 +++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/components/modules/Kue705FO.jsx b/components/modules/Kue705FO.jsx index 3ccbbf2..1e5f3f0 100644 --- a/components/modules/Kue705FO.jsx +++ b/components/modules/Kue705FO.jsx @@ -38,21 +38,52 @@ function Kue705FO({ slot: slot, }; - // Die Basis-URL von der Umgebungsvariable holen const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL; - // Sende die POST-Anfrage an den Server mit der Basis-URL fetch(`${apiUrl}/CPL?Service/KUEdetailTDR.ACP`, { method: "POST", headers: { "Content-Type": "application/json", }, - body: JSON.stringify(data), // Konvertiere die Daten in JSON-Format + body: JSON.stringify(data), + }) + .then((response) => { + if (response.ok) { + console.log("POST erfolgreich gesendet für Slot", slot); + } else { + console.error("Fehler beim Senden der POST-Anfrage"); + } + }) + .catch((error) => { + console.error("Fehler:", error); + }); + }; + + const goLoop = () => { + let slot = slotIndex + 1; + + if (slot >= 32) { + return; + } + + let slotFormat = slot < 10 ? `0${slot}` : `${slot}`; + const data = { + [`KS_${slotFormat}`]: 1, + slot: slot, + }; + + const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL; + + fetch(`${apiUrl}/CPL?Service/KUEdetail.HTML`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(data), }) .then((response) => { if (response.ok) { console.log("POST erfolgreich gesendet für Slot", slot); - // Hier kannst du zusätzliche Logik hinzufügen, z. B. eine Erfolgsnachricht anzeigen } else { console.error("Fehler beim Senden der POST-Anfrage"); } @@ -65,23 +96,27 @@ function Kue705FO({ // Ü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 + } + }; + return (
{isModulPresent ? ( <> - {/* Hauptkörper - Linker Bereich */}
- {/* Header-Bereich mit Slotnummer und Zahnrad */}
- {/* Slotnummer */}
{slotIndex + 1}
- {/* KÜ705-FO Text */}

KÜ705-FO

- {/* Zahnrad-Icon */}
- {/* Betrieb und Alarm Status */}
@@ -102,55 +136,45 @@ function Kue705FO({
- {/* Isolationswert-Anzeige */}
- {isolationswert || ">200"}{" "} - {/* Dynamischer Isolationswert */} + {isolationswert || ">200"}
ISO MOhm
- {/* Weiße Linien */}
- {/* Modulname-Anzeige */}
- {modulName || "Test1"} {/* Dynamischer Modulname */} + {modulName || "Test1"}
- {/* Version */}
- {kueVersion} {/* Dynamische Version */} + {kueVersion}
- {/* Unterer Bereich - Schleifenwiderstand und Messkurve */}
{displayText} - {/* Schleifenwiderstand Anzeige */} +
- {/* Icon rechts oben */} - {/* Wertanzeige */}
- {/* Dynamischer Schleifenwiderstand */}

{schleifenwiderstand || "0"} kOhm

- {/* Schleife und TDR Buttons nebeneinander */}
- {/* Messkurve Button */}