Raise an error upon attempting to cancel a TBR when none is active.
This commit is contained in:
parent
14d7043600
commit
9927ab4989
1 changed files with 10 additions and 1 deletions
|
@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import de.jotomo.ruffyscripter.PumpState;
|
||||
import de.jotomo.ruffyscripter.RuffyScripter;
|
||||
|
||||
// TODO robustness: can a TBR run out, whilst we're trying to cancel it?
|
||||
|
@ -28,11 +29,19 @@ public class CancelTbrCommand implements Command {
|
|||
Double tbrPercentage = (Double) scripter.currentMenu.getAttribute(MenuAttribute.TBR);
|
||||
boolean runtimeDisplayed = scripter.currentMenu.attributes().contains(MenuAttribute.RUNTIME);
|
||||
if (tbrPercentage == 100 && !runtimeDisplayed) {
|
||||
return new CommandResult()
|
||||
// this is likely a relatively harmless error like AAPS trying to cancel a TBR
|
||||
// that has run out in the last minute or so, but for debugging lets raise an error
|
||||
// to make sure we can inspect this situation.
|
||||
// Set enacted=true, so I record is created and AAPS stops thinking a TBR still
|
||||
// running and trying again to cancel it.
|
||||
return new CommandResult().success(false).enacted(true)
|
||||
.state(new PumpState().errorMsg("NO TBR active"));
|
||||
/*
|
||||
.success(true)
|
||||
.enacted(true) // technically, nothing was enacted, but AAPS needs this to recover
|
||||
// when there was an issue and AAPS thinks a TBR is still active
|
||||
.message("No TBR active");
|
||||
*/
|
||||
}
|
||||
log.debug("Cancelling active TBR of " + tbrPercentage + "% with " + runtimeDisplayed + "min remaining");
|
||||
} catch (CommandException e) {
|
||||
|
|
Loading…
Reference in a new issue