- merge from bart

- added new dialogs (Omnipod Mgmt and InitPodWizard), extended OmnipodFragment code
- changes to OmnipodCommunicationManagerInterface
This commit is contained in:
Andy Rozman 2019-08-30 16:20:18 +01:00
parent 8581b00e8a
commit c6d94284d7
12 changed files with 190 additions and 67 deletions

View file

@ -22,9 +22,9 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState
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.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
@ -77,11 +77,11 @@ class OmnipodFragment : Fragment() {
omnipod_pod_status.text = "{fa-bed}"
omnipod_pod_mgmt.setOnClickListener {
// if (OmnipodUtil.getPumpStatus().verifyConfiguration()) {
// startActivity(Intent(context, MedtronicHistoryActivity::class.java))
// } else {
// OmnipodUtil.displayNotConfiguredDialog(context)
// }
if (OmnipodUtil.getPumpStatus().verifyConfiguration()) {
startActivity(Intent(context, PodManagementActivity::class.java))
} else {
OmnipodUtil.displayNotConfiguredDialog(context)
}
}
omnipod_refresh.setOnClickListener {
@ -89,8 +89,8 @@ class OmnipodFragment : Fragment() {
OmnipodUtil.displayNotConfiguredDialog(context)
} else {
omnipod_refresh.isEnabled = false
OmnipodUtil.getPlugin().resetStatusState()
ConfigBuilderPlugin.getPlugin().commandQueue.readStatus("Clicked refresh", object : Callback() {
OmnipodUtil.getPlugin().addPodStatusRequest(OmnipodStatusRequest.ResetState);
ConfigBuilderPlugin.getPlugin().commandQueue.readStatus("Clicked Refresh", object : Callback() {
override fun run() {
activity?.runOnUiThread { omnipod_refresh.isEnabled = true }
}
@ -106,6 +106,16 @@ class OmnipodFragment : Fragment() {
}
}
omnipod_pod_active_alerts_ack.setOnClickListener {
if (!OmnipodUtil.getPumpStatus().verifyConfiguration()) {
OmnipodUtil.displayNotConfiguredDialog(context)
} else {
omnipod_pod_active_alerts_ack.isEnabled = false
OmnipodUtil.getPlugin().addPodStatusRequest(OmnipodStatusRequest.AcknowledgeAlerts);
ConfigBuilderPlugin.getPlugin().commandQueue.readStatus("Clicked Alert Ack", null)
}
}
updateGUI()
}
@ -130,7 +140,7 @@ class OmnipodFragment : Fragment() {
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ updateGUI() }, { FabricPrivacy.logException(it) })
}
override fun onPause() {
super.onPause()
@ -184,12 +194,12 @@ class OmnipodFragment : Fragment() {
MainApp.gs(it.getResourceId(RileyLinkTargetDevice.Omnipod))
} ?: "-"
if (pumpStatus.podNumber==null) {
if (pumpStatus.podNumber == null) {
}
if (pumpStatus.podSessionState==null) {
if (pumpStatus.podSessionState == null) {
omnipod_pod_address.text = MainApp.gs(R.string.omnipod_pod_name_no_info)
omnipod_pod_expiry.text = "-"
omnipod_pod_status.text = "{fa-bed} "
@ -198,23 +208,23 @@ 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.podDeviceState = checkStatusSet(pumpStatus.podDeviceState,
OmnipodUtil.getPodDeviceState()) as PodDeviceState?
var podDeviceState = pumpStatus.podDeviceState
when (podDeviceState) {
null,
PumpDeviceState.Sleeping -> omnipod_pod_status.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name());
PumpDeviceState.NeverContacted,
PumpDeviceState.WakingUp,
PumpDeviceState.PumpUnreachable,
PumpDeviceState.ErrorWhenCommunicating,
PumpDeviceState.TimeoutWhenCommunicating,
PumpDeviceState.InvalidConfiguration -> omnipod_pod_status.text = " " + MainApp.gs(podDeviceState.resourceId)
PumpDeviceState.Active -> {
when (podDeviceState) {
null,
PodDeviceState.Sleeping -> omnipod_pod_status.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name());
PodDeviceState.NeverContacted,
PodDeviceState.WakingUp,
PodDeviceState.PumpUnreachable,
PodDeviceState.ErrorWhenCommunicating,
PodDeviceState.TimeoutWhenCommunicating,
PodDeviceState.InvalidConfiguration -> omnipod_pod_status.text = " " + MainApp.gs(podDeviceState.resourceId)
PodDeviceState.Active -> {
omnipod_pod_status.text = "Active";
omnipod_pod_status.text = "Active";
// val cmd = OmnipodUtil.getCurrentCommand()
// if (cmd == null)
// omnipod_pod_status.text = " " + MainApp.gs(pumpStatus.pumpDeviceState.resourceId)
@ -231,10 +241,9 @@ class OmnipodFragment : Fragment() {
// ?: cmd.getCommandDescription())
// }
// }
}
else -> log.warn("Unknown pump state: " + pumpStatus.podDeviceState)
}
else -> log.warn("Unknown pump state: " + pumpStatus.podDeviceState)
}
}

View file

@ -34,6 +34,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.pod
import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
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.SetupProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalScheduleMapper;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
@ -59,7 +61,7 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
instance = this;
}
@Override
public PumpEnactResult insertCannula(Profile profile) {
if (podState == null || podState.getSetupProgress().isBefore(SetupProgress.PRIMING_FINISHED)) {
// TODO use string resource
@ -86,7 +88,7 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
return new PumpEnactResult().success(true).enacted(true);
}
@Override
public PumpEnactResult pairAndPrime() {
try {
if (podState == null) {
@ -129,6 +131,11 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
return new PumpEnactResult().success(true).enacted(true);
}
@Override
public PumpEnactResult initPod(PodInitActionType podInitActionType, PodInitReceiver podIniReceiver) {
return null;
}
@Override
public PumpEnactResult getPodStatus() {
if (podState == null) {
@ -187,6 +194,17 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
}
@Override
public PumpEnactResult resetPodStatus() {
return null;
}
@Override
public PumpEnactResult setBolus(Double amount) {
return null;
}
// TODO rename back
public PumpEnactResult resetPodState() {
podState = null;
SP.remove(OmnipodConst.Prefs.PodState);
@ -194,7 +212,7 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
return new PumpEnactResult().success(true).enacted(true);
}
@Override
// TODO rename back
public PumpEnactResult bolus(Double units) {
if (!isInitialized()) {
return createNotInitializedResult();

View file

@ -31,9 +31,9 @@ import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
@ -49,6 +49,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPodType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodStatusRequest;
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;
@ -64,7 +66,7 @@ import info.nightscout.androidaps.utils.SP;
*
* @author Andy Rozman (andy.rozman@gmail.com)
*/
public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterface {
public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPumpPluginInterface {
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
@ -202,6 +204,13 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
clearBusyQueue();
}
if (!this.omnipodStatusRequestList.isEmpty()) {
if (!ConfigBuilderPlugin.getPlugin().getCommandQueue().statusInQueue()) {
ConfigBuilderPlugin.getPlugin().getCommandQueue()
.readStatus("Status Refresh Requested", null);
}
}
} while (serviceRunning);
}).start();
@ -249,9 +258,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
clearBusyQueue();
if (busyTimestamps.size() > 0) {
return true;
}
return (busyTimestamps.size() > 0);
}
}
@ -307,13 +314,29 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
if (firstRun) {
initializePump(!isRefresh);
} else {
getPodPumpStatus();
triggerUIChange();
} else if (!omnipodStatusRequestList.isEmpty()) {
List<OmnipodStatusRequest> removeList = new ArrayList<>();
for (OmnipodStatusRequest omnipodStatusRequest : omnipodStatusRequestList) {
// TODO when we get more commands this needs to be extended
omnipodUIComm.executeCommand(OmnipodCommandType.AcknowledgeAlerts);
removeList.add(omnipodStatusRequest);
}
//getPodPumpStatus();
}
triggerUIChange();
}
public void setIsBusy(boolean isBusy) {
this.isBusy = isBusy;
}
private void getPodPumpStatus() {
// TODO read pod status
LOG.error("getPodPumpStatus() NOT IMPLEMENTED");
@ -321,8 +344,20 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
// we would probably need to read Basal Profile here too
}
//OmnipodStatusRequest pumpStatusRequest = null;
void resetStatusState() {
List<OmnipodStatusRequest> omnipodStatusRequestList = new ArrayList<>();
public void addPodStatusRequest(OmnipodStatusRequest pumpStatusRequest) {
if (pumpStatusRequest == OmnipodStatusRequest.ResetState) {
resetStatusState();
} else {
omnipodStatusRequestList.add(pumpStatusRequest);
}
}
public void resetStatusState() {
firstRun = true;
isRefresh = true;
}

View file

@ -8,10 +8,11 @@ import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.data.PodCommResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
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.PodResponseType;
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange;
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
@ -56,7 +57,7 @@ public class OmnipodUITask {
// break;
case InitPod:
returnData = communicationManager.initPod();
returnData = communicationManager.initPod((PodInitActionType) parameters[0], (PodInitReceiver) parameters[1]);
// TODO returnData = communicationManager.pairAndPrime();
break;
@ -98,6 +99,9 @@ public class OmnipodUITask {
returnData = communicationManager.cancelTemporaryBasal();
break;
case AcknowledgeAlerts:
returnData = communicationManager.acknowledgeAlerts();
break;
default: {
LOG.warn("This commandType is not supported (yet) - {}.", commandType);
@ -133,7 +137,7 @@ public class OmnipodUITask {
public <T> T getResult() {
return (T)returnData;
return (T) returnData;
}

View file

@ -12,7 +12,7 @@ public enum OmnipodCommandType {
CancelBolus, //
SetTemporaryBasal,
CancelTemporaryBasal,
ResetPodStatus;
ResetPodStatus, AcknowledgeAlerts;
}

View file

@ -14,10 +14,10 @@ public interface OmnipodCommunicationManagerInterface {
PumpEnactResult initPod(PodInitActionType podInitActionType, PodInitReceiver podIniReceiver);
// TODO remove
PumpEnactResult pairAndPrime();
//PumpEnactResult pairAndPrime();
// TODO remove
PumpEnactResult insertCannula(Profile basalProfile);
//PumpEnactResult insertCannula(Profile basalProfile);
/**

View file

@ -0,0 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.defs;
import info.nightscout.androidaps.interfaces.PumpInterface;
public interface OmnipodPumpPluginInterface extends PumpInterface {
void addPodStatusRequest(OmnipodStatusRequest pumpStatusRequest);
}

View file

@ -0,0 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.defs;
public enum OmnipodStatusRequest {
ResetState, //
AcknowledgeAlerts, //
;
}

View file

@ -1,13 +1,29 @@
package info.nightscout.androidaps.plugins.pump.omnipod.defs;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public enum PodInitActionType {
PairAndPrime, //
PairPod(PairAndPrime), //
PrimePod(PairAndPrime), //
PairAndPrimeWizardStep, //
PairPod(PairAndPrimeWizardStep), //
PrimePod(PairAndPrimeWizardStep), //
FillCannulaWizardStep,
FillCannula(FillCannulaWizardStep),
SetBasalProfile(FillCannulaWizardStep);
;
private PodInitActionType[] parent;
private static Map<PodInitActionType, List<PodInitActionType>> stepsForWizardStep;
static {
// TODO
}
PodInitActionType() {
@ -15,8 +31,31 @@ public enum PodInitActionType {
}
private PodInitActionType(PodInitActionType parent) {
private PodInitActionType(PodInitActionType... parent) {
this.parent = parent;
}
public static List<PodInitActionType> getAvailableWizardSteps(OmnipodPodType podType) {
List<PodInitActionType> outList = new ArrayList<>();
if (podType == OmnipodPodType.Eros) {
outList.add(PodInitActionType.PairAndPrimeWizardStep);
outList.add(PodInitActionType.FillCannulaWizardStep);
} else {
// TODO we might have different wizard steps, with different handling for Dash
}
return outList;
}
public static List<PodInitActionType> getAvailableActionsForWizardSteps(PodInitActionType wizardStep) {
if (stepsForWizardStep.containsKey(wizardStep)) {
return stepsForWizardStep.get(wizardStep);
} else {
return new ArrayList<>();
}
}

View file

@ -24,10 +24,10 @@ import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.bus.RxBus;
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.omnipod.OmnipodPumpPlugin;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPodType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
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;
@ -50,7 +50,7 @@ public class OmnipodUtil extends RileyLinkUtil {
private static Gson gsonInstance = createGson();
private static PodSessionState podSessionState;
private static PodDeviceState podDeviceState;
private static OmnipodPumpPlugin omnipodPumpPlugin;
private static OmnipodPumpPluginInterface omnipodPumpPlugin;
private static OmnipodPodType omnipodPodType;
public static Gson getGsonInstance() {
@ -182,13 +182,13 @@ public class OmnipodUtil extends RileyLinkUtil {
@NotNull
public static OmnipodPumpPlugin getPlugin() {
public static OmnipodPumpPluginInterface getPlugin() {
return OmnipodUtil.omnipodPumpPlugin;
}
@NotNull
public static void setPlugin(OmnipodPumpPlugin pumpPlugin) {
public static void setPlugin(OmnipodPumpPluginInterface pumpPlugin) {
OmnipodUtil.omnipodPumpPlugin = pumpPlugin;
}

View file

@ -15,7 +15,6 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
@ -25,6 +24,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodFragment;
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.ui.OmnipodUIComm;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPodType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
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;
@ -37,7 +37,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod_dash.comm.OmnipodDashComm
*
* @author Andy Rozman (andy.rozman@gmail.com)
*/
public class OmnipodDashPumpPlugin extends OmnipodPumpPlugin implements PumpInterface {
public class OmnipodDashPumpPlugin extends OmnipodPumpPlugin implements OmnipodPumpPluginInterface {
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
@ -192,7 +192,7 @@ public class OmnipodDashPumpPlugin extends OmnipodPumpPlugin implements PumpInte
}
void resetStatusState() {
public void resetStatusState() {
firstRun = true;
isRefresh = true;
}

View file

@ -2,7 +2,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".plugins.pump.omnipod.dialogs.PodManagementActivity">
tools:context="info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity">
<ScrollView
android:layout_width="match_parent"
@ -15,7 +15,7 @@
android:orientation="vertical">
<TextView
android:id="@+id/textView3"
android:id="@+id/initpod_space0"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_weight="0.5"
@ -35,11 +35,11 @@
android:text="@string/careportal_profileswitch" />
<TextView
android:id="@+id/textView4"
android:id="@+id/initpod_space1"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="0.5"
android:text="&nbsp;" />
android:text="" />
<info.nightscout.androidaps.utils.SingleClickButton
android:id="@+id/initpod_remove_pod"
@ -55,11 +55,11 @@
android:text="@string/careportal_temporarytarget" />
<TextView
android:id="@+id/textView5"
android:id="@+id/initpod_space2"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="0.5"
android:text="&nbsp;" />
android:text="" />
<info.nightscout.androidaps.utils.SingleClickButton
android:id="@+id/initpod_reset_pod"
@ -75,11 +75,11 @@
android:text="@string/primefill" />
<TextView
android:id="@+id/textView6"
android:id="@+id/initpod_space3"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="0.5"
android:text="&nbsp;" />
android:text="" />
</LinearLayout>