Remove extreme fluctuation check, because of accuracy decline
parent
c97d8179df
commit
d28d762304
|
|
@ -60,37 +60,12 @@
|
||||||
data.battLastRecorded = batt;
|
data.battLastRecorded = batt;
|
||||||
storage.writeJSON(dataFile, data);
|
storage.writeJSON(dataFile, data);
|
||||||
} else {
|
} else {
|
||||||
|
let weightCoefficient = 1;
|
||||||
let currentDrainage = battChange / deltaHours;
|
let currentDrainage = battChange / deltaHours;
|
||||||
let drainageChange = data.avgBattDrainage - currentDrainage;
|
let drainageChange = data.avgBattDrainage - currentDrainage;
|
||||||
//check if drainage rate has fluctuated quite a bit
|
|
||||||
//If fluctuation event is 0, first time fluctuating like this, cycles > 10 so as not to interfere with initial data collection.
|
|
||||||
if(Math.abs(drainageChange)>currentDrainage*0.7&&data.fluctuationEvent==0&&data.totalCycles>=10){
|
|
||||||
//has fluctuated, first time doing so
|
|
||||||
reason="Skipped: Extreme fluctuation";
|
|
||||||
//set fluctuationevent so it knows what was the first time.
|
|
||||||
data.fluctuationEvent=data.totalCycles+1;
|
|
||||||
data.battLastRecorded=batt;
|
|
||||||
storage.writeJSON(dataFile, data);
|
|
||||||
|
|
||||||
if(getSettings().doLogging){
|
|
||||||
// Always log the sample
|
|
||||||
logBatterySample({
|
|
||||||
battNow: batt,
|
|
||||||
battLast: data.battLastRecorded,
|
|
||||||
battChange: battChange,
|
|
||||||
deltaHours: deltaHours,
|
|
||||||
avgDrainage: data.avgBattDrainage,
|
|
||||||
reason: reason
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}else{
|
|
||||||
data.fluctuationEvent=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
let newAvg = weightedAverage(data.avgBattDrainage, data.totalHours, currentDrainage, deltaHours * weightCoefficient);
|
||||||
|
|
||||||
let newAvg = weightedAverage(data.avgBattDrainage, data.totalHours, currentDrainage, deltaHours);
|
|
||||||
data.avgBattDrainage = newAvg;
|
data.avgBattDrainage = newAvg;
|
||||||
data.timeLastRecorded = now;
|
data.timeLastRecorded = now;
|
||||||
data.totalCycles += 1;
|
data.totalCycles += 1;
|
||||||
|
|
@ -107,6 +82,7 @@
|
||||||
battLast: data.battLastRecorded,
|
battLast: data.battLastRecorded,
|
||||||
battChange: battChange,
|
battChange: battChange,
|
||||||
deltaHours: deltaHours,
|
deltaHours: deltaHours,
|
||||||
|
timeLastRecorded: data.timeLastRecorded,
|
||||||
avgDrainage: data.avgBattDrainage,
|
avgDrainage: data.avgBattDrainage,
|
||||||
reason: reason
|
reason: reason
|
||||||
});
|
});
|
||||||
|
|
@ -126,7 +102,6 @@
|
||||||
timeLastRecorded: Date.now(),
|
timeLastRecorded: Date.now(),
|
||||||
totalCycles: 0,
|
totalCycles: 0,
|
||||||
totalHours: 0,
|
totalHours: 0,
|
||||||
fluctuationEvent:0
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue