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