Fix in active time detection

This commit is contained in:
Martin Bauer 2020-07-15 18:17:12 +02:00
parent 39632d4eec
commit aee89d799c
3 changed files with 19 additions and 8 deletions

View File

@ -20,6 +20,16 @@ function LiveTrainingView(props) {
const laps = (analysis.peaks.size / props.peaksPerLap).toFixed(1);
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();
return (
@ -37,8 +47,8 @@ function LiveTrainingView(props) {
</CycleView>
<CycleView>
<IconCard label="DAUER" value="00:42" iconName="clock" iconType="FontAwesome5" />
<IconCard label="AKTIVE DAUER" value="42:00" iconName="stopwatch" iconType="FontAwesome5" />
<IconCard label="DAUER" value={toTimeStr(analysis.totalTime)} iconName="clock" iconType="FontAwesome5" />
<IconCard label="AKTIVE DAUER" value={toTimeStr(analysis.activeTime)} iconName="stopwatch" iconType="FontAwesome5" />
</CycleView>
<IconCard label="KRAFT" value={totalMomentum} iconName="ruler" iconType="Entypo" />

View File

@ -31,8 +31,9 @@ export default class DataAnalysis {
// active time
const newAverages = this.movingAverage.addVector(newDataArr);
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
const newPeaks = this.peakDetectorSimple.addVector(newDataArr);
@ -52,7 +53,7 @@ export default class DataAnalysis {
this.analyzedUpToIdx = allMeasurements.size;
return {
peaks: this.allPeaks,
totalTime: allMeasurements / analysisParameters.numMeasurementsPerSec,
totalTime: allMeasurements.size / analysisParameters.numMeasurementsPerSec,
activeTime: this.activeMeasurements / analysisParameters.numMeasurementsPerSec,
totalMomentum: this.aggregatedMomentum,

View File

@ -43,8 +43,8 @@ const INITIAL_SETTINGS = {
peakDetectorZScoreThreshold: 2,
peakDetectorZScoreInfluence: 0.1,
activeTimeThreshold: 300,
movingAverageWindowSize: 10*5,
activeTimeThreshold: 700,
movingAverageWindowSize: 10*3,
}
};