Merge branch 'omnipod_eros' of https://github.com/AAPS-Omnipod/AndroidAPS into omnipod_eros

This commit is contained in:
Andy Rozman 2019-12-27 11:07:57 +01:00
commit 3ebb85df46
3 changed files with 21 additions and 12 deletions

View file

@ -179,9 +179,7 @@ public class OmnipodManager {
logStartingCommandExecution("setBasalSchedule [basalSchedule=" + schedule + ", acknowledgementBeep=" + acknowledgementBeep + "]");
try {
// Never emit a beep for suspending delivery, so if the user has beeps enabled,
// they can verify that setting the basal schedule succeeded (not suspending the delivery)
cancelDelivery(EnumSet.allOf(DeliveryType.class), false);
cancelDelivery(EnumSet.allOf(DeliveryType.class), acknowledgementBeep);
} catch (Exception ex) {
logCommandExecutionFinished("setBasalSchedule");
throw ex;
@ -209,9 +207,7 @@ public class OmnipodManager {
logStartingCommandExecution("setTemporaryBasal [tempBasalPair=" + tempBasalPair + ", acknowledgementBeep=" + acknowledgementBeep + ", completionBeep=" + completionBeep + "]");
try {
// Never emit a beep for cancelling temp basal, so if the user has beeps enabled,
// they can verify that setting the temp basal succeeded (and not cancelling it)
cancelDelivery(EnumSet.of(DeliveryType.TEMP_BASAL), false);
cancelDelivery(EnumSet.of(DeliveryType.TEMP_BASAL), acknowledgementBeep);
} catch (Exception ex) {
logCommandExecutionFinished("setTemporaryBasal");
throw ex;
@ -241,7 +237,12 @@ public class OmnipodManager {
logStartingCommandExecution("cancelDelivery [deliveryTypes=" + deliveryTypes + ", acknowledgementBeep=" + acknowledgementBeep + "]");
try {
executeAndVerify(() -> communicationService.executeAction(new CancelDeliveryAction(podState, deliveryTypes, acknowledgementBeep)));
executeAndVerify(() -> {
StatusResponse statusResponse = communicationService.executeAction(new CancelDeliveryAction(podState, deliveryTypes, acknowledgementBeep));
if (isLoggingEnabled()) {
LOG.info("Status response after cancel delivery[types={}]: {}", deliveryTypes.toString(), statusResponse.toString());
}
});
} finally {
logCommandExecutionFinished("cancelDelivery");
}
@ -537,8 +538,11 @@ public class OmnipodManager {
}
try {
logStartingCommandExecution("verifyCommand");
communicationService.sendCommand(StatusResponse.class, podState,
StatusResponse statusResponse = communicationService.sendCommand(StatusResponse.class, podState,
new CancelDeliveryCommand(podState.getCurrentNonce(), BeepType.NO_BEEP, DeliveryType.NONE), false);
if (isLoggingEnabled()) {
LOG.info("Status response after verifyCommand (cancelDelivery[types=DeliveryType.NONE]): {}", statusResponse.toString());
}
} catch (NonceOutOfSyncException ex) {
if (isLoggingEnabled()) {
LOG.info("Command resolved to FAILURE (CERTAIN_FAILURE)", ex);

View file

@ -39,7 +39,7 @@ public class CancelDeliveryAction implements OmnipodAction<StatusResponse> {
List<MessageBlock> messageBlocks = new ArrayList<>();
messageBlocks.add(new CancelDeliveryCommand(podState.getCurrentNonce(),
acknowledgementBeep && deliveryTypes.size() == 1 ? BeepType.BIP_BIP : BeepType.NO_BEEP, deliveryTypes));
acknowledgementBeep && deliveryTypes.size() == 1 ? BeepType.BEEP : BeepType.NO_BEEP, deliveryTypes));
if (acknowledgementBeep && deliveryTypes.size() > 1) {
// Workaround for strange beep behaviour when cancelling multiple delivery types at the same time
@ -49,7 +49,7 @@ public class CancelDeliveryAction implements OmnipodAction<StatusResponse> {
// we should keep the beep config for delivery types that we're not cancelling.
// We currently have no use case that though,
// as we either cancel 1 type or all types,
messageBlocks.add(new BeepConfigCommand(BeepConfigType.BIP_BIP));
messageBlocks.add(new BeepConfigCommand(BeepConfigType.BEEP));
}
return communicationService.exchangeMessages(StatusResponse.class, podState,

View file

@ -8,6 +8,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.Sta
import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
import info.nightscout.androidaps.plugins.pump.omnipod.exception.ActionInitializationException;
import info.nightscout.androidaps.plugins.pump.omnipod.exception.PodFaultException;
public class DeactivatePodAction implements OmnipodAction<StatusResponse> {
private final PodSessionState podState;
@ -24,8 +25,12 @@ public class DeactivatePodAction implements OmnipodAction<StatusResponse> {
@Override
public StatusResponse execute(OmnipodCommunicationService communicationService) {
if (!podState.isSuspended() && !podState.hasFaultEvent()) {
try {
communicationService.executeAction(new CancelDeliveryAction(podState,
EnumSet.allOf(DeliveryType.class), acknowledgementBeep));
} catch(PodFaultException ex) {
// Ignore
}
}
return communicationService.sendCommand(StatusResponse.class, podState, new DeactivatePodCommand(podState.getCurrentNonce()));