Fix partial bolus displayed in error popup.

This commit is contained in:
Johannes Mockenhaupt 2017-12-15 22:46:43 +01:00
parent 7e7b11ba14
commit 92d0630c55
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -406,9 +406,6 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
break; break;
case RECOVERING: case RECOVERING:
event.status = MainApp.sResources.getString(R.string.combo_error_bolus_recovery_progress); event.status = MainApp.sResources.getString(R.string.combo_error_bolus_recovery_progress);
case FINISHED:
// no state, just percent below to close bolus progress dialog
break;
} }
event.percent = percent; event.percent = percent;
MainApp.bus().post(event); MainApp.bus().post(event);
@ -531,17 +528,20 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (lastBolus == null // no bolus ever given if (lastBolus == null // no bolus ever given
|| lastBolus.timestamp < pumpTimeWhenBolusWasRequested // this is not the bolus you're looking for || lastBolus.timestamp < pumpTimeWhenBolusWasRequested // this is not the bolus you're looking for
|| !lastBolus.isValid) { // ext/multiwave bolus || !lastBolus.isValid) { // ext/multiwave bolus
log.debug("It appears no bolus was delivered"); log.debug("No bolus was delivered");
return new PumpEnactResult().success(false).enacted(false) return new PumpEnactResult().success(false).enacted(false)
.comment(MainApp.sResources.getString(R.string.combo_error_no_bolus_delivered)); .comment(MainApp.sResources.getString(R.string.combo_error_no_bolus_delivered));
} else if (Math.abs(lastBolus.amount - detailedBolusInfo.insulin) > 0.01) { // bolus only partially delivered } else if (Math.abs(lastBolus.amount - detailedBolusInfo.insulin) > 0.01) { // bolus only partially delivered
double requestedBolus = detailedBolusInfo.insulin;
detailedBolusInfo.insulin = lastBolus.amount; detailedBolusInfo.insulin = lastBolus.amount;
detailedBolusInfo.source = Source.USER; detailedBolusInfo.source = Source.USER;
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
log.debug(String.format(Locale.getDefault(), "Added partial bolus of %.2f to treatments", lastBolus.amount)); log.debug(String.format(Locale.getDefault(), "Added partial bolus of %.2f to treatments (requested: %.2f", lastBolus.amount, requestedBolus));
return new PumpEnactResult().success(false).enacted(true) return new PumpEnactResult().success(false).enacted(true)
.comment(MainApp.sResources.getString(R.string.combo_error_partial_bolus_delivered, .comment(MainApp.sResources.getString(R.string.combo_error_partial_bolus_delivered,
lastBolus.amount, detailedBolusInfo.insulin)); lastBolus.amount, requestedBolus));
} }
// bolus was correctly and fully delivered // bolus was correctly and fully delivered