Improve button state handling in Omnipod tab, read Pod status on AAPS startup and some cleanup
This commit is contained in:
parent
219b1e02ba
commit
c70fedbc72
|
@ -24,7 +24,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManage
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged
|
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.util.OmnipodUtil
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
@ -99,17 +98,15 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_refresh.setOnClickListener {
|
omnipod_refresh.setOnClickListener {
|
||||||
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() != true) {
|
omnipod_pod_active_alerts_ack.isEnabled = false
|
||||||
displayNotConfiguredDialog()
|
omnipod_refresh.isEnabled = false
|
||||||
} else {
|
omnipod_pod_debug.isEnabled = false
|
||||||
omnipod_refresh.isEnabled = false
|
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequest.GetPodState);
|
||||||
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequest.GetPodState);
|
commandQueue.readStatus("Clicked Refresh", object : Callback() {
|
||||||
commandQueue.readStatus("Clicked Refresh", object : Callback() {
|
override fun run() {
|
||||||
override fun run() {
|
activity?.runOnUiThread { updateOmipodUiElements() }
|
||||||
activity?.runOnUiThread { omnipod_refresh.isEnabled = true }
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_stats.setOnClickListener {
|
omnipod_stats.setOnClickListener {
|
||||||
|
@ -125,8 +122,14 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
displayNotConfiguredDialog()
|
displayNotConfiguredDialog()
|
||||||
} else {
|
} else {
|
||||||
omnipod_pod_active_alerts_ack.isEnabled = false
|
omnipod_pod_active_alerts_ack.isEnabled = false
|
||||||
|
omnipod_refresh.isEnabled = false
|
||||||
|
omnipod_pod_debug.isEnabled = false
|
||||||
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequest.AcknowledgeAlerts);
|
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequest.AcknowledgeAlerts);
|
||||||
commandQueue.readStatus("Clicked Alert Ack", null)
|
commandQueue.readStatus("Clicked Alert Ack", object : Callback() {
|
||||||
|
override fun run() {
|
||||||
|
activity?.runOnUiThread { updateOmipodUiElements() }
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,11 +137,13 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() != true) {
|
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() != true) {
|
||||||
displayNotConfiguredDialog()
|
displayNotConfiguredDialog()
|
||||||
} else {
|
} else {
|
||||||
|
omnipod_pod_active_alerts_ack.isEnabled = false
|
||||||
|
omnipod_refresh.isEnabled = false
|
||||||
omnipod_pod_debug.isEnabled = false
|
omnipod_pod_debug.isEnabled = false
|
||||||
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequest.GetPodPulseLog);
|
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequest.GetPodPulseLog);
|
||||||
commandQueue.readStatus("Clicked Refresh", object : Callback() {
|
commandQueue.readStatus("Clicked Refresh", object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
activity?.runOnUiThread { omnipod_pod_debug.isEnabled = true }
|
activity?.runOnUiThread { updateOmipodUiElements() }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -148,10 +153,6 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
|
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
|
||||||
disposables += rxBus
|
|
||||||
.toObservable(EventOmnipodRefreshButtonState::class.java)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe({ omnipod_refresh.isEnabled = it.newState }, { fabricPrivacy.logException(it) })
|
|
||||||
disposables += rxBus
|
disposables += rxBus
|
||||||
.toObservable(EventRileyLinkDeviceStatusChange::class.java)
|
.toObservable(EventRileyLinkDeviceStatusChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
@ -170,12 +171,12 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setVisibilityOfPodDebugButton() {
|
fun setVisibilityOfPodDebugButton() {
|
||||||
val isEnabled = aapsOmnipodManager.isPodDebuggingOptionsEnabled
|
if (aapsOmnipodManager.isPodDebuggingOptionsEnabled) {
|
||||||
|
|
||||||
if (isEnabled)
|
|
||||||
omnipod_pod_debug.visibility = View.VISIBLE
|
omnipod_pod_debug.visibility = View.VISIBLE
|
||||||
else
|
omnipod_pod_debug.isEnabled = podStateManager.isPodActivationCompleted && rileyLinkServiceData.rileyLinkServiceState.isReady && !commandQueue.statusInQueue()
|
||||||
|
} else {
|
||||||
omnipod_pod_debug.visibility = View.GONE
|
omnipod_pod_debug.visibility = View.GONE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun displayNotConfiguredDialog() {
|
private fun displayNotConfiguredDialog() {
|
||||||
|
@ -294,7 +295,8 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
omnipod_queue.text = status
|
omnipod_queue.text = status
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_refresh.isEnabled = podStateManager.isPodInitialized && podStateManager.podProgressStatus.isAtLeast(PodProgressStatus.PAIRING_COMPLETED)
|
omnipod_refresh.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && podStateManager.isPodInitialized
|
||||||
|
&& podStateManager.podProgressStatus.isAtLeast(PodProgressStatus.PAIRING_COMPLETED) && !commandQueue.statusInQueue()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateLastConnectionUiElements() {
|
private fun updateLastConnectionUiElements() {
|
||||||
|
@ -358,12 +360,12 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateAcknowledgeAlertsUiElements() {
|
private fun updateAcknowledgeAlertsUiElements() {
|
||||||
if (podStateManager.isPodInitialized && podStateManager.hasActiveAlerts()) {
|
if (podStateManager.isPodInitialized && podStateManager.hasActiveAlerts() && !podStateManager.isPodDead) {
|
||||||
omnipod_pod_active_alerts_ack.isEnabled = true
|
|
||||||
omnipod_pod_active_alerts.text = TextUtils.join(System.lineSeparator(), omnipodUtil.getTranslatedActiveAlerts(podStateManager))
|
omnipod_pod_active_alerts.text = TextUtils.join(System.lineSeparator(), omnipodUtil.getTranslatedActiveAlerts(podStateManager))
|
||||||
|
omnipod_pod_active_alerts_ack.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && !commandQueue.statusInQueue()
|
||||||
} else {
|
} else {
|
||||||
omnipod_pod_active_alerts_ack.isEnabled = false
|
|
||||||
omnipod_pod_active_alerts.text = "-"
|
omnipod_pod_active_alerts.text = "-"
|
||||||
|
omnipod_pod_active_alerts_ack.isEnabled = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,12 +67,12 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.pod
|
||||||
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.OmnipodCustomActionType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodStatusRequest;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodStatusRequest;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUIComm;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUIComm;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
|
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.RileyLinkOmnipodService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||||
|
@ -117,11 +117,9 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
|
|
||||||
// variables for handling statuses and history
|
// variables for handling statuses and history
|
||||||
protected boolean firstRun = true;
|
protected boolean firstRun = true;
|
||||||
protected boolean isRefresh = false;
|
|
||||||
protected boolean hasTimeDateOrTimeZoneChanged = false;
|
protected boolean hasTimeDateOrTimeZoneChanged = false;
|
||||||
protected boolean serviceRunning = false;
|
protected boolean serviceRunning = false;
|
||||||
protected boolean displayConnectionMessages = false;
|
protected boolean displayConnectionMessages = false;
|
||||||
private boolean isInitialized = false;
|
|
||||||
private RileyLinkOmnipodService rileyLinkOmnipodService;
|
private RileyLinkOmnipodService rileyLinkOmnipodService;
|
||||||
private boolean busy = false;
|
private boolean busy = false;
|
||||||
private int timeChangeRetries;
|
private int timeChangeRetries;
|
||||||
|
@ -412,16 +410,15 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
@Override
|
@Override
|
||||||
public void getPumpStatus() {
|
public void getPumpStatus() {
|
||||||
if (firstRun) {
|
if (firstRun) {
|
||||||
initializePump(!isRefresh);
|
initializePump();
|
||||||
triggerUIChange();
|
|
||||||
|
|
||||||
} else if (!omnipodStatusRequestList.isEmpty()) {
|
} else if (!omnipodStatusRequestList.isEmpty()) {
|
||||||
Iterator<OmnipodStatusRequest> iterator = omnipodStatusRequestList.iterator();
|
Iterator<OmnipodStatusRequest> iterator = omnipodStatusRequestList.iterator();
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
OmnipodStatusRequest omnipodStatusRequest = iterator.next();
|
OmnipodStatusRequest omnipodStatusRequest = iterator.next();
|
||||||
|
OmnipodUITask omnipodUITask;
|
||||||
if (omnipodStatusRequest == OmnipodStatusRequest.GetPodPulseLog) {
|
if (omnipodStatusRequest == OmnipodStatusRequest.GetPodPulseLog) {
|
||||||
OmnipodUITask omnipodUITask = getDeviceCommandExecutor().executeCommand(omnipodStatusRequest.getCommandType());
|
omnipodUITask = getDeviceCommandExecutor().executeCommand(omnipodStatusRequest.getCommandType());
|
||||||
|
|
||||||
PodInfoRecentPulseLog result = (PodInfoRecentPulseLog) omnipodUITask.returnDataObject;
|
PodInfoRecentPulseLog result = (PodInfoRecentPulseLog) omnipodUITask.returnDataObject;
|
||||||
|
|
||||||
|
@ -440,7 +437,11 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
getDeviceCommandExecutor().executeCommand(omnipodStatusRequest.getCommandType());
|
omnipodUITask = getDeviceCommandExecutor().executeCommand(omnipodStatusRequest.getCommandType());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!omnipodUITask.wasCommandSuccessful()) {
|
||||||
|
// TODO Refresh buttons
|
||||||
}
|
}
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
|
@ -471,8 +472,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setNewBasalProfile(Profile profile) {
|
public PumpEnactResult setNewBasalProfile(Profile profile) {
|
||||||
setRefreshButtonEnabled(false);
|
|
||||||
|
|
||||||
OmnipodUITask responseTask = getDeviceCommandExecutor().executeCommand(OmnipodCommandType.SetBasalProfile,
|
OmnipodUITask responseTask = getDeviceCommandExecutor().executeCommand(OmnipodCommandType.SetBasalProfile,
|
||||||
profile);
|
profile);
|
||||||
|
|
||||||
|
@ -538,43 +537,34 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
|
|
||||||
@NonNull @Override
|
@NonNull @Override
|
||||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
|
if (detailedBolusInfo.insulin == 0 && detailedBolusInfo.carbs == 0) {
|
||||||
|
// neither carbs nor bolus requested
|
||||||
|
aapsLogger.error("deliverTreatment: Invalid input");
|
||||||
|
return new PumpEnactResult(getInjector()).success(false).enacted(false).bolusDelivered(0d).carbsDelivered(0d)
|
||||||
|
.comment(getResourceHelper().gs(info.nightscout.androidaps.core.R.string.invalidinput));
|
||||||
|
} else if (detailedBolusInfo.insulin > 0) {
|
||||||
|
// bolus needed, ask pump to deliver it
|
||||||
|
return deliverBolus(detailedBolusInfo);
|
||||||
|
} else {
|
||||||
|
// no bolus required, carb only treatment
|
||||||
|
activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, true);
|
||||||
|
|
||||||
try {
|
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.INSTANCE;
|
||||||
if (detailedBolusInfo.insulin == 0 && detailedBolusInfo.carbs == 0) {
|
bolusingEvent.setT(new Treatment());
|
||||||
// neither carbs nor bolus requested
|
bolusingEvent.getT().isSMB = detailedBolusInfo.isSMB;
|
||||||
aapsLogger.error("deliverTreatment: Invalid input");
|
bolusingEvent.setPercent(100);
|
||||||
return new PumpEnactResult(getInjector()).success(false).enacted(false).bolusDelivered(0d).carbsDelivered(0d)
|
rxBus.send(bolusingEvent);
|
||||||
.comment(getResourceHelper().gs(info.nightscout.androidaps.core.R.string.invalidinput));
|
|
||||||
} else if (detailedBolusInfo.insulin > 0) {
|
|
||||||
// bolus needed, ask pump to deliver it
|
|
||||||
return deliverBolus(detailedBolusInfo);
|
|
||||||
} else {
|
|
||||||
// no bolus required, carb only treatment
|
|
||||||
activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, true);
|
|
||||||
|
|
||||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.INSTANCE;
|
aapsLogger.debug(LTag.PUMP, "deliverTreatment: Carb only treatment.");
|
||||||
bolusingEvent.setT(new Treatment());
|
|
||||||
bolusingEvent.getT().isSMB = detailedBolusInfo.isSMB;
|
|
||||||
bolusingEvent.setPercent(100);
|
|
||||||
rxBus.send(bolusingEvent);
|
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMP, "deliverTreatment: Carb only treatment.");
|
return new PumpEnactResult(getInjector()).success(true).enacted(true).bolusDelivered(0d)
|
||||||
|
.carbsDelivered(detailedBolusInfo.carbs).comment(getResourceHelper().gs(info.nightscout.androidaps.core.R.string.common_resultok));
|
||||||
return new PumpEnactResult(getInjector()).success(true).enacted(true).bolusDelivered(0d)
|
|
||||||
.carbsDelivered(detailedBolusInfo.carbs).comment(getResourceHelper().gs(info.nightscout.androidaps.core.R.string.common_resultok));
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
triggerUIChange();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopBolusDelivering() {
|
public void stopBolusDelivering() {
|
||||||
setRefreshButtonEnabled(false);
|
|
||||||
|
|
||||||
getDeviceCommandExecutor().executeCommand(OmnipodCommandType.CancelBolus);
|
getDeviceCommandExecutor().executeCommand(OmnipodCommandType.CancelBolus);
|
||||||
|
|
||||||
setRefreshButtonEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if enforceNew===true current temp basal is canceled and new TBR set (duration is prolonged),
|
// if enforceNew===true current temp basal is canceled and new TBR set (duration is prolonged),
|
||||||
|
@ -582,8 +572,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer
|
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer
|
||||||
durationInMinutes, Profile profile, boolean enforceNew) {
|
durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
setRefreshButtonEnabled(false);
|
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute: rate: {}, duration={}", absoluteRate, durationInMinutes);
|
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute: rate: {}, duration={}", absoluteRate, durationInMinutes);
|
||||||
|
|
||||||
// read current TBR
|
// read current TBR
|
||||||
|
@ -597,7 +585,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
if (tbrCurrent != null && !enforceNew) {
|
if (tbrCurrent != null && !enforceNew) {
|
||||||
if (Round.isSame(tbrCurrent.absoluteRate, absoluteRate)) {
|
if (Round.isSame(tbrCurrent.absoluteRate, absoluteRate)) {
|
||||||
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - No enforceNew and same rate. Exiting.");
|
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - No enforceNew and same rate. Exiting.");
|
||||||
finishAction("TBR");
|
refreshOverview("TBR");
|
||||||
return new PumpEnactResult(getInjector()).success(true).enacted(false);
|
return new PumpEnactResult(getInjector()).success(true).enacted(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -614,7 +602,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
incrementStatistics(OmnipodConst.Statistics.TBRsSet);
|
incrementStatistics(OmnipodConst.Statistics.TBRsSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
finishAction("TBR");
|
refreshOverview("TBR");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,21 +620,19 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
||||||
setRefreshButtonEnabled(false);
|
|
||||||
|
|
||||||
TemporaryBasal tbrCurrent = readTBR();
|
TemporaryBasal tbrCurrent = readTBR();
|
||||||
|
|
||||||
if (tbrCurrent == null) {
|
if (tbrCurrent == null) {
|
||||||
aapsLogger.info(LTag.PUMP, "cancelTempBasal - TBR already canceled.");
|
aapsLogger.info(LTag.PUMP, "cancelTempBasal - TBR already canceled.");
|
||||||
finishAction("TBR");
|
refreshOverview("TBR");
|
||||||
return new PumpEnactResult(getInjector()).success(true).enacted(false);
|
return new PumpEnactResult(getInjector()).success(true).enacted(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
OmnipodUITask responseTask2 = getDeviceCommandExecutor().executeCommand(OmnipodCommandType.CancelTemporaryBasal);
|
OmnipodUITask responseTask = getDeviceCommandExecutor().executeCommand(OmnipodCommandType.CancelTemporaryBasal);
|
||||||
|
|
||||||
PumpEnactResult result = responseTask2.getResult();
|
PumpEnactResult result = responseTask.getResult();
|
||||||
|
|
||||||
finishAction("TBR");
|
refreshOverview("TBR");
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
// TODO is this necessary?
|
// TODO is this necessary?
|
||||||
|
@ -836,43 +822,23 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
return rileyLinkOmnipodService.getDeviceCommandExecutor();
|
return rileyLinkOmnipodService.getDeviceCommandExecutor();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getPodPumpStatus() {
|
|
||||||
// TODO read pod status
|
|
||||||
aapsLogger.error(LTag.PUMP, "getPodPumpStatus() NOT IMPLEMENTED");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPodStatusRequest(OmnipodStatusRequest pumpStatusRequest) {
|
public void addPodStatusRequest(OmnipodStatusRequest pumpStatusRequest) {
|
||||||
if (pumpStatusRequest == OmnipodStatusRequest.ResetState) {
|
omnipodStatusRequestList.add(pumpStatusRequest);
|
||||||
resetStatusState();
|
}
|
||||||
|
|
||||||
|
private void initializePump() {
|
||||||
|
if (podStateManager.isPodInitialized() && podStateManager.getPodProgressStatus().isAtLeast(PodProgressStatus.PAIRING_COMPLETED)) {
|
||||||
|
OmnipodUITask omnipodUITask = getDeviceCommandExecutor().executeCommand(OmnipodCommandType.GetPodStatus);
|
||||||
|
if (omnipodUITask.wasCommandSuccessful()) {
|
||||||
|
aapsLogger.debug(LTag.PUMP, "Successfully retrieved Pod status on startup");
|
||||||
|
} else {
|
||||||
|
aapsLogger.warn(LTag.PUMP, "Failed to retrieve Pod status on startup");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
omnipodStatusRequestList.add(pumpStatusRequest);
|
aapsLogger.debug(LTag.PUMP, "Not retrieving Pod status on startup: no Pod running");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetStatusState() {
|
|
||||||
firstRun = true;
|
|
||||||
isRefresh = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME do we actually need this? If a user presses refresh during an action,
|
|
||||||
// I suppose the GetStatusCommand would just be queued?
|
|
||||||
private void setRefreshButtonEnabled(boolean enabled) {
|
|
||||||
rxBus.send(new EventOmnipodRefreshButtonState(enabled));
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME strange
|
|
||||||
private void initializePump(boolean realInit) {
|
|
||||||
setRefreshButtonEnabled(false);
|
|
||||||
|
|
||||||
if (podStateManager.isPodInitialized()) {
|
|
||||||
aapsLogger.debug(LTag.PUMP, "PodStateManager (saved): " + podStateManager);
|
|
||||||
// TODO handle if session state too old
|
|
||||||
getPodPumpStatus();
|
|
||||||
} else {
|
|
||||||
aapsLogger.debug(LTag.PUMP, "No Pod running");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finishAction("Omnipod Pump");
|
refreshOverview("Omnipod Pump");
|
||||||
|
|
||||||
if (!sentIdToFirebase) {
|
if (!sentIdToFirebase) {
|
||||||
Bundle params = new Bundle();
|
Bundle params = new Bundle();
|
||||||
|
@ -883,27 +849,17 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
sentIdToFirebase = true;
|
sentIdToFirebase = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
isInitialized = true;
|
|
||||||
|
|
||||||
this.firstRun = false;
|
this.firstRun = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void triggerUIChange() {
|
|
||||||
rxBus.send(new EventOmnipodPumpValuesChanged());
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
protected PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) {
|
protected PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) {
|
||||||
setRefreshButtonEnabled(false);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OmnipodUITask responseTask = getDeviceCommandExecutor().executeCommand(OmnipodCommandType.SetBolus,
|
OmnipodUITask responseTask = getDeviceCommandExecutor().executeCommand(OmnipodCommandType.SetBolus,
|
||||||
detailedBolusInfo);
|
detailedBolusInfo);
|
||||||
|
|
||||||
PumpEnactResult result = responseTask.getResult();
|
PumpEnactResult result = responseTask.getResult();
|
||||||
|
|
||||||
setRefreshButtonEnabled(true);
|
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
incrementStatistics(detailedBolusInfo.isSMB ? OmnipodConst.Statistics.SMBBoluses
|
incrementStatistics(detailedBolusInfo.isSMB ? OmnipodConst.Statistics.SMBBoluses
|
||||||
: OmnipodConst.Statistics.StandardBoluses);
|
: OmnipodConst.Statistics.StandardBoluses);
|
||||||
|
@ -913,7 +869,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
finishAction("Bolus");
|
refreshOverview("Bolus");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -927,13 +883,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
return activePlugin.getActiveTreatments().getTempBasalFromHistory(System.currentTimeMillis());
|
return activePlugin.getActiveTreatments().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void finishAction(String overviewKey) {
|
protected void refreshOverview(String overviewKey) {
|
||||||
if (overviewKey != null)
|
rxBus.send(new EventRefreshOverview(overviewKey, false));
|
||||||
rxBus.send(new EventRefreshOverview(overviewKey, false));
|
|
||||||
|
|
||||||
triggerUIChange();
|
|
||||||
|
|
||||||
setRefreshButtonEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PumpEnactResult getOperationNotSupportedWithCustomText(int resourceId) {
|
private PumpEnactResult getOperationNotSupportedWithCustomText(int resourceId) {
|
||||||
|
|
|
@ -4,10 +4,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs;
|
||||||
* Created by andy on 4.8.2019
|
* Created by andy on 4.8.2019
|
||||||
*/
|
*/
|
||||||
public enum OmnipodCommandType {
|
public enum OmnipodCommandType {
|
||||||
|
PairAndPrimePod, // First step of Pod activation
|
||||||
PairAndPrimePod, //
|
FillCanulaAndSetBasalProfile, // Second step of Pod activation
|
||||||
FillCanulaAndSetBasalProfile, //
|
|
||||||
//InitPod, //
|
|
||||||
DeactivatePod, //
|
DeactivatePod, //
|
||||||
SetBasalProfile, //
|
SetBasalProfile, //
|
||||||
SetBolus, //
|
SetBolus, //
|
||||||
|
@ -19,6 +17,4 @@ public enum OmnipodCommandType {
|
||||||
SetTime, //
|
SetTime, //
|
||||||
AcknowledgeAlerts, //
|
AcknowledgeAlerts, //
|
||||||
GetPodPulseLog;
|
GetPodPulseLog;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.defs;
|
package info.nightscout.androidaps.plugins.pump.omnipod.defs;
|
||||||
|
|
||||||
public enum OmnipodStatusRequest {
|
public enum OmnipodStatusRequest {
|
||||||
ResetState(OmnipodCommandType.ResetPodStatus), //
|
|
||||||
AcknowledgeAlerts(OmnipodCommandType.AcknowledgeAlerts), //
|
AcknowledgeAlerts(OmnipodCommandType.AcknowledgeAlerts), //
|
||||||
GetPodState(OmnipodCommandType.GetPodStatus), //
|
GetPodState(OmnipodCommandType.GetPodStatus), //
|
||||||
GetPodPulseLog(OmnipodCommandType.GetPodPulseLog);
|
GetPodPulseLog(OmnipodCommandType.GetPodPulseLog);
|
||||||
|
@ -12,7 +11,6 @@ public enum OmnipodStatusRequest {
|
||||||
this.commandType = commandType;
|
this.commandType = commandType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public OmnipodCommandType getCommandType() {
|
public OmnipodCommandType getCommandType() {
|
||||||
return commandType;
|
return commandType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.events
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.Event
|
|
||||||
|
|
||||||
class EventOmnipodRefreshButtonState(val newState: Boolean) : Event()
|
|
Loading…
Reference in a new issue