fix adding contribution from faked extended

This commit is contained in:
Milos Kozak 2017-05-26 12:07:56 +02:00
parent a9b251ce12
commit 4b39578d9c
3 changed files with 14 additions and 3 deletions

View file

@ -22,6 +22,8 @@ public class IobTotal {
public Double netInsulin = 0d; // for calculations from temp basals only
public Double netRatio = 0d; // net ratio at start of temp basal
public Double extendedBolusInsulin = 0d; // total insulin for extended bolus
long time;
public IobTotal(long time) {
@ -42,7 +44,7 @@ public class IobTotal {
netbasalinsulin += other.netbasalinsulin;
hightempinsulin += other.hightempinsulin;
netInsulin += other.netInsulin;
netRatio += other.netRatio;
extendedBolusInsulin += other.extendedBolusInsulin;
return this;
}

View file

@ -159,6 +159,7 @@ public class ExtendedBolus implements Interval {
Iob aIOB = insulinInterface.iobCalcForTreatment(tempBolusPart, time, profile.getDia());
result.iob += aIOB.iobContrib;
result.activity += aIOB.activityContrib;
result.extendedBolusInsulin += tempBolusPart.insulin;
}
}
}

View file

@ -306,13 +306,21 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
//log.debug("BasalIOB " + new Date(time) + " >>> " + calc.basaliob);
total.plus(calc);
}
if (MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses())
if (MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses()) {
IobTotal totalExt = new IobTotal(time);
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
ExtendedBolus e = extendedBoluses.get(pos);
if (e.date > time) continue;
IobTotal calc = e.iobCalc(time);
total.plus(calc);
totalExt.plus(calc);
}
// Convert to basal iob
totalExt.basaliob = totalExt.iob;
totalExt.iob = 0d;
totalExt.netbasalinsulin = totalExt.extendedBolusInsulin;
totalExt.hightempinsulin = totalExt.extendedBolusInsulin;
total.plus(totalExt);
}
return total;
}