Init pod integration is finished.

This commit is contained in:
Andy Rozman 2019-11-24 18:24:23 +00:00
parent b13fbcf8f4
commit 3a1e5f5741
21 changed files with 432 additions and 105 deletions

View file

@ -23,7 +23,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.Riley
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
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.service.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
/**

View file

@ -10,9 +10,6 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventExtendedBolusChange
import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.events.EventTempBasalChange
import info.nightscout.androidaps.logging.L
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
@ -23,15 +20,15 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodStatusRequest
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefreshButtonState
import info.nightscout.androidaps.plugins.pump.omnipod.service.OmnipodPumpStatus
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.queue.events.EventQueueChanged
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.SetWarnColor
@ -208,8 +205,8 @@ class OmnipodFragment : Fragment() {
omnipod_pod_address.text = pumpStatus.podSessionState.address.toString()
omnipod_pod_expiry.text = pumpStatus.podSessionState.expiryDateAsString
pumpStatus.podDeviceState = checkStatusSet(pumpStatus.podDeviceState,
OmnipodUtil.getPodDeviceState()) as PodDeviceState?
//pumpStatus.podSessionState = checkStatusSet(pumpStatus.podSessionState,
// OmnipodUtil.getPodSessionState()) as PodSessionState?
var podDeviceState = pumpStatus.podDeviceState

View file

@ -56,7 +56,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefreshButtonState;
import info.nightscout.androidaps.plugins.pump.omnipod.service.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService;
import info.nightscout.androidaps.plugins.pump.omnipod.util.LogReceiver;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;

View file

@ -10,21 +10,22 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
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.service.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.OmnipodManagerAAPS;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface {
private final OmnipodManager delegate;
private final OmnipodManagerAAPS delegate;
private static AapsOmnipodManager instance;
private OmnipodPumpStatus pumpStatus;
// FIXME this is dirty
public static AapsOmnipodManager getInstance() {
return instance;
}
public AapsOmnipodManager(OmnipodCommunicationService communicationService, PodSessionState podState) {
delegate = new OmnipodManager(communicationService, podState);
delegate = new OmnipodManagerAAPS(communicationService, podState);
instance = this;
}
@ -39,6 +40,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
// FIXME we need a basal profile here
PumpEnactResult result = delegate.insertCannula(profile);
podInitReceiver.returnInitTaskStatus(podInitActionType, result.success, (result.success ? null : result.comment));
OmnipodUtil.setPodSessionState(delegate.podState);
return result;
}
return new PumpEnactResult().success(false).enacted(false).comment("Illegal PodInitActionType: " + podInitActionType.name());
@ -50,8 +52,8 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
}
@Override
public PumpEnactResult deactivatePod() {
return delegate.deactivatePod();
public PumpEnactResult deactivatePod(PodInitReceiver podInitReceiver) {
return delegate.deactivatePod(podInitReceiver);
}
@Override
@ -61,7 +63,6 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
@Override
public PumpEnactResult resetPodStatus() {
pumpStatus.podDeviceState = null;
return delegate.resetPodState();
}
@ -100,12 +101,10 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
return delegate.getPodInfo(podInfoType);
}
// TODO should we add this to the OmnipodCommunicationManager interface?
public PumpEnactResult suspendDelivery() {
return delegate.suspendDelivery();
}
// TODO should we add this to the OmnipodCommunicationManager interface?
public PumpEnactResult resumeDelivery() {
return delegate.resumeDelivery();
}

View file

@ -1,5 +1,7 @@
package info.nightscout.androidaps.plugins.pump.omnipod.comm;
import android.os.SystemClock;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Duration;
@ -37,12 +39,15 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalScheduleMapper;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
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.util.OmnipodConst;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.utils.SP;
public class OmnipodManager {
private final OmnipodCommunicationService communicationService;
private PodSessionState podState;
protected final OmnipodCommunicationService communicationService;
protected PodSessionState podState;
public OmnipodManager(OmnipodCommunicationService communicationService, PodSessionState podState) {
if (communicationService == null) {
@ -181,6 +186,10 @@ public class OmnipodManager {
podState = null;
SP.remove(OmnipodConst.Prefs.PodState);
addToHistory(System.currentTimeMillis(), PodDbEntryType.ResetPodState, null, null, null, null);
OmnipodUtil.setPodSessionState(null);
return new PumpEnactResult().success(true).enacted(true);
}
@ -352,8 +361,27 @@ public class OmnipodManager {
return new PumpEnactResult().success(false).enacted(false).comment("Pod should be initialized first");
}
private void addToHistory(long requestTime, OmnipodAction omnipodAction, long responseTime) {
private void addToHistory(long requestTime, PodDbEntryType entryType, String shortDescription, OmnipodAction omnipodAction, Long responseTime, Object response) {
// TODO andy
PodDbEntry entry = new PodDbEntry(requestTime, entryType);
if (shortDescription!=null) {
entry.setShortDescription(shortDescription);
}
if (omnipodAction!=null) {
}
if (responseTime!=null) {
}
if (response!=null) {
}
}
}

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.omnipod.service.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
public interface OmnipodCommunicationManagerInterface {
@ -23,7 +23,7 @@ public interface OmnipodCommunicationManagerInterface {
/**
* Deactivate Pod
*/
PumpEnactResult deactivatePod();
PumpEnactResult deactivatePod(PodInitReceiver podInitReceiver);
/**
* Set Basal Profile

View file

@ -12,9 +12,16 @@ public enum PodInitActionType {
PairPod(R.string.omnipod_init_pod_pair_pod, PairAndPrimeWizardStep), //
PrimePod(R.string.omnipod_init_pod_prime_pod, PairAndPrimeWizardStep), //
FillCannulaSetBasalProfileWizardStep(),
FillCannula(R.string.omnipod_init_pod_fill_cannula, FillCannulaSetBasalProfileWizardStep),
SetBasalProfile(R.string.omnipod_init_pod_set_basal_profile, FillCannulaSetBasalProfileWizardStep);
FillCannulaSetBasalProfileWizardStep(), //
FillCannula(R.string.omnipod_init_pod_fill_cannula, FillCannulaSetBasalProfileWizardStep), //
SetBasalProfile(R.string.omnipod_init_pod_set_basal_profile, FillCannulaSetBasalProfileWizardStep), //
DeactivatePodWizardStep(), //
CancelDelivery(R.string.omnipod_deactivate_pod_cancel_delivery, DeactivatePodWizardStep), //
DeactivatePod(R.string.omnipod_deactivate_pod_deactivate_pod, DeactivatePodWizardStep) //
;
private int resourceId;
private PodInitActionType parent;
@ -22,12 +29,6 @@ public enum PodInitActionType {
private static Map<PodInitActionType, List<PodInitActionType>> stepsForWizardStep;
static {
// TODO
}
PodInitActionType(int resourceId, PodInitActionType parent) {
this.resourceId = resourceId;
this.parent = parent;
@ -38,6 +39,11 @@ public enum PodInitActionType {
}
public boolean isParent() {
return this.parent == null;
}
public List<PodInitActionType> getChildren() {
List<PodInitActionType> outList = new ArrayList<>();

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dialogs
import android.content.Intent
import android.os.Bundle
import android.os.SystemClock
import com.atech.android.library.wizardpager.WizardPagerActivity
import com.atech.android.library.wizardpager.WizardPagerContext
import com.atech.android.library.wizardpager.data.WizardPagerSettings
@ -9,8 +10,14 @@ import com.atech.android.library.wizardpager.defs.WizardStepsWayType
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.NoSplashActivity
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.pump.omnipod.comm.AapsOmnipodManager
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodCancelAction
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodWizardModel
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.OmnipodManagerAAPS
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefreshButtonState
import info.nightscout.androidaps.utils.OKDialog
import kotlinx.android.synthetic.main.omnipod_pod_mgmt.*
@ -77,8 +84,9 @@ class PodManagementActivity : NoSplashActivity() {
fun resetPodAction() {
OKDialog.showConfirmation(this,
MainApp.gs(R.string.omnipod_cmd_reset_pod_na), null)
MainApp.gs(R.string.omnipod_cmd_reset_pod_desc), Thread {
AapsOmnipodManager.getInstance().resetPodStatus()
})
}
fun showPodHistory() {

View file

@ -25,24 +25,29 @@ import java.util.List;
import java.util.Map;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.AapsOmnipodManager;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver;
/**
* Created by TechFreak on 04/09/2014.
*/
public class InitActionFragment extends Fragment {
public class InitActionFragment extends Fragment implements PodInitReceiver {
private static final String ARG_KEY = "key";
private PageFragmentCallbacks mCallbacks;
private String mKey;
private InitActionPage mPage;
ProgressBar progressBar;
TextView errorView;
private ProgressBar progressBar;
private TextView errorView;
PodInitActionType podInitActionType;
List<PodInitActionType> children;
Map<PodInitActionType, CheckBox> mapCheckBoxes;
private PodInitActionType podInitActionType;
//private List<PodInitActionType> children;
private Map<PodInitActionType, CheckBox> mapCheckBoxes;
private InitActionFragment instance;
public static InitActionFragment create(String key, PodInitActionType podInitActionType) {
Bundle args = new Bundle();
@ -55,7 +60,7 @@ public class InitActionFragment extends Fragment {
}
public InitActionFragment() {
this.instance = this;
}
@Override
@ -80,7 +85,7 @@ public class InitActionFragment extends Fragment {
LinearLayout linearLayout = rootView.findViewById(R.id.initAction_ItemsHolder);
children = podInitActionType.getChildren();
List<PodInitActionType> children = podInitActionType.getChildren();
mapCheckBoxes = new HashMap<>();
for (PodInitActionType child : children) {
@ -118,20 +123,20 @@ public class InitActionFragment extends Fragment {
mCallbacks = null;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// @Override
// public void onViewCreated(View view, Bundle savedInstanceState) {
// super.onViewCreated(view, savedInstanceState);
//
// }
}
@Override
public void setMenuVisibility(boolean menuVisible) {
super.setMenuVisibility(menuVisible);
// In a future update to the support library, this should override setUserVisibleHint
// instead of setMenuVisibility.
}
// @Override
// public void setMenuVisibility(boolean menuVisible) {
// super.setMenuVisibility(menuVisible);
//
// // In a future update to the support library, this should override setUserVisibleHint
// // instead of setMenuVisibility.
//
// }
public PodInitActionType getPodInitActionType() {
return podInitActionType;
@ -152,22 +157,31 @@ public class InitActionFragment extends Fragment {
new AsyncTask<Void, Void, String>() {
protected void onPreExecute() {
//progressBar.setVisibility(View.VISIBLE);
}
PumpEnactResult callResult;
;
protected void onPreExecute() {
progressBar.setVisibility(View.VISIBLE);
}
@Override
protected String doInBackground(Void... params) {
System.out.println("ACTION: doInBackground Started: ");
SystemClock.sleep(5000);
mPage.setActionCompleted(true);
if (podInitActionType == PodInitActionType.PairAndPrimeWizardStep) {
this.callResult = AapsOmnipodManager.getInstance().initPod(
podInitActionType,
instance,
null
);
} else if (podInitActionType == PodInitActionType.FillCannulaSetBasalProfileWizardStep) {
this.callResult = AapsOmnipodManager.getInstance().initPod(
podInitActionType,
instance,
ProfileFunctions.getInstance().getProfile()
);
} else if (podInitActionType == PodInitActionType.DeactivatePodWizardStep) {
this.callResult = AapsOmnipodManager.getInstance().deactivatePod(instance);
}
System.out.println("ACTION: doInBackground Finished: ");
return "Test";
return "OK";
}
@Override
@ -176,20 +190,17 @@ public class InitActionFragment extends Fragment {
System.out.println("ACTION: onPostExecute: " + result);
boolean isOk = false;
for (PodInitActionType actionType : mapCheckBoxes.keySet()) {
mapCheckBoxes.get(actionType).setChecked(true);
mapCheckBoxes.get(actionType).setTextColor(isOk ? Color.rgb(34, 135, 91) : Color.rgb(168, 36, 15));
}
boolean isOk = callResult.success;
progressBar.setVisibility(View.GONE);
if (!isOk) {
errorView.setVisibility(View.VISIBLE);
errorView.setText("Error containg pod.");
errorView.setText(callResult.comment);
}
mPage.setActionCompleted(isOk);
mPage.getData().putString(Page.SIMPLE_DATA_KEY, "ddd");
mPage.notifyDataChanged();
}
@ -199,4 +210,28 @@ public class InitActionFragment extends Fragment {
System.out.println("ACTION: Not visible");
}
}
@Override
public void returnInitTaskStatus(PodInitActionType podInitActionType, boolean isSuccess, String errorMessage) {
if (podInitActionType.isParent()) {
for (PodInitActionType actionType : mapCheckBoxes.keySet()) {
setCheckBox(actionType, isSuccess);
}
} else {
setCheckBox(podInitActionType, isSuccess);
}
}
public void setCheckBox(PodInitActionType podInitActionType, boolean isSuccess) {
getActivity().runOnUiThread(() -> {
mapCheckBoxes.get(podInitActionType).setChecked(true);
mapCheckBoxes.get(podInitActionType).setTextColor(isSuccess ? Color.rgb(34, 135, 91) :
Color.rgb(168, 36, 15));
});
}
}

View file

@ -32,6 +32,7 @@ import java.util.List;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FirmwareVersion;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
public class PodInfoFragment extends Fragment {
@ -77,31 +78,35 @@ public class PodInfoFragment extends Fragment {
if (isInitPod) {
createDataOfPod();
if (createDataOfPod()) {
ListView listView = (ListView) rootView.findViewById(R.id.podInfoList);
listView.setAdapter(new PodInfoAdapter(mCurrentReviewItems, getContext()));
listView.setChoiceMode(ListView.CHOICE_MODE_NONE);
ListView listView = (ListView) rootView.findViewById(R.id.podInfoList);
listView.setAdapter(new PodInfoAdapter(mCurrentReviewItems, getContext()));
listView.setChoiceMode(ListView.CHOICE_MODE_NONE);
}
}
return rootView;
}
private void createDataOfPod() {
private boolean createDataOfPod() {
// TODO
PodSessionState podSessionState = OmnipodUtil.getPodSessionState();
PodSessionState podSessionState = new PodSessionState(DateTimeZone.UTC,
483748738,
new DateTime(),
new FirmwareVersion(1,0,0),
new FirmwareVersion(1,0,0),
574875,
5487584,
1,
1
);
// PodSessionState podSessionState = new PodSessionState(DateTimeZone.UTC,
// 483748738,
// new DateTime(),
// new FirmwareVersion(1,0,0),
// new FirmwareVersion(1,0,0),
// 574875,
// 5487584,
// 1,
// 1
// );
if (podSessionState==null)
return false;
mCurrentReviewItems = new ArrayList<>();
mCurrentReviewItems.add(new ReviewItem("Pod Address", "" + podSessionState.getAddress(), "33"));
@ -109,6 +114,7 @@ public class PodInfoFragment extends Fragment {
mCurrentReviewItems.add(new ReviewItem("Firmware Version", podSessionState.getPiVersion().toString(), "35"));
mCurrentReviewItems.add(new ReviewItem("LOT", "" + podSessionState.getLot(), "36"));
return true;
}
@Override

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.pump.omnipod.service;
package info.nightscout.androidaps.plugins.pump.omnipod.driver;
import org.jetbrains.annotations.Nullable;
import org.joda.time.LocalDateTime;

View file

@ -0,0 +1,95 @@
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.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) {
super(communicationService, podState);
}
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());
}
private void addToHistory(long requestTime, PodDbEntryType entryType, OmnipodAction omnipodAction, Long responseTime, Object response, boolean success) {
// TODO andy
PodDbEntry entry = new PodDbEntry(requestTime, entryType);
if (omnipodAction!=null) {
}
if (responseTime!=null) {
entry.setDateTimeResponse(responseTime);
}
if (response!=null) {
}
}
}

View file

@ -0,0 +1,104 @@
package info.nightscout.androidaps.plugins.pump.omnipod.driver.db;
import info.nightscout.androidaps.db.DbObjectBase;
/**
* Created by andy on 24.11.2019
*/
public class PodDbEntry implements DbObjectBase {
private long dateTime;
private PodDbEntryType podDbEntryType;
private String shortDescription;
private String request;
private long dateTimeResponse;
private String response;
private boolean success;
private long pumpId;
public PodDbEntry(PodDbEntryType podDbEntryType) {
this.dateTime = System.currentTimeMillis();
this.podDbEntryType = podDbEntryType;
generatePumpId();
}
public PodDbEntry(long requestTime, PodDbEntryType podDbEntryType) {
this.dateTime = requestTime;
this.podDbEntryType = podDbEntryType;
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() {
return dateTime;
}
public void setDateTime(long dateTime) {
this.dateTime = dateTime;
}
public PodDbEntryType getPodDbEntryType() {
return podDbEntryType;
}
public void setPodDbEntryType(PodDbEntryType podDbEntryType) {
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() {
return this.dateTime;
}
@Override
public long getPumpId() {
return pumpId;
}
private void generatePumpId() {
// TODO
}
public String getShortDescription() {
return shortDescription;
}
public void setShortDescription(String shortDescription) {
this.shortDescription = shortDescription;
}
}

View file

@ -0,0 +1,41 @@
package info.nightscout.androidaps.plugins.pump.omnipod.driver.db;
/**
* Created by andy on 24.11.2019
*/
public enum PodDbEntryType {
PairAndPrime(1),
InsertCannula(2),
DeactivatePod(3),
ResetPodState(4),
SetTemporaryBasal(10),
CancelTemporaryBasal(11),
SetBasalSchedule(20),
GetPodStatus(30),
GetPodInfo(31),
SetBolus(40),
CancelBolus(41),
ConfigureAlerts(50),
AcknowledgeAlerts(51),
SuspendDelivery(60),
ResumeDelivery(61)
;
private int code;
PodDbEntryType(int code) {
this.code = code;
}
public int getCode() {
return code;
}
}

View file

@ -7,7 +7,7 @@ import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
import info.nightscout.androidaps.plugins.pump.omnipod.service.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
/**

View file

@ -6,7 +6,7 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType;
import info.nightscout.androidaps.plugins.pump.omnipod.service.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
/**
* Created by andy on 4.8.2019

View file

@ -66,7 +66,7 @@ public class OmnipodUITask {
break;
case DeactivatePod:
returnData = communicationManager.deactivatePod();
returnData = communicationManager.deactivatePod((PodInitReceiver) parameters[0]);
break;
case ResetPodStatus:

View file

@ -28,6 +28,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
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.util.OmnipodConst;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.utils.SP;

View file

@ -31,7 +31,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInt
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange;
import info.nightscout.androidaps.plugins.pump.omnipod.service.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService;
import info.nightscout.androidaps.utils.OKDialog;
@ -48,8 +48,8 @@ public class OmnipodUtil extends RileyLinkUtil {
private static OmnipodPumpStatus omnipodPumpStatus;
private static OmnipodCommandType currentCommand;
private static Gson gsonInstance = createGson();
private static PodSessionState podSessionState;
private static PodDeviceState podDeviceState;
//private static PodSessionState podSessionState;
//private static PodDeviceState podDeviceState;
private static OmnipodPumpPluginInterface omnipodPumpPlugin;
private static OmnipodPodType omnipodPodType;
@ -170,14 +170,9 @@ public class OmnipodUtil extends RileyLinkUtil {
RxBus.INSTANCE.send(new EventOmnipodDeviceStatusChange(podSessionState));
}
@Nullable
public static PodDeviceState getPodDeviceState() {
return null;
}
public static void setPodDeviceState(PodDeviceState podDeviceState) {
OmnipodUtil.podDeviceState = podDeviceState;
public static void setPodDeviceState(PodDeviceState podSessionState) {
omnipodPumpStatus.podDeviceState = podSessionState;
}
@ -200,4 +195,13 @@ public class OmnipodUtil extends RileyLinkUtil {
public static OmnipodPodType getOmnipodPodType() {
return omnipodPodType;
}
public static PodDeviceState getPodDeviceState() {
return omnipodPumpStatus.podDeviceState;
}
public static PodSessionState getPodSessionState() {
return omnipodPumpStatus.podSessionState;
}
}

View file

@ -15,7 +15,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunication
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.service.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.utils.SP;
@ -73,7 +73,7 @@ public class OmnipodDashCommunicationManager implements OmnipodCommunicationMana
}
public PumpEnactResult deactivatePod() {
public PumpEnactResult deactivatePod(PodInitReceiver podInitReceiver) {
return null;
}

View file

@ -1654,6 +1654,7 @@
<string name="omnipod_cmd_init_pod_na">Init Pod not available at the moment.</string>
<string name="omnipod_cmd_deactivate_pod_na">Deactivate Pod not available at the moment.</string>
<string name="omnipod_cmd_reset_pod_na">Reset Pod not available at the moment.</string>
<string name="omnipod_cmd_reset_pod_desc">If you press "OK" Pod will be forcefully removed. Do this only if Deactivate Pod fails.</string>
<string name="omnipod_cmd_pod_history_na">Pod History not available at the moment.</string>
<string name="omnipod_namex" translatable="false">Omnipod</string>
@ -1676,6 +1677,8 @@
<string name="omnipod_init_pod_prime_pod">Prime Pod</string>
<string name="omnipod_init_pod_fill_cannula">Fill Cannula</string>
<string name="omnipod_init_pod_set_basal_profile">Set Basal Profile</string>
<string name="omnipod_deactivate_pod_cancel_delivery">Cancel Delivery</string>
<string name="omnipod_deactivate_pod_deactivate_pod">Deactivate Pod</string>
<!-- Omnipod Dash -->