diff --git a/app/src/main/java/info/nightscout/androidaps/db/Treatment.java b/app/src/main/java/info/nightscout/androidaps/db/Treatment.java index aebd52ac30..971e1d55f1 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/Treatment.java +++ b/app/src/main/java/info/nightscout/androidaps/db/Treatment.java @@ -183,10 +183,8 @@ public class Treatment implements DataPointWithLabelInterface { public Iob iobCalc(long time, double dia) { if (!isValid) return new Iob(); - InsulinInterface insulinInterface = MainApp.getInsulinIterfaceById(insulinInterfaceID); - if (insulinInterface == null) - insulinInterface = ConfigBuilderPlugin.getActiveInsulin(); + InsulinInterface insulinInterface = ConfigBuilderPlugin.getActiveInsulin(); return insulinInterface.iobCalcForTreatment(this, time, dia); } } 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 acaecac190..44b54876ef 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 @@ -185,7 +185,11 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { total.iob += tIOB.iobContrib; total.activity += tIOB.activityContrib; if (!t.isSMB) { - Iob bIOB = t.iobCalc(time, dia / SP.getDouble("openapsama_bolussnooze_dia_divisor", 2.0)); + // instead of dividing the DIA that only worked on the bilinear curves, + // multiply the time the treatment is seen active. + long timeSinceTreatent = t.date - time; + long snoozeTime = t.date - (long)(timeSinceTreatent * SP.getDouble("openapsama_bolussnooze_dia_divisor", 2.0)); + Iob bIOB = t.iobCalc(snoozeTime, dia); total.bolussnooze += bIOB.iobContrib; } else { total.basaliob += t.insulin;