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:
@@ -1,12 +1,13 @@
|
||||
// /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
|
||||
: "/api/cpl/systemVoltTempAPIHandler";
|
||||
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) => {
|
||||
const script = document.createElement("script");
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user