Show warning for uncertain failures and refresh overview when pod suspended state has changed
This commit is contained in:
parent
d63f34f316
commit
43f6c3dfd2
|
@ -78,6 +78,7 @@ public class Notification {
|
|||
public static final int USERMESSAGE = 53;
|
||||
public static final int OVER_24H_TIME_CHANGE_REQUESTED = 54;
|
||||
public static final int INVALID_VERSION = 55;
|
||||
public static final int OMNIPOD_PUMP_ALARM = 56;
|
||||
|
||||
|
||||
public int id;
|
||||
|
|
|
@ -63,7 +63,7 @@ public class OmnipodManager {
|
|||
protected PodSessionState podState;
|
||||
|
||||
private ActiveBolusData activeBolusData;
|
||||
private final Object bolusDataLock = new Object();
|
||||
private final Object bolusDataMutex = new Object();
|
||||
|
||||
public OmnipodManager(OmnipodCommunicationService communicationService, PodSessionState podState,
|
||||
PodStateChangedHandler podStateChangedHandler) {
|
||||
|
@ -224,7 +224,8 @@ public class OmnipodManager {
|
|||
try {
|
||||
// As the cancel delivery command is a single packet command,
|
||||
// first verify that the pod is reachable by obtaining a status response
|
||||
// FIXME is this actually necessary?
|
||||
// FIXME replace this with padding the CancelDelivery command message
|
||||
// with GetStatusResponse commands to ensure that the message > 1 packets
|
||||
StatusResponse podStatus = getPodStatus();
|
||||
} catch (OmnipodException ex) {
|
||||
logCommandExecutionFinished("cancelDelivery");
|
||||
|
@ -286,7 +287,7 @@ public class OmnipodManager {
|
|||
|
||||
SingleSubject<BolusDeliveryResult> bolusCompletionSubject = SingleSubject.create();
|
||||
|
||||
synchronized (bolusDataLock) {
|
||||
synchronized (bolusDataMutex) {
|
||||
activeBolusData = new ActiveBolusData(units, startDate, bolusCompletionSubject, disposables);
|
||||
}
|
||||
|
||||
|
@ -294,7 +295,7 @@ public class OmnipodManager {
|
|||
.delay(estimatedRemainingBolusDuration.getMillis() + 250, TimeUnit.MILLISECONDS) //
|
||||
.observeOn(Schedulers.io()) //
|
||||
.doOnComplete(() -> {
|
||||
synchronized (bolusDataLock) {
|
||||
synchronized (bolusDataMutex) {
|
||||
for (int i = 0; i < ACTION_VERIFICATION_TRIES; i++) {
|
||||
try {
|
||||
// Retrieve a status response in order to update the pod state
|
||||
|
@ -325,7 +326,7 @@ public class OmnipodManager {
|
|||
public synchronized void cancelBolus(boolean acknowledgementBeep) {
|
||||
assertReadyForDelivery();
|
||||
|
||||
synchronized (bolusDataLock) {
|
||||
synchronized (bolusDataMutex) {
|
||||
if (activeBolusData == null) {
|
||||
throw new IllegalDeliveryStatusException(DeliveryStatus.BOLUS_IN_PROGRESS, podState.getLastDeliveryStatus());
|
||||
}
|
||||
|
@ -335,6 +336,7 @@ public class OmnipodManager {
|
|||
try {
|
||||
cancelDelivery(EnumSet.of(DeliveryType.BOLUS), acknowledgementBeep);
|
||||
} catch (PodFaultException ex) {
|
||||
podState.setFaultEvent(ex.getFaultEvent());
|
||||
if (isLoggingEnabled()) {
|
||||
LOG.info("Ignoring PodFaultException in cancelBolus", ex);
|
||||
}
|
||||
|
|
|
@ -20,9 +20,12 @@ import info.nightscout.androidaps.data.PumpEnactResult;
|
|||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.events.Event;
|
||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||
|
@ -101,6 +104,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
pumpStatus.pumpStatusType = PumpStatusType.Suspended;
|
||||
sendEvent(new EventOmnipodAcknowledgeAlertsChanged());
|
||||
sendEvent(new EventOmnipodPumpValuesChanged());
|
||||
sendEvent(new EventRefreshOverview("Omnipod Pump"));
|
||||
} else {
|
||||
// Update active alerts
|
||||
if (podSessionState.hasActiveAlerts()) {
|
||||
|
@ -131,6 +135,10 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
pumpStatus.reservoirRemainingUnits = podSessionState.getReservoirLevel() == null ? 75.0 : podSessionState.getReservoirLevel();
|
||||
pumpStatus.pumpStatusType = podSessionState.isSuspended() ? PumpStatusType.Suspended : PumpStatusType.Running;
|
||||
sendEvent(new EventOmnipodPumpValuesChanged());
|
||||
|
||||
if (podSessionState.isSuspended() != PumpStatusType.Suspended.equals(pumpStatus.pumpStatusType)) {
|
||||
sendEvent(new EventRefreshOverview("Omnipod Pump"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -256,8 +264,10 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
}
|
||||
|
||||
if (OmnipodManager.CommandDeliveryStatus.UNCERTAIN_FAILURE.equals(bolusCommandResult.getCommandDeliveryStatus())) {
|
||||
// TODO notify user about uncertain failure ---> we're unsure whether or not the bolus has been delivered
|
||||
// For safety reasons, we should treat this as a bolus that has been delivered, in order to prevent insulin overdose
|
||||
// For safety reasons, we treat this as a bolus that has successfully been delivered, in order to prevent insulin overdose
|
||||
|
||||
// FIXME We can't dismiss the alert while the bolus progress dialog is open, so don't use a sound
|
||||
showNotification(getStringResource(R.string.omnipod_bolus_failed_uncertain), Notification.URGENT, null);
|
||||
}
|
||||
|
||||
// Wait for the bolus to finish
|
||||
|
@ -510,6 +520,17 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
RxBus.INSTANCE.send(event);
|
||||
}
|
||||
|
||||
private void showNotification(String message, int urgency, Integer sound) {
|
||||
Notification notification = new Notification( //
|
||||
Notification.OMNIPOD_PUMP_ALARM, //
|
||||
message, //
|
||||
urgency);
|
||||
if (sound != null) {
|
||||
notification.soundId = sound;
|
||||
}
|
||||
sendEvent(new EventNewNotification(notification));
|
||||
}
|
||||
|
||||
private String translateAlertType(AlertType alertType) {
|
||||
if (alertType == null) {
|
||||
return getStringResource(R.string.omnipod_alert_unknown_alert);
|
||||
|
|
|
@ -1744,6 +1744,7 @@
|
|||
<string name="omnipod_alert_unknown_alert">Unknown alert</string>
|
||||
<string name="omnipod_error_set_basal_failed_uncertain">Setting basal profile failed. Delivery might be suspended! Please refresh pod status.</string>
|
||||
<string name="omnipod_error_set_time_failed_uncertain">Setting time 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>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue