- added command for Pod Debugging as async (with pump queue)
This commit is contained in:
parent
64310f4e28
commit
72b32be6f6
6 changed files with 49 additions and 32 deletions
|
@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory
|
||||||
class OmnipodFragment : Fragment() {
|
class OmnipodFragment : Fragment() {
|
||||||
private val LOG = LoggerFactory.getLogger(L.PUMP)
|
private val LOG = LoggerFactory.getLogger(L.PUMP)
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
private var podAvailable = false
|
//private var podAvailable = false
|
||||||
|
|
||||||
operator fun CompositeDisposable.plusAssign(disposable: Disposable) {
|
operator fun CompositeDisposable.plusAssign(disposable: Disposable) {
|
||||||
add(disposable)
|
add(disposable)
|
||||||
|
@ -116,10 +116,20 @@ class OmnipodFragment : Fragment() {
|
||||||
if (!OmnipodUtil.getPumpStatus().verifyConfiguration()) {
|
if (!OmnipodUtil.getPumpStatus().verifyConfiguration()) {
|
||||||
OmnipodUtil.displayNotConfiguredDialog(context)
|
OmnipodUtil.displayNotConfiguredDialog(context)
|
||||||
} else {
|
} else {
|
||||||
val readPulseLog = AapsOmnipodManager.getInstance().readPulseLog()
|
// val readPulseLog = AapsOmnipodManager.getInstance().readPulseLog()
|
||||||
|
//
|
||||||
|
// OKDialog.show(MainApp.instance().applicationContext, MainApp.gs(R.string.action),
|
||||||
|
// "Pulse Log:\n" + readPulseLog.toString(), null)
|
||||||
|
//
|
||||||
|
|
||||||
|
omnipod_pod_debug.isEnabled = false
|
||||||
|
OmnipodUtil.getPlugin().addPodStatusRequest(OmnipodStatusRequest.GetPodPulseLog);
|
||||||
|
ConfigBuilderPlugin.getPlugin().commandQueue.readStatus("Clicked Refresh", object : Callback() {
|
||||||
|
override fun run() {
|
||||||
|
activity?.runOnUiThread { omnipod_pod_debug.isEnabled = true }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
OKDialog.show(MainApp.instance().applicationContext, MainApp.gs(R.string.action),
|
|
||||||
"Pulse Log:\n" + readPulseLog.toString(), null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,25 +187,6 @@ class OmnipodFragment : Fragment() {
|
||||||
loopHandler.removeCallbacks(refreshLoop)
|
loopHandler.removeCallbacks(refreshLoop)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Subscribe
|
|
||||||
// fun onStatusEvent(c: EventPumpStatusChanged) {
|
|
||||||
// activity?.runOnUiThread { updateGUI() }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Subscribe
|
|
||||||
// fun onStatusEvent(s: EventTempBasalChange) {
|
|
||||||
// activity?.runOnUiThread { updateGUI() }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Subscribe
|
|
||||||
// fun onStatusEvent(s: EventExtendedBolusChange) {
|
|
||||||
// activity?.runOnUiThread { updateGUI() }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Subscribe
|
|
||||||
// fun onStatusEvent(s: EventQueueChanged) {
|
|
||||||
// activity?.runOnUiThread { updateGUI() }
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
private fun setDeviceStatus() {
|
private fun setDeviceStatus() {
|
||||||
|
@ -231,7 +222,7 @@ class OmnipodFragment : Fragment() {
|
||||||
pumpStatus.podAvailable = false
|
pumpStatus.podAvailable = false
|
||||||
pumpStatus.podNumber == null
|
pumpStatus.podNumber == null
|
||||||
} else {
|
} else {
|
||||||
podAvailable = true
|
//podAvailable = true
|
||||||
pumpStatus.podAvailable = true
|
pumpStatus.podAvailable = true
|
||||||
omnipod_pod_address.text = pumpStatus.podSessionState.address.toString()
|
omnipod_pod_address.text = pumpStatus.podSessionState.address.toString()
|
||||||
omnipod_pod_expiry.text = pumpStatus.podSessionState.expiryDateAsString
|
omnipod_pod_expiry.text = pumpStatus.podSessionState.expiryDateAsString
|
||||||
|
@ -339,7 +330,7 @@ class OmnipodFragment : Fragment() {
|
||||||
|
|
||||||
setDeviceStatus()
|
setDeviceStatus()
|
||||||
|
|
||||||
if (podAvailable) {
|
if (pumpStatus.podAvailable) {
|
||||||
// last connection
|
// last connection
|
||||||
if (pumpStatus.lastConnection != 0L) {
|
if (pumpStatus.lastConnection != 0L) {
|
||||||
val minAgo = DateUtil.minAgo(pumpStatus.lastConnection)
|
val minAgo = DateUtil.minAgo(pumpStatus.lastConnection)
|
||||||
|
@ -372,7 +363,7 @@ class OmnipodFragment : Fragment() {
|
||||||
// last bolus
|
// last bolus
|
||||||
val bolus = pumpStatus.lastBolusAmount
|
val bolus = pumpStatus.lastBolusAmount
|
||||||
val bolusTime = pumpStatus.lastBolusTime
|
val bolusTime = pumpStatus.lastBolusTime
|
||||||
if (bolus != null && bolusTime != null && podAvailable) {
|
if (bolus != null && bolusTime != null && pumpStatus.podAvailable) {
|
||||||
val agoMsc = System.currentTimeMillis() - pumpStatus.lastBolusTime.time
|
val agoMsc = System.currentTimeMillis() - pumpStatus.lastBolusTime.time
|
||||||
val bolusMinAgo = agoMsc.toDouble() / 60.0 / 1000.0
|
val bolusMinAgo = agoMsc.toDouble() / 60.0 / 1000.0
|
||||||
val unit = MainApp.gs(R.string.insulin_unit_shortname)
|
val unit = MainApp.gs(R.string.insulin_unit_shortname)
|
||||||
|
@ -411,7 +402,6 @@ class OmnipodFragment : Fragment() {
|
||||||
omnipod_lastbolus.text = ""
|
omnipod_lastbolus.text = ""
|
||||||
omnipod_lastconnection.text = ""
|
omnipod_lastconnection.text = ""
|
||||||
omnipod_lastconnection.setTextColor(Color.WHITE)
|
omnipod_lastconnection.setTextColor(Color.WHITE)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_errors.text = pumpStatus.errorInfo
|
omnipod_errors.text = pumpStatus.errorInfo
|
||||||
|
|
|
@ -47,6 +47,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ResetRileyLinkConfigurationTask;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ResetRileyLinkConfigurationTask;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentHighFlashLogDump;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
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.OmnipodCommunicationManagerInterface;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType;
|
||||||
|
@ -374,8 +375,23 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
List<OmnipodStatusRequest> removeList = new ArrayList<>();
|
List<OmnipodStatusRequest> removeList = new ArrayList<>();
|
||||||
|
|
||||||
for (OmnipodStatusRequest omnipodStatusRequest : omnipodStatusRequestList) {
|
for (OmnipodStatusRequest omnipodStatusRequest : omnipodStatusRequestList) {
|
||||||
// TODO when we get more commands this needs to be extended
|
if (omnipodStatusRequest==OmnipodStatusRequest.GetPodPulseLog) {
|
||||||
omnipodUIComm.executeCommand(omnipodStatusRequest.getCommandType());
|
OmnipodUITask omnipodUITask = omnipodUIComm.executeCommand(omnipodStatusRequest.getCommandType());
|
||||||
|
|
||||||
|
PodInfoRecentHighFlashLogDump result = (PodInfoRecentHighFlashLogDump)omnipodUITask.returnDataObject;
|
||||||
|
|
||||||
|
if (result==null) {
|
||||||
|
LOG.warn("Result was null.");
|
||||||
|
} else {
|
||||||
|
LOG.warn("Result was NOT null.");
|
||||||
|
|
||||||
|
OKDialog.show(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.action),
|
||||||
|
"Pulse Log:\n" + result.toString(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
omnipodUIComm.executeCommand(omnipodStatusRequest.getCommandType());
|
||||||
|
}
|
||||||
removeList.add(omnipodStatusRequest);
|
removeList.add(omnipodStatusRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,8 @@ public enum OmnipodCommandType {
|
||||||
ResetPodStatus, //
|
ResetPodStatus, //
|
||||||
GetPodStatus, //
|
GetPodStatus, //
|
||||||
SetTime, //
|
SetTime, //
|
||||||
AcknowledgeAlerts;
|
AcknowledgeAlerts, //
|
||||||
|
GetPodPulseLog;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentHighFlashLogDump;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
||||||
|
|
||||||
public interface OmnipodCommunicationManagerInterface {
|
public interface OmnipodCommunicationManagerInterface {
|
||||||
|
@ -71,4 +72,7 @@ public interface OmnipodCommunicationManagerInterface {
|
||||||
|
|
||||||
|
|
||||||
void setPumpStatus(OmnipodPumpStatus pumpStatusLocal);
|
void setPumpStatus(OmnipodPumpStatus pumpStatusLocal);
|
||||||
|
|
||||||
|
|
||||||
|
PodInfoRecentHighFlashLogDump readPulseLog();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs;
|
||||||
public enum OmnipodStatusRequest {
|
public enum OmnipodStatusRequest {
|
||||||
ResetState(OmnipodCommandType.ResetPodStatus), //
|
ResetState(OmnipodCommandType.ResetPodStatus), //
|
||||||
AcknowledgeAlerts(OmnipodCommandType.AcknowledgeAlerts), //
|
AcknowledgeAlerts(OmnipodCommandType.AcknowledgeAlerts), //
|
||||||
GetPodState(OmnipodCommandType.GetPodStatus) //
|
GetPodState(OmnipodCommandType.GetPodStatus), //
|
||||||
|
GetPodPulseLog(OmnipodCommandType.GetPodPulseLog)
|
||||||
;
|
;
|
||||||
|
|
||||||
private OmnipodCommandType commandType;
|
private OmnipodCommandType commandType;
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class OmnipodUITask {
|
||||||
private String errorDescription;
|
private String errorDescription;
|
||||||
private Object[] parameters;
|
private Object[] parameters;
|
||||||
private PodResponseType responseType;
|
private PodResponseType responseType;
|
||||||
|
public Object returnDataObject;
|
||||||
|
|
||||||
|
|
||||||
public OmnipodUITask(OmnipodCommandType commandType) {
|
public OmnipodUITask(OmnipodCommandType commandType) {
|
||||||
|
@ -88,6 +89,10 @@ public class OmnipodUITask {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GetPodPulseLog:
|
||||||
|
returnDataObject = communicationManager.readPulseLog();
|
||||||
|
break;
|
||||||
|
|
||||||
case GetPodStatus:
|
case GetPodStatus:
|
||||||
returnData = communicationManager.getPodStatus();
|
returnData = communicationManager.getPodStatus();
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue