From 19b661fc7036edcfe17d1f9a590a4514d45beb1a Mon Sep 17 00:00:00 2001 From: Ismail Ali Date: Sun, 23 Feb 2025 11:59:40 +0100 Subject: [PATCH] refactor: OPC-UA Variablen aus variablesSlice entfernt und in opcuaSettingsSlice integriert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - OPC-UA Variablen (`opcUaZustand`, `opcUaActiveClientCount`, `opcUaNodesetName`) aus `variablesSlice` entfernt - `_app.tsx` angepasst, um OPC-UA Daten direkt in `opcuaSettingsSlice` zu speichern - `loadWindowVariables.ts` aktualisiert: - OPC-UA Status, Verschlüsselung, aktive Clients und Nodeset werden nun in `opcuaSettingsSlice` gespeichert - `variablesSlice` speichert keine OPC-UA Daten mehr - Redux-Store aufgeräumt: DevTools zeigt keine OPC-UA Variablen mehr in `variablesSlice` Jetzt ist die Trennung zwischen `variablesSlice` und `opcuaSettingsSlice` vollständig! 🚀🔥 --- config/webVersion.ts | 2 +- pages/_app.tsx | 19 +++++++++++++++++-- redux/slices/variablesSlice.ts | 28 +++------------------------- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/config/webVersion.ts b/config/webVersion.ts index ecd1f86..a32a719 100644 --- a/config/webVersion.ts +++ b/config/webVersion.ts @@ -6,5 +6,5 @@ 2: Patch oder Hotfix (Bugfixes oder kleine Änderungen). */ -const webVersion = "1.6.92"; +const webVersion = "1.6.93"; export default webVersion; diff --git a/pages/_app.tsx b/pages/_app.tsx index 663336c..72775ea 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -8,7 +8,12 @@ import Footer from "../components/footer/Footer"; import "../styles/globals.css"; import { Provider } from "react-redux"; import { setVariables } from "../redux/slices/variablesSlice"; -import { setSystemSettings } from "../redux/slices/systemSettingsSlice"; // ✅ Für System-Settings +import { setSystemSettings } from "../redux/slices/systemSettingsSlice"; // ✅ System-Settings +import { + setOpcUaZustand, + setOpcUaActiveClientCount, + setOpcUaNodesetName, +} from "../redux/slices/opcuaSettingsSlice"; // ✅ OPC-UA Settings import store from "../redux/store"; import { AppProps } from "next/app"; import WindowVariablesInitializer from "../components/WindowVariablesInitializer"; @@ -22,9 +27,12 @@ function MyApp({ Component, pageProps }: AppProps) { const variables = await loadWindowVariables(); if (!variables) throw new Error("Sitzungsfehler"); - // ✅ System-Settings und last20Messages separat speichern + // ✅ OPC-UA Werte, System-Settings und last20Messages separat speichern const { last20Messages, // Entfernen für eigenes Redux-Slice + opcUaZustand, + opcUaActiveClientCount, + opcUaNodesetName, deviceName, mac1, ip, @@ -56,6 +64,13 @@ function MyApp({ Component, pageProps }: AppProps) { }) ); + // ✅ Speichere OPC-UA Einstellungen in opcuaSettingsSlice + store.dispatch(setOpcUaZustand(opcUaZustand || "Offline")); + store.dispatch(setOpcUaActiveClientCount(opcUaActiveClientCount || 0)); + store.dispatch( + setOpcUaNodesetName(opcUaNodesetName || "DefaultNodeset") + ); + // ✅ Speichere alle anderen Variablen in variablesSlice store.dispatch(setVariables(restVariables)); diff --git a/redux/slices/variablesSlice.ts b/redux/slices/variablesSlice.ts index e18b1db..7998bf8 100644 --- a/redux/slices/variablesSlice.ts +++ b/redux/slices/variablesSlice.ts @@ -14,7 +14,6 @@ export interface VariablesState { obereSchleifenGrenzwerte: number[]; schleifenintervall: number[]; //--------------- - de: string | null; counter: number | null; flutter: string | null; @@ -25,8 +24,8 @@ export interface VariablesState { kueAlarm1: number[]; kueAlarm2: number[]; kueResidence: string[]; - kueCableBreak: number[]; - kueGroundFault: number[]; + kueCableBreak: string[]; + kueGroundFault: string[]; kueLimit1: number | null; kueLimit2Low: number | null; kueDelay1: number | null; @@ -50,15 +49,11 @@ export interface VariablesState { win_analogeEingaenge6: string | null; win_analogeEingaenge7: string | null; win_analogeEingaenge8: string | null; - opcUaZustand: string | null; - opcUaActiveClientCount: number | null; - opcUaNodesetName: string | null; } // Initialer Zustand const initialState: VariablesState = { selectedFileName: null, - //------------ selectedChartData: null, kueBezeichnungen: [], isolationsgrenzwerte: [], @@ -66,8 +61,6 @@ const initialState: VariablesState = { untereSchleifenGrenzwerte: [], obereSchleifenGrenzwerte: [], schleifenintervall: [], - //--------------- - de: null, counter: null, flutter: null, @@ -103,9 +96,6 @@ const initialState: VariablesState = { win_analogeEingaenge6: null, win_analogeEingaenge7: null, win_analogeEingaenge8: null, - opcUaZustand: null, - opcUaActiveClientCount: null, - opcUaNodesetName: null, }; // Slice erstellen @@ -124,7 +114,6 @@ const variablesSlice = createSlice({ (state[key] as VariablesState[keyof VariablesState]) = value; }, setVariables(state, action: PayloadAction>) { - //console.log("setVariables aufgerufen mit:", action.payload); Object.entries(action.payload).forEach(([key, value]) => { (state[ key as keyof VariablesState @@ -137,15 +126,6 @@ const variablesSlice = createSlice({ setSelectedFileName(state, action: PayloadAction) { state.selectedFileName = action.payload; }, - setOpcUaZustand(state, action: PayloadAction) { - state.opcUaZustand = action.payload; - }, - setOpcUaActiveClientCount(state, action: PayloadAction) { - state.opcUaActiveClientCount = action.payload; - }, - setOpcUaNodesetName(state, action: PayloadAction) { - state.opcUaNodesetName = action.payload; - }, }, }); @@ -154,8 +134,6 @@ export const { setVariables, setSelectedChartData, setSelectedFileName, - setOpcUaZustand, - setOpcUaActiveClientCount, - setOpcUaNodesetName, } = variablesSlice.actions; + export default variablesSlice.reducer;