refactor: OPC-UA Variablen aus variablesSlice entfernt und in opcuaSettingsSlice integriert

- 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! 🚀🔥
This commit is contained in:
Ismail Ali
2025-02-23 11:59:40 +01:00
parent 772ef50af5
commit 19b661fc70
3 changed files with 21 additions and 28 deletions

View File

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

View File

@@ -8,7 +8,12 @@ import Footer from "../components/footer/Footer";
import "../styles/globals.css"; import "../styles/globals.css";
import { Provider } from "react-redux"; import { Provider } from "react-redux";
import { setVariables } from "../redux/slices/variablesSlice"; 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 store from "../redux/store";
import { AppProps } from "next/app"; import { AppProps } from "next/app";
import WindowVariablesInitializer from "../components/WindowVariablesInitializer"; import WindowVariablesInitializer from "../components/WindowVariablesInitializer";
@@ -22,9 +27,12 @@ function MyApp({ Component, pageProps }: AppProps) {
const variables = await loadWindowVariables(); const variables = await loadWindowVariables();
if (!variables) throw new Error("Sitzungsfehler"); if (!variables) throw new Error("Sitzungsfehler");
// ✅ System-Settings und last20Messages separat speichern // ✅ OPC-UA Werte, System-Settings und last20Messages separat speichern
const { const {
last20Messages, // Entfernen für eigenes Redux-Slice last20Messages, // Entfernen für eigenes Redux-Slice
opcUaZustand,
opcUaActiveClientCount,
opcUaNodesetName,
deviceName, deviceName,
mac1, mac1,
ip, 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 // ✅ Speichere alle anderen Variablen in variablesSlice
store.dispatch(setVariables(restVariables)); store.dispatch(setVariables(restVariables));

View File

@@ -14,7 +14,6 @@ export interface VariablesState {
obereSchleifenGrenzwerte: number[]; obereSchleifenGrenzwerte: number[];
schleifenintervall: number[]; schleifenintervall: number[];
//--------------- //---------------
de: string | null; de: string | null;
counter: number | null; counter: number | null;
flutter: string | null; flutter: string | null;
@@ -25,8 +24,8 @@ export interface VariablesState {
kueAlarm1: number[]; kueAlarm1: number[];
kueAlarm2: number[]; kueAlarm2: number[];
kueResidence: string[]; kueResidence: string[];
kueCableBreak: number[]; kueCableBreak: string[];
kueGroundFault: number[]; kueGroundFault: string[];
kueLimit1: number | null; kueLimit1: number | null;
kueLimit2Low: number | null; kueLimit2Low: number | null;
kueDelay1: number | null; kueDelay1: number | null;
@@ -50,15 +49,11 @@ export interface VariablesState {
win_analogeEingaenge6: string | null; win_analogeEingaenge6: string | null;
win_analogeEingaenge7: string | null; win_analogeEingaenge7: string | null;
win_analogeEingaenge8: string | null; win_analogeEingaenge8: string | null;
opcUaZustand: string | null;
opcUaActiveClientCount: number | null;
opcUaNodesetName: string | null;
} }
// Initialer Zustand // Initialer Zustand
const initialState: VariablesState = { const initialState: VariablesState = {
selectedFileName: null, selectedFileName: null,
//------------
selectedChartData: null, selectedChartData: null,
kueBezeichnungen: [], kueBezeichnungen: [],
isolationsgrenzwerte: [], isolationsgrenzwerte: [],
@@ -66,8 +61,6 @@ const initialState: VariablesState = {
untereSchleifenGrenzwerte: [], untereSchleifenGrenzwerte: [],
obereSchleifenGrenzwerte: [], obereSchleifenGrenzwerte: [],
schleifenintervall: [], schleifenintervall: [],
//---------------
de: null, de: null,
counter: null, counter: null,
flutter: null, flutter: null,
@@ -103,9 +96,6 @@ const initialState: VariablesState = {
win_analogeEingaenge6: null, win_analogeEingaenge6: null,
win_analogeEingaenge7: null, win_analogeEingaenge7: null,
win_analogeEingaenge8: null, win_analogeEingaenge8: null,
opcUaZustand: null,
opcUaActiveClientCount: null,
opcUaNodesetName: null,
}; };
// Slice erstellen // Slice erstellen
@@ -124,7 +114,6 @@ const variablesSlice = createSlice({
(state[key] as VariablesState[keyof VariablesState]) = value; (state[key] as VariablesState[keyof VariablesState]) = value;
}, },
setVariables(state, action: PayloadAction<Partial<VariablesState>>) { setVariables(state, action: PayloadAction<Partial<VariablesState>>) {
//console.log("setVariables aufgerufen mit:", action.payload);
Object.entries(action.payload).forEach(([key, value]) => { Object.entries(action.payload).forEach(([key, value]) => {
(state[ (state[
key as keyof VariablesState key as keyof VariablesState
@@ -137,15 +126,6 @@ const variablesSlice = createSlice({
setSelectedFileName(state, action: PayloadAction<string | null>) { setSelectedFileName(state, action: PayloadAction<string | null>) {
state.selectedFileName = action.payload; state.selectedFileName = action.payload;
}, },
setOpcUaZustand(state, action: PayloadAction<string | null>) {
state.opcUaZustand = action.payload;
},
setOpcUaActiveClientCount(state, action: PayloadAction<number | null>) {
state.opcUaActiveClientCount = action.payload;
},
setOpcUaNodesetName(state, action: PayloadAction<string | null>) {
state.opcUaNodesetName = action.payload;
},
}, },
}); });
@@ -154,8 +134,6 @@ export const {
setVariables, setVariables,
setSelectedChartData, setSelectedChartData,
setSelectedFileName, setSelectedFileName,
setOpcUaZustand,
setOpcUaActiveClientCount,
setOpcUaNodesetName,
} = variablesSlice.actions; } = variablesSlice.actions;
export default variablesSlice.reducer; export default variablesSlice.reducer;