2020-06-02 17:19:09 +02:00
|
|
|
import { combineReducers } from 'redux';
|
2020-06-23 21:36:14 +02:00
|
|
|
import { CHANGE_THEME, CHANGE_USER_NAME, NEW_DEVICE_DATA, START_SESSION, STOP_SESSION, RESET_DEVICE_DATA } from './ActionCreators';
|
2020-06-28 18:55:58 +02:00
|
|
|
import { deviceStateReducer } from "./DeviceReduxCoupling";
|
2020-06-02 17:19:09 +02:00
|
|
|
|
|
|
|
const INITIAL_SETTINGS = {
|
|
|
|
theme: "hot",
|
|
|
|
username: "",
|
2020-06-28 18:55:58 +02:00
|
|
|
swimTrackerHost: "192.168.178.110",
|
2020-06-02 17:19:09 +02:00
|
|
|
|
2020-06-28 18:55:58 +02:00
|
|
|
analysis: {
|
|
|
|
peaksPerLap: 30,
|
|
|
|
windowSizeInSecs: 5,
|
|
|
|
numMeasurementsPerSec: 10,
|
2020-06-02 17:19:09 +02:00
|
|
|
|
2020-06-28 18:55:58 +02:00
|
|
|
peakDetector: 'SIMPLE', // either 'SIMPLE' or 'ZSCORE'
|
|
|
|
peakDetectorSimpleThreshold: 2500,
|
2020-06-02 17:19:09 +02:00
|
|
|
|
2020-06-28 18:55:58 +02:00
|
|
|
peakDetectorZScoreLag: 8, // peak detector z-score values
|
|
|
|
peakDetectorZScoreThreshold: 2,
|
|
|
|
peakDetectorZScoreInfluence: 0.1,
|
2020-06-02 17:19:09 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-06-28 18:55:58 +02:00
|
|
|
|
2020-06-02 17:19:09 +02:00
|
|
|
const settingsReducer = (state = INITIAL_SETTINGS, action) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case CHANGE_THEME:
|
|
|
|
return { ...state, theme: action.newThemeName };
|
|
|
|
case CHANGE_USER_NAME:
|
|
|
|
return { ...state, username: action.newUsername };
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default combineReducers({
|
|
|
|
settings: settingsReducer,
|
2020-06-28 18:55:58 +02:00
|
|
|
deviceState: deviceStateReducer,
|
2020-06-02 17:19:09 +02:00
|
|
|
});
|