From ec28f922232843128f775f9e616250f68062965b Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Tue, 28 Jan 2020 22:54:38 +0000 Subject: [PATCH] - fixed endless loop - status works correctly when RL is not present --- .../plugins/pump/omnipod/OmnipodFragment.kt | 2 ++ .../pump/omnipod/OmnipodPumpPlugin.java | 36 +++++++++++++------ .../pump/omnipod/util/OmnipodUtil.java | 16 ++++----- app/src/main/res/layout/omnipod_fragment.xml | 2 +- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt index c077cdd009..9b1c485092 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt @@ -217,6 +217,8 @@ class OmnipodFragment : Fragment() { val driverState = OmnipodUtil.getDriverState(); + LOG.info("getDriverState: [driverState={}]", driverState) + if (driverState == OmnipodDriverState.NotInitalized) { omnipod_pod_address.text = MainApp.gs(R.string.omnipod_pod_name_no_info) omnipod_pod_expiry.text = "-" diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 366796c63e..e988c2e61c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -108,7 +108,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump boolean omnipodServiceRunning = false; private long nextPodCheck = 0L; - OmnipodDriverState driverState = OmnipodDriverState.NotInitalized; + //OmnipodDriverState driverState = OmnipodDriverState.NotInitalized; private OmnipodPumpPlugin() { @@ -124,11 +124,16 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump displayConnectionMessages = false; - OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros); - if (OmnipodUtil.isOmnipodEros()) { - OmnipodUtil.setPlugin(this); - } + +// if (OmnipodUtil.isOmnipodEros()) { +// OmnipodUtil.setPlugin(this); +// OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros); +// } + + // TODO ccc + OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros); + OmnipodUtil.setPlugin(this); serviceConnection = new ServiceConnection() { @@ -284,7 +289,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump private void doPodCheck() { if (System.currentTimeMillis() > this.nextPodCheck) { - if (!getPodPumpStatusObject().podAvailable && omnipodServiceRunning) { + if (OmnipodUtil.getDriverState()==OmnipodDriverState.Initalized_NoPod) { Notification notification = new Notification(Notification.OMNIPOD_POD_NOT_ATTACHED, MainApp.gs(R.string.omnipod_error_pod_not_attached), Notification.NORMAL); RxBus.INSTANCE.send(new EventNewNotification(notification)); } else { @@ -376,7 +381,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump public boolean isConnected() { if (isLoggingEnabled() && displayConnectionMessages) LOG.debug(getLogPrefix() + "isConnected"); - return isServiceSet() && this.omnipodService.isInitialized() && isInitialized; + return isServiceSet() && omnipodService.isInitialized(); } @@ -384,14 +389,22 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump public boolean isConnecting() { if (isLoggingEnabled() && displayConnectionMessages) LOG.debug(getLogPrefix() + "isConnecting"); - return !isServiceSet() || (!omnipodService.isInitialized() || (!isInitialized)); + return !isServiceSet() || !omnipodService.isInitialized(); } @Override public boolean isSuspended() { - return (driverState == OmnipodDriverState.Initalized_NoPod) || + + return (OmnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) || (OmnipodUtil.getPodSessionState() != null && OmnipodUtil.getPodSessionState().isSuspended()); + +// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) || +// (OmnipodUtil.getPodSessionState() != null && OmnipodUtil.getPodSessionState().isSuspended()); +// +// TODO ddd +// return (OmnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) || +// (OmnipodUtil.getPodSessionState() != null && OmnipodUtil.getPodSessionState().isSuspended()); // // return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) || // (OmnipodUtil.getPodSessionState() != null && OmnipodUtil.getPodSessionState().isSuspended()); @@ -491,7 +504,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump @Override public void setDriverState(OmnipodDriverState state) { - this.driverState = state; + //this.driverState = state; } @@ -511,7 +524,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump if (isLoggingEnabled()) LOG.info(getLogPrefix() + "initializePump - start"); - OmnipodPumpStatus podPumpStatus = getPodPumpStatusObject(); + // TODO ccc + //OmnipodPumpStatus podPumpStatus = getPodPumpStatusObject(); setRefreshButtonEnabled(false); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java index 8e8ea7ab3a..f5a32d6226 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java @@ -55,7 +55,7 @@ public class OmnipodUtil extends RileyLinkUtil { //private static PodDeviceState podDeviceState; private static OmnipodPumpPluginInterface omnipodPumpPlugin; private static OmnipodPodType omnipodPodType; - private static OmnipodDriverState driverState; + private static OmnipodDriverState driverState = OmnipodDriverState.NotInitalized; public static Gson getGsonInstance() { return gsonInstance; @@ -162,13 +162,13 @@ public class OmnipodUtil extends RileyLinkUtil { OmnipodUtil.driverState = state; // TODO maybe remove - if (OmnipodUtil.omnipodPumpStatus != null) { - OmnipodUtil.omnipodPumpStatus.driverState = state; - } - - if (OmnipodUtil.omnipodPumpPlugin != null) { - OmnipodUtil.omnipodPumpPlugin.setDriverState(state); - } +// if (OmnipodUtil.omnipodPumpStatus != null) { +// OmnipodUtil.omnipodPumpStatus.driverState = state; +// } +// +// if (OmnipodUtil.omnipodPumpPlugin != null) { +// OmnipodUtil.omnipodPumpPlugin.setDriverState(state); +// } } public static void setPumpStatus(OmnipodPumpStatus omnipodPumpStatus) { diff --git a/app/src/main/res/layout/omnipod_fragment.xml b/app/src/main/res/layout/omnipod_fragment.xml index 629d431e43..2068f90557 100644 --- a/app/src/main/res/layout/omnipod_fragment.xml +++ b/app/src/main/res/layout/omnipod_fragment.xml @@ -219,7 +219,7 @@ android:id="@+id/omnipod_queue" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="content" + android:text="" android:textAlignment="center" />