Fix in active time detection
This commit is contained in:
parent
39632d4eec
commit
aee89d799c
|
@ -20,6 +20,16 @@ function LiveTrainingView(props) {
|
||||||
const laps = (analysis.peaks.size / props.peaksPerLap).toFixed(1);
|
const laps = (analysis.peaks.size / props.peaksPerLap).toFixed(1);
|
||||||
const totalMomentum = Math.trunc(analysis.totalMomentum * props.kgFactor / 10 / 60);
|
const totalMomentum = Math.trunc(analysis.totalMomentum * props.kgFactor / 10 / 60);
|
||||||
|
|
||||||
|
const toTimeStr = seconds => {
|
||||||
|
let minuteStr = String(Math.floor(seconds / 60));
|
||||||
|
if(minuteStr.length < 2)
|
||||||
|
minuteStr = "0" + minuteStr;
|
||||||
|
let secondStr = String(Math.floor(seconds % 60));
|
||||||
|
if(secondStr.length < 2)
|
||||||
|
secondStr = "0" + secondStr;
|
||||||
|
return minuteStr + ":" + secondStr;
|
||||||
|
}
|
||||||
|
console.log("Active", analysis.activeTime);
|
||||||
useKeepAwake();
|
useKeepAwake();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -37,8 +47,8 @@ function LiveTrainingView(props) {
|
||||||
</CycleView>
|
</CycleView>
|
||||||
|
|
||||||
<CycleView>
|
<CycleView>
|
||||||
<IconCard label="DAUER" value="00:42" iconName="clock" iconType="FontAwesome5" />
|
<IconCard label="DAUER" value={toTimeStr(analysis.totalTime)} iconName="clock" iconType="FontAwesome5" />
|
||||||
<IconCard label="AKTIVE DAUER" value="42:00" iconName="stopwatch" iconType="FontAwesome5" />
|
<IconCard label="AKTIVE DAUER" value={toTimeStr(analysis.activeTime)} iconName="stopwatch" iconType="FontAwesome5" />
|
||||||
</CycleView>
|
</CycleView>
|
||||||
<IconCard label="KRAFT" value={totalMomentum} iconName="ruler" iconType="Entypo" />
|
<IconCard label="KRAFT" value={totalMomentum} iconName="ruler" iconType="Entypo" />
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,11 @@ export default class DataAnalysis {
|
||||||
// active time
|
// active time
|
||||||
const newAverages = this.movingAverage.addVector(newDataArr);
|
const newAverages = this.movingAverage.addVector(newDataArr);
|
||||||
this.activeMeasurements += newAverages.reduce((n, val) => {
|
this.activeMeasurements += newAverages.reduce((n, val) => {
|
||||||
return n + (val >= analysisParameters.activeTimeThreshold);
|
return n + ((val >= analysisParameters.activeTimeThreshold) ? 1 : 0);
|
||||||
});
|
}, 0);
|
||||||
|
console.log("data", newDataArr, "newAverages", newAverages, "reduction", this.activeMeasurements);
|
||||||
|
|
||||||
// peaks
|
// peaks
|
||||||
const newPeaks = this.peakDetectorSimple.addVector(newDataArr);
|
const newPeaks = this.peakDetectorSimple.addVector(newDataArr);
|
||||||
this.allPeaks = this.allPeaks.concat(List(newPeaks));
|
this.allPeaks = this.allPeaks.concat(List(newPeaks));
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ export default class DataAnalysis {
|
||||||
this.analyzedUpToIdx = allMeasurements.size;
|
this.analyzedUpToIdx = allMeasurements.size;
|
||||||
return {
|
return {
|
||||||
peaks: this.allPeaks,
|
peaks: this.allPeaks,
|
||||||
totalTime: allMeasurements / analysisParameters.numMeasurementsPerSec,
|
totalTime: allMeasurements.size / analysisParameters.numMeasurementsPerSec,
|
||||||
activeTime: this.activeMeasurements / analysisParameters.numMeasurementsPerSec,
|
activeTime: this.activeMeasurements / analysisParameters.numMeasurementsPerSec,
|
||||||
|
|
||||||
totalMomentum: this.aggregatedMomentum,
|
totalMomentum: this.aggregatedMomentum,
|
||||||
|
|
|
@ -43,8 +43,8 @@ const INITIAL_SETTINGS = {
|
||||||
peakDetectorZScoreThreshold: 2,
|
peakDetectorZScoreThreshold: 2,
|
||||||
peakDetectorZScoreInfluence: 0.1,
|
peakDetectorZScoreInfluence: 0.1,
|
||||||
|
|
||||||
activeTimeThreshold: 300,
|
activeTimeThreshold: 700,
|
||||||
movingAverageWindowSize: 10*5,
|
movingAverageWindowSize: 10*3,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue