From f37a2452fb0ef19b6c2f4cccfe04940b6762aefc Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Sat, 15 Aug 2020 19:01:48 +0200 Subject: [PATCH] Small cleanup and added some TODOs --- .../androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java | 4 +++- .../plugins/pump/omnipod/defs/state/PodStateManager.java | 6 +----- .../pump/omnipod/driver/comm/AapsPodStateManager.java | 7 ++++++- 3 files changed, 10 insertions(+), 7 deletions(-) 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 af7f8974ef..d84f191f11 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 @@ -111,6 +111,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump // TODO make non-static just inject the Singleton and use a getter) public static boolean isBusy = false; + // TODO it seems that we never add anything to this list? + // I Wouldn't know why we need it anyway protected List busyTimestamps = new ArrayList<>(); protected boolean sentIdToFirebase = false; protected boolean hasTimeDateOrTimeZoneChanged = false; @@ -406,7 +408,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump if (isServiceSet()) { - if (isBusy || !podStateManager.isPodRunning() || podStateManager.hasFaultEvent()) + if (isBusy || !podStateManager.isPodRunning()) return true; if (busyTimestamps.size() > 0) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodStateManager.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodStateManager.java index d5b8d7c868..9607df66a2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodStateManager.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodStateManager.java @@ -368,11 +368,7 @@ public abstract class PodStateManager { podState.setExpiresAt(expiresAtCalculated); } - boolean newSuspendedState = statusResponse.getDeliveryStatus() == DeliveryStatus.SUSPENDED; - if (podState.isSuspended() != newSuspendedState) { - aapsLogger.info(LTag.PUMPCOMM, "Updating pod suspended state in updateFromStatusResponse. newSuspendedState={}, statusResponse={}", newSuspendedState, statusResponse.toString()); - podState.setSuspended(newSuspendedState); - } + podState.setSuspended(statusResponse.getDeliveryStatus() == DeliveryStatus.SUSPENDED); podState.setActiveAlerts(statusResponse.getAlerts()); podState.setLastDeliveryStatus(statusResponse.getDeliveryStatus()); podState.setReservoirLevel(statusResponse.getReservoirLevel()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsPodStateManager.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsPodStateManager.java index 93a2f22595..5723c5bce6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsPodStateManager.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsPodStateManager.java @@ -70,6 +70,8 @@ public class AapsPodStateManager extends PodStateManager { omnipodPumpStatus.lastBolusTime = null; omnipodPumpStatus.lastBolusAmount = null; omnipodPumpStatus.reservoirRemainingUnits = 0.0; + // TODO this does not seem to set the pump status to suspended anymore + // Also, verify that AAPS is aware that no insulin is delivered anymore at this point omnipodPumpStatus.pumpStatusType = PumpStatusType.Suspended; sendEvent(new EventRefreshOverview("Omnipod Pump", false)); } else { @@ -77,7 +79,7 @@ public class AapsPodStateManager extends PodStateManager { Double lastBolusAmount = getLastBolusAmount(); // Update other info: last bolus, units remaining, suspended - boolean suspended = isSuspended() || !isPodRunning() || hasFaultEvent(); + boolean suspended = isSuspended() || !isPodRunning(); if (Objects.equals(lastBolusStartTime, omnipodPumpStatus.lastBolusTime) // || !Objects.equals(lastBolusAmount, omnipodPumpStatus.lastBolusAmount) // || !isReservoirStatusUpToDate(omnipodPumpStatus, getReservoirLevel()) @@ -85,7 +87,10 @@ public class AapsPodStateManager extends PodStateManager { omnipodPumpStatus.lastBolusTime = lastBolusStartTime; omnipodPumpStatus.lastBolusAmount = lastBolusAmount; omnipodPumpStatus.reservoirRemainingUnits = getReservoirLevel() == null ? 75.0 : getReservoirLevel(); + boolean sendRefreshOverviewEvent = suspended != PumpStatusType.Suspended.equals(omnipodPumpStatus.pumpStatusType); + // TODO this does not seem to set the pump status to suspended anymore + // Also, verify that AAPS is aware that no insulin is delivered anymore at this point omnipodPumpStatus.pumpStatusType = suspended ? PumpStatusType.Suspended : PumpStatusType.Running; if (sendRefreshOverviewEvent) {