fix double carbs when carbtime != 0

This commit is contained in:
Milos Kozak 2016-09-09 11:04:50 +02:00
parent 47bff5ad5e
commit 77916ec4ae

View file

@ -364,7 +364,8 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
if (result.success) { if (result.success) {
Treatment t = new Treatment(); Treatment t = new Treatment();
t.insulin = result.bolusDelivered; t.insulin = result.bolusDelivered;
t.carbs = (double) result.carbsDelivered; if (carbTime == 0)
t.carbs = (double) result.carbsDelivered; // with different carbTime record will come back from nightscout
t.created_at = new Date(); t.created_at = new Date();
try { try {
MainApp.getDbHelper().getDaoTreatments().create(t); MainApp.getDbHelper().getDaoTreatments().create(t);
@ -372,6 +373,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
e.printStackTrace(); e.printStackTrace();
} }
t.setTimeIndex(t.getTimeIndex()); t.setTimeIndex(t.getTimeIndex());
t.carbs = (double) result.carbsDelivered;
uploadBolusWizardRecord(t, glucose, glucoseType, carbTime, boluscalc); uploadBolusWizardRecord(t, glucose, glucoseType, carbTime, boluscalc);
MainApp.bus().post(new EventTreatmentChange()); MainApp.bus().post(new EventTreatmentChange());
} }