Handle errors when reading the history for verification fails.

This commit is contained in:
Johannes Mockenhaupt 2017-12-13 13:54:23 +01:00
parent 25f46fe601
commit 67eb6b20ed
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 8 additions and 0 deletions

View file

@ -511,6 +511,13 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
log.debug("Trying to determine from pump history what was actually delivered");
CommandResult readLastBolusResult = runCommand(MainApp.sResources.getString(R.string.combo_activity_verifying_delivered_bolus), 3,
() -> ruffyScripter.readHistory(new PumpHistoryRequest().bolusHistory(PumpHistoryRequest.LAST)));
if (!readLastBolusResult.success || readLastBolusResult.history == null) {
// this happens when the cartridge runs empty during delivery, the pump will be in an error
// state with multiple alarms ringing and no chance of reading history
return new PumpEnactResult().success(false).enacted(false)
.comment(MainApp.sResources.getString(R.string.combo_error_bolus_verification_failed));
}
List<Bolus> bolusHistory = readLastBolusResult.history.bolusHistory;
Bolus lastBolus = !bolusHistory.isEmpty() ? bolusHistory.get(0) : null;

View file

@ -840,5 +840,6 @@
<string name="combo_error_no_bolus_delivered">Bolus delivery failed. It appears no bolus was delivered. To be sure, please check the pump to avoid a double bolus and then bolus again. To guard against bugs, boluses are not automatically retried.</string>
<string name="combo_error_partial_bolus_delivered">Only %.2f U of the requested bolus of %.2f U was delivered due to an error. Please check the pump to verify this and take appropriate actions.</string>
<string name="combo_activity_verifying_delivered_bolus">Verifying delivered bolus</string>
<string name="combo_error_bolus_verification_failed">Delivering the bolus and verifying the pump\'s history failed, please check the pump and manually create a bolus record using the Careportal tab if a bolus was delivered.</string>
</resources>