Rename SetupProgress to ActivationProgress

This commit is contained in:
Bart Sopers 2020-10-17 17:08:47 +02:00
parent fb1ed7588a
commit b4813ad708
14 changed files with 78 additions and 78 deletions

View file

@ -72,9 +72,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.definition.OmnipodCustomA
import info.nightscout.androidaps.plugins.pump.omnipod.definition.OmnipodStorageKeys; import info.nightscout.androidaps.plugins.pump.omnipod.definition.OmnipodStorageKeys;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.service.ExpirationReminderBuilder; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.service.ExpirationReminderBuilder;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoRecentPulseLog; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoRecentPulseLog;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertConfiguration; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertConfiguration;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.SetupProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager;
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodPumpValuesChanged; import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodPumpValuesChanged;
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodTbrChanged; import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodTbrChanged;
@ -257,9 +257,9 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
// BS @ 2020-10-17 FIXME: for backwards compatibility; remove before release // BS @ 2020-10-17 FIXME: for backwards compatibility; remove before release
if (podStateManager.isPodInitialized() && if (podStateManager.isPodInitialized() &&
podStateManager.getSetupProgress() == SetupProgress.NONE && podStateManager.getActivationProgress() == ActivationProgress.NONE &&
podStateManager.getPodProgressStatus().isAtLeast(PodProgressStatus.ABOVE_FIFTY_UNITS)) { podStateManager.getPodProgressStatus().isAtLeast(PodProgressStatus.ABOVE_FIFTY_UNITS)) {
podStateManager.setSetupProgress(SetupProgress.COMPLETED); podStateManager.setActivationProgress(ActivationProgress.COMPLETED);
} }
lastConnectionTimeMillis = sp.getLong( lastConnectionTimeMillis = sp.getLong(
@ -930,7 +930,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
} }
private void initializeAfterRileyLinkConnection() { private void initializeAfterRileyLinkConnection() {
if (podStateManager.getSetupProgress().isAtLeast(SetupProgress.PAIRING_COMPLETED)) { if (podStateManager.getActivationProgress().isAtLeast(ActivationProgress.PAIRING_COMPLETED)) {
for (int i = 0; STARTUP_STATUS_REQUEST_TRIES > i; i++) { for (int i = 0; STARTUP_STATUS_REQUEST_TRIES > i; i++) {
PumpEnactResult result = executeCommand(OmnipodCommandType.GET_POD_STATUS, aapsOmnipodManager::getPodStatus); PumpEnactResult result = executeCommand(OmnipodCommandType.GET_POD_STATUS, aapsOmnipodManager::getPodStatus);
if (result.success) { if (result.success) {

View file

@ -38,7 +38,7 @@ public class AssignAddressAction implements OmnipodAction<Void> {
podStateManager.initState(generateRandomAddress()); podStateManager.initState(generateRandomAddress());
} }
if (podStateManager.getSetupProgress().needsPairing()) { if (podStateManager.getActivationProgress().needsPairing()) {
AssignAddressCommand assignAddress = new AssignAddressCommand(podStateManager.getAddress()); AssignAddressCommand assignAddress = new AssignAddressCommand(podStateManager.getAddress());
OmnipodMessage assignAddressMessage = new OmnipodMessage(OmnipodConstants.DEFAULT_ADDRESS, OmnipodMessage assignAddressMessage = new OmnipodMessage(OmnipodConstants.DEFAULT_ADDRESS,
Collections.singletonList(assignAddress), podStateManager.getMessageNumber()); Collections.singletonList(assignAddress), podStateManager.getMessageNumber());

View file

@ -6,11 +6,11 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.service.ExpirationReminderBuilder; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.service.ExpirationReminderBuilder;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertConfiguration; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertConfiguration;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.SetupProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BasalSchedule; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BasalSchedule;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalSetupProgressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalActivationProgressException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager;
import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager;
@ -37,29 +37,29 @@ public class InsertCannulaAction implements OmnipodAction<Void> {
@Override @Override
public Void execute(OmnipodRileyLinkCommunicationManager communicationService) { public Void execute(OmnipodRileyLinkCommunicationManager communicationService) {
if (podStateManager.getSetupProgress().isBefore(SetupProgress.PRIMING_COMPLETED)) { if (podStateManager.getActivationProgress().isBefore(ActivationProgress.PRIMING_COMPLETED)) {
throw new IllegalSetupProgressException(SetupProgress.PRIMING_COMPLETED, podStateManager.getSetupProgress()); throw new IllegalActivationProgressException(ActivationProgress.PRIMING_COMPLETED, podStateManager.getActivationProgress());
} }
if (podStateManager.getSetupProgress().needsBasalSchedule()) { if (podStateManager.getActivationProgress().needsBasalSchedule()) {
podStateManager.setBasalSchedule(initialBasalSchedule); podStateManager.setBasalSchedule(initialBasalSchedule);
communicationService.executeAction(new SetBasalScheduleAction(podStateManager, initialBasalSchedule, communicationService.executeAction(new SetBasalScheduleAction(podStateManager, initialBasalSchedule,
true, podStateManager.getScheduleOffset(), false)); true, podStateManager.getScheduleOffset(), false));
podStateManager.setSetupProgress(SetupProgress.BASAL_INITIALIZED); podStateManager.setActivationProgress(ActivationProgress.BASAL_INITIALIZED);
} }
if (podStateManager.getSetupProgress().needsExpirationReminders()) { if (podStateManager.getActivationProgress().needsExpirationReminders()) {
communicationService.executeAction(new ConfigureAlertsAction(podStateManager, buildAlertConfigurations())); communicationService.executeAction(new ConfigureAlertsAction(podStateManager, buildAlertConfigurations()));
podStateManager.setExpirationAlertTimeBeforeShutdown(expirationReminderTimeBeforeShutdown); podStateManager.setExpirationAlertTimeBeforeShutdown(expirationReminderTimeBeforeShutdown);
podStateManager.setLowReservoirAlertUnits(lowReservoirAlertUnits); podStateManager.setLowReservoirAlertUnits(lowReservoirAlertUnits);
podStateManager.setSetupProgress(SetupProgress.EXPIRATION_REMINDERS_SET); podStateManager.setActivationProgress(ActivationProgress.EXPIRATION_REMINDERS_SET);
} }
if (podStateManager.getSetupProgress().needsCannulaInsertion()) { if (podStateManager.getActivationProgress().needsCannulaInsertion()) {
communicationService.executeAction(new BolusAction(podStateManager, OmnipodConstants.POD_CANNULA_INSERTION_BOLUS_UNITS, communicationService.executeAction(new BolusAction(podStateManager, OmnipodConstants.POD_CANNULA_INSERTION_BOLUS_UNITS,
Duration.standardSeconds(1), false, false)); Duration.standardSeconds(1), false, false));
podStateManager.setSetupProgress(SetupProgress.INSERTING_CANNULA); podStateManager.setActivationProgress(ActivationProgress.INSERTING_CANNULA);
} }
return null; return null;

View file

@ -1,8 +1,8 @@
package info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action; package info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.service.PrimeService; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.service.PrimeService;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.SetupProgress; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalSetupProgressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalActivationProgressException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager;
import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager;
@ -24,24 +24,24 @@ public class PrimeAction implements OmnipodAction<Void> {
@Override @Override
public Void execute(OmnipodRileyLinkCommunicationManager communicationService) { public Void execute(OmnipodRileyLinkCommunicationManager communicationService) {
if (podStateManager.getSetupProgress().isBefore(SetupProgress.PAIRING_COMPLETED)) { if (podStateManager.getActivationProgress().isBefore(ActivationProgress.PAIRING_COMPLETED)) {
throw new IllegalSetupProgressException(SetupProgress.PAIRING_COMPLETED, podStateManager.getSetupProgress()); throw new IllegalActivationProgressException(ActivationProgress.PAIRING_COMPLETED, podStateManager.getActivationProgress());
} }
if (podStateManager.getSetupProgress().needsDisableTab5Sub16And17()) { if (podStateManager.getActivationProgress().needsDisableTab5Sub16And17()) {
// FaultConfigCommand sets internal pod variables to effectively disable $6x faults which occur more often with a 0 TBR // FaultConfigCommand sets internal pod variables to effectively disable $6x faults which occur more often with a 0 TBR
service.executeDisableTab5Sub16And17FaultConfigCommand(communicationService, podStateManager); service.executeDisableTab5Sub16And17FaultConfigCommand(communicationService, podStateManager);
podStateManager.setSetupProgress(SetupProgress.TAB_5_SUB_16_AND_17_DISABLED); podStateManager.setActivationProgress(ActivationProgress.TAB_5_SUB_16_AND_17_DISABLED);
} }
if (podStateManager.getSetupProgress().needsSetupReminders()) { if (podStateManager.getActivationProgress().needsSetupReminders()) {
service.executeFinishSetupReminderAlertCommand(communicationService, podStateManager); service.executeFinishSetupReminderAlertCommand(communicationService, podStateManager);
podStateManager.setSetupProgress(SetupProgress.SETUP_REMINDERS_SET); podStateManager.setActivationProgress(ActivationProgress.SETUP_REMINDERS_SET);
} }
if (podStateManager.getSetupProgress().needsPriming()) { if (podStateManager.getActivationProgress().needsPriming()) {
service.executePrimeBolusCommand(communicationService, podStateManager); service.executePrimeBolusCommand(communicationService, podStateManager);
podStateManager.setSetupProgress(SetupProgress.PRIMING); podStateManager.setActivationProgress(ActivationProgress.PRIMING);
} }
return null; return null;

View file

@ -8,10 +8,10 @@ import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.OmnipodMessage; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.OmnipodMessage;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.SetupPodCommand; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.SetupPodCommand;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.VersionResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.VersionResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PacketType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PacketType;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.SetupProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalMessageAddressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalMessageAddressException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPacketTypeException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPacketTypeException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPodProgressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPodProgressException;
@ -40,7 +40,7 @@ public class SetupPodAction implements OmnipodAction<Void> {
throw new IllegalPodProgressException(PodProgressStatus.REMINDER_INITIALIZED, podStateManager.isPodInitialized() ? podStateManager.getPodProgressStatus() : null); throw new IllegalPodProgressException(PodProgressStatus.REMINDER_INITIALIZED, podStateManager.isPodInitialized() ? podStateManager.getPodProgressStatus() : null);
} }
if (podStateManager.getSetupProgress().needsPairing()) { if (podStateManager.getActivationProgress().needsPairing()) {
DateTime activationDate = DateTime.now(podStateManager.getTimeZone()); DateTime activationDate = DateTime.now(podStateManager.getTimeZone());
SetupPodCommand setupPodCommand = new SetupPodCommand(podStateManager.getAddress(), activationDate, SetupPodCommand setupPodCommand = new SetupPodCommand(podStateManager.getAddress(), activationDate,
@ -67,7 +67,7 @@ public class SetupPodAction implements OmnipodAction<Void> {
} }
} }
podStateManager.setSetupProgress(SetupProgress.PAIRING_COMPLETED); podStateManager.setActivationProgress(ActivationProgress.PAIRING_COMPLETED);
} }
return null; return null;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.driver.definition; package info.nightscout.androidaps.plugins.pump.omnipod.driver.definition;
public enum SetupProgress { public enum ActivationProgress {
NONE, NONE,
PAIRING_COMPLETED, PAIRING_COMPLETED,
TAB_5_SUB_16_AND_17_DISABLED, TAB_5_SUB_16_AND_17_DISABLED,
@ -52,15 +52,15 @@ public enum SetupProgress {
return this == COMPLETED; return this == COMPLETED;
} }
public boolean isBefore(SetupProgress other) { public boolean isBefore(ActivationProgress other) {
return ordinal() < other.ordinal(); return ordinal() < other.ordinal();
} }
public boolean isAtLeast(SetupProgress other) { public boolean isAtLeast(ActivationProgress other) {
return ordinal() >= other.ordinal(); return ordinal() >= other.ordinal();
} }
public boolean isAfter(SetupProgress other) { public boolean isAfter(ActivationProgress other) {
return ordinal() > other.ordinal(); return ordinal() > other.ordinal();
} }
} }

View file

@ -2,23 +2,23 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.exception;
import java.util.Locale; import java.util.Locale;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.SetupProgress; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress;
public class IllegalSetupProgressException extends OmnipodException { public class IllegalActivationProgressException extends OmnipodException {
private final SetupProgress expected; private final ActivationProgress expected;
private final SetupProgress actual; private final ActivationProgress actual;
public IllegalSetupProgressException(SetupProgress expected, SetupProgress actual) { public IllegalActivationProgressException(ActivationProgress expected, ActivationProgress actual) {
super(String.format(Locale.getDefault(), "Illegal setup progress: %s, expected: %s", actual, expected), true); super(String.format(Locale.getDefault(), "Illegal setup progress: %s, expected: %s", actual, expected), true);
this.expected = expected; this.expected = expected;
this.actual = actual; this.actual = actual;
} }
public SetupProgress getExpected() { public ActivationProgress getExpected() {
return expected; return expected;
} }
public SetupProgress getActual() { public ActivationProgress getActual() {
return actual; return actual;
} }
} }

View file

@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mess
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoRecentPulseLog; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoRecentPulseLog;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertConfiguration; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertConfiguration;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.BeepType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.BeepType;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.DeliveryStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.DeliveryStatus;
@ -38,13 +39,12 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.Deliver
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodInfoType; 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.PodProgressStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.SetupProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BasalSchedule; 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.CommandFailedAfterChangingDeliveryStatusException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.DeliveryStatusVerificationFailedException; 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.IllegalDeliveryStatusException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPodProgressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPodProgressException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalSetupProgressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalActivationProgressException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.NonceOutOfSyncException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.NonceOutOfSyncException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.OmnipodException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.OmnipodException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.PodFaultException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.PodFaultException;
@ -89,16 +89,16 @@ public class OmnipodManager {
public synchronized Single<Boolean> pairAndPrime() { public synchronized Single<Boolean> pairAndPrime() {
if (podStateManager.isPodInitialized()) { if (podStateManager.isPodInitialized()) {
if (podStateManager.getSetupProgress().isAfter(SetupProgress.PRIMING)) { if (podStateManager.getActivationProgress().isAfter(ActivationProgress.PRIMING)) {
return Single.just(true); return Single.just(true);
} }
if (podStateManager.getSetupProgress().needsPrimingVerification()) { if (podStateManager.getActivationProgress().needsPrimingVerification()) {
return Single.fromCallable(() -> verifyPodProgressStatus(PodProgressStatus.PRIMING_COMPLETED, SetupProgress.PRIMING_COMPLETED)); return Single.fromCallable(() -> verifyPodProgressStatus(PodProgressStatus.PRIMING_COMPLETED, ActivationProgress.PRIMING_COMPLETED));
} }
} }
// Always send both 0x07 and 0x03 on retries // Always send both 0x07 and 0x03 on retries
if (podStateManager.getSetupProgress().isBefore(SetupProgress.PAIRING_COMPLETED)) { if (podStateManager.getActivationProgress().isBefore(ActivationProgress.PAIRING_COMPLETED)) {
communicationService.executeAction( communicationService.executeAction(
new AssignAddressAction(podStateManager, aapsLogger)); new AssignAddressAction(podStateManager, aapsLogger));
@ -110,22 +110,22 @@ public class OmnipodManager {
long delayInMillis = calculateEstimatedBolusDuration(DateTime.now().minus(OmnipodConstants.AVERAGE_BOLUS_COMMAND_COMMUNICATION_DURATION), OmnipodConstants.POD_PRIME_BOLUS_UNITS, OmnipodConstants.POD_PRIMING_DELIVERY_RATE).getMillis(); long delayInMillis = calculateEstimatedBolusDuration(DateTime.now().minus(OmnipodConstants.AVERAGE_BOLUS_COMMAND_COMMUNICATION_DURATION), OmnipodConstants.POD_PRIME_BOLUS_UNITS, OmnipodConstants.POD_PRIMING_DELIVERY_RATE).getMillis();
return Single.timer(delayInMillis, TimeUnit.MILLISECONDS) // return Single.timer(delayInMillis, TimeUnit.MILLISECONDS) //
.map(o -> verifyPodProgressStatus(PodProgressStatus.PRIMING_COMPLETED, SetupProgress.PRIMING_COMPLETED)) // .map(o -> verifyPodProgressStatus(PodProgressStatus.PRIMING_COMPLETED, ActivationProgress.PRIMING_COMPLETED)) //
.subscribeOn(Schedulers.io()); .subscribeOn(Schedulers.io());
} }
public synchronized Single<Boolean> insertCannula( public synchronized Single<Boolean> insertCannula(
BasalSchedule basalSchedule, Duration expirationReminderTimeBeforeShutdown, Integer lowReservoirAlertUnits) { BasalSchedule basalSchedule, Duration expirationReminderTimeBeforeShutdown, Integer lowReservoirAlertUnits) {
if (podStateManager.getSetupProgress().isBefore(SetupProgress.PRIMING_COMPLETED)) { if (podStateManager.getActivationProgress().isBefore(ActivationProgress.PRIMING_COMPLETED)) {
throw new IllegalSetupProgressException(SetupProgress.PRIMING_COMPLETED, podStateManager.getSetupProgress()); throw new IllegalActivationProgressException(ActivationProgress.PRIMING_COMPLETED, podStateManager.getActivationProgress());
} }
if (podStateManager.isPodInitialized()) { if (podStateManager.isPodInitialized()) {
if (podStateManager.getSetupProgress().isCompleted()) { if (podStateManager.getActivationProgress().isCompleted()) {
return Single.just(true); return Single.just(true);
} }
if (podStateManager.getSetupProgress().needsCannulaInsertionVerification()) { if (podStateManager.getActivationProgress().needsCannulaInsertionVerification()) {
return Single.fromCallable(() -> verifyPodProgressStatus(PodProgressStatus.ABOVE_FIFTY_UNITS, SetupProgress.COMPLETED)); return Single.fromCallable(() -> verifyPodProgressStatus(PodProgressStatus.ABOVE_FIFTY_UNITS, ActivationProgress.COMPLETED));
} }
} }
@ -134,7 +134,7 @@ public class OmnipodManager {
long delayInMillis = calculateEstimatedBolusDuration(DateTime.now().minus(OmnipodConstants.AVERAGE_BOLUS_COMMAND_COMMUNICATION_DURATION), OmnipodConstants.POD_CANNULA_INSERTION_BOLUS_UNITS, OmnipodConstants.POD_CANNULA_INSERTION_DELIVERY_RATE).getMillis(); long delayInMillis = calculateEstimatedBolusDuration(DateTime.now().minus(OmnipodConstants.AVERAGE_BOLUS_COMMAND_COMMUNICATION_DURATION), OmnipodConstants.POD_CANNULA_INSERTION_BOLUS_UNITS, OmnipodConstants.POD_CANNULA_INSERTION_DELIVERY_RATE).getMillis();
return Single.timer(delayInMillis, TimeUnit.MILLISECONDS) // return Single.timer(delayInMillis, TimeUnit.MILLISECONDS) //
.map(o -> verifyPodProgressStatus(PodProgressStatus.ABOVE_FIFTY_UNITS, SetupProgress.COMPLETED)) // .map(o -> verifyPodProgressStatus(PodProgressStatus.ABOVE_FIFTY_UNITS, ActivationProgress.COMPLETED)) //
.subscribeOn(Schedulers.io()); .subscribeOn(Schedulers.io());
} }
@ -545,7 +545,7 @@ public class OmnipodManager {
* @return true if the Pod's progress status matches the expected status, otherwise false * @return true if the Pod's progress status matches the expected status, otherwise false
* @throws PodProgressStatusVerificationFailedException in case reading the Pod status fails * @throws PodProgressStatusVerificationFailedException in case reading the Pod status fails
*/ */
private boolean verifyPodProgressStatus(PodProgressStatus expectedPodProgressStatus, SetupProgress setupProgress) { private boolean verifyPodProgressStatus(PodProgressStatus expectedPodProgressStatus, ActivationProgress activationProgress) {
Boolean result = null; Boolean result = null;
Throwable lastException = null; Throwable lastException = null;
@ -554,7 +554,7 @@ public class OmnipodManager {
StatusResponse statusResponse = getPodStatus(); StatusResponse statusResponse = getPodStatus();
if (statusResponse.getPodProgressStatus().equals(expectedPodProgressStatus)) { if (statusResponse.getPodProgressStatus().equals(expectedPodProgressStatus)) {
podStateManager.setSetupProgress(setupProgress); podStateManager.setActivationProgress(activationProgress);
return true; return true;
} else { } else {
result = false; result = false;

View file

@ -23,6 +23,7 @@ import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusUpdatableResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusUpdatableResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoDetailedStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoDetailedStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSet; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSet;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSlot; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSlot;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertType;
@ -32,7 +33,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.Firmwar
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodCrc; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodCrc;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.SetupProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BasalSchedule; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BasalSchedule;
// TODO add nullchecks on some setters // TODO add nullchecks on some setters
@ -82,7 +82,7 @@ public abstract class PodStateManager {
* @return true if we have a Pod state and the Pod activation has been completed. The pod could also be dead at this point * @return true if we have a Pod state and the Pod activation has been completed. The pod could also be dead at this point
*/ */
public final boolean isPodActivationCompleted() { public final boolean isPodActivationCompleted() {
return getSetupProgress().isCompleted(); return getActivationProgress().isCompleted();
} }
/** /**
@ -337,15 +337,15 @@ public abstract class PodStateManager {
return activatedAt == null ? null : activatedAt.withZone(getSafe(() -> podState.getTimeZone())).plus(OmnipodConstants.NOMINAL_POD_LIFE); return activatedAt == null ? null : activatedAt.withZone(getSafe(() -> podState.getTimeZone())).plus(OmnipodConstants.NOMINAL_POD_LIFE);
} }
public final SetupProgress getSetupProgress() { public final ActivationProgress getActivationProgress() {
if (hasPodState()) { if (hasPodState()) {
return Optional.ofNullable(podState.getSetupProgress()).orElse(SetupProgress.NONE); return Optional.ofNullable(podState.getActivationProgress()).orElse(ActivationProgress.NONE);
} }
return SetupProgress.NONE; return ActivationProgress.NONE;
} }
public final void setSetupProgress(SetupProgress setupProgress) { public final void setActivationProgress(ActivationProgress activationProgress) {
setAndStore(() -> podState.setSetupProgress(setupProgress)); setAndStore(() -> podState.setActivationProgress(activationProgress));
} }
public final PodProgressStatus getPodProgressStatus() { public final PodProgressStatus getPodProgressStatus() {
@ -655,7 +655,7 @@ public abstract class PodStateManager {
private Integer totalTicksDelivered; private Integer totalTicksDelivered;
private boolean suspended; private boolean suspended;
private NonceState nonceState; private NonceState nonceState;
private SetupProgress setupProgress = SetupProgress.NONE; private ActivationProgress activationProgress = ActivationProgress.NONE;
private PodProgressStatus podProgressStatus; private PodProgressStatus podProgressStatus;
private DeliveryStatus lastDeliveryStatus; private DeliveryStatus lastDeliveryStatus;
private AlertSet activeAlerts; private AlertSet activeAlerts;
@ -824,12 +824,12 @@ public abstract class PodStateManager {
this.nonceState = nonceState; this.nonceState = nonceState;
} }
SetupProgress getSetupProgress() { ActivationProgress getActivationProgress() {
return setupProgress; return activationProgress;
} }
void setSetupProgress(SetupProgress setupProgress) { void setActivationProgress(ActivationProgress activationProgress) {
this.setupProgress = setupProgress; this.activationProgress = activationProgress;
} }
PodProgressStatus getPodProgressStatus() { PodProgressStatus getPodProgressStatus() {
@ -968,7 +968,7 @@ public abstract class PodStateManager {
", totalTicksDelivered=" + totalTicksDelivered + ", totalTicksDelivered=" + totalTicksDelivered +
", suspended=" + suspended + ", suspended=" + suspended +
", nonceState=" + nonceState + ", nonceState=" + nonceState +
", setupProgress=" + setupProgress + ", activationProgress=" + activationProgress +
", podProgressStatus=" + podProgressStatus + ", podProgressStatus=" + podProgressStatus +
", lastDeliveryStatus=" + lastDeliveryStatus + ", lastDeliveryStatus=" + lastDeliveryStatus +
", activeAlerts=" + activeAlerts + ", activeAlerts=" + activeAlerts +

View file

@ -62,7 +62,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalM
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPacketTypeException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPacketTypeException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPodProgressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPodProgressException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalResponseException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalResponseException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalSetupProgressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalActivationProgressException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalVersionResponseTypeException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalVersionResponseTypeException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.MessageDecodingException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.MessageDecodingException;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.NonceOutOfSyncException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.NonceOutOfSyncException;
@ -774,7 +774,7 @@ public class AapsOmnipodManager {
comment = getStringResource(R.string.omnipod_error_crc_mismatch); comment = getStringResource(R.string.omnipod_error_crc_mismatch);
} else if (ex instanceof IllegalPacketTypeException) { } else if (ex instanceof IllegalPacketTypeException) {
comment = getStringResource(R.string.omnipod_error_invalid_packet_type); comment = getStringResource(R.string.omnipod_error_invalid_packet_type);
} else if (ex instanceof IllegalPodProgressException || ex instanceof IllegalSetupProgressException || } else if (ex instanceof IllegalPodProgressException || ex instanceof IllegalActivationProgressException ||
ex instanceof IllegalDeliveryStatusException) { ex instanceof IllegalDeliveryStatusException) {
comment = getStringResource(R.string.omnipod_error_invalid_progress_state); comment = getStringResource(R.string.omnipod_error_invalid_progress_state);
} else if (ex instanceof IllegalVersionResponseTypeException) { } else if (ex instanceof IllegalVersionResponseTypeException) {

View file

@ -23,9 +23,9 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyL
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin
import info.nightscout.androidaps.plugins.pump.omnipod.R import info.nightscout.androidaps.plugins.pump.omnipod.R
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.SetupProgress
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodPumpValuesChanged import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodPumpValuesChanged
import info.nightscout.androidaps.plugins.pump.omnipod.manager.AapsOmnipodManager import info.nightscout.androidaps.plugins.pump.omnipod.manager.AapsOmnipodManager
@ -346,7 +346,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
if (!podStateManager.isPodInitialized) { if (!podStateManager.isPodInitialized) {
resourceHelper.gs(R.string.omnipod_pod_status_waiting_for_activation) resourceHelper.gs(R.string.omnipod_pod_status_waiting_for_activation)
} else { } else {
if (podStateManager.setupProgress.isBefore(SetupProgress.PRIMING_COMPLETED)) { if (podStateManager.activationProgress.isBefore(ActivationProgress.PRIMING_COMPLETED)) {
resourceHelper.gs(R.string.omnipod_pod_status_waiting_for_activation) resourceHelper.gs(R.string.omnipod_pod_status_waiting_for_activation)
} else { } else {
resourceHelper.gs(R.string.omnipod_pod_status_waiting_for_cannula_insertion) resourceHelper.gs(R.string.omnipod_pod_status_waiting_for_cannula_insertion)
@ -453,7 +453,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
} }
private fun updateRefreshStatusButton() { private fun updateRefreshStatusButton() {
omnipod_overview_button_refresh_status.isEnabled = podStateManager.isPodInitialized && podStateManager.setupProgress.isAtLeast(SetupProgress.PAIRING_COMPLETED) omnipod_overview_button_refresh_status.isEnabled = podStateManager.isPodInitialized && podStateManager.activationProgress.isAtLeast(ActivationProgress.PAIRING_COMPLETED)
&& rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty() && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
} }

View file

@ -9,7 +9,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData
import info.nightscout.androidaps.plugins.pump.omnipod.R import info.nightscout.androidaps.plugins.pump.omnipod.R
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.SetupProgress import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodPumpValuesChanged import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodPumpValuesChanged
import info.nightscout.androidaps.plugins.pump.omnipod.manager.AapsOmnipodManager import info.nightscout.androidaps.plugins.pump.omnipod.manager.AapsOmnipodManager
@ -95,7 +95,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
if (rileyLinkServiceData.rileyLinkServiceState.isReady) { if (rileyLinkServiceData.rileyLinkServiceState.isReady) {
omnipod_pod_management_button_activate_pod.isEnabled = !podStateManager.isPodActivationCompleted omnipod_pod_management_button_activate_pod.isEnabled = !podStateManager.isPodActivationCompleted
omnipod_pod_management_button_deactivate_pod.isEnabled = podStateManager.setupProgress.isAtLeast(SetupProgress.PAIRING_COMPLETED) omnipod_pod_management_button_deactivate_pod.isEnabled = podStateManager.activationProgress.isAtLeast(ActivationProgress.PAIRING_COMPLETED)
if (discardButtonEnabled) { if (discardButtonEnabled) {
omnipod_pod_management_button_discard_pod.isEnabled = true omnipod_pod_management_button_discard_pod.isEnabled = true
} }

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation
import android.os.Bundle import android.os.Bundle
import androidx.annotation.IdRes import androidx.annotation.IdRes
import info.nightscout.androidaps.plugins.pump.omnipod.R import info.nightscout.androidaps.plugins.pump.omnipod.R
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.SetupProgress import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.activity.OmnipodWizardActivityBase import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.activity.OmnipodWizardActivityBase
import javax.inject.Inject import javax.inject.Inject
@ -25,7 +25,7 @@ class PodActivationWizardActivity : OmnipodWizardActivityBase() {
setContentView(R.layout.omnipod_pod_activation_wizard_activity) setContentView(R.layout.omnipod_pod_activation_wizard_activity)
startDestination = savedInstanceState?.getInt(KEY_START_DESTINATION, R.id.fillPodInfoFragment) startDestination = savedInstanceState?.getInt(KEY_START_DESTINATION, R.id.fillPodInfoFragment)
?: if (!podStateManager.isPodInitialized || podStateManager.setupProgress.isBefore(SetupProgress.PRIMING_COMPLETED)) { ?: if (!podStateManager.isPodInitialized || podStateManager.activationProgress.isBefore(ActivationProgress.PRIMING_COMPLETED)) {
R.id.fillPodInfoFragment R.id.fillPodInfoFragment
} else { } else {
R.id.attachPodInfoFragment R.id.attachPodInfoFragment

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.fra
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.SetupProgress import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.ActionFragmentBase import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.ActionFragmentBase
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.PodDeactivationWizardActivity import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.PodDeactivationWizardActivity
@ -26,7 +26,7 @@ abstract class PodActivationActionFragmentBase : ActionFragmentBase() {
} }
override fun onActionFailure() { override fun onActionFailure() {
if (podStateManager.isPodActivationTimeExceeded && podStateManager.setupProgress.isAtLeast(SetupProgress.PAIRING_COMPLETED)) { if (podStateManager.isPodActivationTimeExceeded && podStateManager.activationProgress.isAtLeast(ActivationProgress.PAIRING_COMPLETED)) {
omnipod_wizard_button_retry.visibility = View.GONE omnipod_wizard_button_retry.visibility = View.GONE
omnipod_wizard_button_deactivate_pod.visibility = View.VISIBLE omnipod_wizard_button_deactivate_pod.visibility = View.VISIBLE
} }