Multiply time passed instead of divide dia.

This commit is contained in:
AdrianLxM 2017-08-19 20:12:37 +02:00
parent 6b8dd5868d
commit d49eea854c
2 changed files with 6 additions and 4 deletions

View file

@ -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);
}
}

View file

@ -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;