Merge pull request #380 from MilosKozak/dia-divisor-fix

Dia divisor / bolussnooze fix
This commit is contained in:
Milos Kozak 2017-08-20 21:52:42 +02:00 committed by GitHub
commit 33cf707d45
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 timeSinceTreatment = time - t.date;
long snoozeTime = t.date + (long)(timeSinceTreatment * SP.getDouble("openapsama_bolussnooze_dia_divisor", 2.0));
Iob bIOB = t.iobCalc(snoozeTime, dia);
total.bolussnooze += bIOB.iobContrib;
} else {
total.basaliob += t.insulin;