feat: Meldung für Events darstellen (Kalibrierung, TDR ud Schleifenmessung)

This commit is contained in:
ISA
2025-08-13 12:13:16 +02:00
parent 48d634295a
commit 0fb6d184bd
13 changed files with 188 additions and 8 deletions

View File

@@ -0,0 +1,58 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
export interface DeviceEventsState {
ksx: number[]; // 32 Slots: Schleifenmessung aktiv
ksy: number[]; // 32 Slots: TDR-Messung aktiv
ksz: number[]; // 32 Slots: Abgleich aktiv
anyLoopActive: boolean;
anyTdrActive: boolean;
anyAlignmentActive: boolean;
}
const ZERO32 = Array.from({ length: 32 }, () => 0);
const initialState: DeviceEventsState = {
ksx: ZERO32.slice(),
ksy: ZERO32.slice(),
ksz: ZERO32.slice(),
anyLoopActive: false,
anyTdrActive: false,
anyAlignmentActive: false,
};
export const deviceEventsSlice = createSlice({
name: "deviceEvents",
initialState,
reducers: {
setEvents(
state,
action: PayloadAction<{ ksx?: number[]; ksy?: number[]; ksz?: number[] }>
) {
const to32 = (arr?: number[]) => {
if (!Array.isArray(arr)) return ZERO32.slice();
const a = arr
.slice(0, 32)
.map((v) => (typeof v === "number" && v ? 1 : 0));
while (a.length < 32) a.push(0);
return a;
};
state.ksx = to32(action.payload.ksx);
state.ksy = to32(action.payload.ksy);
state.ksz = to32(action.payload.ksz);
state.anyLoopActive = state.ksx.some((v) => v === 1);
state.anyTdrActive = state.ksy.some((v) => v === 1);
state.anyAlignmentActive = state.ksz.some((v) => v === 1);
},
resetEvents(state) {
state.ksx = ZERO32.slice();
state.ksy = ZERO32.slice();
state.ksz = ZERO32.slice();
state.anyLoopActive = false;
state.anyTdrActive = false;
state.anyAlignmentActive = false;
},
},
});
export const { setEvents, resetEvents } = deviceEventsSlice.actions;
export default deviceEventsSlice.reducer;

View File

@@ -39,6 +39,7 @@ import { useDispatch, useSelector, TypedUseSelectorHook } from "react-redux";
import systemChartReducer from "./slices/systemChartSlice";
import analogInputsUiReducer from "./slices/analogInputs/analogInputsUiSlice";
import dateRangePickerReducer from "./slices/dateRangePickerSlice";
import deviceEventsReducer from "./slices/deviceEventsSlice";
const rootReducer = combineReducers({
systemspannung5Vplus: systemspannung5VplusReducer,
@@ -78,6 +79,7 @@ const rootReducer = combineReducers({
selectedAnalogInput: selectedAnalogInputReducer,
analogInputsUi: analogInputsUiReducer,
dateRangePicker: dateRangePickerReducer,
deviceEvents: deviceEventsReducer,
});
// ⬆️ Alle deine Imports und combineReducers bleiben so wie du sie geschrieben hast ...