Merge branch 'omnipod_eros' of https://github.com/AAPS-Omnipod/AndroidAPS into omnipod_eros
This commit is contained in:
commit
3ae074da57
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -269,8 +277,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
|
||||
|
@ -304,7 +314,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
|
||||
@Override
|
||||
public PumpEnactResult setTemporaryBasal(TempBasalPair tempBasalPair) {
|
||||
boolean beepsEnabled = isBasalBeepsEnabled();
|
||||
boolean beepsEnabled = isTempBasalBeepsEnabled();
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
delegate.setTemporaryBasal(tempBasalPair, beepsEnabled, beepsEnabled);
|
||||
|
@ -322,7 +332,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
public PumpEnactResult cancelTemporaryBasal() {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
delegate.cancelTemporaryBasal(isBasalBeepsEnabled());
|
||||
delegate.cancelTemporaryBasal(isTempBasalBeepsEnabled());
|
||||
addSuccessToHistory(time, PodHistoryEntryType.CancelTemporaryBasal, null);
|
||||
} catch (Exception ex) {
|
||||
String comment = handleAndTranslateException(ex);
|
||||
|
@ -555,6 +565,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);
|
||||
|
@ -589,6 +610,11 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
return this.pumpStatus.beepBasalEnabled;
|
||||
}
|
||||
|
||||
private boolean isTempBasalBeepsEnabled() {
|
||||
// TODO add separate setting for temp basal beeps
|
||||
return this.pumpStatus.beepBasalEnabled;
|
||||
}
|
||||
|
||||
private String getStringResource(int id, Object... args) {
|
||||
return MainApp.gs(id, args);
|
||||
}
|
||||
|
|
|
@ -106,6 +106,11 @@ public class OmnipodDashCommunicationManager implements OmnipodCommunicationMana
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setTime() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPumpStatus(OmnipodPumpStatus pumpStatusLocal) {
|
||||
|
||||
|
|
|
@ -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