Attempt to cancel Omnipod TBR when AAPS is not aware of a TBR

This commit is contained in:
Bart Sopers 2020-11-19 19:36:46 +01:00
parent 3daff2527e
commit eb37370fd1
2 changed files with 34 additions and 6 deletions

View file

@ -518,10 +518,32 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
firstRun = false;
} else if (!podStateManager.isBasalCertain() || !podStateManager.isTempBasalCertain()) {
aapsLogger.info(LTag.PUMP, "Acknowledged AAPS getPumpStatus request because basal and/or temp basal is uncertain");
executeCommand(OmnipodCommandType.GET_POD_STATUS, aapsOmnipodManager::getPodStatus);
getPodStatus();
}
}
private PumpEnactResult getPodStatus() {
PumpEnactResult result = executeCommand(OmnipodCommandType.GET_POD_STATUS, aapsOmnipodManager::getPodStatus);
// bit hacky...
if (result.success && !activePlugin.getActiveTreatments().isTempBasalInProgress() && podStateManager.isTempBasalRunning()) {
aapsLogger.warn(LTag.PUMP, "Cancelling TBR because AAPS is not aware of any running TBR");
getCommandQueue().cancelTempBasal(true, new Callback() {
@Override public void run() {
if (result.success) {
aapsLogger.info(LTag.PUMP, "Successfully cancelled TBR because AAPS was not aware of any running TBR");
} else {
aapsLogger.error(LTag.PUMP, "Failed to cancel TBR because AAPS was not aware of any running TBR");
rxBus.send(new EventNewNotification(new Notification(Notification.OMNIPOD_PUMP_ALARM, resourceHelper.gs(R.string.omnipod_error_tbr_running_but_aaps_not_aware), Notification.NORMAL).sound(R.raw.boluserror)));
}
}
});
}
return result;
}
@NonNull
@Override
public PumpEnactResult setNewBasalProfile(Profile profile) {
@ -785,7 +807,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
case ACKNOWLEDGE_ALERTS:
return executeCommand(OmnipodCommandType.ACKNOWLEDGE_ALERTS, aapsOmnipodManager::acknowledgeAlerts);
case GET_POD_STATUS:
return executeCommand(OmnipodCommandType.GET_POD_STATUS, aapsOmnipodManager::getPodStatus);
return getPodStatus();
case READ_PULSE_LOG:
return retrievePulseLog();
case SUSPEND_DELIVERY:
@ -861,7 +883,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
} else {
// Even if automatically changing the time is disabled, we still want to at least do a GetStatus request,
// in order to update the Pod's activation time, which we need for calculating the time on the Pod
result = executeCommand(OmnipodCommandType.GET_POD_STATUS, aapsOmnipodManager::getPodStatus);
result = getPodStatus();
}
if (result.success) {
@ -992,15 +1014,19 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
private void initializeAfterRileyLinkConnection() {
if (podStateManager.getActivationProgress().isAtLeast(ActivationProgress.PAIRING_COMPLETED)) {
boolean success = true;
for (int i = 0; STARTUP_STATUS_REQUEST_TRIES > i; i++) {
PumpEnactResult result = executeCommand(OmnipodCommandType.GET_POD_STATUS, aapsOmnipodManager::getPodStatus);
PumpEnactResult result = getPodStatus();
if (result.success) {
success = true;
aapsLogger.debug(LTag.PUMP, "Successfully retrieved Pod status on startup");
break;
} else {
aapsLogger.warn(LTag.PUMP, "Failed to retrieve Pod status on startup");
}
}
if (!success) {
aapsLogger.warn(LTag.PUMP, "Failed to retrieve Pod status on startup");
rxBus.send(new EventNewNotification(new Notification(Notification.OMNIPOD_PUMP_ALARM, resourceHelper.gs(R.string.omnipod_error_failed_to_refresh_status_on_startup), Notification.NORMAL)));
}
} else {
aapsLogger.debug(LTag.PUMP, "Not retrieving Pod status on startup: no Pod running");
}

View file

@ -122,6 +122,7 @@
<string name="omnipod_error_unknown_custom_command">Unknown custom command: %1$s</string>
<string name="omnipod_error_failed_to_read_pulse_log">Failed to read Pulse Log</string>
<string name="omnipod_error_failed_to_refresh_status">Failed to refresh status</string>
<string name="omnipod_error_failed_to_refresh_status_on_startup">Failed to refresh status on startup</string>
<string name="omnipod_error_failed_to_acknowledge_alerts">Failed to acknowledge alerts</string>
<string name="omnipod_error_failed_to_suspend_delivery">Failed to suspend delivery</string>
<string name="omnipod_error_failed_to_set_time">Failed to set time</string>
@ -135,6 +136,7 @@
<string name="omnipod_error_pod_fault_activation_time_exceeded">The Pod\'s activation time has been exceeded. This Pod can no longer be activated.</string>
<string name="omnipod_error_failed_to_verify_activation_progress">Failed to verify activation progress. Please retry.</string>
<string name="omnipod_error_pod_suspended">Pod suspended</string>
<string name="omnipod_error_tbr_running_but_aaps_not_aware">A temporary basal is running on the Pod, but AAPS is unaware of this temp basal. Please cancel your temporary basal.</string>
<!-- Omnipod - Confirmation -->
<string name="omnipod_confirmation">Confirmation</string>