diff --git a/app/src/main/java/info/nightscout/androidaps/data/IobTotal.java b/app/src/main/java/info/nightscout/androidaps/data/IobTotal.java index ed3096c945..1787f6b0d5 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/IobTotal.java +++ b/app/src/main/java/info/nightscout/androidaps/data/IobTotal.java @@ -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; } diff --git a/app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java b/app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java index 6e5ba4978d..503ccace22 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java @@ -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; } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java index d54c660559..1360500468 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java @@ -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; }