Bug fixes and improvements in PodStateManager stuff
This commit is contained in:
parent
b50670cceb
commit
3bc53544a2
|
@ -487,17 +487,17 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
public boolean isSuspended() {
|
||||
|
||||
return (omnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) ||
|
||||
(omnipodUtil.getPodStateManager() != null && omnipodUtil.getPodStateManager().isSuspended());
|
||||
(omnipodUtil.getPodStateManager() != null && omnipodUtil.getPodStateManager().hasState() && omnipodUtil.getPodStateManager().isSuspended());
|
||||
|
||||
// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) ||
|
||||
// (OmnipodUtil.getPodStateManager() != null && OmnipodUtil.getPodStateManager().isSuspended());
|
||||
// (OmnipodUtil.getPodStateManager() != null && omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended());
|
||||
//
|
||||
// TODO ddd
|
||||
// return (OmnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) ||
|
||||
// (OmnipodUtil.getPodStateManager() != null && OmnipodUtil.getPodStateManager().isSuspended());
|
||||
// (OmnipodUtil.getPodStateManager() != null && omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended());
|
||||
//
|
||||
// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) ||
|
||||
// (OmnipodUtil.getPodStateManager() != null && OmnipodUtil.getPodStateManager().isSuspended());
|
||||
// (OmnipodUtil.getPodStateManager() != null && omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -81,7 +81,7 @@ public class OmnipodManager {
|
|||
logStartingCommandExecution("pairAndPrime");
|
||||
|
||||
try {
|
||||
if (!podStateManager.hasState() || !podStateManager.getSetupProgress().isBefore(SetupProgress.POD_CONFIGURED)) {
|
||||
if (!podStateManager.hasState() || !podStateManager.isPaired() || podStateManager.getSetupProgress().isBefore(SetupProgress.POD_CONFIGURED)) {
|
||||
// Always send both 0x07 and 0x03 on retries
|
||||
communicationService.executeAction(
|
||||
new AssignAddressAction(podStateManager));
|
||||
|
@ -105,7 +105,7 @@ public class OmnipodManager {
|
|||
}
|
||||
|
||||
public synchronized Single<SetupActionResult> insertCannula(BasalSchedule basalSchedule) {
|
||||
if (!podStateManager.hasState() || podStateManager.getSetupProgress().isBefore(SetupProgress.PRIMING_FINISHED)) {
|
||||
if (!podStateManager.hasState() || !podStateManager.isPaired() || podStateManager.getSetupProgress().isBefore(SetupProgress.PRIMING_FINISHED)) {
|
||||
throw new IllegalSetupProgressException(SetupProgress.PRIMING_FINISHED, !podStateManager.hasState() ? null : podStateManager.getSetupProgress());
|
||||
} else if (podStateManager.getSetupProgress().isAfter(SetupProgress.CANNULA_INSERTING)) {
|
||||
throw new IllegalSetupProgressException(SetupProgress.CANNULA_INSERTING, podStateManager.getSetupProgress());
|
||||
|
@ -455,14 +455,6 @@ public class OmnipodManager {
|
|||
}
|
||||
}
|
||||
|
||||
public PodStateManager getPodStateManager() {
|
||||
return this.podStateManager;
|
||||
}
|
||||
|
||||
public String getPodStateAsString() {
|
||||
return podStateManager.hasState() ? podStateManager.toString() : "null";
|
||||
}
|
||||
|
||||
// Only works for commands with nonce resyncable message blocks
|
||||
// FIXME method is too big, needs refactoring
|
||||
private StatusResponse executeAndVerify(VerifiableAction runnable) {
|
||||
|
|
|
@ -99,7 +99,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
wizardPagerContext.clearContext()
|
||||
wizardPagerContext.pagerSettings = pagerSettings
|
||||
val podStateManager = omnipodUtil.getPodStateManager()
|
||||
val isFullInit = podStateManager == null || podStateManager.setupProgress.isBefore(SetupProgress.PRIMING_FINISHED)
|
||||
val isFullInit = podStateManager == null || !podStateManager.isPaired || podStateManager.setupProgress.isBefore(SetupProgress.PRIMING_FINISHED)
|
||||
if (isFullInit) {
|
||||
wizardPagerContext.wizardModel = FullInitPodWizardModel(applicationContext)
|
||||
} else {
|
||||
|
|
|
@ -84,6 +84,7 @@ import io.reactivex.disposables.Disposable;
|
|||
|
||||
public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||
|
||||
private final PodStateManager podStateManager;
|
||||
private OmnipodUtil omnipodUtil;
|
||||
private AAPSLogger aapsLogger;
|
||||
private RxBusWrapper rxBus;
|
||||
|
@ -113,6 +114,10 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
ResourceHelper resourceHelper,
|
||||
HasAndroidInjector injector,
|
||||
ActivePluginProvider activePlugin) {
|
||||
if (podStateManager == null) {
|
||||
throw new IllegalArgumentException("Pod state manager can not be null");
|
||||
}
|
||||
this.podStateManager = podStateManager;
|
||||
this.omnipodUtil = omnipodUtil;
|
||||
this.aapsLogger = aapsLogger;
|
||||
this.rxBus = rxBus;
|
||||
|
@ -135,7 +140,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
}
|
||||
|
||||
public PodStateManager getPodStateManager() {
|
||||
return delegate.getPodStateManager();
|
||||
return podStateManager;
|
||||
}
|
||||
|
||||
private void updatePumpStatus(PodStateManager podStateManager) {
|
||||
|
@ -368,8 +373,8 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
|
||||
activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
|
||||
if (delegate.getPodStateManager().hasFaultEvent()) {
|
||||
showPodFaultErrorDialog(delegate.getPodStateManager().getFaultEvent().getFaultEventCode(), R.raw.urgentalarm);
|
||||
if (podStateManager.hasFaultEvent()) {
|
||||
showPodFaultErrorDialog(podStateManager.getFaultEvent().getFaultEventCode(), R.raw.urgentalarm);
|
||||
}
|
||||
|
||||
return new PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(unitsDelivered);
|
||||
|
@ -468,7 +473,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
@Override
|
||||
public void setPumpStatus(OmnipodPumpStatus pumpStatus) {
|
||||
this.pumpStatus = pumpStatus;
|
||||
updatePumpStatus(delegate.getPodStateManager());
|
||||
updatePumpStatus(podStateManager);
|
||||
}
|
||||
|
||||
// TODO should we add this to the OmnipodCommunicationManager interface?
|
||||
|
@ -553,7 +558,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
}
|
||||
|
||||
public String getPodStateAsString() {
|
||||
return delegate.getPodStateAsString();
|
||||
return podStateManager.toString();
|
||||
}
|
||||
|
||||
private void reportImplicitlyCanceledTbr() {
|
||||
|
|
Loading…
Reference in a new issue