From a0ca8cf9cc3e4175771dc063d726227776ab4dcd Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Mon, 10 Aug 2020 17:58:54 +0200 Subject: [PATCH] - Partial fix for display of RL status - Fix IllegalStateException when AssignAddressAction is executed when an address has already been assigned - Improve (not yet used) custom unreachable alert check - Remove hasFixedUnreachableAlert from PumpType - Remove omnipodPumpStatus.podAvailable in favor of PodStateManager - Remove some unused code / comments - Add a bunch of TODOs --- .../interfaces/PumpDescription.java | 3 -- .../plugins/pump/common/defs/PumpType.java | 16 +++------ .../RileyLinkStatusGeneralFragment.java | 9 +++-- .../plugins/pump/omnipod/OmnipodFragment.kt | 33 +++++++++---------- .../pump/omnipod/OmnipodPumpPlugin.java | 30 +++++++---------- .../comm/OmnipodCommunicationManager.java | 2 ++ .../comm/action/AssignAddressAction.java | 7 ++-- .../comm/action/SetTempBasalAction.java | 2 +- .../pump/omnipod/defs/PodDeviceState.java | 1 + .../omnipod/driver/OmnipodDriverState.java | 1 + .../omnipod/driver/OmnipodPumpStatus.java | 11 +------ .../driver/comm/AapsOmnipodManager.java | 1 + .../pump/omnipod/util/OmnipodUtil.java | 5 --- 13 files changed, 48 insertions(+), 73 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java index 0b83944d94..81a5d9e7ae 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java @@ -55,7 +55,6 @@ public class PumpDescription { public boolean supportsTDDs; public boolean needsManualTDDLoad; - public boolean hasFixedUnreachableAlert; public boolean hasCustomUnreachableAlertCheck; public void resetSettings() { @@ -90,7 +89,6 @@ public class PumpDescription { supportsTDDs = false; needsManualTDDLoad = true; - hasFixedUnreachableAlert = false; hasCustomUnreachableAlertCheck = false; } @@ -140,7 +138,6 @@ public class PumpDescription { is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min); - hasFixedUnreachableAlert = pumpType.getHasFixedUnreachableAlert(); hasCustomUnreachableAlertCheck = pumpType.getHasCustomUnreachableAlertCheck(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.java index 3fff66fdf7..4e80cafd12 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.java @@ -102,13 +102,13 @@ public enum PumpType { new DoseSettings(0.05d, 30, 8 * 60, 0.05d), // PumpTempBasalType.Absolute, // new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, // - 0.05d, null, 0.05d, null, PumpCapability.OmnipodCapabilities, true, true), + 0.05d, null, 0.05d, null, PumpCapability.OmnipodCapabilities, true), Insulet_Omnipod_Dash("Insulet Omnipod Dash", ManufacturerType.Insulet, "Omnipod Dash", 0.05d, null, // new DoseSettings(0.05d, 30, 8 * 60, 0.05d), // PumpTempBasalType.Absolute, // new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, // - 0.05d, null, 0.05d, null, PumpCapability.OmnipodCapabilities, true, true), // TODO just copied OmniPod for now + 0.05d, null, 0.05d, null, PumpCapability.OmnipodCapabilities, true), // TODO just copied OmniPod for now // Medtronic Medtronic_512_712("Medtronic 512/712", ManufacturerType.Medtronic, "512/712", 0.1d, null, // @@ -163,7 +163,6 @@ public enum PumpType { private double baseBasalStep; // private DoseStepSize baseBasalSpecialSteps; // private PumpCapability pumpCapability; - private boolean hasFixedUnreachableAlert; private boolean hasCustomUnreachableAlertCheck; private PumpType parent; @@ -231,7 +230,7 @@ public enum PumpType { PumpCapability pumpCapability) { this(description, manufacturer, model, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType, tbrSettings, specialBasalDurations, baseBasalMinValue, null, baseBasalStep, - baseBasalSpecialSteps, pumpCapability, false, false); + baseBasalSpecialSteps, pumpCapability, false); } @@ -249,7 +248,6 @@ public enum PumpType { double baseBasalStep, DoseStepSize baseBasalSpecialSteps, // PumpCapability pumpCapability, - boolean hasFixedUnreachableAlert, boolean hasCustomUnreachableAlertCheck) { this.description = description; this.manufacturer = manufacturer; @@ -265,17 +263,11 @@ public enum PumpType { this.baseBasalStep = baseBasalStep; this.baseBasalSpecialSteps = baseBasalSpecialSteps; this.pumpCapability = pumpCapability; - this.hasFixedUnreachableAlert = hasFixedUnreachableAlert; this.hasCustomUnreachableAlertCheck = hasCustomUnreachableAlertCheck; } - - public boolean getHasFixedUnreachableAlert() { - return hasFixedUnreachableAlert; - } - public boolean getHasCustomUnreachableAlertCheck() { - return hasFixedUnreachableAlert; + return hasCustomUnreachableAlertCheck; } public String getDescription() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java index 623ecae9ef..a0760c8b1b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java @@ -31,6 +31,8 @@ import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil; import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin; import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; +import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin; +import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; import info.nightscout.androidaps.utils.resources.ResourceHelper; @@ -167,10 +169,11 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re this.pumpFrequency.setText(resourceHelper.gs(R.string.omnipod_frequency)); + // TODO needs improvement if (omnipodPumpStatus != null) { - - if (omnipodPumpStatus.podAvailable) { - this.serialNumber.setText(omnipodPumpStatus.podLotNumber); + PodStateManager podStateManager = ((OmnipodPumpPlugin) pumpPlugin).getPodStateManager(); + if (podStateManager.isPaired()) { + this.serialNumber.setText(podStateManager.getLot()); this.connectedDevice.setText(omnipodPumpStatus.pumpType == PumpType.Insulet_Omnipod ? "Eros Pod" : "Dash Pod"); } else { this.serialNumber.setText("??"); 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 e1c22dc78e..a124c9f7a4 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 @@ -218,16 +218,18 @@ class OmnipodFragment : DaggerFragment() { aapsLogger.info(LTag.PUMP, "setDeviceStatus: [pumpStatus={}]", omnipodPumpStatus) - val resourceId = rileyLinkServiceData.rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.Omnipod) + val rileyLinkServiceState = rileyLinkServiceData.rileyLinkServiceState + + val resourceId = rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.Omnipod) val rileyLinkError = rileyLinkServiceData.rileyLinkError omnipod_rl_status.text = when { - omnipodPumpStatus.rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId) - omnipodPumpStatus.rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId) - omnipodPumpStatus.rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId) - omnipodPumpStatus.rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump)) - else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId) + rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId) + rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId) + rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId) + rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump)) + else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId) } omnipod_rl_status.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE) @@ -235,7 +237,7 @@ class OmnipodFragment : DaggerFragment() { // RileyLinkUtil.getError()) as RileyLinkError? omnipod_errors.text = - omnipodPumpStatus.rileyLinkError?.let { + rileyLinkError?.let { resourceHelper.gs(it.getResourceId(RileyLinkTargetDevice.Omnipod)) } ?: "-" @@ -258,11 +260,9 @@ class OmnipodFragment : DaggerFragment() { } else { omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_no_pod_connected) } - omnipodPumpStatus.podAvailable = false omnipodPumpStatus.podNumber == null } else { omnipodPumpStatus.podLotNumber = "" + podStateManager.lot - omnipodPumpStatus.podAvailable = podStateManager.isSetupCompleted omnipod_pod_address.text = podStateManager.address.toString() omnipod_pod_lot.text = podStateManager.lot.toString() omnipod_pod_tid.text = podStateManager.tid.toString() @@ -270,13 +270,11 @@ class OmnipodFragment : DaggerFragment() { omnipod_pod_expiry.text = podStateManager.expiryDateAsString omnipodPumpStatus.podNumber = podStateManager.address.toString() - var podDeviceState = omnipodPumpStatus.podDeviceState - var stateText: String? - if(podStateManager.hasFaultEvent()) { + if (podStateManager.hasFaultEvent()) { val faultEventCode = podStateManager.faultEvent.faultEventCode - stateText = resourceHelper.gs(R.string.omnipod_pod_status_pod_fault) + " ("+ faultEventCode.value +" "+ faultEventCode.name +")" + stateText = resourceHelper.gs(R.string.omnipod_pod_status_pod_fault) + " (" + faultEventCode.value + " " + faultEventCode.name + ")" } else if (podStateManager.isSetupCompleted) { stateText = resourceHelper.gs(R.string.omnipod_pod_status_pod_running) if (podStateManager.lastDeliveryStatus != null) { @@ -323,8 +321,9 @@ class OmnipodFragment : DaggerFragment() { setDeviceStatus() - if (omnipodPumpStatus.podAvailable) { + if (podStateManager.isPaired) { // last connection + // TODO replace with podStateManager.getLastSuccessfulCommunication if (omnipodPumpStatus.lastConnection != 0L) { //val minAgo = DateUtil.minAgo(pumpStatus.lastConnection) val min = (System.currentTimeMillis() - omnipodPumpStatus.lastConnection) / 1000 / 60 @@ -355,9 +354,10 @@ class OmnipodFragment : DaggerFragment() { } // last bolus + // TODO replace with podStateManager.getLastBolus val bolus = omnipodPumpStatus.lastBolusAmount val bolusTime = omnipodPumpStatus.lastBolusTime - if (bolus != null && bolusTime != null && omnipodPumpStatus.podAvailable) { + if (bolus != null && bolusTime != null) { val agoMsc = System.currentTimeMillis() - omnipodPumpStatus.lastBolusTime.time val bolusMinAgo = agoMsc.toDouble() / 60.0 / 1000.0 val unit = resourceHelper.gs(R.string.insulin_unit_shortname) @@ -401,8 +401,7 @@ class OmnipodFragment : DaggerFragment() { updateAcknowledgeAlerts() - omnipod_refresh.isEnabled = omnipodPumpStatus.podAvailable - + omnipod_refresh.isEnabled = podStateManager.isPaired } private fun updateAcknowledgeAlerts() { 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 49b7faa7fe..ed5580af3f 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 @@ -88,9 +88,7 @@ import io.reactivex.schedulers.Schedulers; */ @Singleton public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPumpPluginInterface, RileyLinkPumpDevice { - - // TODO Dagger (maybe done) - @Inject protected PodStateManager podStateManager; + protected PodStateManager podStateManager; private static OmnipodPumpPlugin plugin = null; private RileyLinkServiceData rileyLinkServiceData; private ServiceTaskExecutor serviceTaskExecutor; @@ -110,6 +108,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump private boolean isInitialized = false; protected OmnipodCommunicationManagerInterface omnipodCommunicationManager; + // TODO make non-static just inject the Singleton and use a getter) public static boolean isBusy = false; protected List busyTimestamps = new ArrayList<>(); protected boolean sentIdToFirebase = false; @@ -135,6 +134,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump SP sp, OmnipodUtil omnipodUtil, OmnipodPumpStatus omnipodPumpStatus, + PodStateManager podStateManager, CommandQueueProvider commandQueue, FabricPrivacy fabricPrivacy, RileyLinkServiceData rileyLinkServiceData, @@ -150,7 +150,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump PumpType.Insulet_Omnipod, injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy ); - injector.androidInjector().inject(this); + this.podStateManager = podStateManager; this.rileyLinkServiceData = rileyLinkServiceData; this.serviceTaskExecutor = serviceTaskExecutor; @@ -182,6 +182,9 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return plugin; } + public PodStateManager getPodStateManager() { + return podStateManager; + } @Override protected void onStart() { @@ -402,7 +405,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump if (isServiceSet()) { - if (isBusy || !omnipodPumpStatus.podAvailable) + if (isBusy || !podStateManager.isSetupCompleted()) return true; if (busyTimestamps.size() > 0) { @@ -491,19 +494,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump @Override public boolean isSuspended() { - return omnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod || !podStateManager.isSetupCompleted() || podStateManager.isSuspended(); - -// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) || -// (omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended()); -// -// TODO ddd -// return (OmnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) || -// (omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended()); -// -// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) || -// (omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended()); } @Override @@ -1001,9 +993,9 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump @Override public boolean isUnreachableAlertTimeoutExceeded(long unreachableTimeoutMilliseconds) { - if (omnipodPumpStatus.lastConnection != 0 || omnipodPumpStatus.lastErrorConnection != 0) { - if (omnipodPumpStatus.lastConnection + unreachableTimeoutMilliseconds < System.currentTimeMillis()) { - if (omnipodPumpStatus.lastErrorConnection > omnipodPumpStatus.lastConnection) { + if (podStateManager.isSetupCompleted() && podStateManager.getLastSuccessfulCommunication() != null) { // Null check for backwards compatibility + if (podStateManager.getLastSuccessfulCommunication().getMillis() + unreachableTimeoutMilliseconds < System.currentTimeMillis()) { + if (podStateManager.getLastFailedCommunication() != null && podStateManager.getLastSuccessfulCommunication().isBefore(podStateManager.getLastFailedCommunication())) { // We exceeded the alert threshold, and our last connection failed // We should show an alert return true; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java index 7c9a96c0b4..fecd5beeb5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java @@ -50,6 +50,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst; /** * Created by andy on 6/29/18. */ +// TODO make singleton public class OmnipodCommunicationManager extends RileyLinkCommunicationManager { @Inject public AAPSLogger aapsLogger; @@ -58,6 +59,7 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager { //@Inject RileyLinkServiceData rileyLinkServiceData; //@Inject ServiceTaskExecutor serviceTaskExecutor; + @Inject public OmnipodCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) { super(injector, rfspy); omnipodPumpStatus.previousConnection = sp.getLong( diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/AssignAddressAction.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/AssignAddressAction.java index 0637a75872..dac2fbf100 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/AssignAddressAction.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/AssignAddressAction.java @@ -7,10 +7,12 @@ import java.util.Random; import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager; import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalMessageAddressException; +import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalSetupProgressException; import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalVersionResponseTypeException; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.AssignAddressCommand; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.VersionResponse; +import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress; import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst; @@ -29,8 +31,8 @@ public class AssignAddressAction implements OmnipodAction { if (!podStateManager.hasState()) { podStateManager.initState(generateRandomAddress()); } - if (podStateManager.isPaired()) { - throw new IllegalStateException("podStateManager already has a paired Pod"); + if (podStateManager.isPaired() && podStateManager.getSetupProgress().isAfter(SetupProgress.ADDRESS_ASSIGNED)) { + throw new IllegalSetupProgressException(SetupProgress.ADDRESS_ASSIGNED, podStateManager.getSetupProgress()); } AssignAddressCommand assignAddress = new AssignAddressCommand(podStateManager.getAddress()); @@ -53,7 +55,6 @@ public class AssignAddressAction implements OmnipodAction { return assignAddressResponse; } - private static int generateRandomAddress() { // Create random address with 20 bits to match PDM, could easily use 24 bits instead return 0x1f000000 | (new Random().nextInt() & 0x000fffff); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/SetTempBasalAction.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/SetTempBasalAction.java index 0610256d81..3f908c1a3a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/SetTempBasalAction.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/SetTempBasalAction.java @@ -46,7 +46,7 @@ public class SetTempBasalAction implements OmnipodAction { OmnipodMessage message = new OmnipodMessage(podStateManager.getAddress(), messageBlocks, podStateManager.getMessageNumber()); StatusResponse statusResponse = communicationService.exchangeMessages(StatusResponse.class, podStateManager, message); - podStateManager.setLastTempBasal(new DateTime().minus(OmnipodConst.AVERAGE_TEMP_BASAL_COMMAND_COMMUNICATION_DURATION), rate, duration); + podStateManager.setLastTempBasal(DateTime.now().minus(OmnipodConst.AVERAGE_TEMP_BASAL_COMMAND_COMMUNICATION_DURATION), rate, duration); return statusResponse; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodDeviceState.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodDeviceState.java index 5e903b5ae4..2336905a53 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodDeviceState.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodDeviceState.java @@ -6,6 +6,7 @@ import info.nightscout.androidaps.R; * Created by andy on 4.8.2019 */ +// FIXME remove public enum PodDeviceState { // FIXME diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodDriverState.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodDriverState.java index c2910dab89..daa51b3685 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodDriverState.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodDriverState.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver; +// TODO replace with method calls on PodStateManager public enum OmnipodDriverState { NotInitalized, // when we start diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java index e069875d27..f445d0e332 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java @@ -26,6 +26,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP; */ @Singleton public class OmnipodPumpStatus extends PumpStatus { + // TODO remove all fields that can also be obtained via PodStateManager private final ResourceHelper resourceHelper; private final SP sp; @@ -37,8 +38,6 @@ public class OmnipodPumpStatus extends PumpStatus { public boolean inPreInit = true; // statuses - public RileyLinkServiceState rileyLinkServiceState = RileyLinkServiceState.NotStarted; - public RileyLinkError rileyLinkError; public double currentBasal = 0; public long tempBasalStart; public long tempBasalEnd; @@ -51,9 +50,6 @@ public class OmnipodPumpStatus extends PumpStatus { public String podNumber; public PodDeviceState podDeviceState = PodDeviceState.NeverContacted; - // FIXME replace with method calls on PodStateManager - public boolean podAvailable = false; - public boolean podAvailibityChecked = false; public boolean ackAlertsAvailable = false; public String ackAlertsText = null; @@ -88,9 +84,7 @@ public class OmnipodPumpStatus extends PumpStatus { this.reservoirRemainingUnits = 75d; this.batteryRemaining = 75; this.lastConnection = sp.getLong(OmnipodConst.Statistics.LastGoodPumpCommunicationTime, 0L); - this.lastDataTime = this.lastConnection; this.pumpType = PumpType.Insulet_Omnipod; - this.podAvailable = false; } @@ -133,8 +127,6 @@ public class OmnipodPumpStatus extends PumpStatus { "errorDescription='" + errorDescription + '\'' + ", rileyLinkAddress='" + rileyLinkAddress + '\'' + ", inPreInit=" + inPreInit + - ", rileyLinkServiceState=" + rileyLinkServiceState + - ", rileyLinkError=" + rileyLinkError + ", currentBasal=" + currentBasal + ", tempBasalStart=" + tempBasalStart + ", tempBasalEnd=" + tempBasalEnd + @@ -143,7 +135,6 @@ public class OmnipodPumpStatus extends PumpStatus { ", regexMac='" + regexMac + '\'' + ", podNumber='" + podNumber + '\'' + ", podDeviceState=" + podDeviceState + - ", podAvailable=" + podAvailable + ", ackAlertsAvailable=" + ackAlertsAvailable + ", ackAlertsText='" + ackAlertsText + '\'' + ", lastDataTime=" + lastDataTime + diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java index f814a1082f..c9aae39438 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java @@ -72,6 +72,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; import io.reactivex.disposables.Disposable; +// TODO make singleton public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface { private final PodStateManager podStateManager; 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 7fde7c640f..c6fe6ec806 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 @@ -131,11 +131,6 @@ public class OmnipodUtil { return gsonBuilder.create(); } - public void notifyDeviceStatusChanged() { - - } - - public void setPodDeviceState(PodDeviceState podDeviceState) { omnipodPumpStatus.podDeviceState = podDeviceState; }