fix: Korrektes Laden der Systemspannungs- und Temperaturdaten in Produktionsumgebung

- Anpassung des fetchSystemVoltTempService: Unterscheidung zwischen Entwicklungs- und Produktionsumgebung (win_systemVoltTempMockData vs. win_systemVoltTemp)
- Mapping der geladenen Array-Daten auf korrekte Schlüssel für Redux Slice (z.B. "+5V", "+15V", "ADC Temp", "CPU Temp")
- Fehlerbehebung: In Produktion wurden Werte im Frontend auf 0 angezeigt, obwohl Redux Slice aktualisiert wurde
- Verbesserung der Stabilität durch bessere Prüfung auf geladene Variablen
This commit is contained in:
ISA
2025-04-28 13:48:15 +02:00
parent c55cec046a
commit 0efaedb059
5 changed files with 53 additions and 20 deletions

View File

@@ -1,9 +1,25 @@
// /apiMockData/SERVICE/systemVoltTempMockData.js
var win_systemVoltTempMockData = {
"+5V": 5.03,
"+15V": 15.02,
"-15V": -15.01,
"-98V": -97.8,
"ADC Temp": 42.5,
"CPU Temp": 47.3,
};
var win_systemVoltTempMockData = [
15.06, 4.984809, -15.086375, -96.480942, 59.782001, 56.919998,
];
/*
var win_systemVoltTempMockData = ["+15V","+5V", "-15V","-98V","ADC Temperatur", "CPU Temperatur"];
ae09.value=system[0]; //+15V
ae11.value=system[1]; //5V
ae15.value=system[2]; //-15V
Messpannung
ae16.value=system[3]; //-96V
Temperatur AD Wandler
ae17.value=system[4]; //-96V
Temperatur CPU
ae18.value=system[5]; //-96V
CGI-Variable
var win_systemVoltTemp=[<%=AAV09%>,<%=AAV11%>,<%=AAV15%>,<%=AAV16%>,<%=AAV17%>,<%=AAV18%>];
*/

View File

@@ -74,7 +74,7 @@ export default function AnalogeEingaengeTable() {
<div className="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50">
<div className="bg-white p-6 rounded-lg shadow-lg w-1/2 max-w-xl">
<div className="border-b pb-2 mb-4">
<h2 className="text-xl font-bold text-blue-500">
<h2 className="text-xl font-bold text-littwin-blue">
Analoger Eingang {selectedEingang.id}
</h2>
</div>
@@ -114,7 +114,7 @@ export default function AnalogeEingaengeTable() {
<div className="flex justify-end mt-6">
<button
onClick={closeSettingsModal}
className="px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg transition"
className="px-4 py-2 bg-blue-500 hover:bg-littwin-blue text-white rounded-lg transition"
>
Schließen
</button>

View File

@@ -6,5 +6,5 @@
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
*/
const webVersion = "1.6.291";
const webVersion = "1.6.292";
export default webVersion;

View File

@@ -1 +1,2 @@
// /public/CPL/SERVICE/ae.js
var win_systemVoltTemp=[<%=AAV09%>,<%=AAV11%>,<%=AAV15%>,<%=AAV16%>,<%=AAV17%>,<%=AAV18%>];

View File

@@ -1,11 +1,12 @@
// /services/fetchSystemVoltTempService.ts
// fetchSystemVoltTempService.ts
export const fetchSystemVoltTempService = async () => {
if (typeof window === "undefined") return null;
const scriptSrc =
process.env.NEXT_PUBLIC_NODE_ENV === "production"
? "/CPL?/CPL/SERVICE/voltTemp.js" // ⬅️ später anpassen, wenn CPL liefert
const isProduction = process.env.NEXT_PUBLIC_NODE_ENV === "production";
const scriptSrc = isProduction
? "/CPL?/CPL/SERVICE/systemVoltTemp.js"
: "/api/cpl/systemVoltTempAPIHandler";
await new Promise<void>((resolve, reject) => {
@@ -19,12 +20,27 @@ export const fetchSystemVoltTempService = async () => {
});
const win = window as any;
const data = win.win_systemVoltTempMockData;
let rawData: any;
if (!data) {
console.warn("⚠️ win_systemVoltTempMockData fehlt oder ungültig:", data);
if (isProduction) {
rawData = win.win_systemVoltTemp; // Produktion
} else {
rawData = win.win_systemVoltTempMockData; // Entwicklung
}
if (!rawData) {
console.warn("⚠️ SystemVoltTemp-Daten fehlen oder ungültig:", rawData);
return null;
}
return data;
const result = {
"+15V": rawData[0],
"+5V": rawData[1],
"-15V": rawData[2],
"-98V": rawData[3],
"ADC Temp": rawData[4], // Achtung: Hier 'ADC Temp' anstatt "Temperatur AD Wandler"
"CPU Temp": rawData[5], // 'CPU Temp' anstatt "Temperatur CPU"
};
return result;
};