Prevent TBR from being cancelled twice when setting a new TBR

This commit is contained in:
Bart Sopers 2019-12-27 10:10:48 -05:00
parent 3ebb85df46
commit 12a71b8d3e
3 changed files with 0 additions and 18 deletions

View file

@ -200,28 +200,15 @@ public class OmnipodManager {
} }
} }
// CAUTION: cancels temp basal and then sets new temp basal. An OmnipodException[certainFailure=false] indicates that the pod might have cancelled the previous temp basal, but did not set a new temp basal
public synchronized void setTemporaryBasal(TempBasalPair tempBasalPair, boolean acknowledgementBeep, boolean completionBeep) { public synchronized void setTemporaryBasal(TempBasalPair tempBasalPair, boolean acknowledgementBeep, boolean completionBeep) {
assertReadyForDelivery(); assertReadyForDelivery();
logStartingCommandExecution("setTemporaryBasal [tempBasalPair=" + tempBasalPair + ", acknowledgementBeep=" + acknowledgementBeep + ", completionBeep=" + completionBeep + "]"); logStartingCommandExecution("setTemporaryBasal [tempBasalPair=" + tempBasalPair + ", acknowledgementBeep=" + acknowledgementBeep + ", completionBeep=" + completionBeep + "]");
try {
cancelDelivery(EnumSet.of(DeliveryType.TEMP_BASAL), acknowledgementBeep);
} catch (Exception ex) {
logCommandExecutionFinished("setTemporaryBasal");
throw ex;
}
try { try {
executeAndVerify(() -> communicationService.executeAction(new SetTempBasalAction( executeAndVerify(() -> communicationService.executeAction(new SetTempBasalAction(
podState, tempBasalPair.getInsulinRate(), Duration.standardMinutes(tempBasalPair.getDurationMinutes()), podState, tempBasalPair.getInsulinRate(), Duration.standardMinutes(tempBasalPair.getDurationMinutes()),
acknowledgementBeep, completionBeep))); acknowledgementBeep, completionBeep)));
} catch (OmnipodException ex) {
// Treat all exceptions as uncertain failures, because all delivery has been suspended here.
// Setting this to an uncertain failure will enable for the user to get an appropriate warning
ex.setCertainFailure(false);
throw ex;
} finally { } finally {
logCommandExecutionFinished("setTemporaryBasal"); logCommandExecutionFinished("setTemporaryBasal");
} }

View file

@ -335,10 +335,6 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
delegate.setTemporaryBasal(tempBasalPair, beepsEnabled, beepsEnabled); delegate.setTemporaryBasal(tempBasalPair, beepsEnabled, beepsEnabled);
addSuccessToHistory(time, PodHistoryEntryType.SetTemporaryBasal, tempBasalPair); addSuccessToHistory(time, PodHistoryEntryType.SetTemporaryBasal, tempBasalPair);
} catch (Exception ex) { } catch (Exception ex) {
if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) {
addToHistory(time, PodHistoryEntryType.SetTemporaryBasal, "Uncertain failure", false);
return new PumpEnactResult().success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_set_temp_basal_failed_uncertain));
}
String comment = handleAndTranslateException(ex); String comment = handleAndTranslateException(ex);
addFailureToHistory(time, PodHistoryEntryType.SetTemporaryBasal, comment); addFailureToHistory(time, PodHistoryEntryType.SetTemporaryBasal, comment);
return new PumpEnactResult().success(false).enacted(false).comment(comment); return new PumpEnactResult().success(false).enacted(false).comment(comment);

View file

@ -1761,7 +1761,6 @@
<string name="omnipod_alert_low_reservoir">Low reservoir</string> <string name="omnipod_alert_low_reservoir">Low reservoir</string>
<string name="omnipod_alert_unknown_alert">Unknown alert</string> <string name="omnipod_alert_unknown_alert">Unknown alert</string>
<string name="omnipod_error_set_basal_failed_uncertain">Setting basal profile might have failed. Delivery might be suspended! Please refresh pod status.</string> <string name="omnipod_error_set_basal_failed_uncertain">Setting basal profile might have failed. Delivery might be suspended! Please refresh pod status.</string>
<string name="omnipod_error_set_temp_basal_failed_uncertain">Setting temp basal might have failed. If there was a temp basal already running, that may have been cancelled! Please refresh pod status.</string>
<string name="omnipod_error_set_time_failed_uncertain">Setting time might have failed. Delivery might be suspended! Please refresh pod status.</string> <string name="omnipod_error_set_time_failed_uncertain">Setting time might have failed. Delivery might be suspended! Please refresh pod status.</string>
<string name="omnipod_bolus_failed_uncertain">Unable to verify whether the bolus succeeded. Please verify that your pod is bolusing or cancel the bolus.</string> <string name="omnipod_bolus_failed_uncertain">Unable to verify whether the bolus succeeded. Please verify that your pod is bolusing or cancel the bolus.</string>