From 61c67d7390a0fdc07c75bab4b92719e528617cd6 Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Wed, 27 Nov 2019 22:33:46 +0000 Subject: [PATCH] - Removing OmnipodManagerAAPS - new database entry class --- .../driver/comm/AapsOmnipodManager.java | 2 +- .../driver/comm/OmnipodManagerAAPS.java | 80 ------------------- .../pump/omnipod/driver/db/PodDbEntry.java | 50 ++---------- 3 files changed, 9 insertions(+), 123 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/OmnipodManagerAAPS.java 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 7e9e5fc947..39157c03d9 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 @@ -37,7 +37,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface } public AapsOmnipodManager(OmnipodCommunicationService communicationService, PodSessionState podState, OmnipodPumpStatus pumpStatus) { - delegate = new OmnipodManagerAAPS(communicationService, podState, pumpStatus); + delegate = new OmnipodManager(communicationService, podState); this.pumpStatus = pumpStatus; instance = this; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/OmnipodManagerAAPS.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/OmnipodManagerAAPS.java deleted file mode 100644 index 1ca3b3c1df..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/OmnipodManagerAAPS.java +++ /dev/null @@ -1,80 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.driver.comm; - - -import info.nightscout.androidaps.data.PumpEnactResult; -import info.nightscout.androidaps.plugins.bus.RxBus; -import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService; -import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodManager; -import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.DeactivatePodAction; -import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.OmnipodAction; -import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface; -import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; -import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver; -import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodDbEntry; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodDbEntryType; -import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged; -import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst; -import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil; -import info.nightscout.androidaps.utils.SP; - -/** - * Created by andy on 24.11.2019 - */ - -// TODO this should be used instead of AapsOmnipodManager -public class OmnipodManagerAAPS extends OmnipodManager //implements OmnipodCommunicationManagerInterface -{ - - public OmnipodManagerAAPS(OmnipodCommunicationService communicationService, PodSessionState podState, OmnipodPumpStatus pumpStatus) { - super(communicationService, podState); - communicationService.setPumpStatus(pumpStatus); - } - - - public PumpEnactResult deactivatePod(PodInitReceiver podInitReceiver) { - - if (podState == null) { - // TODO use string resource - podInitReceiver.returnInitTaskStatus(PodInitActionType.DeactivatePodWizardStep, false, "Pod should be paired and primed first"); - - return new PumpEnactResult().success(false).enacted(false).comment("Pod should be paired and primed first"); - } - - try { - communicationService.executeAction(new DeactivatePodAction(podState, true)); - resetPodStateInternal(); - podInitReceiver.returnInitTaskStatus(PodInitActionType.DeactivatePodWizardStep, true, null); - - } catch (Exception ex) { - // TODO distinguish between certain and uncertain failures - // TODO user friendly error messages (string resources) - podInitReceiver.returnInitTaskStatus(PodInitActionType.DeactivatePodWizardStep, false, "Error communicating with Pod [msg=" + ex.getMessage() + "]"); - - return new PumpEnactResult().success(false).enacted(false).comment(ex.getMessage()); - } - - return new PumpEnactResult().success(true).enacted(true); - } - - - public PumpEnactResult resetPodState() { - resetPodStateInternal(); - - //addToHistory(System.currentTimeMillis(), PodDbEntryType.ResetPodState, null, null, null, true); - - return new PumpEnactResult().success(true).enacted(true); - } - - private void resetPodStateInternal() { - podState = null; - SP.remove(OmnipodConst.Prefs.PodState); - - OmnipodUtil.setPodSessionState(null); - RxBus.INSTANCE.send(new EventOmnipodPumpValuesChanged()); - } - - - -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodDbEntry.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodDbEntry.java index 215a12eb75..e39994cb19 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodDbEntry.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodDbEntry.java @@ -9,12 +9,15 @@ public class PodDbEntry implements DbObjectBase { private long dateTime; private PodDbEntryType podDbEntryType; - private String shortDescription; - private String request; - private long dateTimeResponse; - private String response; + private String data; private boolean success; private long pumpId; + private Boolean successConfirmed; + + //private String request; + //private long dateTimeResponse; + //private String response; + public PodDbEntry(PodDbEntryType podDbEntryType) { this.dateTime = System.currentTimeMillis(); @@ -29,15 +32,6 @@ public class PodDbEntry implements DbObjectBase { generatePumpId(); } - public PodDbEntry(long requestTime, PodDbEntryType podDbEntryType, String shortDescription, String request, Long dateTimeResponse, String response) { - this.dateTime = requestTime; - this.podDbEntryType = podDbEntryType; - this.shortDescription = shortDescription; - this.request = request; - this.dateTimeResponse = dateTimeResponse; - this.response = response; - generatePumpId(); - } public long getDateTime() { @@ -56,29 +50,6 @@ public class PodDbEntry implements DbObjectBase { this.podDbEntryType = podDbEntryType; } - public String getRequest() { - return request; - } - - public void setRequest(String request) { - this.request = request; - } - - public long getDateTimeResponse() { - return dateTimeResponse; - } - - public void setDateTimeResponse(long dateTimeResponse) { - this.dateTimeResponse = dateTimeResponse; - } - - public String getResponse() { - return response; - } - - public void setResponse(String response) { - this.response = response; - } @Override public long getDate() { @@ -92,13 +63,8 @@ public class PodDbEntry implements DbObjectBase { private void generatePumpId() { // TODO + // yyyymmddhhMMssxx (time and xx is code of podDbEntryType) } - public String getShortDescription() { - return shortDescription; - } - public void setShortDescription(String shortDescription) { - this.shortDescription = shortDescription; - } }