Try to verify delivery status in case of failures in commands that change delivery status
This commit is contained in:
parent
923294ed1f
commit
77b359fa74
|
@ -30,4 +30,8 @@ public enum DeliveryStatus {
|
|||
public boolean isBolusing() {
|
||||
return this.equals(BOLUS_IN_PROGRESS) || this.equals(BOLUS_AND_TEMP_BASAL);
|
||||
}
|
||||
|
||||
public boolean isTbrRunning() {
|
||||
return this.equals(TEMP_BASAL_RUNNING) || this.equals(BOLUS_AND_TEMP_BASAL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.driver.exception;
|
||||
|
||||
public class CommandFailedAfterChangingDeliveryStatusException extends OmnipodException {
|
||||
public CommandFailedAfterChangingDeliveryStatusException(String message, Throwable cause) {
|
||||
super(message, cause, false);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.driver.exception;
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.DeliveryStatus;
|
||||
|
||||
public class DeliveryStatusVerificationFailedException extends OmnipodException {
|
||||
private final DeliveryStatus expectedStatus;
|
||||
|
||||
public DeliveryStatusVerificationFailedException(DeliveryStatus expectedStatus, Throwable cause) {
|
||||
super("Failed to verify delivery status (expected=" + expectedStatus + ")", cause, false);
|
||||
this.expectedStatus = expectedStatus;
|
||||
}
|
||||
|
||||
public DeliveryStatus getExpectedStatus() {
|
||||
return expectedStatus;
|
||||
}
|
||||
}
|
|
@ -38,7 +38,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PacketT
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodInfoType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BasalSchedule;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommandFailedAfterChangingDeliveryStatusException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommunicationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.DeliveryStatusVerificationFailedException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalDeliveryStatusException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPacketTypeException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPodProgressException;
|
||||
|
@ -196,23 +198,36 @@ public class OmnipodManager {
|
|||
|
||||
// CAUTION: cancels all delivery
|
||||
// CAUTION: suspends and then resumes delivery. An OmnipodException[certainFailure=false] indicates that the pod is or might be suspended
|
||||
public synchronized StatusResponse setBasalSchedule(BasalSchedule schedule, boolean acknowledgementBeep) {
|
||||
public synchronized void setBasalSchedule(BasalSchedule schedule, boolean acknowledgementBeep) {
|
||||
assertReadyForDelivery();
|
||||
|
||||
logStartingCommandExecution("setBasalSchedule [basalSchedule=" + schedule + ", acknowledgementBeep=" + acknowledgementBeep + "]");
|
||||
|
||||
try {
|
||||
cancelDelivery(EnumSet.allOf(DeliveryType.class), acknowledgementBeep);
|
||||
boolean wasSuspended = !podStateManager.isSuspended();
|
||||
if (wasSuspended) {
|
||||
suspendDelivery(acknowledgementBeep);
|
||||
}
|
||||
|
||||
try {
|
||||
return executeAndVerify(() -> communicationService.executeAction(new SetBasalScheduleAction(podStateManager, schedule,
|
||||
executeAndVerify(() -> communicationService.executeAction(new SetBasalScheduleAction(podStateManager, schedule,
|
||||
false, podStateManager.getScheduleOffset(), acknowledgementBeep)));
|
||||
} catch (OmnipodException ex) {
|
||||
// TODO try to recover or at least verify whether or not the Pod is suspended
|
||||
// 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;
|
||||
if (ex.isCertainFailure()) {
|
||||
if (!wasSuspended) {
|
||||
throw new CommandFailedAfterChangingDeliveryStatusException("Suspending delivery succeeded but setting the new basal schedule did not", ex);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
|
||||
// verifyDeliveryStatus will throw an exception if verification fails
|
||||
if (!verifyDeliveryStatus(DeliveryStatus.NORMAL, ex)) {
|
||||
if (!wasSuspended) {
|
||||
throw new CommandFailedAfterChangingDeliveryStatusException("Suspending delivery succeeded but setting the new basal schedule did not", ex);
|
||||
}
|
||||
ex.setCertainFailure(true);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
logCommandExecutionFinished("setBasalSchedule");
|
||||
|
@ -220,25 +235,50 @@ 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 StatusResponse setTemporaryBasal(double rate, Duration duration, boolean acknowledgementBeep, boolean completionBeep) {
|
||||
public synchronized void setTemporaryBasal(double rate, Duration duration, boolean acknowledgementBeep, boolean completionBeep) {
|
||||
assertReadyForDelivery();
|
||||
|
||||
logStartingCommandExecution("setTemporaryBasal [rate=" + rate + ", duration=" + duration + ", acknowledgementBeep=" + acknowledgementBeep + ", completionBeep=" + completionBeep + "]");
|
||||
|
||||
boolean cancelCurrentTbr = podStateManager.getLastDeliveryStatus().isTbrRunning();
|
||||
|
||||
try {
|
||||
cancelDelivery(EnumSet.of(DeliveryType.TEMP_BASAL), acknowledgementBeep);
|
||||
if (cancelCurrentTbr) {
|
||||
try {
|
||||
cancelDelivery(EnumSet.of(DeliveryType.TEMP_BASAL), acknowledgementBeep);
|
||||
} catch (OmnipodException ex) {
|
||||
if (ex.isCertainFailure()) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
// verifyDeliveryStatus will throw an exception if verification fails
|
||||
if (!verifyDeliveryStatus(DeliveryStatus.NORMAL, ex)) {
|
||||
ex.setCertainFailure(true);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
StatusResponse statusResponse = executeAndVerify(() -> communicationService.executeAction(new SetTempBasalAction(
|
||||
podStateManager, rate, duration,
|
||||
acknowledgementBeep, completionBeep)));
|
||||
return statusResponse;
|
||||
executeAndVerify(() -> communicationService.executeAction(new SetTempBasalAction(
|
||||
podStateManager, rate, duration, acknowledgementBeep, completionBeep)));
|
||||
} catch (OmnipodException ex) {
|
||||
// Treat all exceptions as uncertain failures, because the old TBR has been cancelled here
|
||||
// Setting this to an uncertain failure will enable for the user to get an appropriate warning
|
||||
// TODO try to recover
|
||||
ex.setCertainFailure(false);
|
||||
throw ex;
|
||||
if (ex.isCertainFailure()) {
|
||||
if (cancelCurrentTbr) {
|
||||
throw new CommandFailedAfterChangingDeliveryStatusException("Failed to set new TBR while cancelling old TBR succeeded", ex);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
|
||||
// verifyDeliveryStatus will throw an exception if verification fails
|
||||
if (!verifyDeliveryStatus(DeliveryStatus.TEMP_BASAL_RUNNING, ex)) {
|
||||
if (cancelCurrentTbr) {
|
||||
throw new CommandFailedAfterChangingDeliveryStatusException("Failed to set new TBR while cancelling old TBR succeeded", ex);
|
||||
}
|
||||
|
||||
ex.setCertainFailure(true);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
logCommandExecutionFinished("setTemporaryBasal");
|
||||
|
@ -327,7 +367,7 @@ public class OmnipodManager {
|
|||
.observeOn(Schedulers.io()) //
|
||||
.doOnComplete(() -> {
|
||||
synchronized (bolusDataMutex) {
|
||||
double unitsNotDelivered = 0.0d;
|
||||
double bolusNotDelivered = 0.0d;
|
||||
|
||||
for (int i = 0; i < ACTION_VERIFICATION_TRIES; i++) {
|
||||
try {
|
||||
|
@ -340,7 +380,7 @@ public class OmnipodManager {
|
|||
}
|
||||
} catch (PodFaultException ex) {
|
||||
// Substract units not delivered in case of a Pod failure
|
||||
unitsNotDelivered = ex.getFaultEvent().getBolusNotDelivered();
|
||||
bolusNotDelivered = ex.getFaultEvent().getBolusNotDelivered();
|
||||
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Caught PodFaultException in bolus completion verification", ex);
|
||||
break;
|
||||
|
@ -350,7 +390,7 @@ public class OmnipodManager {
|
|||
}
|
||||
|
||||
if (hasActiveBolus()) {
|
||||
activeBolusData.bolusCompletionSubject.onSuccess(new BolusDeliveryResult(units - unitsNotDelivered));
|
||||
activeBolusData.bolusCompletionSubject.onSuccess(new BolusDeliveryResult(units - bolusNotDelivered));
|
||||
activeBolusData = null;
|
||||
}
|
||||
}
|
||||
|
@ -384,9 +424,9 @@ public class OmnipodManager {
|
|||
}
|
||||
}
|
||||
|
||||
private void discardActiveBolusData(double unitsNotDelivered) {
|
||||
private void discardActiveBolusData(double bolusNotDelivered) {
|
||||
synchronized (bolusDataMutex) {
|
||||
double unitsDelivered = activeBolusData.getUnits() - unitsNotDelivered;
|
||||
double unitsDelivered = activeBolusData.getUnits() - bolusNotDelivered;
|
||||
podStateManager.setLastBolus(activeBolusData.getStartDate(), unitsDelivered);
|
||||
activeBolusData.getDisposables().dispose();
|
||||
activeBolusData.getBolusCompletionSubject().onSuccess(new BolusDeliveryResult(unitsDelivered));
|
||||
|
@ -395,19 +435,24 @@ public class OmnipodManager {
|
|||
}
|
||||
|
||||
public synchronized void suspendDelivery(boolean acknowledgementBeep) {
|
||||
cancelDelivery(EnumSet.allOf(DeliveryType.class), acknowledgementBeep);
|
||||
}
|
||||
|
||||
// Same as setting basal schedule, but without suspending delivery first
|
||||
public synchronized StatusResponse resumeDelivery(boolean acknowledgementBeep) {
|
||||
assertReadyForDelivery();
|
||||
logStartingCommandExecution("resumeDelivery");
|
||||
|
||||
logStartingCommandExecution("suspendDelivery");
|
||||
|
||||
try {
|
||||
return executeAndVerify(() -> communicationService.executeAction(new SetBasalScheduleAction(podStateManager, podStateManager.getBasalSchedule(),
|
||||
false, podStateManager.getScheduleOffset(), acknowledgementBeep)));
|
||||
cancelDelivery(EnumSet.allOf(DeliveryType.class), acknowledgementBeep);
|
||||
} catch (OmnipodException ex) {
|
||||
if (ex.isCertainFailure()) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
// verifyDeliveryStatus will throw an exception if verification fails
|
||||
if (!verifyDeliveryStatus(DeliveryStatus.SUSPENDED, ex)) {
|
||||
ex.setCertainFailure(true);
|
||||
throw ex;
|
||||
}
|
||||
} finally {
|
||||
logCommandExecutionFinished("resumeDelivery");
|
||||
logCommandExecutionFinished("suspendDelivery");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,7 +464,7 @@ public class OmnipodManager {
|
|||
logStartingCommandExecution("setTime [acknowledgementBeeps=" + acknowledgementBeeps + "]");
|
||||
|
||||
try {
|
||||
cancelDelivery(EnumSet.allOf(DeliveryType.class), acknowledgementBeeps);
|
||||
suspendDelivery(acknowledgementBeeps);
|
||||
|
||||
DateTimeZone oldTimeZone = podStateManager.getTimeZone();
|
||||
|
||||
|
@ -430,12 +475,20 @@ public class OmnipodManager {
|
|||
|
||||
setBasalSchedule(podStateManager.getBasalSchedule(), acknowledgementBeeps);
|
||||
} 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
|
||||
// TODO try to recover or at least verify whether or not the Pod is suspended
|
||||
podStateManager.setTimeZone(oldTimeZone);
|
||||
ex.setCertainFailure(false);
|
||||
throw ex;
|
||||
if (ex.isCertainFailure()) {
|
||||
podStateManager.setTimeZone(oldTimeZone);
|
||||
throw new CommandFailedAfterChangingDeliveryStatusException("Suspending delivery succeeded but resuming did not", ex);
|
||||
}
|
||||
|
||||
try {
|
||||
// verifyDeliveryStatus will throw an exception if verification fails
|
||||
if (!verifyDeliveryStatus(DeliveryStatus.NORMAL, ex)) {
|
||||
throw new CommandFailedAfterChangingDeliveryStatusException("Suspending delivery succeeded but resuming did not", ex);
|
||||
}
|
||||
} catch (Exception ex2) {
|
||||
podStateManager.setTimeZone(oldTimeZone);
|
||||
throw ex2;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
logCommandExecutionFinished("setTime");
|
||||
|
@ -450,7 +503,6 @@ public class OmnipodManager {
|
|||
logStartingCommandExecution("deactivatePod");
|
||||
|
||||
// Try to get pulse log for diagnostics
|
||||
// FIXME replace by storing to file
|
||||
try {
|
||||
PodInfoResponse podInfoResponse = communicationService.executeAction(new GetPodInfoAction(podStateManager, PodInfoType.RECENT_PULSE_LOG));
|
||||
PodInfoRecentPulseLog pulseLogInfo = podInfoResponse.getPodInfo();
|
||||
|
@ -559,6 +611,27 @@ public class OmnipodManager {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param expectedStatus expected delivery status
|
||||
* @param verificationCause the Exception causing us to verify the delivery status
|
||||
* @return true if the Pod's status matches the expected status, otherwise false
|
||||
* @throws DeliveryStatusVerificationFailedException in case reading the Pod status fails
|
||||
*/
|
||||
private boolean verifyDeliveryStatus(DeliveryStatus expectedStatus, Throwable verificationCause) {
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Attempting to verify delivery status (expected={})", expectedStatus);
|
||||
for (int i = 0; 2 > i; i++) {
|
||||
try {
|
||||
StatusResponse podStatus = getPodStatus();
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Resolved delivery status (expected={}, actual={})", expectedStatus, podStatus.getDeliveryStatus());
|
||||
return podStatus.getDeliveryStatus().equals(expectedStatus);
|
||||
} catch (Exception ignored) {
|
||||
// ignore and try to continue
|
||||
}
|
||||
}
|
||||
aapsLogger.warn(LTag.PUMPCOMM, "Failed to verify delivery status");
|
||||
throw new DeliveryStatusVerificationFailedException(expectedStatus, verificationCause);
|
||||
}
|
||||
|
||||
private void logStartingCommandExecution(String action) {
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Starting command execution for action: " + action);
|
||||
}
|
||||
|
|
|
@ -49,9 +49,11 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodInfo
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BasalSchedule;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BasalScheduleEntry;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.ActionInitializationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommandFailedAfterChangingDeliveryStatusException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommandInitializationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommunicationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CrcMismatchException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.DeliveryStatusVerificationFailedException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalDeliveryStatusException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalMessageAddressException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalMessageSequenceNumberException;
|
||||
|
@ -217,7 +219,7 @@ public class AapsOmnipodManager {
|
|||
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
|
||||
}
|
||||
|
||||
reportImplicitlyCanceledTbr();
|
||||
reportImplicitlyCancelledTbr();
|
||||
|
||||
addSuccessToHistory(time, PodHistoryEntryType.DEACTIVATE_POD, null);
|
||||
|
||||
|
@ -228,6 +230,8 @@ public class AapsOmnipodManager {
|
|||
|
||||
public PumpEnactResult setBasalProfile(Profile profile) {
|
||||
long time = System.currentTimeMillis();
|
||||
PodHistoryEntryType historyEntryType = podStateManager.isSuspended() ? PodHistoryEntryType.RESUME_DELIVERY : PodHistoryEntryType.SET_BASAL_SCHEDULE;
|
||||
|
||||
try {
|
||||
BasalSchedule basalSchedule;
|
||||
try {
|
||||
|
@ -237,17 +241,22 @@ public class AapsOmnipodManager {
|
|||
}
|
||||
delegate.setBasalSchedule(basalSchedule, isBasalBeepsEnabled());
|
||||
// Because setting a basal profile actually suspends and then resumes delivery, TBR is implicitly cancelled
|
||||
reportImplicitlyCanceledTbr();
|
||||
addSuccessToHistory(time, PodHistoryEntryType.SET_BASAL_SCHEDULE, profile.getBasalValues());
|
||||
reportImplicitlyCancelledTbr();
|
||||
addSuccessToHistory(time, historyEntryType, profile.getBasalValues());
|
||||
} catch (CommandFailedAfterChangingDeliveryStatusException ex) {
|
||||
reportImplicitlyCancelledTbr();
|
||||
String comment = getStringResource(R.string.omnipod_error_set_basal_failed_delivery_suspended);
|
||||
showErrorDialog(comment, R.raw.boluserror);
|
||||
addFailureToHistory(time, historyEntryType, comment);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
|
||||
} catch (DeliveryStatusVerificationFailedException ex) {
|
||||
String comment = getStringResource(R.string.omnipod_error_set_basal_failed_delivery_might_be_suspended);
|
||||
showErrorDialog(comment, R.raw.boluserror);
|
||||
addFailureToHistory(time, historyEntryType, comment);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
|
||||
} catch (Exception ex) {
|
||||
if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) {
|
||||
reportImplicitlyCanceledTbr();
|
||||
addToHistory(time, PodHistoryEntryType.SET_BASAL_SCHEDULE, "Uncertain failure", false);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_set_basal_failed_uncertain));
|
||||
}
|
||||
String comment = handleAndTranslateException(ex);
|
||||
reportImplicitlyCanceledTbr();
|
||||
addFailureToHistory(time, PodHistoryEntryType.SET_BASAL_SCHEDULE, comment);
|
||||
addFailureToHistory(time, historyEntryType, comment);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
|
||||
}
|
||||
|
||||
|
@ -257,7 +266,7 @@ public class AapsOmnipodManager {
|
|||
public PumpEnactResult discardPodState() {
|
||||
podStateManager.discardState();
|
||||
|
||||
reportImplicitlyCanceledTbr();
|
||||
reportImplicitlyCancelledTbr();
|
||||
|
||||
addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.RESET_POD_STATE, null);
|
||||
|
||||
|
@ -364,7 +373,7 @@ public class AapsOmnipodManager {
|
|||
return new PumpEnactResult(injector).success(true).enacted(true);
|
||||
} catch (PodFaultException ex) {
|
||||
aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus (implicitly because of a Pod Fault)");
|
||||
showPodFaultErrorDialog(ex.getFaultEvent().getFaultEventCode(), null);
|
||||
showPodFaultErrorDialog(ex.getFaultEvent().getFaultEventCode());
|
||||
addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.CANCEL_BOLUS, null);
|
||||
return new PumpEnactResult(injector).success(true).enacted(true);
|
||||
} catch (Exception ex) {
|
||||
|
@ -383,17 +392,23 @@ public class AapsOmnipodManager {
|
|||
try {
|
||||
delegate.setTemporaryBasal(PumpType.Insulet_Omnipod.determineCorrectBasalSize(tempBasalPair.getInsulinRate()), Duration.standardMinutes(tempBasalPair.getDurationMinutes()), beepsEnabled, beepsEnabled);
|
||||
time = System.currentTimeMillis();
|
||||
} catch (CommandFailedAfterChangingDeliveryStatusException ex) {
|
||||
reportImplicitlyCancelledTbr();
|
||||
String comment = getStringResource(R.string.omnipod_cancelled_old_tbr_failed_to_set_new);
|
||||
addFailureToHistory(time, PodHistoryEntryType.SET_TEMPORARY_BASAL, comment);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
|
||||
} catch (DeliveryStatusVerificationFailedException ex) {
|
||||
String comment = getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_might_be_cancelled);
|
||||
showNotification(comment, Notification.URGENT, R.raw.boluserror);
|
||||
addFailureToHistory(time, PodHistoryEntryType.SET_TEMPORARY_BASAL, comment);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
|
||||
} catch (Exception ex) {
|
||||
if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) {
|
||||
addToHistory(time, PodHistoryEntryType.SET_TEMPORARY_BASAL, "Uncertain failure", false);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_set_temp_basal_failed_uncertain));
|
||||
}
|
||||
String comment = handleAndTranslateException(ex);
|
||||
addFailureToHistory(time, PodHistoryEntryType.SET_TEMPORARY_BASAL, comment);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
|
||||
}
|
||||
|
||||
reportImplicitlyCanceledTbr();
|
||||
reportImplicitlyCancelledTbr();
|
||||
|
||||
long pumpId = addSuccessToHistory(time, PodHistoryEntryType.SET_TEMPORARY_BASAL, tempBasalPair);
|
||||
|
||||
|
@ -436,42 +451,19 @@ public class AapsOmnipodManager {
|
|||
return new PumpEnactResult(injector).success(true).enacted(true);
|
||||
}
|
||||
|
||||
public PumpEnactResult getPodInfo(PodInfoType podInfoType) {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
// TODO how can we return the PodInfo response?
|
||||
// This method is useless unless we return the PodInfoResponse,
|
||||
// because the pod state we keep, doesn't get updated from a PodInfoResponse.
|
||||
// We use StatusResponses for that, which can be obtained from the getPodStatus method
|
||||
PodInfoResponse podInfo = delegate.getPodInfo(podInfoType);
|
||||
addSuccessToHistory(time, PodHistoryEntryType.GET_POD_INFO, podInfo);
|
||||
return new PumpEnactResult(injector).success(true).enacted(true);
|
||||
} catch (Exception ex) {
|
||||
String comment = handleAndTranslateException(ex);
|
||||
addFailureToHistory(time, PodHistoryEntryType.GET_POD_INFO, comment);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
|
||||
}
|
||||
}
|
||||
|
||||
public PumpEnactResult suspendDelivery() {
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
delegate.suspendDelivery(isBasalBeepsEnabled());
|
||||
} catch (Exception ex) {
|
||||
String comment = handleAndTranslateException(ex);
|
||||
addFailureToHistory(time, PodHistoryEntryType.SUSPEND_DELIVERY, comment);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
|
||||
}
|
||||
|
||||
return new PumpEnactResult(injector).success(true).enacted(true);
|
||||
}
|
||||
|
||||
public PumpEnactResult resumeDelivery() {
|
||||
try {
|
||||
delegate.resumeDelivery(isBasalBeepsEnabled());
|
||||
} catch (Exception ex) {
|
||||
String comment = handleAndTranslateException(ex);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
|
||||
}
|
||||
|
||||
reportImplicitlyCancelledTbr();
|
||||
addSuccessToHistory(time, PodHistoryEntryType.SUSPEND_DELIVERY, null);
|
||||
return new PumpEnactResult(injector).success(true).enacted(true);
|
||||
}
|
||||
|
||||
|
@ -481,16 +473,21 @@ public class AapsOmnipodManager {
|
|||
try {
|
||||
delegate.setTime(isBasalBeepsEnabled());
|
||||
// Because set time actually suspends and then resumes delivery, TBR is implicitly cancelled
|
||||
reportImplicitlyCanceledTbr();
|
||||
reportImplicitlyCancelledTbr();
|
||||
addSuccessToHistory(time, PodHistoryEntryType.SET_TIME, null);
|
||||
} catch (CommandFailedAfterChangingDeliveryStatusException ex) {
|
||||
reportImplicitlyCancelledTbr();
|
||||
String comment = getStringResource(R.string.omnipod_error_set_time_failed_delivery_suspended);
|
||||
showErrorDialog(comment, R.raw.boluserror);
|
||||
addFailureToHistory(time, PodHistoryEntryType.SET_TIME, comment);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
|
||||
} catch (DeliveryStatusVerificationFailedException ex) {
|
||||
String comment = getStringResource(R.string.omnipod_error_set_time_failed_delivery_might_be_suspended);
|
||||
showErrorDialog(comment, R.raw.boluserror);
|
||||
addFailureToHistory(time, PodHistoryEntryType.SET_TIME, comment);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
|
||||
} catch (Exception ex) {
|
||||
if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) {
|
||||
reportImplicitlyCanceledTbr();
|
||||
addFailureToHistory(time, PodHistoryEntryType.SET_TIME, "Uncertain failure");
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_set_time_failed_uncertain));
|
||||
}
|
||||
String comment = handleAndTranslateException(ex);
|
||||
reportImplicitlyCanceledTbr();
|
||||
addFailureToHistory(time, PodHistoryEntryType.SET_TIME, comment);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
|
||||
}
|
||||
|
@ -545,7 +542,7 @@ public class AapsOmnipodManager {
|
|||
activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
}
|
||||
|
||||
private void reportImplicitlyCanceledTbr() {
|
||||
private void reportImplicitlyCancelledTbr() {
|
||||
//TreatmentsPlugin plugin = TreatmentsPlugin.getPlugin();
|
||||
TreatmentsInterface plugin = activePlugin.getActiveTreatments();
|
||||
if (plugin.isTempBasalInProgress()) {
|
||||
|
@ -680,17 +677,13 @@ public class AapsOmnipodManager {
|
|||
}
|
||||
|
||||
private void showPodFaultErrorDialog(FaultEventCode faultEventCode) {
|
||||
showErrorDialog(createPodFaultErrorMessage(faultEventCode), null);
|
||||
showPodFaultErrorDialog(faultEventCode, R.raw.boluserror);
|
||||
}
|
||||
|
||||
private void showPodFaultErrorDialog(FaultEventCode faultEventCode, Integer sound) {
|
||||
showErrorDialog(createPodFaultErrorMessage(faultEventCode), sound);
|
||||
}
|
||||
|
||||
private void showErrorDialog(String message) {
|
||||
showErrorDialog(message, null);
|
||||
}
|
||||
|
||||
private void showErrorDialog(String message, Integer sound) {
|
||||
Intent intent = new Intent(context, ErrorHelperActivity.class);
|
||||
intent.putExtra("soundid", sound);
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
<string name="omnipod_cmd_bolus_value">%1$.2f U</string>
|
||||
<string name="omnipod_cmd_bolus_value_with_carbs">%1$.2f U, CH=%2$.1f g</string>
|
||||
<string name="omnipod_cmd_tbr_value">Rate: %1$.2f U, duration: %2$d min</string>
|
||||
<string name="omnipod_cmd_discard_pod_desc">If you press <b>OK</b>, the Pod state will be forcibly reset and you will not be able to communicate with the Pod anymore. Do this only if you can not communicate with the Pod anymore. If you can still communicate with the Pod, please use the <b>Deactivate Pod</b> option.</string>
|
||||
<string name="omnipod_cmd_discard_pod_desc">If you press <b>OK</b>, the Pod state will be forcibly reset and you will not be able to communicate with the Pod anymore. Do this only if you can not communicate with the Pod anymore. If you can still communicate with the Pod, please use the <b>Deactivate Pod</b> option.\n\nIf you wish to proceed, please make sure to also remove the Pod from your body.</string>
|
||||
<string name="omnipod_cmd_pod_history_na">Pod History not available at the moment.</string>
|
||||
<string name="omnipod_init_pod_wizard_step1_title">Fill the Pod</string>
|
||||
<string name="omnipod_init_pod_wizard_step1_desc">\nFill the new Pod with enough insulin for 3 days.\n\nListen for two beeps from the Pod during the filling process. These indicate that the minimum amount of 85U has been inserted. Be sure to completely empty the fill syringe, even after hearing the two beeps.\n\nAfter filling the Pod, please press <b>Next</b>.\n\n<b>Note:</b> do not remove the Pod\'s needle cap at this time.</string>
|
||||
|
@ -132,9 +132,11 @@
|
|||
<string name="omnipod_alert_shutdown_imminent">Shutdown is imminent</string>
|
||||
<string name="omnipod_alert_low_reservoir">Low reservoir</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_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_basal_failed_delivery_might_be_suspended">Setting basal profile might have failed. Delivery might be suspended! Please refresh Pod status and resume delivery from the Omnipod tab if needed.</string>
|
||||
<string name="omnipod_error_set_basal_failed_delivery_suspended">Setting basal profile failed. Delivery is suspended! Please resume delivery from the Omnipod tab.</string>
|
||||
<string name="omnipod_error_set_temp_basal_failed_old_tbr_might_be_cancelled">Setting temp basal might have failed. If a temp basal was already running, it might have been cancelled without AndroidAPS being aware!</string>
|
||||
<string name="omnipod_error_set_time_failed_delivery_might_be_suspended">Setting time might have failed. Delivery might be suspended! Please refresh Pod status and resume delivery from the Omnipod tab if needed.</string>
|
||||
<string name="omnipod_error_set_time_failed_delivery_suspended">Setting time failed. Delivery is suspended! Please resume delivery from the Omnipod tab.</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_rl_stats">RL stats</string>
|
||||
<string name="omnipod_read_pulse_log_short">Pulse log</string>
|
||||
|
@ -158,6 +160,8 @@
|
|||
<string name="omnipod_cmd_pair_and_prime">Pair and prime</string>
|
||||
<string name="omnipod_cmd_fill_cannula_set_basal_profile">Fill cannula and set basal profile</string>
|
||||
<string name="omnipod_cmd_get_pulse_log">Get pulse log</string>
|
||||
<string name="omnipod_uncertain_failure">Uncertain failure</string>
|
||||
<string name="omnipod_cancelled_old_tbr_failed_to_set_new">Cancelled the old temporary basal, but failed to set new temporary basal</string>
|
||||
|
||||
<plurals name="omnipod_minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
|
Loading…
Reference in a new issue