import { combineReducers } from 'redux'; import { deviceStateReducer } from "./DeviceReduxCoupling"; export const CHANGE_USER_NAME = "SET_USERNAME"; export const RESET_DEVICE_DATA = "RESET_DEVICE_DATA"; export const CHANGE_SWIMTRACKER_HOSTNAME = "CHANGE_SWIMTRACKER_HOSTNAME"; export const changeUsername = newUsername => ({ type: CHANGE_USER_NAME, newUserName: newUsername, }); export const changeSwimTrackerHostname = newSwimTrackerHost => ({ type: CHANGE_SWIMTRACKER_HOSTNAME, newSwimTrackerHost: newSwimTrackerHost, }); export const startSession = () => ({ type: START_SESSION }); export const stopSession = () => ({ type: STOP_SESSION }); const INITIAL_SETTINGS = { username: "", swimTrackerHost: "swimtracker", analysis: { peaksPerLap: 30, windowSizeInSecs: 5, numMeasurementsPerSec: 10, kgFactor: 1.0 / (701.0 * 2.4), 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_USER_NAME: return { ...state, username: action.newUsername }; case CHANGE_SWIMTRACKER_HOSTNAME: return { ...state, swimTrackerHost: action.newSwimTrackerHost }; default: return state; } }; export default combineReducers({ settings: settingsReducer, deviceState: deviceStateReducer, });