fix iob calculation in the past

This commit is contained in:
Milos Kozak 2017-01-17 16:19:34 +01:00
parent 12eec7108a
commit 1b385c10e3
3 changed files with 3 additions and 1 deletions

View file

@ -184,8 +184,8 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
long oldestDataAvailable = MainApp.getConfigBuilder().getActiveTempBasals().oldestDataAvaialable();
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString());
List<BgReading> bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(Math.max(oldestDataAvailable, (long) (new Date().getTime() - 60 * 60 * 1000L * (24 + profile.getDia()))), false);
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString() + " (" + bgReadings.size() + " records)");
AutosensResult autosensResult = Autosens.detectSensitivityandCarbAbsorption(bgReadings, new Date().getTime());
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobArray, glucoseStatus, mealData,

View file

@ -173,6 +173,7 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface {
IobTotal total = new IobTotal(time);
for (Integer pos = 0; pos < tempBasals.size(); pos++) {
TempBasal t = tempBasals.get(pos);
if (t.timeStart.getTime() > time) continue;
IobTotal calc = t.iobCalc(now);
total.plus(calc);
}

View file

@ -123,6 +123,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
Date now = new Date(time);
for (Integer pos = 0; pos < treatments.size(); pos++) {
Treatment t = treatments.get(pos);
if (t.created_at.getTime() > time) continue;
Iob tIOB = t.iobCalc(now, dia);
total.iob += tIOB.iobContrib;
total.activity += tIOB.activityContrib;