67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
import { combineReducers } from 'redux';
|
|
import { deviceStateReducer } from "./DeviceReduxCoupling";
|
|
|
|
export const CHANGE_USER_NAME = "SET_USERNAME";
|
|
export const CHANGE_THEME = "CHANGE_THEME";
|
|
export const RESET_DEVICE_DATA = "RESET_DEVICE_DATA";
|
|
|
|
|
|
export const changeUsername = newUsername => ({
|
|
type: CHANGE_USER_NAME,
|
|
newUserName: newUsername,
|
|
});
|
|
|
|
export const changeTheme = newThemeName => ({
|
|
type: CHANGE_THEME,
|
|
newThemeName: newThemeName
|
|
});
|
|
|
|
export const startSession = () => ({
|
|
type: START_SESSION
|
|
});
|
|
|
|
export const stopSession = () => ({
|
|
type: STOP_SESSION
|
|
});
|
|
|
|
const INITIAL_SETTINGS = {
|
|
theme: "hot",
|
|
username: "",
|
|
//swimTrackerHost: "192.168.178.107",
|
|
swimTrackerHost: "192.168.178.110",
|
|
|
|
analysis: {
|
|
peaksPerLap: 30,
|
|
windowSizeInSecs: 5,
|
|
numMeasurementsPerSec: 10,
|
|
|
|
kgFactor: 1.0 / 701.0,
|
|
|
|
peakDetector: 'SIMPLE', // either 'SIMPLE' or 'ZSCORE'
|
|
peakDetectorSimpleThreshold: 2000,
|
|
|
|
peakDetectorZScoreLag: 8, // peak detector z-score values
|
|
peakDetectorZScoreThreshold: 2,
|
|
peakDetectorZScoreInfluence: 0.1,
|
|
|
|
activeTimeThreshold: 700,
|
|
movingAverageWindowSize: 10*3,
|
|
}
|
|
};
|
|
|
|
|
|
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,
|
|
deviceState: deviceStateReducer,
|
|
}); |