Prepare OmnipodManager and AapsOmnipodManager for configurable beeps
This commit is contained in:
parent
321f5eec3c
commit
b186f01c11
|
@ -136,37 +136,37 @@ public class OmnipodManager {
|
|||
executeAndVerify(() -> communicationService.executeAction(new AcknowledgeAlertsAction(podState, podState.getActiveAlerts())));
|
||||
}
|
||||
|
||||
public synchronized void setBasalSchedule(BasalSchedule schedule) {
|
||||
public synchronized void setBasalSchedule(BasalSchedule schedule, boolean acknowledgementBeep) {
|
||||
assertReadyForDelivery();
|
||||
|
||||
executeAndVerify(() -> communicationService.executeAction(new SetBasalScheduleAction(podState, schedule,
|
||||
false, podState.getScheduleOffset(), true)));
|
||||
false, podState.getScheduleOffset(), acknowledgementBeep)));
|
||||
}
|
||||
|
||||
public synchronized void setTemporaryBasal(TempBasalPair tempBasalPair) {
|
||||
public synchronized void setTemporaryBasal(TempBasalPair tempBasalPair, boolean acknowledgementBeep, boolean completionBeep) {
|
||||
assertReadyForDelivery();
|
||||
|
||||
executeAndVerify(() -> communicationService.executeAction(new SetTempBasalAction(new SetTempBasalService(),
|
||||
podState, tempBasalPair.getInsulinRate(), Duration.standardMinutes(tempBasalPair.getDurationMinutes()),
|
||||
true, true)));
|
||||
acknowledgementBeep, completionBeep)));
|
||||
}
|
||||
|
||||
public synchronized void cancelTemporaryBasal() {
|
||||
public synchronized void cancelTemporaryBasal(boolean acknowledgementBeep) {
|
||||
assertReadyForDelivery();
|
||||
|
||||
executeAndVerify(() -> communicationService.executeAction(new CancelDeliveryAction(podState, DeliveryType.TEMP_BASAL, true)));
|
||||
executeAndVerify(() -> communicationService.executeAction(new CancelDeliveryAction(podState, DeliveryType.TEMP_BASAL, acknowledgementBeep)));
|
||||
}
|
||||
|
||||
// Returns a SingleSubject that returns when the bolus has finished.
|
||||
// When a bolus is cancelled, it will return after cancellation and report the estimated units delivered
|
||||
// Only throws OmnipodException[certainFailure=false]
|
||||
public synchronized BolusCommandResult bolus(Double units, BolusProgressIndicationConsumer progressIndicationConsumer) {
|
||||
public synchronized BolusCommandResult bolus(Double units, boolean acknowledgementBeep, boolean completionBeep, BolusProgressIndicationConsumer progressIndicationConsumer) {
|
||||
assertReadyForDelivery();
|
||||
|
||||
CommandDeliveryStatus commandDeliveryStatus = CommandDeliveryStatus.SUCCESS;
|
||||
|
||||
try {
|
||||
executeAndVerify(() -> communicationService.executeAction(new BolusAction(podState, units, true, true)));
|
||||
executeAndVerify(() -> communicationService.executeAction(new BolusAction(podState, units, acknowledgementBeep, completionBeep)));
|
||||
} catch (OmnipodException ex) {
|
||||
if (ex.isCertainFailure()) {
|
||||
throw ex;
|
||||
|
@ -236,7 +236,7 @@ public class OmnipodManager {
|
|||
return new BolusCommandResult(commandDeliveryStatus, bolusCompletionSubject);
|
||||
}
|
||||
|
||||
public synchronized void cancelBolus() {
|
||||
public synchronized void cancelBolus(boolean acknowledgementBeep) {
|
||||
assertReadyForDelivery();
|
||||
|
||||
synchronized (bolusDataLock) {
|
||||
|
@ -244,7 +244,7 @@ public class OmnipodManager {
|
|||
throw new IllegalDeliveryStatusException(DeliveryStatus.BOLUS_IN_PROGRESS, podState.getLastDeliveryStatus());
|
||||
}
|
||||
|
||||
executeAndVerify(() -> communicationService.executeAction(new CancelDeliveryAction(podState, DeliveryType.BOLUS, true)));
|
||||
executeAndVerify(() -> communicationService.executeAction(new CancelDeliveryAction(podState, DeliveryType.BOLUS, acknowledgementBeep)));
|
||||
|
||||
activeBolusData.getDisposables().dispose();
|
||||
activeBolusData.getBolusCompletionSubject().onSuccess(new BolusDeliveryResult(activeBolusData.estimateUnitsDelivered()));
|
||||
|
@ -253,40 +253,40 @@ public class OmnipodManager {
|
|||
}
|
||||
|
||||
// CAUTION: cancels TBR and bolus
|
||||
public synchronized void suspendDelivery() {
|
||||
public synchronized void suspendDelivery(boolean acknowledgementBeep) {
|
||||
assertReadyForDelivery();
|
||||
|
||||
executeAndVerify(() -> communicationService.executeAction(new CancelDeliveryAction(podState, EnumSet.allOf(DeliveryType.class), true)));
|
||||
executeAndVerify(() -> communicationService.executeAction(new CancelDeliveryAction(podState, EnumSet.allOf(DeliveryType.class), acknowledgementBeep)));
|
||||
}
|
||||
|
||||
public synchronized void resumeDelivery() {
|
||||
public synchronized void resumeDelivery(boolean acknowledgementBeep) {
|
||||
assertReadyForDelivery();
|
||||
|
||||
executeAndVerify(() -> communicationService.executeAction(new SetBasalScheduleAction(podState, podState.getBasalSchedule(),
|
||||
true, podState.getScheduleOffset(), true)));
|
||||
true, podState.getScheduleOffset(), acknowledgementBeep)));
|
||||
}
|
||||
|
||||
// CAUTION: cancels TBR and bolus
|
||||
// CAUTION: suspends and then resumes delivery.
|
||||
// If any error occurs during the command sequence, delivery could be suspended
|
||||
public synchronized void setTime() {
|
||||
public synchronized void setTime(boolean acknowledgementBeeps) {
|
||||
assertReadyForDelivery();
|
||||
|
||||
suspendDelivery();
|
||||
suspendDelivery(acknowledgementBeeps);
|
||||
|
||||
// Joda seems to cache the default time zone, so we use the JVM's
|
||||
DateTimeZone.setDefault(DateTimeZone.forTimeZone(TimeZone.getDefault()));
|
||||
podState.setTimeZone(DateTimeZone.getDefault());
|
||||
|
||||
resumeDelivery();
|
||||
resumeDelivery(acknowledgementBeeps);
|
||||
}
|
||||
|
||||
public synchronized void deactivatePod() {
|
||||
public synchronized void deactivatePod(boolean acknowledgementBeep) {
|
||||
if (podState == null) {
|
||||
throw new IllegalSetupProgressException(SetupProgress.ADDRESS_ASSIGNED, null);
|
||||
}
|
||||
|
||||
executeAndVerify(() -> communicationService.executeAction(new DeactivatePodAction(podState, true)));
|
||||
executeAndVerify(() -> communicationService.executeAction(new DeactivatePodAction(podState, acknowledgementBeep)));
|
||||
|
||||
resetPodState();
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
@Override
|
||||
public PumpEnactResult deactivatePod(PodInitReceiver podInitReceiver) {
|
||||
try {
|
||||
delegate.deactivatePod();
|
||||
delegate.deactivatePod(true);
|
||||
} catch (Exception ex) {
|
||||
String comment = handleAndTranslateException(ex);
|
||||
podInitReceiver.returnInitTaskStatus(PodInitActionType.DeactivatePodWizardStep, false, comment);
|
||||
|
@ -127,7 +127,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
@Override
|
||||
public PumpEnactResult setBasalProfile(Profile basalProfile) {
|
||||
try {
|
||||
delegate.setBasalSchedule(mapProfileToBasalSchedule(basalProfile));
|
||||
delegate.setBasalSchedule(mapProfileToBasalSchedule(basalProfile), isBasalBeepsEnabled());
|
||||
} catch (Exception ex) {
|
||||
String comment = handleAndTranslateException(ex);
|
||||
return new PumpEnactResult().success(false).enacted(false).comment(comment);
|
||||
|
@ -151,8 +151,11 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
@Override
|
||||
public PumpEnactResult setBolus(Double units/*, boolean isSmb*/) {
|
||||
OmnipodManager.BolusCommandResult bolusCommandResult;
|
||||
|
||||
boolean beepsEnabled = /* isSmb ? isSmbBeepsEnabled() : */ isBolusBeepsEnabled();
|
||||
|
||||
try {
|
||||
bolusCommandResult = delegate.bolus(units, /* isSmb ? null : */
|
||||
bolusCommandResult = delegate.bolus(units, beepsEnabled, beepsEnabled, /* isSmb ? null : */
|
||||
(estimatedUnitsDelivered, percentage) -> {
|
||||
EventOverviewBolusProgress progressUpdateEvent = EventOverviewBolusProgress.INSTANCE;
|
||||
progressUpdateEvent.setStatus(getStringResource(R.string.bolusdelivering, units));
|
||||
|
@ -188,7 +191,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
@Override
|
||||
public PumpEnactResult cancelBolus() {
|
||||
try {
|
||||
delegate.cancelBolus();
|
||||
delegate.cancelBolus(isBolusBeepsEnabled());
|
||||
} catch (Exception ex) {
|
||||
String comment = handleAndTranslateException(ex);
|
||||
return new PumpEnactResult().success(false).enacted(false).comment(comment);
|
||||
|
@ -199,8 +202,9 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
|
||||
@Override
|
||||
public PumpEnactResult setTemporaryBasal(TempBasalPair tempBasalPair) {
|
||||
boolean beepsEnabled = isBasalBeepsEnabled();
|
||||
try {
|
||||
delegate.setTemporaryBasal(tempBasalPair);
|
||||
delegate.setTemporaryBasal(tempBasalPair, beepsEnabled, beepsEnabled);
|
||||
} catch (Exception ex) {
|
||||
String comment = handleAndTranslateException(ex);
|
||||
return new PumpEnactResult().success(false).enacted(false).comment(comment);
|
||||
|
@ -212,7 +216,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
@Override
|
||||
public PumpEnactResult cancelTemporaryBasal() {
|
||||
try {
|
||||
delegate.cancelTemporaryBasal();
|
||||
delegate.cancelTemporaryBasal(isBasalBeepsEnabled());
|
||||
} catch (Exception ex) {
|
||||
String comment = handleAndTranslateException(ex);
|
||||
return new PumpEnactResult().success(false).enacted(false).comment(comment);
|
||||
|
@ -255,7 +259,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
|
||||
public PumpEnactResult suspendDelivery() {
|
||||
try {
|
||||
delegate.suspendDelivery();
|
||||
delegate.suspendDelivery(isBasalBeepsEnabled());
|
||||
} catch (Exception ex) {
|
||||
String comment = handleAndTranslateException(ex);
|
||||
return new PumpEnactResult().success(false).enacted(false).comment(comment);
|
||||
|
@ -266,7 +270,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
|
||||
public PumpEnactResult resumeDelivery() {
|
||||
try {
|
||||
delegate.resumeDelivery();
|
||||
delegate.resumeDelivery(isBasalBeepsEnabled());
|
||||
} catch (Exception ex) {
|
||||
String comment = handleAndTranslateException(ex);
|
||||
return new PumpEnactResult().success(false).enacted(false).comment(comment);
|
||||
|
@ -278,8 +282,10 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
// TODO should we add this to the OmnipodCommunicationManager interface?
|
||||
public PumpEnactResult setTime() {
|
||||
try {
|
||||
delegate.setTime();
|
||||
// CAUTION cancels TBR
|
||||
delegate.setTime(isBasalBeepsEnabled());
|
||||
} catch (Exception ex) {
|
||||
// CAUTION pod could be suspended
|
||||
String comment = handleAndTranslateException(ex);
|
||||
return new PumpEnactResult().success(false).enacted(false).comment(comment);
|
||||
}
|
||||
|
@ -378,6 +384,21 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
return comment;
|
||||
}
|
||||
|
||||
private boolean isBolusBeepsEnabled() {
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isSmbBeepsEnabled() {
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isBasalBeepsEnabled() {
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getStringResource(int id, Object... args) {
|
||||
return MainApp.gs(id, args);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ buildscript {
|
|||
maven { url 'https://maven.fabric.io/public' }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.2'
|
||||
classpath 'com.android.tools.build:gradle:3.5.3'
|
||||
classpath 'com.google.gms:google-services:4.3.3'
|
||||
classpath 'io.fabric.tools:gradle:1.31.2'
|
||||
|
||||
|
|
Loading…
Reference in a new issue