feat: Einzelne CGI-Befehle für digitale Eingänge in Produktionsumgebung umgesetzt
- Änderungen (Name, Invertierung, Filterzeit, Gewichtung, Zähler aktiv) werden einzeln erkannt - Pro Änderung wird jeweils ein separater CGI-Request gesendet (z. B. DEN1=..., DEI1=...) - Verbesserte Trennung zwischen Entwicklungs- und Produktionsumgebung
This commit is contained in:
@@ -1,34 +1,245 @@
|
|||||||
|
|
||||||
// auto-generated from update API
|
// auto-generated from update API
|
||||||
var win_de_state = [
|
var win_de_state = [
|
||||||
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,
|
1,
|
||||||
0, 0, 0, 0, 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,
|
||||||
|
0
|
||||||
];
|
];
|
||||||
var win_de_invert = [
|
var win_de_invert = [
|
||||||
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,
|
1,
|
||||||
0, 0, 0, 0, 0, 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
|
||||||
];
|
];
|
||||||
var win_de_counter = [
|
var win_de_counter = [
|
||||||
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, 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
|
||||||
];
|
];
|
||||||
var win_de_time_filter = [
|
var win_de_time_filter = [
|
||||||
2000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1500,
|
||||||
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,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
];
|
];
|
||||||
var win_de_weighting = [
|
var win_de_weighting = [
|
||||||
1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
600,
|
||||||
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,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
];
|
];
|
||||||
var win_de_counter_active = [
|
var win_de_counter_active = [
|
||||||
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, 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,
|
||||||
|
0
|
||||||
];
|
];
|
||||||
var win_de_offline = [
|
var win_de_offline = [
|
||||||
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,
|
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,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
];
|
];
|
||||||
var win_de_label = [
|
var win_de_label = [
|
||||||
"DE1",
|
"DE112",
|
||||||
"DE2",
|
"DE2",
|
||||||
"DE3",
|
"DE3",
|
||||||
"DE4",
|
"DE4",
|
||||||
@@ -59,5 +270,5 @@ var win_de_label = [
|
|||||||
"DE29",
|
"DE29",
|
||||||
"DE30",
|
"DE30",
|
||||||
"DE31",
|
"DE31",
|
||||||
"DE32",
|
"DE32"
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ export default function InputModal({ selectedInput, closeInputModal, isOpen }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const [isInitialLoad, setIsInitialLoad] = useState(true);
|
const [isInitialLoad, setIsInitialLoad] = useState(true);
|
||||||
|
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState("");
|
||||||
const [invertiert, setInvertiert] = useState(false);
|
const [invertiert, setInvertiert] = useState(false);
|
||||||
const [filterzeit, setFilterzeit] = useState(0);
|
const [filterzeit, setFilterzeit] = useState(0);
|
||||||
@@ -37,58 +36,97 @@ export default function InputModal({ selectedInput, closeInputModal, isOpen }) {
|
|||||||
|
|
||||||
if (!isOpen || !selectedInput || !reduxInput) return null;
|
if (!isOpen || !selectedInput || !reduxInput) return null;
|
||||||
|
|
||||||
|
const sendCgiUpdate = async (param: string) => {
|
||||||
|
const url = `/CPL?/eingaenge.html&${param}`;
|
||||||
|
console.log("📡 CGI senden:", url);
|
||||||
|
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Fehler bei CGI-Aufruf: ${param}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleSpeichern = async () => {
|
const handleSpeichern = async () => {
|
||||||
const updates: any = { id: reduxInput.id };
|
const id = reduxInput.id;
|
||||||
let hasChange = false;
|
let hasChange = false;
|
||||||
|
|
||||||
if (name !== reduxInput.name) {
|
|
||||||
updates.name = name;
|
|
||||||
dispatch(updateName({ id: reduxInput.id, name }));
|
|
||||||
hasChange = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (invertiert !== reduxInput.invertierung) {
|
|
||||||
updates.invertierung = invertiert ? 1 : 0;
|
|
||||||
dispatch(
|
|
||||||
updateInvertierung({ id: reduxInput.id, invertierung: invertiert })
|
|
||||||
);
|
|
||||||
hasChange = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filterzeit !== reduxInput.filterzeit) {
|
|
||||||
updates.filterzeit = filterzeit;
|
|
||||||
hasChange = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gewichtung !== reduxInput.gewichtung) {
|
|
||||||
updates.gewichtung = gewichtung;
|
|
||||||
hasChange = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (zaehlerAktiv !== reduxInput.zaehlerAktiv) {
|
|
||||||
updates.zaehlerAktiv = zaehlerAktiv ? 1 : 0;
|
|
||||||
hasChange = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasChange) {
|
|
||||||
alert("⚠️ Keine Änderungen erkannt.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch("/api/cpl/updateDigitaleEingaenge", {
|
// PRODUKTIONSUMGEBUNG (CGI-Modus)
|
||||||
method: "POST",
|
if (process.env.NEXT_PUBLIC_NODE_ENV === "production") {
|
||||||
headers: { "Content-Type": "application/json" },
|
if (name !== reduxInput.name) {
|
||||||
body: JSON.stringify(updates),
|
await sendCgiUpdate(`DEN${id}=${encodeURIComponent(name)}`);
|
||||||
});
|
dispatch(updateName({ id, name }));
|
||||||
|
hasChange = true;
|
||||||
|
}
|
||||||
|
if (invertiert !== reduxInput.invertierung) {
|
||||||
|
await sendCgiUpdate(`DEI${id}=${invertiert ? 1 : 0}`);
|
||||||
|
dispatch(updateInvertierung({ id, invertierung: invertiert }));
|
||||||
|
hasChange = true;
|
||||||
|
}
|
||||||
|
if (filterzeit !== reduxInput.filterzeit) {
|
||||||
|
await sendCgiUpdate(`DEF${id}=${filterzeit}`);
|
||||||
|
hasChange = true;
|
||||||
|
}
|
||||||
|
if (gewichtung !== reduxInput.gewichtung) {
|
||||||
|
await sendCgiUpdate(`DEG${id}=${gewichtung}`);
|
||||||
|
hasChange = true;
|
||||||
|
}
|
||||||
|
if (zaehlerAktiv !== reduxInput.zaehlerAktiv) {
|
||||||
|
await sendCgiUpdate(`DEZ${id}=${zaehlerAktiv ? 1 : 0}`);
|
||||||
|
hasChange = true;
|
||||||
|
}
|
||||||
|
if (!hasChange) {
|
||||||
|
alert("⚠️ Keine Änderungen erkannt.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
alert("✅ Daten erfolgreich an die CPL-Hardware gesendet!");
|
||||||
|
} else {
|
||||||
|
// ENTWICKLUNGSUMGEBUNG (lokale API)
|
||||||
|
const updates: any = { id };
|
||||||
|
if (name !== reduxInput.name) {
|
||||||
|
updates.name = name;
|
||||||
|
dispatch(updateName({ id, name }));
|
||||||
|
hasChange = true;
|
||||||
|
}
|
||||||
|
if (invertiert !== reduxInput.invertierung) {
|
||||||
|
updates.invertierung = invertiert ? 1 : 0;
|
||||||
|
dispatch(updateInvertierung({ id, invertierung: invertiert }));
|
||||||
|
hasChange = true;
|
||||||
|
}
|
||||||
|
if (filterzeit !== reduxInput.filterzeit) {
|
||||||
|
updates.filterzeit = filterzeit;
|
||||||
|
hasChange = true;
|
||||||
|
}
|
||||||
|
if (gewichtung !== reduxInput.gewichtung) {
|
||||||
|
updates.gewichtung = gewichtung;
|
||||||
|
hasChange = true;
|
||||||
|
}
|
||||||
|
if (zaehlerAktiv !== reduxInput.zaehlerAktiv) {
|
||||||
|
updates.zaehlerAktiv = zaehlerAktiv ? 1 : 0;
|
||||||
|
hasChange = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!hasChange) {
|
||||||
const errData = await res.json();
|
alert("⚠️ Keine Änderungen erkannt.");
|
||||||
throw new Error(errData.error || "Unbekannter Fehler");
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await fetch("/api/cpl/updateDigitaleEingaenge", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify(updates),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
const errData = await res.json();
|
||||||
|
throw new Error(errData.error || "Unbekannter Fehler");
|
||||||
|
}
|
||||||
|
|
||||||
|
alert("✅ Daten lokal gespeichert!");
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsInitialLoad(true); // Reset
|
setIsInitialLoad(true);
|
||||||
closeInputModal(); // Modal schließen bei Erfolg
|
closeInputModal();
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
alert("❌ Fehler beim Speichern: " + err.message);
|
alert("❌ Fehler beim Speichern: " + err.message);
|
||||||
}
|
}
|
||||||
@@ -181,7 +219,7 @@ export default function InputModal({ selectedInput, closeInputModal, isOpen }) {
|
|||||||
<div>
|
<div>
|
||||||
<strong>Gewichtung:</strong>
|
<strong>Gewichtung:</strong>
|
||||||
</div>
|
</div>
|
||||||
<div className="relative">
|
<div>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
min={0}
|
min={0}
|
||||||
@@ -196,11 +234,6 @@ export default function InputModal({ selectedInput, closeInputModal, isOpen }) {
|
|||||||
className="border border-gray-300 rounded px-2 py-1 w-full"
|
className="border border-gray-300 rounded px-2 py-1 w-full"
|
||||||
title="Maximal 1000 erlaubt"
|
title="Maximal 1000 erlaubt"
|
||||||
/>
|
/>
|
||||||
{gewichtung > 1000 && (
|
|
||||||
<div className="text-sm text-red-600 mt-1">
|
|
||||||
Maximalwert 1000 überschritten!
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -6,5 +6,5 @@
|
|||||||
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
const webVersion = "1.6.280";
|
const webVersion = "1.6.281";
|
||||||
export default webVersion;
|
export default webVersion;
|
||||||
|
|||||||
Reference in New Issue
Block a user