From f251427d1b35c8c2e84f246c3539aa8f1e42d9fb Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 15 Jul 2017 18:35:41 +0200 Subject: [PATCH] Remove ReadStateCommand, all state will be return through the PumpState field on CommandResult, so it's passed back after every command. --- .../commands/ReadStateCommand.java | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 app/src/main/java/de/jotomo/ruffyscripter/commands/ReadStateCommand.java diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadStateCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadStateCommand.java deleted file mode 100644 index 139e727aad..0000000000 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadStateCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -package de.jotomo.ruffyscripter.commands; - -import org.monkey.d.ruffy.ruffy.driver.display.Menu; -import org.monkey.d.ruffy.ruffy.driver.display.MenuAttribute; -import org.monkey.d.ruffy.ruffy.driver.display.MenuType; -import org.monkey.d.ruffy.ruffy.driver.display.menu.MenuTime; - -import de.jotomo.ruffyscripter.RuffyScripter; - -/** - * Reads the status displayed in the main menu. Usually TBR state or warning/error if any. - * This command is 'read-only', no buttons are pushed and so no vibrations are caused. - */ -public class ReadStateCommand implements Command { - @Override - public CommandResult execute(RuffyScripter scripter) { - try { - PumpState state = new PumpState(); - Menu displayedMenu = scripter.currentMenu; - MenuType displayedMenuType = displayedMenu.getType(); - if (displayedMenuType == MenuType.MAIN_MENU) { - Double tbrPercentage = (Double) displayedMenu.getAttribute(MenuAttribute.TBR); - if (tbrPercentage != 100) { - state.tbrActive = true; - Double displayedTbr = (Double) scripter.currentMenu.getAttribute(MenuAttribute.TBR); - state.tbrPercent = displayedTbr.intValue(); - MenuTime durationMenuTime = ((MenuTime) displayedMenu.getAttribute(MenuAttribute.RUNTIME)); - state.tbrRemainingDuration = durationMenuTime.getHour() * 60 + durationMenuTime.getMinute(); - } - } else if (displayedMenuType == MenuType.WARNING_OR_ERROR) { - state.isErrorOrWarning = true; - state.errorMsg = (String) displayedMenu.getAttribute(MenuAttribute.MESSAGE); - } else { - throw new CommandException().success(false).message("Neither MAIN_MENU nor WARNING_OR_ERROR is displayed, but " + displayedMenuType); - } - - return new CommandResult().success(true).enacted(false).state(state); - } catch (CommandException e) { - return e.toCommandResult(); - } - } - - @Override - public String toString() { - return "ReadStateCommand{}"; - } - -}