(R.id.initpod_waiting_for_rl_layout)
+
+ if (rileyLinkServiceData.rileyLinkServiceState.isReady) {
+ waitingForRlView.visibility = View.GONE
+ } else {
// if rileylink is not running we disable all operations that require a RL connection
+ waitingForRlView.visibility = View.VISIBLE
initpod_init_pod.isEnabled = false
initpod_remove_pod.isEnabled = false
initpod_reset_pod.isEnabled = false
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/defs/PodActionType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/defs/PodActionType.java
similarity index 100%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/defs/PodActionType.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/defs/PodActionType.java
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java
similarity index 99%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java
index 8dce02d7e0..192dde6c26 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java
@@ -30,8 +30,8 @@ import javax.inject.Inject;
import dagger.android.HasAndroidInjector;
import dagger.android.support.DaggerFragment;
-import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.PumpEnactResult;
+import info.nightscout.androidaps.plugins.pump.omnipod.R;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionPage.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionPage.java
similarity index 99%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionPage.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionPage.java
index 8b34b99193..3ba9145749 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionPage.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionPage.java
@@ -14,7 +14,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
/**
* Created by andy on 12/11/2019
- *
+ *
* This page is for InitPod and RemovePod, but Fragments called for this 2 actions are different
*/
public class InitActionPage extends Page {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java
similarity index 87%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java
index 129d551985..5496843cf9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java
@@ -16,6 +16,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodMa
public class InitPodTask extends AsyncTask {
@Inject ProfileFunction profileFunction;
+ @Inject AapsOmnipodManager aapsOmnipodManager;
private InitActionFragment initActionFragment;
public InitPodTask(HasAndroidInjector injector, InitActionFragment initActionFragment) {
@@ -34,19 +35,19 @@ public class InitPodTask extends AsyncTask {
@Override
protected String doInBackground(Void... params) {
if (initActionFragment.podInitActionType == PodInitActionType.PairAndPrimeWizardStep) {
- initActionFragment.callResult = AapsOmnipodManager.getInstance().initPod(
+ initActionFragment.callResult = aapsOmnipodManager.initPod(
initActionFragment.podInitActionType,
initActionFragment,
null
);
} else if (initActionFragment.podInitActionType == PodInitActionType.FillCannulaSetBasalProfileWizardStep) {
- initActionFragment.callResult = AapsOmnipodManager.getInstance().initPod(
+ initActionFragment.callResult = aapsOmnipodManager.initPod(
initActionFragment.podInitActionType,
initActionFragment,
profileFunction.getProfile()
);
} else if (initActionFragment.podInitActionType == PodInitActionType.DeactivatePodWizardStep) {
- initActionFragment.callResult = AapsOmnipodManager.getInstance().deactivatePod(initActionFragment);
+ initActionFragment.callResult = aapsOmnipodManager.deactivatePod(initActionFragment);
}
return "OK";
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/FullInitPodWizardModel.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/FullInitPodWizardModel.java
similarity index 97%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/FullInitPodWizardModel.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/FullInitPodWizardModel.java
index a2e7383091..7c70f64c2c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/FullInitPodWizardModel.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/FullInitPodWizardModel.java
@@ -5,7 +5,7 @@ import android.content.Context;
import com.atech.android.library.wizardpager.model.DisplayTextPage;
import com.tech.freak.wizardpager.model.PageList;
-import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.plugins.pump.omnipod.R;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitActionPage;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/InitPodWizardModel.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/InitPodWizardModel.java
similarity index 100%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/InitPodWizardModel.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/InitPodWizardModel.java
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/RemovePodWizardModel.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/RemovePodWizardModel.java
similarity index 97%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/RemovePodWizardModel.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/RemovePodWizardModel.java
index 1350ae1a49..c0088984b4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/RemovePodWizardModel.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/RemovePodWizardModel.java
@@ -24,7 +24,7 @@ import com.atech.android.library.wizardpager.model.DisplayTextPage;
import com.tech.freak.wizardpager.model.AbstractWizardModel;
import com.tech.freak.wizardpager.model.PageList;
-import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.plugins.pump.omnipod.R;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.PodInfoFragment;
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.removepod.RemovePodActionPage;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/ShortInitPodWizardModel.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/ShortInitPodWizardModel.java
similarity index 96%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/ShortInitPodWizardModel.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/ShortInitPodWizardModel.java
index 5499fdf8ec..51676a20a6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/ShortInitPodWizardModel.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/ShortInitPodWizardModel.java
@@ -5,7 +5,7 @@ import android.content.Context;
import com.atech.android.library.wizardpager.model.DisplayTextPage;
import com.tech.freak.wizardpager.model.PageList;
-import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.plugins.pump.omnipod.R;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitActionPage;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java
similarity index 69%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java
index c6837f1644..80935bad7c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java
@@ -9,17 +9,14 @@ import org.json.JSONObject;
import javax.inject.Inject;
import dagger.android.HasAndroidInjector;
-import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.Source;
+import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
-import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity;
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.defs.PodActionType;
-import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState;
-import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
@@ -29,18 +26,16 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
*/
public class InitPodRefreshAction extends AbstractCancelAction implements FinishActionInterface {
- private PodManagementActivity podManagementActivity;
private PodActionType actionType;
- @Inject OmnipodUtil omnipodUtil;
@Inject PodStateManager podStateManager;
@Inject AAPSLogger aapsLogger;
@Inject SP sp;
@Inject NSUpload nsUpload;
+ @Inject DatabaseHelperInterface databaseHelper;
- public InitPodRefreshAction(HasAndroidInjector injector, PodManagementActivity podManagementActivity, PodActionType actionType) {
+ public InitPodRefreshAction(HasAndroidInjector injector, PodActionType actionType) {
injector.androidInjector().inject(this);
- this.podManagementActivity = podManagementActivity;
this.actionType = actionType;
}
@@ -49,32 +44,19 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish
if (cancelReason != null && cancelReason.trim().length() > 0) {
this.cancelActionText = cancelReason;
}
-
- if (this.cancelActionText.equals("Cancel")) {
- //AapsOmnipodManager.getInstance().resetPodStatus();
- }
-
- podManagementActivity.refreshButtons();
}
@Override
public void execute() {
if (actionType == PodActionType.InitPod) {
- if (!podStateManager.isPodRunning()) {
- omnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodInitializing);
- } else {
- omnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodAttached);
+ if (podStateManager.isPodRunning()) {
uploadCareportalEvent(System.currentTimeMillis(), CareportalEvent.SITECHANGE);
}
- } else {
- omnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod);
}
-
- podManagementActivity.refreshButtons();
}
private void uploadCareportalEvent(long date, String event) {
- if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date) != null)
+ if (databaseHelper.getCareportalEventFromTimestamp(date) != null)
return;
try {
JSONObject data = new JSONObject();
@@ -87,14 +69,13 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish
careportalEvent.source = Source.USER;
careportalEvent.eventType = event;
careportalEvent.json = data.toString();
- MainApp.getDbHelper().createOrUpdate(careportalEvent);
+ databaseHelper.createOrUpdate(careportalEvent);
nsUpload.uploadCareportalEntryToNS(data);
} catch (JSONException e) {
aapsLogger.error(LTag.PUMPCOMM, "Unhandled exception when uploading SiteChange event.", e);
}
}
-
@Override
public String getFinishActionText() {
return "Finish_OK";
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoFragment.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoFragment.java
similarity index 99%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoFragment.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoFragment.java
index 128211c6fd..0d4f3c52c6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoFragment.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoFragment.java
@@ -21,7 +21,7 @@ import java.util.ArrayList;
import javax.inject.Inject;
import dagger.android.support.DaggerFragment;
-import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.plugins.pump.omnipod.R;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoPage.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoPage.java
similarity index 100%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoPage.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoPage.java
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemoveActionFragment.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemoveActionFragment.java
similarity index 92%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemoveActionFragment.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemoveActionFragment.java
index beea880d6f..935ee65085 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemoveActionFragment.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemoveActionFragment.java
@@ -17,8 +17,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.In
public class RemoveActionFragment extends InitActionFragment implements PodInitReceiver {
public static RemoveActionFragment create(String key, PodInitActionType podInitActionType) {
Bundle args = new Bundle();
- args.putString(InitActionFragment.ARG_KEY, key);
- args.putSerializable(InitActionFragment.ARG_POD_INIT_ACTION_TYPE, podInitActionType);
+ args.putString(ARG_KEY, key);
+ args.putSerializable(ARG_POD_INIT_ACTION_TYPE, podInitActionType);
RemoveActionFragment fragment = new RemoveActionFragment();
fragment.setArguments(args);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemovePodActionPage.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemovePodActionPage.java
similarity index 99%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemovePodActionPage.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemovePodActionPage.java
index 7f5b2b8503..444c8a4b11 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemovePodActionPage.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemovePodActionPage.java
@@ -11,7 +11,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.In
/**
* Created by andy on 12/11/2019
- *
*/
public class RemovePodActionPage extends InitActionPage {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java
similarity index 92%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java
index 0e1ab17b05..c7d9f24da1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java
@@ -15,7 +15,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
-import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
/**
@@ -27,7 +26,6 @@ public class OmnipodPumpStatus extends PumpStatus {
// TODO remove all fields that can also be obtained via PodStateManager
// We can probably get rid of this class altogether
- private final ResourceHelper resourceHelper;
private final SP sp;
private final RileyLinkUtil rileyLinkUtil;
private final RxBusWrapper rxBus;
@@ -47,9 +45,6 @@ public class OmnipodPumpStatus extends PumpStatus {
public String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
- public boolean ackAlertsAvailable = false;
- public String ackAlertsText = null;
-
public boolean beepBolusEnabled = true;
public boolean beepBasalEnabled = true;
public boolean beepSMBEnabled = true;
@@ -57,16 +52,13 @@ public class OmnipodPumpStatus extends PumpStatus {
public boolean podDebuggingOptionsEnabled = false;
public boolean timeChangeEventEnabled = true;
- public OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
private PumpDeviceState pumpDeviceState;
@Inject
- public OmnipodPumpStatus(ResourceHelper resourceHelper,
- info.nightscout.androidaps.utils.sharedPreferences.SP sp,
+ public OmnipodPumpStatus(SP sp,
RxBusWrapper rxBus,
RileyLinkUtil rileyLinkUtil) {
super(PumpType.Insulet_Omnipod);
- this.resourceHelper = resourceHelper;
this.sp = sp;
this.rxBus = rxBus;
this.rileyLinkUtil = rileyLinkUtil;
@@ -139,7 +131,6 @@ public class OmnipodPumpStatus extends PumpStatus {
"rileyLinkErrorDescription='" + rileyLinkErrorDescription + '\'' +
", rileyLinkAddress='" + rileyLinkAddress + '\'' +
", inPreInit=" + inPreInit +
- ", currentBasal=" + currentBasal +
", tempBasalStart=" + tempBasalStart +
", tempBasalEnd=" + tempBasalEnd +
", tempBasalAmount=" + tempBasalAmount +
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java
similarity index 84%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java
index c9725df95a..645802bd87 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java
@@ -10,17 +10,20 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
import dagger.android.HasAndroidInjector;
-import info.nightscout.androidaps.MainApp;
-import info.nightscout.androidaps.R;
import info.nightscout.androidaps.activities.ErrorHelperActivity;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
+import info.nightscout.androidaps.db.OmnipodHistoryRecord;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
+import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
@@ -33,6 +36,7 @@ import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
+import info.nightscout.androidaps.plugins.pump.omnipod.R;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodManager;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.SetupActionResult;
@@ -65,15 +69,16 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalSchedu
import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalScheduleEntry;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
-import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistory;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistoryEntryType;
import info.nightscout.androidaps.plugins.pump.omnipod.exception.OmnipodException;
+import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
import io.reactivex.disposables.Disposable;
+import io.reactivex.subjects.SingleSubject;
-// TODO make singleton
+@Singleton
public class AapsOmnipodManager implements IOmnipodManager {
private final PodStateManager podStateManager;
@@ -85,16 +90,12 @@ public class AapsOmnipodManager implements IOmnipodManager {
private final ActivePluginProvider activePlugin;
private final OmnipodPumpStatus pumpStatus;
private final Context context;
+ private final SP sp;
private final OmnipodManager delegate;
+ private DatabaseHelperInterface databaseHelper;
- //TODO: remove and use injection
- private static AapsOmnipodManager instance;
-
- public static AapsOmnipodManager getInstance() {
- return instance;
- }
-
+ @Inject
public AapsOmnipodManager(OmnipodCommunicationManager communicationService,
PodStateManager podStateManager,
OmnipodPumpStatus pumpStatus,
@@ -105,7 +106,8 @@ public class AapsOmnipodManager implements IOmnipodManager {
ResourceHelper resourceHelper,
HasAndroidInjector injector,
ActivePluginProvider activePlugin,
- Context context) {
+ Context context,
+ DatabaseHelperInterface databaseHelper) {
if (podStateManager == null) {
throw new IllegalArgumentException("Pod state manager can not be null");
}
@@ -118,9 +120,10 @@ public class AapsOmnipodManager implements IOmnipodManager {
this.activePlugin = activePlugin;
this.pumpStatus = pumpStatus;
this.context = context;
+ this.databaseHelper = databaseHelper;
+ this.sp = sp;
delegate = new OmnipodManager(aapsLogger, sp, communicationService, podStateManager);
- instance = this;
}
public PodStateManager getPodStateManager() {
@@ -271,47 +274,82 @@ public class AapsOmnipodManager implements IOmnipodManager {
showErrorDialog(getStringResource(R.string.omnipod_bolus_failed_uncertain), R.raw.boluserror);
}
+ detailedBolusInfo.date = bolusStarted.getTime();
+ detailedBolusInfo.source = Source.PUMP;
+
+ // Store the current bolus for in case the app crashes, gets killed, the phone dies or whatever before the bolus finishes
+ // If we have a stored value for the current bolus on startup, we'll create a Treatment for it
+ // However this can potentially be hours later if for example your phone died and you can't charge it
+ // FIXME !!!
+ // The proper solution here would be to create a treatment right after the bolus started,
+ // and update that treatment after the bolus has finished in case the actual units delivered don't match the requested bolus units
+ // That way, the bolus would immediately be sent to NS so in case the phone dies you could still see the bolus
+ // Unfortunately this doesn't work because
+ // a) when cancelling a bolus within a few seconds of starting it, after updating the Treatment,
+ // we get a new treatment event from NS containing the originally created treatment with the original insulin amount.
+ // This event is processed in TreatmentService.createTreatmentFromJsonIfNotExists().
+ // Opposed to what the name of this method suggests, it does createOrUpdate,
+ // overwriting the insulin delivered with the original value.
+ // So practically it seems impossible to update a Treatment when using NS
+ // b) we only send newly created treatments to NS, so the insulin amount in NS would never be updated
+ //
+ // I discussed this with the AAPS team but nobody seems to care so we're stuck with this ugly workaround for now
+ try {
+ sp.putString(OmnipodConst.Prefs.CurrentBolus, omnipodUtil.getGsonInstance().toJson(detailedBolusInfo));
+ } catch (Exception ex) {
+ aapsLogger.error(LTag.PUMP, "Failed to store current bolus to SP", ex);
+ }
+
// Wait for the bolus to finish
OmnipodManager.BolusDeliveryResult bolusDeliveryResult =
bolusCommandResult.getDeliveryResultSubject().blockingGet();
- double unitsDelivered = bolusDeliveryResult.getUnitsDelivered();
+ detailedBolusInfo.insulin = bolusDeliveryResult.getUnitsDelivered();
- long pumpId = addSuccessToHistory(bolusStarted.getTime(), PodHistoryEntryType.SetBolus, unitsDelivered + ";" + detailedBolusInfo.carbs);
+ addBolusToHistory(detailedBolusInfo);
- detailedBolusInfo.date = bolusStarted.getTime();
- detailedBolusInfo.insulin = unitsDelivered;
- detailedBolusInfo.pumpId = pumpId;
- detailedBolusInfo.source = Source.PUMP;
+ sp.remove(OmnipodConst.Prefs.CurrentBolus);
- activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, false);
-
- if (podStateManager.hasFaultEvent()) {
- showPodFaultErrorDialog(podStateManager.getFaultEvent().getFaultEventCode(), R.raw.urgentalarm);
- }
-
- return new PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(unitsDelivered);
+ return new PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(detailedBolusInfo.insulin);
}
@Override
public PumpEnactResult cancelBolus() {
- long time = System.currentTimeMillis();
+ SingleSubject bolusCommandExecutionSubject = delegate.getBolusCommandExecutionSubject();
+ if (bolusCommandExecutionSubject != null) {
+ // Wait until the bolus command has actually been executed before sending the cancel bolus command
+ aapsLogger.debug(LTag.PUMP, "Cancel bolus was requested, but the bolus command is still being executed. Awaiting bolus command execution");
+ boolean bolusCommandSuccessfullyExecuted = bolusCommandExecutionSubject.blockingGet();
+ if (bolusCommandSuccessfullyExecuted) {
+ aapsLogger.debug(LTag.PUMP, "Bolus command successfully executed. Proceeding bolus cancellation");
+ } else {
+ aapsLogger.debug(LTag.PUMP, "Not cancelling bolus: bolus command failed");
+ String comment = getStringResource(R.string.omnipod_bolus_did_not_succeed);
+ addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.CancelBolus, comment);
+ return new PumpEnactResult(injector).success(true).enacted(false).comment(comment);
+ }
+ }
+
String comment = null;
- while (delegate.hasActiveBolus()) {
+ for (int i = 1; delegate.hasActiveBolus(); i++) {
+ aapsLogger.debug(LTag.PUMP, "Attempting to cancel bolus (#{})", i);
try {
delegate.cancelBolus(isBolusBeepsEnabled());
- addSuccessToHistory(time, PodHistoryEntryType.CancelBolus, null);
+ aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus", i);
+ addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.CancelBolus, null);
return new PumpEnactResult(injector).success(true).enacted(true);
} catch (PodFaultException ex) {
+ aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus (implicitly because of a Pod Fault)");
showPodFaultErrorDialog(ex.getFaultEvent().getFaultEventCode(), null);
- addSuccessToHistory(time, PodHistoryEntryType.CancelBolus, null);
+ addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.CancelBolus, null);
return new PumpEnactResult(injector).success(true).enacted(true);
} catch (Exception ex) {
+ aapsLogger.debug(LTag.PUMP, "Failed to cancel bolus", ex);
comment = handleAndTranslateException(ex);
}
}
- addFailureToHistory(time, PodHistoryEntryType.CancelBolus, comment);
+ addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.CancelBolus, comment);
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
}
@@ -464,6 +502,12 @@ public class AapsOmnipodManager implements IOmnipodManager {
return delegate.isPodRunning();
}
+ public void addBolusToHistory(DetailedBolusInfo detailedBolusInfo) {
+ long pumpId = addSuccessToHistory(detailedBolusInfo.date, PodHistoryEntryType.SetBolus, detailedBolusInfo.insulin + ";" + detailedBolusInfo.carbs);
+ detailedBolusInfo.pumpId = pumpId;
+ activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, false);
+ }
+
private void reportImplicitlyCanceledTbr() {
//TreatmentsPlugin plugin = TreatmentsPlugin.getPlugin();
TreatmentsInterface plugin = activePlugin.getActiveTreatments();
@@ -493,22 +537,22 @@ public class AapsOmnipodManager implements IOmnipodManager {
}
private long addToHistory(long requestTime, PodHistoryEntryType entryType, Object data, boolean success) {
- PodHistory podHistory = new PodHistory(requestTime, entryType);
+ OmnipodHistoryRecord omnipodHistoryRecord = new OmnipodHistoryRecord(requestTime, entryType.getCode());
if (data != null) {
if (data instanceof String) {
- podHistory.setData((String) data);
+ omnipodHistoryRecord.setData((String) data);
} else {
- podHistory.setData(omnipodUtil.getGsonInstance().toJson(data));
+ omnipodHistoryRecord.setData(omnipodUtil.getGsonInstance().toJson(data));
}
}
- podHistory.setSuccess(success);
- podHistory.setPodSerial(podStateManager.hasPodState() ? String.valueOf(podStateManager.getAddress()) : "None");
+ omnipodHistoryRecord.setSuccess(success);
+ omnipodHistoryRecord.setPodSerial(podStateManager.hasPodState() ? String.valueOf(podStateManager.getAddress()) : "None");
- MainApp.getDbHelper().createOrUpdate(podHistory);
+ databaseHelper.createOrUpdate(omnipodHistoryRecord);
- return podHistory.getPumpId();
+ return omnipodHistoryRecord.getPumpId();
}
private void handleSetupActionResult(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver, SetupActionResult res, long time, Profile profile) {
@@ -571,7 +615,7 @@ public class AapsOmnipodManager implements IOmnipodManager {
comment = getStringResource(R.string.omnipod_driver_error_not_enough_data);
} else if (ex instanceof PodFaultException) {
FaultEventCode faultEventCode = ((PodFaultException) ex).getFaultEvent().getFaultEventCode();
- showPodFaultErrorDialog(faultEventCode, R.raw.urgentalarm);
+ showPodFaultErrorDialog(faultEventCode);
comment = createPodFaultErrorMessage(faultEventCode);
} else if (ex instanceof PodReturnedErrorResponseException) {
comment = getStringResource(R.string.omnipod_driver_error_pod_returned_error_response);
@@ -599,15 +643,23 @@ public class AapsOmnipodManager implements IOmnipodManager {
rxBus.send(event);
}
+ private void showPodFaultErrorDialog(FaultEventCode faultEventCode) {
+ showErrorDialog(createPodFaultErrorMessage(faultEventCode), null);
+ }
+
private void showPodFaultErrorDialog(FaultEventCode faultEventCode, Integer sound) {
showErrorDialog(createPodFaultErrorMessage(faultEventCode), sound);
}
+ private void showErrorDialog(String message) {
+ showErrorDialog(message, null);
+ }
+
private void showErrorDialog(String message, Integer sound) {
Intent intent = new Intent(context, ErrorHelperActivity.class);
- intent.putExtra("soundid", sound == null ? 0 : sound);
+ intent.putExtra("soundid", sound);
intent.putExtra("status", message);
- intent.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror));
+ intent.putExtra("title", resourceHelper.gs(R.string.error));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsPodStateManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsPodStateManager.java
similarity index 100%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsPodStateManager.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsPodStateManager.java
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistoryEntryType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistoryEntryType.java
similarity index 92%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistoryEntryType.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistoryEntryType.java
index 981796b497..351a845e8d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistoryEntryType.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistoryEntryType.java
@@ -5,8 +5,8 @@ import androidx.annotation.StringRes;
import java.util.HashMap;
import java.util.Map;
-import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup;
+import info.nightscout.androidaps.plugins.pump.omnipod.R;
/**
* Created by andy on 24.11.2019
@@ -37,8 +37,7 @@ public enum PodHistoryEntryType {
SuspendDelivery(60, R.string.omnipod_cmd_suspend_delivery, PumpHistoryEntryGroup.Basal),
ResumeDelivery(61, R.string.omnipod_cmd_resume_delivery, PumpHistoryEntryGroup.Basal),
- UnknownEntryType(99, R.string.omnipod_cmd_unknown_entry)
- ;
+ UnknownEntryType(99, R.string.omnipod_cmd_unknown_entry);
private int code;
private static Map instanceMap;
@@ -48,7 +47,6 @@ public enum PodHistoryEntryType {
private PumpHistoryEntryGroup group;
-
static {
instanceMap = new HashMap<>();
@@ -57,7 +55,6 @@ public enum PodHistoryEntryType {
}
}
-
PodHistoryEntryType(int code, @StringRes int resourceId) {
this.code = code;
this.resourceId = resourceId;
@@ -77,6 +74,9 @@ public enum PodHistoryEntryType {
return this.group;
}
+ public static PodHistoryEntryType getByCode(long code) {
+ return getByCode((int) code);
+ }
public static PodHistoryEntryType getByCode(int code) {
if (instanceMap.containsKey(code)) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java
similarity index 64%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java
index 637f884500..d39559e4b5 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java
@@ -3,30 +3,34 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.ui;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
-import info.nightscout.androidaps.plugins.pump.common.defs.DeviceCommandExecutor;
+import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
+import info.nightscout.androidaps.plugins.pump.omnipod.data.RLHistoryItemOmnipod;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.IOmnipodManager;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
/**
* Created by andy on 4.8.2019
*/
-public class OmnipodUIComm implements DeviceCommandExecutor {
+public class OmnipodUIComm {
private final HasAndroidInjector injector;
private final AAPSLogger aapsLogger;
- private final IOmnipodManager omnipodCommunicationManager;
private final OmnipodUIPostprocessor omnipodUIPostprocessor;
+ private final IOmnipodManager omnipodCommunicationManager;
+ private RileyLinkUtil rileyLinkUtil;
public OmnipodUIComm(
HasAndroidInjector injector,
AAPSLogger aapsLogger,
OmnipodUIPostprocessor omnipodUIPostprocessor,
- IOmnipodManager omnipodCommunicationManager
+ IOmnipodManager omnipodCommunicationManager,
+ RileyLinkUtil rileyLinkUtil
) {
this.injector = injector;
this.aapsLogger = aapsLogger;
this.omnipodUIPostprocessor = omnipodUIPostprocessor;
this.omnipodCommunicationManager = omnipodCommunicationManager;
+ this.rileyLinkUtil = rileyLinkUtil;
}
@@ -36,34 +40,10 @@ public class OmnipodUIComm implements DeviceCommandExecutor {
OmnipodUITask task = new OmnipodUITask(injector, commandType, parameters);
- // new Thread(() -> {
- // LOG.warn("@@@ Start Thread");
- //
- // task.execute(getCommunicationManager());
- //
- // LOG.warn("@@@ End Thread");
- // });
+ rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItemOmnipod(commandType));
task.execute(this.omnipodCommunicationManager);
- // for (int i = 0; i < getMaxWaitTime(commandType); i++) {
- // synchronized (task) {
- // // try {
- // //
- // // //task.wait(1000);
- // // } catch (InterruptedException e) {
- // // LOG.error("executeCommand InterruptedException", e);
- // // }
- //
- //
- // SystemClock.sleep(1000);
- // }
- //
- // if (task.isReceived()) {
- // break;
- // }
- // }
-
if (!task.isReceived()) {
aapsLogger.warn(LTag.PUMP, "Reply not received for " + commandType);
}
diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIPostprocessor.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIPostprocessor.java
new file mode 100644
index 0000000000..33d734bdde
--- /dev/null
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIPostprocessor.java
@@ -0,0 +1,64 @@
+package info.nightscout.androidaps.plugins.pump.omnipod.driver.ui;
+
+import java.util.Date;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import info.nightscout.androidaps.data.DetailedBolusInfo;
+import info.nightscout.androidaps.data.PumpEnactResult;
+import info.nightscout.androidaps.logging.AAPSLogger;
+import info.nightscout.androidaps.logging.LTag;
+import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
+
+/**
+ * Created by andy on 4.8.2019
+ */
+// TODO remove once OmnipodPumpStatus has been removed
+@Singleton
+public class OmnipodUIPostprocessor {
+ private final AAPSLogger aapsLogger;
+ private final OmnipodPumpStatus pumpStatus;
+
+ @Inject
+ public OmnipodUIPostprocessor(AAPSLogger aapsLogger, OmnipodPumpStatus pumpStatus) {
+ this.aapsLogger = aapsLogger;
+ this.pumpStatus = pumpStatus;
+ }
+
+ // this is mostly intended for command that return certain statuses (Remaining Insulin, ...), and
+ // where responses won't be directly used
+ public void postProcessData(OmnipodUITask uiTask) {
+
+ switch (uiTask.commandType) {
+ case SetBolus:
+ if (uiTask.returnData != null) {
+
+ PumpEnactResult result = uiTask.returnData;
+
+ DetailedBolusInfo detailedBolusInfo = (DetailedBolusInfo) uiTask.getObjectFromParameters(0);
+
+ if (result.success) {
+ boolean isSmb = detailedBolusInfo.isSMB;
+
+ if (!isSmb) {
+ pumpStatus.lastBolusAmount = detailedBolusInfo.insulin;
+ pumpStatus.lastBolusTime = new Date();
+ }
+ }
+ }
+ break;
+
+ case CancelTemporaryBasal:
+ pumpStatus.tempBasalStart = 0;
+ pumpStatus.tempBasalEnd = 0;
+ pumpStatus.tempBasalAmount = null;
+ pumpStatus.tempBasalLength = null;
+ break;
+
+ default:
+ aapsLogger.debug(LTag.PUMP, "Post-processing not implemented for {}.", uiTask.commandType.name());
+
+ }
+ }
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUITask.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUITask.java
similarity index 100%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUITask.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUITask.java
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodAcknowledgeAlertsChanged.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodAcknowledgeAlertsChanged.kt
similarity index 100%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodAcknowledgeAlertsChanged.kt
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodAcknowledgeAlertsChanged.kt
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodPumpValuesChanged.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodPumpValuesChanged.kt
similarity index 100%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodPumpValuesChanged.kt
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodPumpValuesChanged.kt
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodRefreshButtonState.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodRefreshButtonState.kt
similarity index 61%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodRefreshButtonState.kt
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodRefreshButtonState.kt
index 8bbbfd33e6..9ad6f2129e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodRefreshButtonState.kt
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodRefreshButtonState.kt
@@ -2,4 +2,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.events
import info.nightscout.androidaps.events.Event
-class EventOmnipodRefreshButtonState (val newState : Boolean): Event()
\ No newline at end of file
+class EventOmnipodRefreshButtonState(val newState: Boolean) : Event()
\ No newline at end of file
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/exception/OmnipodException.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/exception/OmnipodException.java
similarity index 100%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/exception/OmnipodException.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/exception/OmnipodException.java
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java
similarity index 85%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java
index 73209ce876..58e35dd8fd 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java
@@ -9,18 +9,17 @@ import org.apache.commons.lang3.StringUtils;
import javax.inject.Inject;
-import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkBLE;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkEncodingType;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkTargetFrequency;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService;
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
+import info.nightscout.androidaps.plugins.pump.omnipod.R;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
@@ -43,11 +42,9 @@ public class RileyLinkOmnipodService extends RileyLinkService {
@Inject OmnipodUtil omnipodUtil;
@Inject OmnipodUIPostprocessor omnipodUIPostprocessor;
@Inject PodStateManager podStateManager;
-
- private static RileyLinkOmnipodService instance;
-
- private OmnipodCommunicationManager omnipodCommunicationManager;
- private AapsOmnipodManager aapsOmnipodManager;
+ @Inject DatabaseHelperInterface databaseHelper;
+ @Inject AapsOmnipodManager aapsOmnipodManager;
+ @Inject OmnipodCommunicationManager omnipodCommunicationManager;
private IBinder mBinder = new LocalBinder();
private boolean rileyLinkAddressChanged = false;
@@ -57,11 +54,6 @@ public class RileyLinkOmnipodService extends RileyLinkService {
public RileyLinkOmnipodService() {
super();
- instance = this;
- }
-
- public static RileyLinkOmnipodService getInstance() {
- return instance;
}
@Override
@@ -70,22 +62,20 @@ public class RileyLinkOmnipodService extends RileyLinkService {
super.onConfigurationChanged(newConfig);
}
-
@Override
public IBinder onBind(Intent intent) {
return mBinder;
}
-
@Override
public RileyLinkEncodingType getEncoding() {
return RileyLinkEncodingType.Manchester;
}
-
/**
* If you have customized RileyLinkServiceData you need to override this
*/
+ @Override
public void initRileyLinkServiceData() {
rileyLinkServiceData.targetDevice = RileyLinkTargetDevice.Omnipod;
@@ -94,8 +84,6 @@ public class RileyLinkOmnipodService extends RileyLinkService {
// get most recently used RileyLink address
rileyLinkServiceData.rileylinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
- rileyLinkBLE = new RileyLinkBLE(injector, this); // or this
- rfspy = new RFSpy(injector, rileyLinkBLE);
rfspy.startReader();
initializeErosOmnipodManager();
@@ -105,23 +93,12 @@ public class RileyLinkOmnipodService extends RileyLinkService {
}
private void initializeErosOmnipodManager() {
- AapsOmnipodManager instance = AapsOmnipodManager.getInstance();
- if (instance == null) {
- OmnipodCommunicationManager omnipodCommunicationService = new OmnipodCommunicationManager(injector, rfspy);
- this.omnipodCommunicationManager = omnipodCommunicationService;
-
- aapsOmnipodManager = new AapsOmnipodManager(omnipodCommunicationService, podStateManager, omnipodPumpStatus,
- omnipodUtil, aapsLogger, rxBus, sp, resourceHelper, injector, activePlugin, this);
-
- omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUIPostprocessor, aapsOmnipodManager);
-
- } else {
- aapsOmnipodManager = instance;
+ if (omnipodUIComm == null) {
+ omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUIPostprocessor, aapsOmnipodManager, rileyLinkUtil);
}
rxBus.send(new EventOmnipodPumpValuesChanged());
}
-
public OmnipodUIComm getDeviceCommandExecutor() {
return this.omnipodUIComm;
}
@@ -130,7 +107,6 @@ public class RileyLinkOmnipodService extends RileyLinkService {
rfspy.resetRileyLinkConfiguration();
}
-
@Override
public RileyLinkCommunicationManager getDeviceCommunicationManager() {
return omnipodCommunicationManager;
@@ -141,15 +117,12 @@ public class RileyLinkOmnipodService extends RileyLinkService {
this.omnipodPumpStatus.setPumpDeviceState(pumpDeviceState);
}
-
public class LocalBinder extends Binder {
-
public RileyLinkOmnipodService getServiceInstance() {
return RileyLinkOmnipodService.this;
}
}
-
/* private functions */
// PumpInterface - REMOVE
@@ -158,7 +131,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
return rileyLinkServiceData.rileyLinkServiceState.isReady();
}
-
+ @Override
public boolean verifyConfiguration() {
try {
omnipodPumpStatus.rileyLinkErrorDescription = null;
@@ -202,11 +175,8 @@ public class RileyLinkOmnipodService extends RileyLinkService {
}
}
-
private boolean reconfigureService() {
-
if (!inPreInit) {
-
if (rileyLinkAddressChanged) {
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkNewAddressSet, this);
rileyLinkAddressChanged = false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmniCRC.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmniCRC.java
similarity index 98%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmniCRC.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmniCRC.java
index ba5c91c0b5..77d0cc1aad 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmniCRC.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmniCRC.java
@@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.pump.omnipod.util;
public class OmniCRC {
- public static final int[] crc16lookup = new int[] {
+ public static final int[] crc16lookup = new int[]{
0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022,
0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072,
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java
similarity index 90%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java
index 35889383c2..81bbf5d501 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java
@@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.util;
import org.joda.time.Duration;
-import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.plugins.pump.omnipod.R;
/**
* Created by andy on 4.8.2019
@@ -12,8 +12,9 @@ public class OmnipodConst {
static final String Prefix = "AAPS.Omnipod.";
- public class Prefs {
+ public static class Prefs {
public static final String PodState = Prefix + "pod_state";
+ public static final String CurrentBolus = Prefix + "current_bolus";
public static final int BeepBasalEnabled = R.string.key_omnipod_beep_basal_enabled;
public static final int BeepBolusEnabled = R.string.key_omnipod_beep_bolus_enabled;
public static final int BeepSMBEnabled = R.string.key_omnipod_beep_smb_enabled;
@@ -22,15 +23,13 @@ public class OmnipodConst {
public static final int TimeChangeEventEnabled = R.string.key_omnipod_timechange_enabled;
}
- public class Statistics {
+ public static class Statistics {
public static final String StatsPrefix = "omnipod_";
public static final String FirstPumpStart = Prefix + "first_pump_use";
public static final String LastGoodPumpCommunicationTime = Prefix + "lastGoodPumpCommunicationTime";
- //public static final String LastGoodPumpFrequency = Prefix + "LastGoodPumpFrequency";
public static final String TBRsSet = StatsPrefix + "tbrs_set";
public static final String StandardBoluses = StatsPrefix + "std_boluses_delivered";
public static final String SMBBoluses = StatsPrefix + "smb_boluses_delivered";
- //public static final String LastPumpHistoryEntry = StatsPrefix + "pump_history_entry";
}
public static final double POD_PULSE_SIZE = 0.05;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java
similarity index 74%
rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java
rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java
index 599deb8197..ddc0022372 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java
@@ -16,16 +16,12 @@ import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
-import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.logging.AAPSLogger;
+import info.nightscout.androidaps.plugins.pump.omnipod.R;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSet;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSlot;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
-import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState;
-import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
-import info.nightscout.androidaps.utils.sharedPreferences.SP;
/**
* Created by andy on 4/8/19.
@@ -33,39 +29,15 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
@Singleton
public class OmnipodUtil {
- private final AAPSLogger aapsLogger;
- private final OmnipodPumpStatus omnipodPumpStatus;
private final ResourceHelper resourceHelper;
- private final SP sp;
private Gson gsonInstance = createGson();
- private OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
@Inject
- public OmnipodUtil(
- AAPSLogger aapsLogger,
- OmnipodPumpStatus omnipodPumpStatus,
- SP sp,
- ResourceHelper resourceHelper
- ) {
- this.aapsLogger = aapsLogger;
- this.omnipodPumpStatus = omnipodPumpStatus;
- this.sp = sp;
+ public OmnipodUtil(ResourceHelper resourceHelper) {
this.resourceHelper = resourceHelper;
}
- public OmnipodDriverState getDriverState() {
- return driverState;
- }
-
- public void setDriverState(OmnipodDriverState state) {
- if (driverState == state)
- return;
-
- driverState = state;
- omnipodPumpStatus.driverState = state;
- }
-
private Gson createGson() {
GsonBuilder gsonBuilder = new GsonBuilder()
.registerTypeAdapter(DateTime.class, (JsonSerializer) (dateTime, typeOfSrc, context) ->
@@ -84,14 +56,6 @@ public class OmnipodUtil {
return this.gsonInstance;
}
- public AAPSLogger getAapsLogger() {
- return this.aapsLogger;
- }
-
- public SP getSp() {
- return this.sp;
- }
-
public List getTranslatedActiveAlerts(PodStateManager podStateManager) {
List translatedAlerts = new ArrayList<>();
AlertSet activeAlerts = podStateManager.getActiveAlerts();
diff --git a/omnipod/src/main/res/drawable/ic_actions_temptarget.xml b/omnipod/src/main/res/drawable/ic_actions_temptarget.xml
new file mode 100644
index 0000000000..5dbd5d8b0c
--- /dev/null
+++ b/omnipod/src/main/res/drawable/ic_actions_temptarget.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/omnipod/src/main/res/drawable/ic_cp_pump_canula.xml b/omnipod/src/main/res/drawable/ic_cp_pump_canula.xml
new file mode 100644
index 0000000000..b43de7ceaa
--- /dev/null
+++ b/omnipod/src/main/res/drawable/ic_cp_pump_canula.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/layout/omnipod_fragment.xml b/omnipod/src/main/res/layout/omnipod_fragment.xml
similarity index 99%
rename from app/src/main/res/layout/omnipod_fragment.xml
rename to omnipod/src/main/res/layout/omnipod_fragment.xml
index 7502f89d92..72c3910ad9 100644
--- a/app/src/main/res/layout/omnipod_fragment.xml
+++ b/omnipod/src/main/res/layout/omnipod_fragment.xml
@@ -219,7 +219,7 @@
android:layout_weight="1.5"
android:gravity="end"
android:paddingRight="5dp"
- android:text="@string/omnipod_pod_fw_version"
+ android:text="@string/omnipod_pod_firmware_version"
android:textSize="14sp" />
-
+
+
+
+
+
+
+