CancelTbrCommand: shortcut requests to cancel TBR when none is active.

This commit is contained in:
Johannes Mockenhaupt 2017-10-31 00:49:16 +01:00
parent 1658ed14c9
commit 50cbcaba52
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -22,6 +22,14 @@ public class CancelTbrCommand extends BaseCommand {
public void execute() { public void execute() {
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU); scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
PumpState pumpState = scripter.readPumpStateInternal(); 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 log.debug("Cancelling active TBR of " + pumpState.tbrPercent
+ "% with " + pumpState.tbrRemainingDuration + " min remaining"); + "% with " + pumpState.tbrRemainingDuration + " min remaining");
SetTbrCommand setTbrCommand = new SetTbrCommand(100, 0); SetTbrCommand setTbrCommand = new SetTbrCommand(100, 0);