- fixed endless loop

- status works correctly when RL is not present
This commit is contained in:
Andy Rozman 2020-01-28 22:54:38 +00:00
parent bc6e4be3ad
commit ec28f92223
4 changed files with 36 additions and 20 deletions

View file

@ -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 = "-"

View file

@ -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);

View file

@ -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) {

View file

@ -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" />
<View