New data processing

This commit is contained in:
Martin Bauer
2020-06-23 21:36:14 +02:00
parent 655d8b0dc8
commit 00be9e1db2
5 changed files with 61 additions and 57 deletions

View File

@@ -4,6 +4,7 @@ export const CHANGE_USER_NAME = "SET_USERNAME";
export const CHANGE_THEME = "CHANGE_THEME";
export const START_SESSION = "START_SESSION";
export const STOP_SESSION = "STOP_SESSION";
export const RESET_DEVICE_DATA = "RESET_DEVICE_DATA";
export const reportDeviceData = (sessionId, newDataStart, data, analysis) => ({
type: NEW_DEVICE_DATA,
@@ -13,6 +14,10 @@ export const reportDeviceData = (sessionId, newDataStart, data, analysis) => ({
analysis: analysis,
})
export const resetDeviceData = () => ({
type: RESET_DEVICE_DATA,
});
export const changeUsername = newUsername => ({
type: CHANGE_USER_NAME,
newUserName: newUsername,

View File

@@ -1,16 +1,16 @@
import { combineReducers } from 'redux';
import { List } from 'immutable';
import { CHANGE_THEME, CHANGE_USER_NAME, NEW_DEVICE_DATA, START_SESSION, STOP_SESSION } from './ActionCreators';
import { CHANGE_THEME, CHANGE_USER_NAME, NEW_DEVICE_DATA, START_SESSION, STOP_SESSION, RESET_DEVICE_DATA } from './ActionCreators';
const INITIAL_SETTINGS = {
theme: "hot",
username: "",
deviceURL: "http://192.168.178.110",
deviceURL: "http://192.168.178.107",
peaksPerLap: 30,
// advanced
peakDetector: 'SIMPLE', // either 'SIMPLE' or 'ZSCORE'
peakDetectorSimpleThreshold: 4000,
peakDetectorSimpleThreshold: 2500,
peakDetectorZScoreLag: 8, // peak detector z-score values
peakDetectorZScoreThreshold: 2,
@@ -19,6 +19,7 @@ const INITIAL_SETTINGS = {
const INITIAL_CURRENT_SESSION = {
running: false,
sessionId: 0,
rawData: List(),
analysis: {
'peaks': List(),
@@ -62,9 +63,12 @@ const currentSessionReducer = (state = INITIAL_CURRENT_SESSION, action) => {
case NEW_DEVICE_DATA:
return {
running: action.data.size > 0,
sessionId: action.sessionId,
rawData: action.data,
analysis: { ...state.analysis, ...action.analysis },
}
case RESET_DEVICE_DATA:
return INITIAL_CURRENT_SESSION
default:
return state
}