Update ComboPlugin.cancelTempBasal to user newly added userRequested param.
This commit is contained in:
parent
8369893428
commit
8aabc346c0
|
@ -548,7 +548,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelTempBasal() {
|
public PumpEnactResult cancelTempBasal(boolean userRequested) {
|
||||||
log.debug("cancelTempBasal called");
|
log.debug("cancelTempBasal called");
|
||||||
|
|
||||||
CommandResult commandResult = null;
|
CommandResult commandResult = null;
|
||||||
|
@ -557,8 +557,9 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
|
|
||||||
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
|
|
||||||
if (activeTemp == null) {
|
if (activeTemp == null || userRequested) {
|
||||||
log.debug("cancelTempBasal really cancelling tbr.");
|
/* v1 compatibility to sync DB to pump if they diverged (activeTemp == null) */
|
||||||
|
log.debug("cancelTempBasal: hard-cancelling TBR since user requested");
|
||||||
commandResult = runCommand(new CancelTbrCommand());
|
commandResult = runCommand(new CancelTbrCommand());
|
||||||
if (commandResult.enacted) {
|
if (commandResult.enacted) {
|
||||||
tempBasal = new TemporaryBasal(commandResult.completionTime);
|
tempBasal = new TemporaryBasal(commandResult.completionTime);
|
||||||
|
@ -567,14 +568,20 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
pumpEnactResult.isTempCancel = true;
|
pumpEnactResult.isTempCancel = true;
|
||||||
}
|
}
|
||||||
} else if ((activeTemp.percentRate >= 90 && activeTemp.percentRate <= 110) && activeTemp.getPlannedRemainingMinutes() <= 15 ) {
|
} else if ((activeTemp.percentRate >= 90 && activeTemp.percentRate <= 110) && activeTemp.getPlannedRemainingMinutes() <= 15 ) {
|
||||||
// do nothing.
|
// Let fake neutral temp keep running (see below)
|
||||||
log.debug("cancelTempBasal skipping changing tbr since it already is at " + activeTemp.percentRate + "% and running for another " + activeTemp.getPlannedRemainingMinutes() + " mins.");
|
log.debug("cancelTempBasal: skipping changing tbr since it already is at " + activeTemp.percentRate + "% and running for another " + activeTemp.getPlannedRemainingMinutes() + " mins.");
|
||||||
pumpEnactResult.comment = "cancelTempBasal skipping changing tbr since it already is at " + activeTemp.percentRate + "% and running for another " + activeTemp.getPlannedRemainingMinutes() + " mins.";
|
pumpEnactResult.comment = "cancelTempBasal skipping changing tbr since it already is at " + activeTemp.percentRate + "% and running for another " + activeTemp.getPlannedRemainingMinutes() + " mins.";
|
||||||
|
// TODO check what AAPS does with this; no DB update is required;
|
||||||
|
// looking at info/nightscout/androidaps/plugins/Loop/LoopPlugin.java:280
|
||||||
|
// both values are used as one:
|
||||||
|
// if (applyResult.enacted || applyResult.success) { ...
|
||||||
pumpEnactResult.enacted = true; // all fine though...
|
pumpEnactResult.enacted = true; // all fine though...
|
||||||
pumpEnactResult.success = true; // just roll with it...
|
pumpEnactResult.success = true; // just roll with it...
|
||||||
} else {
|
} else {
|
||||||
|
// Set a fake neutral temp to avoid TBR cancel alert. Decide 90% vs 110% based on
|
||||||
|
// on whether the TBR we're cancelling is above or below 100%.
|
||||||
long percentage = (activeTemp.percentRate > 100) ? 110:90;
|
long percentage = (activeTemp.percentRate > 100) ? 110:90;
|
||||||
log.debug("cancelTempBasal changing tbr to " + percentage + "% for 15 mins.");
|
log.debug("cancelTempBasal: changing tbr to " + percentage + "% for 15 mins.");
|
||||||
commandResult = runCommand(new SetTbrCommand(percentage, 15));
|
commandResult = runCommand(new SetTbrCommand(percentage, 15));
|
||||||
if (commandResult.enacted) {
|
if (commandResult.enacted) {
|
||||||
tempBasal = new TemporaryBasal(commandResult.completionTime);
|
tempBasal = new TemporaryBasal(commandResult.completionTime);
|
||||||
|
|
Loading…
Reference in a new issue