From 50cbcaba52855a90fd1533c671affd1c9b09ee12 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Tue, 31 Oct 2017 00:49:16 +0100 Subject: [PATCH] CancelTbrCommand: shortcut requests to cancel TBR when none is active. --- .../jotomo/ruffyscripter/commands/CancelTbrCommand.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/CancelTbrCommand.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/CancelTbrCommand.java index 441d91ea5e..c8a04f33ad 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/CancelTbrCommand.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/CancelTbrCommand.java @@ -22,6 +22,14 @@ public class CancelTbrCommand extends BaseCommand { public void execute() { scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU); PumpState pumpState = scripter.readPumpStateInternal(); + if (!pumpState.tbrActive) { + // This is non-critical; when cancelling a TBR and the connection was interrupted + // the TBR was cancelled by that. In that case not cancelling anything is fine. + result.success = true; + result.enacted = false; + return; + } + log.debug("Cancelling active TBR of " + pumpState.tbrPercent + "% with " + pumpState.tbrRemainingDuration + " min remaining"); SetTbrCommand setTbrCommand = new SetTbrCommand(100, 0);