Replace PodCommsResponse with PumpEnactResult
This commit is contained in:
parent
78f402a367
commit
ed52070a4c
|
@ -11,6 +11,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.Profile;
|
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.common.data.TempBasalPair;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.AcknowledgeAlertsAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.AcknowledgeAlertsAction;
|
||||||
|
@ -28,7 +29,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.Inser
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.PairService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.PairService;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.PrimeService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.PrimeService;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.SetTempBasalService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.SetTempBasalService;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.data.PodCommResponse;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfo;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfo;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoResponse;
|
||||||
|
@ -60,12 +60,8 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OmnipodManager(OmnipodCommunicationService communicationService) {
|
|
||||||
this(communicationService, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse insertCannula(Profile profile) {
|
public PumpEnactResult insertCannula(Profile profile) {
|
||||||
if (podState == null || podState.getSetupProgress().isBefore(SetupProgress.PRIMING_FINISHED)) {
|
if (podState == null || podState.getSetupProgress().isBefore(SetupProgress.PRIMING_FINISHED)) {
|
||||||
throw new IllegalArgumentException("Pod should be paired and primed first");
|
throw new IllegalArgumentException("Pod should be paired and primed first");
|
||||||
} else if (podState.getSetupProgress().isAfter(SetupProgress.CANNULA_INSERTING)) {
|
} else if (podState.getSetupProgress().isAfter(SetupProgress.CANNULA_INSERTING)) {
|
||||||
|
@ -84,7 +80,7 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse pairAndPrime() {
|
public PumpEnactResult pairAndPrime() {
|
||||||
if (podState == null) {
|
if (podState == null) {
|
||||||
podState = communicationService.executeAction(new PairAction(new PairService()));
|
podState = communicationService.executeAction(new PairAction(new PairService()));
|
||||||
}
|
}
|
||||||
|
@ -103,7 +99,7 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse cancelBolus() {
|
public PumpEnactResult cancelBolus() {
|
||||||
if (!isInitialized()) {
|
if (!isInitialized()) {
|
||||||
throw new IllegalStateException("Pod should be initialized first");
|
throw new IllegalStateException("Pod should be initialized first");
|
||||||
}
|
}
|
||||||
|
@ -113,7 +109,7 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse getPodStatus() {
|
public PumpEnactResult getPodStatus() {
|
||||||
if (podState == null) {
|
if (podState == null) {
|
||||||
throw new IllegalStateException("Pod should be paired first");
|
throw new IllegalStateException("Pod should be paired first");
|
||||||
}
|
}
|
||||||
|
@ -123,7 +119,7 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse deactivatePod() {
|
public PumpEnactResult deactivatePod() {
|
||||||
if (podState == null) {
|
if (podState == null) {
|
||||||
throw new IllegalStateException("Pod should be paired first");
|
throw new IllegalStateException("Pod should be paired first");
|
||||||
}
|
}
|
||||||
|
@ -134,7 +130,7 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse setBasalProfile(Profile basalProfile) {
|
public PumpEnactResult setBasalProfile(Profile basalProfile) {
|
||||||
if (!isInitialized()) {
|
if (!isInitialized()) {
|
||||||
throw new IllegalStateException("Pod should be initialized first");
|
throw new IllegalStateException("Pod should be initialized first");
|
||||||
}
|
}
|
||||||
|
@ -146,7 +142,7 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse resetPodState() {
|
public PumpEnactResult resetPodState() {
|
||||||
podState = null;
|
podState = null;
|
||||||
SP.remove(OmnipodConst.Prefs.PodState);
|
SP.remove(OmnipodConst.Prefs.PodState);
|
||||||
|
|
||||||
|
@ -154,7 +150,7 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse bolus(Double units) {
|
public PumpEnactResult bolus(Double units) {
|
||||||
if (!isInitialized()) {
|
if (!isInitialized()) {
|
||||||
throw new IllegalStateException("Pod should be initialized first");
|
throw new IllegalStateException("Pod should be initialized first");
|
||||||
}
|
}
|
||||||
|
@ -164,7 +160,7 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse setTemporaryBasal(TempBasalPair tempBasalPair) {
|
public PumpEnactResult setTemporaryBasal(TempBasalPair tempBasalPair) {
|
||||||
if (!isInitialized()) {
|
if (!isInitialized()) {
|
||||||
throw new IllegalStateException("Pod should be initialized first");
|
throw new IllegalStateException("Pod should be initialized first");
|
||||||
}
|
}
|
||||||
|
@ -176,7 +172,7 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse cancelTemporaryBasal() {
|
public PumpEnactResult cancelTemporaryBasal() {
|
||||||
if (!isInitialized()) {
|
if (!isInitialized()) {
|
||||||
throw new IllegalStateException("Pod should be initialized first");
|
throw new IllegalStateException("Pod should be initialized first");
|
||||||
}
|
}
|
||||||
|
@ -186,7 +182,7 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse acknowledgeAlerts() {
|
public PumpEnactResult acknowledgeAlerts() {
|
||||||
if (!isInitialized()) {
|
if (!isInitialized()) {
|
||||||
throw new IllegalStateException("Pod should be initialized first");
|
throw new IllegalStateException("Pod should be initialized first");
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,12 +113,14 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
|
|
||||||
serviceConnection = new ServiceConnection() {
|
serviceConnection = new ServiceConnection() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.debug("RileyLinkOmnipodService is disconnected");
|
LOG.debug("RileyLinkOmnipodService is disconnected");
|
||||||
omnipodService = null;
|
omnipodService = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.debug("RileyLinkOmnipodService is connected");
|
LOG.debug("RileyLinkOmnipodService is connected");
|
||||||
|
@ -143,12 +145,10 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected OmnipodPumpPlugin(PluginDescription pluginDescription, PumpType pumpType) {
|
protected OmnipodPumpPlugin(PluginDescription pluginDescription, PumpType pumpType) {
|
||||||
super(pluginDescription, pumpType);
|
super(pluginDescription, pumpType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static OmnipodPumpPlugin getPlugin() {
|
public static OmnipodPumpPlugin getPlugin() {
|
||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
plugin = new OmnipodPumpPlugin();
|
plugin = new OmnipodPumpPlugin();
|
||||||
|
@ -186,6 +186,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onStartCustomActions() {
|
public void onStartCustomActions() {
|
||||||
|
|
||||||
// check status every minute (if any status needs refresh we send readStatus command)
|
// check status every minute (if any status needs refresh we send readStatus command)
|
||||||
|
@ -204,6 +205,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class getServiceClass() {
|
public Class getServiceClass() {
|
||||||
return RileyLinkOmnipodService.class;
|
return RileyLinkOmnipodService.class;
|
||||||
}
|
}
|
||||||
|
@ -435,11 +437,13 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void triggerUIChange() {
|
protected void triggerUIChange() {
|
||||||
RxBus.INSTANCE.send(new EventOmnipodPumpValuesChanged());
|
RxBus.INSTANCE.send(new EventOmnipodPumpValuesChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
@NonNull
|
@NonNull
|
||||||
protected PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) {
|
protected PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) {
|
||||||
|
|
||||||
|
@ -452,11 +456,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
OmnipodUITask responseTask = omnipodUIComm.executeCommand(OmnipodCommandType.SetBolus,
|
OmnipodUITask responseTask = omnipodUIComm.executeCommand(OmnipodCommandType.SetBolus,
|
||||||
detailedBolusInfo.insulin);
|
detailedBolusInfo.insulin);
|
||||||
|
|
||||||
Boolean response = responseTask.wasCommandSuccessful();
|
PumpEnactResult result = responseTask.getResult();
|
||||||
|
|
||||||
setRefreshButtonEnabled(true);
|
setRefreshButtonEnabled(true);
|
||||||
|
|
||||||
if (response) {
|
if (result.success) {
|
||||||
|
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
|
||||||
|
|
||||||
|
@ -474,51 +478,36 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
long time = System.currentTimeMillis() + (bolusTime * 1000);
|
long time = System.currentTimeMillis() + (bolusTime * 1000);
|
||||||
|
|
||||||
this.busyTimestamps.add(time);
|
this.busyTimestamps.add(time);
|
||||||
|
|
||||||
return new PumpEnactResult().success(true) //
|
|
||||||
.enacted(true) //
|
|
||||||
.bolusDelivered(detailedBolusInfo.insulin) //
|
|
||||||
.carbsDelivered(detailedBolusInfo.carbs);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return new PumpEnactResult() //
|
|
||||||
.success(false) //
|
|
||||||
.enacted(false) //
|
|
||||||
.comment(MainApp.gs(R.string.medtronic_cmd_bolus_could_not_be_delivered));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
finishAction("Bolus");
|
finishAction("Bolus");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void stopBolusDelivering() {
|
public void stopBolusDelivering() {
|
||||||
|
|
||||||
LOG.info(getLogPrefix() + "stopBolusDelivering");
|
LOG.info(getLogPrefix() + "stopBolusDelivering");
|
||||||
|
|
||||||
setRefreshButtonEnabled(false);
|
setRefreshButtonEnabled(false);
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
OmnipodUITask responseTask = omnipodUIComm.executeCommand(OmnipodCommandType.CancelBolus);
|
OmnipodUITask responseTask = omnipodUIComm.executeCommand(OmnipodCommandType.CancelBolus);
|
||||||
|
|
||||||
Boolean response = responseTask.wasCommandSuccessful();
|
PumpEnactResult result = responseTask.getResult();
|
||||||
|
|
||||||
setRefreshButtonEnabled(true);
|
setRefreshButtonEnabled(true);
|
||||||
|
|
||||||
LOG.info(getLogPrefix() + "stopBolusDelivering - wasSuccess={}", response);
|
LOG.info(getLogPrefix() + "stopBolusDelivering - wasSuccess={}", result.success);
|
||||||
|
|
||||||
if (response) {
|
if (result.success) {
|
||||||
// TODO fix bolus record with cancel
|
// TODO fix bolus record with cancel
|
||||||
|
|
||||||
//TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
|
//TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
|
||||||
finishAction("Bolus");
|
finishAction("Bolus");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void incrementStatistics(String statsKey) {
|
private void incrementStatistics(String statsKey) {
|
||||||
|
@ -551,7 +540,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tbrCurrent != null && !enforceNew) {
|
if (tbrCurrent != null && !enforceNew) {
|
||||||
|
|
||||||
if (OmnipodUtil.isSame(tbrCurrent.getInsulinRate(), absoluteRate)) {
|
if (OmnipodUtil.isSame(tbrCurrent.getInsulinRate(), absoluteRate)) {
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.info(getLogPrefix() + "setTempBasalAbsolute - No enforceNew and same rate. Exiting.");
|
LOG.info(getLogPrefix() + "setTempBasalAbsolute - No enforceNew and same rate. Exiting.");
|
||||||
|
@ -568,10 +556,9 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
// CANCEL
|
// CANCEL
|
||||||
OmnipodUITask responseTask2 = omnipodUIComm.executeCommand(OmnipodCommandType.CancelTemporaryBasal);
|
OmnipodUITask responseTask2 = omnipodUIComm.executeCommand(OmnipodCommandType.CancelTemporaryBasal);
|
||||||
|
|
||||||
Boolean response = responseTask2.wasCommandSuccessful();
|
PumpEnactResult result = responseTask2.getResult();
|
||||||
;
|
|
||||||
|
|
||||||
if (response) {
|
if (result.success) {
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.info(getLogPrefix() + "setTempBasalAbsolute - Current TBR cancelled.");
|
LOG.info(getLogPrefix() + "setTempBasalAbsolute - Current TBR cancelled.");
|
||||||
} else {
|
} else {
|
||||||
|
@ -580,8 +567,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
|
|
||||||
finishAction("TBR");
|
finishAction("TBR");
|
||||||
|
|
||||||
return new PumpEnactResult().success(false).enacted(false)
|
return result;
|
||||||
.comment(MainApp.gs(R.string.medtronic_cmd_cant_cancel_tbr_stop_op));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,12 +575,12 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
OmnipodUITask responseTask = omnipodUIComm.executeCommand(OmnipodCommandType.SetTemporaryBasal,
|
OmnipodUITask responseTask = omnipodUIComm.executeCommand(OmnipodCommandType.SetTemporaryBasal,
|
||||||
absoluteRate, durationInMinutes);
|
absoluteRate, durationInMinutes);
|
||||||
|
|
||||||
Boolean response = responseTask.wasCommandSuccessful();
|
PumpEnactResult result = responseTask.getResult();
|
||||||
|
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.info(getLogPrefix() + "setTempBasalAbsolute - setTBR. Response: " + response);
|
LOG.info(getLogPrefix() + "setTempBasalAbsolute - setTBR. Response: " + result.success);
|
||||||
|
|
||||||
if (response) {
|
if (result.success) {
|
||||||
pumpStatusLocal.tempBasalStart = System.currentTimeMillis();
|
pumpStatusLocal.tempBasalStart = System.currentTimeMillis();
|
||||||
pumpStatusLocal.tempBasalAmount = absoluteRate;
|
pumpStatusLocal.tempBasalAmount = absoluteRate;
|
||||||
pumpStatusLocal.tempBasalLength = durationInMinutes;
|
pumpStatusLocal.tempBasalLength = durationInMinutes;
|
||||||
|
@ -609,19 +595,10 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStart);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStart);
|
||||||
|
|
||||||
incrementStatistics(OmnipodConst.Statistics.TBRsSet);
|
incrementStatistics(OmnipodConst.Statistics.TBRsSet);
|
||||||
|
|
||||||
finishAction("TBR");
|
|
||||||
|
|
||||||
return new PumpEnactResult().success(true).enacted(true) //
|
|
||||||
.absolute(absoluteRate).duration(durationInMinutes);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
finishAction("TBR");
|
|
||||||
|
|
||||||
return new PumpEnactResult().success(false).enacted(false) //
|
|
||||||
.comment(MainApp.gs(R.string.medtronic_cmd_tbr_could_not_be_delivered));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
finishAction("TBR");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TempBasalPair readTBR() {
|
protected TempBasalPair readTBR() {
|
||||||
|
@ -682,11 +659,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
|
|
||||||
OmnipodUITask responseTask2 = omnipodUIComm.executeCommand(OmnipodCommandType.CancelTemporaryBasal);
|
OmnipodUITask responseTask2 = omnipodUIComm.executeCommand(OmnipodCommandType.CancelTemporaryBasal);
|
||||||
|
|
||||||
Boolean response = responseTask2.wasCommandSuccessful();
|
PumpEnactResult result = responseTask2.getResult();
|
||||||
|
|
||||||
finishAction("TBR");
|
finishAction("TBR");
|
||||||
|
|
||||||
if (response) {
|
if (result.success) {
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.info(getLogPrefix() + "cancelTempBasal - Cancel TBR successful.");
|
LOG.info(getLogPrefix() + "cancelTempBasal - Cancel TBR successful.");
|
||||||
|
|
||||||
|
@ -696,17 +673,12 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
|
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
|
||||||
|
|
||||||
return new PumpEnactResult().success(true).enacted(true) //
|
|
||||||
.isTempCancel(true);
|
|
||||||
} else {
|
} else {
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.info(getLogPrefix() + "cancelTempBasal - Cancel TBR failed.");
|
LOG.info(getLogPrefix() + "cancelTempBasal - Cancel TBR failed.");
|
||||||
|
|
||||||
return new PumpEnactResult().success(response).enacted(response) //
|
|
||||||
.comment(MainApp.gs(R.string.medtronic_cmd_cant_cancel_tbr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -732,19 +704,16 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
|
||||||
OmnipodUITask responseTask = omnipodUIComm.executeCommand(OmnipodCommandType.SetBasalProfile,
|
OmnipodUITask responseTask = omnipodUIComm.executeCommand(OmnipodCommandType.SetBasalProfile,
|
||||||
profile);
|
profile);
|
||||||
|
|
||||||
Boolean response = responseTask.wasCommandSuccessful();
|
PumpEnactResult result = responseTask.getResult();
|
||||||
|
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.info(getLogPrefix() + "Basal Profile was set: " + response);
|
LOG.info(getLogPrefix() + "Basal Profile was set: " + result.success);
|
||||||
|
|
||||||
if (response) {
|
if (result.success) {
|
||||||
this.currentProfile = profile;
|
this.currentProfile = profile;
|
||||||
return new PumpEnactResult().success(true).enacted(true);
|
|
||||||
} else {
|
|
||||||
return new PumpEnactResult().success(response).enacted(response) //
|
|
||||||
.comment(MainApp.gs(R.string.medtronic_cmd_basal_profile_could_not_be_set));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
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.data.PodCommResponse;
|
|
||||||
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.PodDeviceState;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
|
||||||
|
@ -25,7 +25,7 @@ public class OmnipodUITask {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||||
|
|
||||||
public OmnipodCommandType commandType;
|
public OmnipodCommandType commandType;
|
||||||
public PodCommResponse returnData;
|
public PumpEnactResult returnData;
|
||||||
private String errorDescription;
|
private String errorDescription;
|
||||||
private Object[] parameters;
|
private Object[] parameters;
|
||||||
private PodResponseType responseType;
|
private PodResponseType responseType;
|
||||||
|
@ -128,11 +128,10 @@ public class OmnipodUITask {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Object getResult() {
|
public <T> T getResult() {
|
||||||
return returnData;
|
return (T)returnData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isReceived() {
|
public boolean isReceived() {
|
||||||
return (returnData != null || errorDescription != null);
|
return (returnData != null || errorDescription != null);
|
||||||
}
|
}
|
||||||
|
@ -184,12 +183,5 @@ public class OmnipodUITask {
|
||||||
return this.responseType;
|
return this.responseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean wasCommandSuccessful() {
|
|
||||||
if (returnData == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return returnData.isAcknowledged();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,71 +1,70 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.defs;
|
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.plugins.pump.common.data.TempBasalPair;
|
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.data.PodCommResponse;
|
|
||||||
|
|
||||||
public interface OmnipodCommunicationManagerInterface {
|
public interface OmnipodCommunicationManagerInterface {
|
||||||
|
|
||||||
// TODO add methods that can be used by OmniPod Eros and Omnipod Dash
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pair and prime
|
* Pair and prime
|
||||||
*/
|
*/
|
||||||
PodCommResponse pairAndPrime();
|
PumpEnactResult pairAndPrime();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert cannula
|
* Insert cannula
|
||||||
*/
|
*/
|
||||||
PodCommResponse insertCannula(Profile basalProfile);
|
PumpEnactResult insertCannula(Profile basalProfile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Pod Status (is pod running, battery left ?, reservoir, etc)
|
* Get Pod Status (is pod running, battery left ?, reservoir, etc)
|
||||||
*/
|
*/
|
||||||
PodCommResponse getPodStatus();
|
// TODO we should probably return a (wrapped) StatusResponse instead of a PumpEnactResult
|
||||||
|
PumpEnactResult getPodStatus();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deactivate Pod
|
* Deactivate Pod
|
||||||
*/
|
*/
|
||||||
PodCommResponse deactivatePod();
|
PumpEnactResult deactivatePod();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Basal Profile
|
* Set Basal Profile
|
||||||
*/
|
*/
|
||||||
PodCommResponse setBasalProfile(Profile basalProfile);
|
PumpEnactResult setBasalProfile(Profile basalProfile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset Pod state (if we forget to disconnect Pod and want to init new pod, and want to forget current pod)
|
* Reset Pod state (if we forget to disconnect Pod and want to init new pod, and want to forget current pod)
|
||||||
*/
|
*/
|
||||||
PodCommResponse resetPodState();
|
PumpEnactResult resetPodState();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Bolus
|
* Set Bolus
|
||||||
*
|
*
|
||||||
* @param amount amount of bolus in U
|
* @param amount amount of bolus in U
|
||||||
*/
|
*/
|
||||||
PodCommResponse bolus(Double amount);
|
PumpEnactResult bolus(Double amount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel Bolus (if bolus is already stopped, return acknowledgment)
|
* Cancel Bolus (if bolus is already stopped, return acknowledgment)
|
||||||
*/
|
*/
|
||||||
PodCommResponse cancelBolus();
|
PumpEnactResult cancelBolus();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Temporary Basal
|
* Set Temporary Basal
|
||||||
*
|
*
|
||||||
* @param tempBasalPair TempBasalPair object containg amount and duration in minutes
|
* @param tempBasalPair TempBasalPair object containg amount and duration in minutes
|
||||||
*/
|
*/
|
||||||
PodCommResponse setTemporaryBasal(TempBasalPair tempBasalPair);
|
PumpEnactResult setTemporaryBasal(TempBasalPair tempBasalPair);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel Temporary Basal (if TB is already stopped, return acknowledgment)
|
* Cancel Temporary Basal (if TB is already stopped, return acknowledgment)
|
||||||
*/
|
*/
|
||||||
PodCommResponse cancelTemporaryBasal();
|
PumpEnactResult cancelTemporaryBasal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acknowledge alerts
|
* Acknowledge alerts
|
||||||
*/
|
*/
|
||||||
PodCommResponse acknowledgeAlerts();
|
PumpEnactResult acknowledgeAlerts();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeErosOmnipodManager() {
|
private void initializeErosOmnipodManager() {
|
||||||
|
if(OmnipodManager.getInstance() == null) {
|
||||||
PodSessionState podState = null;
|
PodSessionState podState = null;
|
||||||
if (SP.contains(OmnipodConst.Prefs.PodState)) {
|
if (SP.contains(OmnipodConst.Prefs.PodState)) {
|
||||||
try {
|
try {
|
||||||
|
@ -123,6 +124,9 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
omnipodCommunicationManager = new OmnipodManager(new OmnipodCommunicationService(rfspy), podState);
|
omnipodCommunicationManager = new OmnipodManager(new OmnipodCommunicationService(rfspy), podState);
|
||||||
|
} else {
|
||||||
|
omnipodCommunicationManager = OmnipodManager.getInstance();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,11 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||||
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.ble.RFSpy;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.data.PodCommResponse;
|
|
||||||
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.state.PodSessionState;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||||
|
@ -62,7 +62,7 @@ public class OmnipodDashCommunicationManager implements OmnipodCommunicationMana
|
||||||
|
|
||||||
// This are just skeleton methods, we need to see what we can get returned and act accordingly
|
// This are just skeleton methods, we need to see what we can get returned and act accordingly
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse pairAndPrime() {
|
public PumpEnactResult pairAndPrime() {
|
||||||
//omnipodManager.pairAndPrime();
|
//omnipodManager.pairAndPrime();
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,52 +70,52 @@ public class OmnipodDashCommunicationManager implements OmnipodCommunicationMana
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse insertCannula(Profile basalProfile) {
|
public PumpEnactResult insertCannula(Profile basalProfile) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse getPodStatus() {
|
public PumpEnactResult getPodStatus() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse deactivatePod() {
|
public PumpEnactResult deactivatePod() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse setBasalProfile(Profile basalProfile) {
|
public PumpEnactResult setBasalProfile(Profile basalProfile) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse resetPodState() {
|
public PumpEnactResult resetPodState() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse bolus(Double parameter) {
|
public PumpEnactResult bolus(Double parameter) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse cancelBolus() {
|
public PumpEnactResult cancelBolus() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse setTemporaryBasal(TempBasalPair tempBasalPair) {
|
public PumpEnactResult setTemporaryBasal(TempBasalPair tempBasalPair) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse cancelTemporaryBasal() {
|
public PumpEnactResult cancelTemporaryBasal() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodCommResponse acknowledgeAlerts() {
|
public PumpEnactResult acknowledgeAlerts() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue