TDR und Schleifen-Messung funktionieren mit der Icon
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import React, { useState } from "react";
|
||||
import { Icon } from "@iconify/react"; // Für Iconify Icons
|
||||
|
||||
function Kue705FO({
|
||||
isolationswert, // Übergabeparameter für den Isolationswert
|
||||
@@ -11,6 +10,7 @@ function Kue705FO({
|
||||
}) {
|
||||
const [activeButton, setActiveButton] = useState("Schleife");
|
||||
const [displayText, setDisplayText] = useState("Schleifenwiderstand [kOhm]");
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleButtonClick = (button) => {
|
||||
if (button === "Schleife") {
|
||||
@@ -22,75 +22,76 @@ function Kue705FO({
|
||||
}
|
||||
};
|
||||
|
||||
// Funktion für die Aktualisierung (TDR-Aufruf)
|
||||
// Funktion für die TDR-Messung
|
||||
const goTDR = () => {
|
||||
let slot = slotIndex + 1; // Slotnummer (index beginnt bei 0, also +1)
|
||||
let slot = slotIndex; // Verwende direkt slotIndex, da Slot 0 der erste Slot ist
|
||||
|
||||
// Bedingung: wenn der Slot größer als 32 ist, wird die Funktion beendet
|
||||
if (slot >= 32) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Bereite die Slot-Informationen vor
|
||||
let slotFormat = slot < 10 ? `0${slot}` : `${slot}`;
|
||||
const data = {
|
||||
[`KTT${slotFormat}`]: 1,
|
||||
slot: slot,
|
||||
};
|
||||
|
||||
const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
||||
|
||||
fetch(`${apiUrl}/CPL?Service/KUEdetailTDR.ACP`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
setLoading(true); // Ladezustand setzen
|
||||
fetch(
|
||||
`${apiUrl}/CPL?Service/KUEdetailTDR.ACP&KTT${slotFormat}=1&slot=${slot}`,
|
||||
{
|
||||
method: "GET",
|
||||
}
|
||||
)
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
console.log("POST erfolgreich gesendet für Slot", slot);
|
||||
console.log("TDR erfolgreich gestartet für Slot", slot);
|
||||
console.log(
|
||||
"URL:",
|
||||
`${apiUrl}/CPL?Service/KUEdetailTDR.ACP&KTT${slotFormat}=1&slot=${slot}`
|
||||
);
|
||||
console.log("Antwort:", response);
|
||||
} else {
|
||||
console.error("Fehler beim Senden der POST-Anfrage");
|
||||
console.error("Fehler beim Senden der TDR-Anfrage");
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Fehler:", error);
|
||||
});
|
||||
})
|
||||
.finally(() => setLoading(false)); // Ladezustand wieder deaktivieren
|
||||
};
|
||||
|
||||
// Funktion für die Schleifenmessung
|
||||
const goLoop = () => {
|
||||
let slot = slotIndex + 1;
|
||||
let slot = slotIndex; // Verwende direkt slotIndex
|
||||
|
||||
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),
|
||||
})
|
||||
setLoading(true); // Ladezustand setzen
|
||||
fetch(
|
||||
`${apiUrl}/CPL?Service/KUEdetail.HTML&KS_${slotFormat}=1&slot=${slot}`,
|
||||
{
|
||||
method: "GET",
|
||||
}
|
||||
)
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
console.log("POST erfolgreich gesendet für Slot", slot);
|
||||
console.log("Schleifenmessung erfolgreich gestartet für Slot", slot);
|
||||
console.log(
|
||||
"URL:",
|
||||
`${apiUrl}/CPL?Service/KUEdetail.HTML&KS_${slotFormat}=1&slot=${slot}`
|
||||
);
|
||||
console.log("Antwort:", response);
|
||||
} else {
|
||||
console.error("Fehler beim Senden der POST-Anfrage");
|
||||
console.error("Fehler beim Senden der Schleifen-Anfrage");
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Fehler:", error);
|
||||
});
|
||||
})
|
||||
.finally(() => setLoading(false)); // Ladezustand wieder deaktivieren
|
||||
};
|
||||
|
||||
// Überprüfe, ob ein Modul im Slot vorhanden ist
|
||||
@@ -112,7 +113,7 @@ function Kue705FO({
|
||||
<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] ">
|
||||
<div className="relative w-[20px] h-[20px] bg-gray-800 flex items-center justify-center">
|
||||
<span className="text-white text-[10px]">{slotIndex + 1}</span>
|
||||
<span className="text-white text-[10px]">{slotIndex}</span>
|
||||
</div>
|
||||
|
||||
<h3 className="text-white font-bold text-[9px] mr-4">KÜ705-FO</h3>
|
||||
@@ -164,6 +165,7 @@ function Kue705FO({
|
||||
<button
|
||||
onClick={handleRefreshClick} // Dynamische Funktion basierend auf aktivem Button
|
||||
className="absolute -top-1 -right-1 w-[20px] h-[20px] bg-gray-400 flex items-center justify-center"
|
||||
disabled={loading} // Disable button while loading
|
||||
>
|
||||
<span className="text-white text-[18px]">⟳</span>
|
||||
</button>
|
||||
@@ -206,7 +208,7 @@ function Kue705FO({
|
||||
</>
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-full text-gray-500">
|
||||
<p>Kein Modul im Slot {slotIndex + 1}</p>
|
||||
<p>Kein Modul im Slot {slotIndex}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user