fix iob calculation in the past
This commit is contained in:
parent
12eec7108a
commit
1b385c10e3
3 changed files with 3 additions and 1 deletions
|
@ -184,8 +184,8 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
||||||
|
|
||||||
long oldestDataAvailable = MainApp.getConfigBuilder().getActiveTempBasals().oldestDataAvaialable();
|
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);
|
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());
|
AutosensResult autosensResult = Autosens.detectSensitivityandCarbAbsorption(bgReadings, new Date().getTime());
|
||||||
|
|
||||||
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobArray, glucoseStatus, mealData,
|
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobArray, glucoseStatus, mealData,
|
||||||
|
|
|
@ -173,6 +173,7 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface {
|
||||||
IobTotal total = new IobTotal(time);
|
IobTotal total = new IobTotal(time);
|
||||||
for (Integer pos = 0; pos < tempBasals.size(); pos++) {
|
for (Integer pos = 0; pos < tempBasals.size(); pos++) {
|
||||||
TempBasal t = tempBasals.get(pos);
|
TempBasal t = tempBasals.get(pos);
|
||||||
|
if (t.timeStart.getTime() > time) continue;
|
||||||
IobTotal calc = t.iobCalc(now);
|
IobTotal calc = t.iobCalc(now);
|
||||||
total.plus(calc);
|
total.plus(calc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
Date now = new Date(time);
|
Date now = new Date(time);
|
||||||
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
||||||
Treatment t = treatments.get(pos);
|
Treatment t = treatments.get(pos);
|
||||||
|
if (t.created_at.getTime() > time) continue;
|
||||||
Iob tIOB = t.iobCalc(now, dia);
|
Iob tIOB = t.iobCalc(now, dia);
|
||||||
total.iob += tIOB.iobContrib;
|
total.iob += tIOB.iobContrib;
|
||||||
total.activity += tIOB.activityContrib;
|
total.activity += tIOB.activityContrib;
|
||||||
|
|
Loading…
Reference in a new issue