More improvements for PodStateManager
This commit is contained in:
parent
2a73127202
commit
10cde3e744
4 changed files with 23 additions and 22 deletions
|
@ -487,17 +487,17 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
public boolean isSuspended() {
|
public boolean isSuspended() {
|
||||||
|
|
||||||
return (omnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) ||
|
return (omnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) ||
|
||||||
(omnipodUtil.getPodStateManager() != null && omnipodUtil.getPodStateManager().hasState() && omnipodUtil.getPodStateManager().isSuspended());
|
(omnipodUtil.getPodStateManager().hasState() && omnipodUtil.getPodStateManager().isSuspended());
|
||||||
|
|
||||||
// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) ||
|
// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) ||
|
||||||
// (OmnipodUtil.getPodStateManager() != null && omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended());
|
// (omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended());
|
||||||
//
|
//
|
||||||
// TODO ddd
|
// TODO ddd
|
||||||
// return (OmnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) ||
|
// return (OmnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) ||
|
||||||
// (OmnipodUtil.getPodStateManager() != null && omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended());
|
// (omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended());
|
||||||
//
|
//
|
||||||
// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) ||
|
// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) ||
|
||||||
// (OmnipodUtil.getPodStateManager() != null && omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended());
|
// (omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -579,6 +579,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
//getPodPumpStatusObject().driverState = OmnipodDriverState.Initalized_PodAvailable;
|
//getPodPumpStatusObject().driverState = OmnipodDriverState.Initalized_PodAvailable;
|
||||||
//driverState = OmnipodDriverState.Initalized_PodAvailable;
|
//driverState = OmnipodDriverState.Initalized_PodAvailable;
|
||||||
|
// FIXME this does not seem to make sense
|
||||||
omnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodAttached);
|
omnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodAttached);
|
||||||
// we would probably need to read Basal Profile here too
|
// we would probably need to read Basal Profile here too
|
||||||
}
|
}
|
||||||
|
@ -621,21 +622,20 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
setRefreshButtonEnabled(false);
|
setRefreshButtonEnabled(false);
|
||||||
|
|
||||||
PodStateManager podStateManager = omnipodUtil.getPodStateManager();
|
try {
|
||||||
|
PodStateManager podStateManager = omnipodUtil.getPodStateManager();
|
||||||
if (podStateManager != null) {
|
} catch(Exception ex) {
|
||||||
if (!isRefresh) {
|
|
||||||
pumpState = PumpDriverState.Initialized;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO handle if session state too old
|
|
||||||
getPodPumpStatus();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
aapsLogger.error(LTag.PUMP, "No PodStateManager found");
|
|
||||||
omnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod);
|
omnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod);
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isRefresh) {
|
||||||
|
pumpState = PumpDriverState.Initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO handle if pod state too old
|
||||||
|
getPodPumpStatus();
|
||||||
|
|
||||||
finishAction("Omnipod Pump");
|
finishAction("Omnipod Pump");
|
||||||
|
|
||||||
// if (!sentIdToFirebase) {
|
// if (!sentIdToFirebase) {
|
||||||
|
|
|
@ -99,7 +99,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
||||||
wizardPagerContext.clearContext()
|
wizardPagerContext.clearContext()
|
||||||
wizardPagerContext.pagerSettings = pagerSettings
|
wizardPagerContext.pagerSettings = pagerSettings
|
||||||
val podStateManager = omnipodUtil.getPodStateManager()
|
val podStateManager = omnipodUtil.getPodStateManager()
|
||||||
val isFullInit = podStateManager == null || !podStateManager.isPaired || podStateManager.setupProgress.isBefore(SetupProgress.PRIMING_FINISHED)
|
val isFullInit = !podStateManager.isPaired || podStateManager.setupProgress.isBefore(SetupProgress.PRIMING_FINISHED)
|
||||||
if (isFullInit) {
|
if (isFullInit) {
|
||||||
wizardPagerContext.wizardModel = FullInitPodWizardModel(applicationContext)
|
wizardPagerContext.wizardModel = FullInitPodWizardModel(applicationContext)
|
||||||
} else {
|
} else {
|
||||||
|
@ -150,13 +150,11 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refreshButtons() {
|
fun refreshButtons() {
|
||||||
initpod_init_pod.isEnabled = omnipodUtil.podStateManager == null || !omnipodUtil.podStateManager.isPaired() ||
|
initpod_init_pod.isEnabled = !omnipodUtil.podStateManager.isPaired() ||
|
||||||
omnipodUtil.getPodStateManager().getSetupProgress().isBefore(SetupProgress.COMPLETED)
|
omnipodUtil.getPodStateManager().getSetupProgress().isBefore(SetupProgress.COMPLETED)
|
||||||
|
|
||||||
val isPodSessionActive = omnipodUtil.podStateManager != null && omnipodUtil.podStateManager.hasState()
|
initpod_remove_pod.isEnabled = omnipodUtil.podStateManager.hasState() && omnipodUtil.podStateManager.isPaired
|
||||||
|
initpod_reset_pod.isEnabled = omnipodUtil.podStateManager.hasState()
|
||||||
initpod_remove_pod.isEnabled = isPodSessionActive && omnipodUtil.podStateManager.isPaired
|
|
||||||
initpod_reset_pod.isEnabled = isPodSessionActive
|
|
||||||
|
|
||||||
if (omnipodUtil.getDriverState() == OmnipodDriverState.NotInitalized) {
|
if (omnipodUtil.getDriverState() == OmnipodDriverState.NotInitalized) {
|
||||||
// if rileylink is not running we disable all operations
|
// if rileylink is not running we disable all operations
|
||||||
|
|
|
@ -56,6 +56,7 @@ public class AapsPodStateManager implements PodStateManager {
|
||||||
@Override public void removeState() {
|
@Override public void removeState() {
|
||||||
this.podState = null;
|
this.podState = null;
|
||||||
persistPodState();
|
persistPodState();
|
||||||
|
notifyPodStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,6 +66,7 @@ public class AapsPodStateManager implements PodStateManager {
|
||||||
}
|
}
|
||||||
podState = new PodState(address);
|
podState = new PodState(address);
|
||||||
persistPodState();
|
persistPodState();
|
||||||
|
notifyPodStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean isPaired() {
|
@Override public boolean isPaired() {
|
||||||
|
|
|
@ -173,6 +173,7 @@ public class OmnipodUtil {
|
||||||
|
|
||||||
public PodStateManager getPodStateManager() {
|
public PodStateManager getPodStateManager() {
|
||||||
if (omnipodPumpStatus.podStateManager == null) {
|
if (omnipodPumpStatus.podStateManager == null) {
|
||||||
|
aapsLogger.error("OmnipodUtil.getPodStateManager was called, but podStateManager is null");
|
||||||
throw new IllegalStateException("Pod state manager is null");
|
throw new IllegalStateException("Pod state manager is null");
|
||||||
}
|
}
|
||||||
return omnipodPumpStatus.podStateManager;
|
return omnipodPumpStatus.podStateManager;
|
||||||
|
|
Loading…
Reference in a new issue