diff --git a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index 3d11cf68d7..460743ab7e 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -305,7 +305,7 @@ public class RuffyScripter { log.debug("Pump state before running command: " + pumpState); long cmdStartTime = System.currentTimeMillis(); cmd.setScripter(scripter); - returnable.cmdResult = cmd.execute(pumpState); + returnable.cmdResult = cmd.execute(); long cmdEndTime = System.currentTimeMillis(); returnable.cmdResult.completionTime = cmdEndTime; log.debug("Executing " + cmd + " took " + (cmdEndTime - cmdStartTime) + "ms"); @@ -602,7 +602,7 @@ public class RuffyScripter { /** This reads the state of the, which is whatever is currently displayed on the display, * no actions are performed. */ - private PumpState readPumpState() { + public PumpState readPumpState() { PumpState state = new PumpState(); Menu menu = currentMenu; if (menu == null) { diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java index 3eb0b1ba26..944da9b585 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java @@ -11,7 +11,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; -import de.jotomo.ruffyscripter.PumpState; import de.jotomo.ruffyscripter.RuffyScripter; public class BolusCommand extends BaseCommand { @@ -35,7 +34,7 @@ public class BolusCommand extends BaseCommand { } @Override - public CommandResult execute(PumpState initialPumpState) { + public CommandResult execute() { try { enterBolusMenu(scripter); diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/CancelTbrCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/CancelTbrCommand.java index 047ac56376..9ad4aae940 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/CancelTbrCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/CancelTbrCommand.java @@ -22,10 +22,11 @@ public class CancelTbrCommand extends BaseCommand { } @Override - public CommandResult execute(PumpState initialPumpState) { + public CommandResult execute() { try { scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU); - if (!initialPumpState.tbrActive) { + PumpState pumpState = scripter.readPumpState(); + if (!pumpState.tbrActive) { log.debug("active temp basal 90s ago: " + MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis() - 90 * 1000)); log.debug("active temp basal 60s ago: " + @@ -46,9 +47,9 @@ public class CancelTbrCommand extends BaseCommand { .enacted(true) .message("No TBR active"); } - log.debug("Cancelling active TBR of " + initialPumpState.tbrPercent - + "% with " + initialPumpState.tbrRemainingDuration + " min remaining"); - return new SetTbrCommand(100, 0).execute(initialPumpState); + log.debug("Cancelling active TBR of " + pumpState.tbrPercent + + "% with " + pumpState.tbrRemainingDuration + " min remaining"); + return new SetTbrCommand(100, 0).execute(); } catch (CommandException e) { return e.toCommandResult(); } diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/Command.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/Command.java index 6848a2c3f2..e472d56fa9 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/Command.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/Command.java @@ -2,7 +2,6 @@ package de.jotomo.ruffyscripter.commands; import java.util.List; -import de.jotomo.ruffyscripter.PumpState; import de.jotomo.ruffyscripter.RuffyScripter; /** @@ -13,7 +12,7 @@ import de.jotomo.ruffyscripter.RuffyScripter; * sequence, letting the methods take care of waits. */ public interface Command { - CommandResult execute(PumpState initialPumpState); + CommandResult execute(); List validateArguments(); void setScripter(RuffyScripter scripter); } diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/DetermineCapabilitiesCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/DetermineCapabilitiesCommand.java index 8eef298154..502b472fbc 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/DetermineCapabilitiesCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/DetermineCapabilitiesCommand.java @@ -12,7 +12,6 @@ import java.util.Collections; import java.util.List; import de.jotomo.ruffyscripter.PumpCapabilities; -import de.jotomo.ruffyscripter.PumpState; import de.jotomo.ruffyscripter.RuffyScripter; @@ -27,7 +26,7 @@ public class DetermineCapabilitiesCommand extends BaseCommand { } @Override - public CommandResult execute(PumpState initialPumpState) { + public CommandResult execute() { try { //read main menu 100% or TBR? Read remaining duration. diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/GetBasalCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/GetBasalCommand.java index b8b451b901..f69012ff29 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/GetBasalCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/GetBasalCommand.java @@ -10,7 +10,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import de.jotomo.ruffyscripter.PumpState; import de.jotomo.ruffyscripter.RuffyScripter; public class GetBasalCommand extends BaseCommand { @@ -102,7 +101,7 @@ public class GetBasalCommand extends BaseCommand { // } // } @Override - public CommandResult execute(PumpState initialPumpState) { + public CommandResult execute() { try { Map rate = new HashMap<>(); diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadPumpStateCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadPumpStateCommand.java index c346661c74..06ae717633 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadPumpStateCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadPumpStateCommand.java @@ -3,11 +3,9 @@ package de.jotomo.ruffyscripter.commands; import java.util.Collections; import java.util.List; -import de.jotomo.ruffyscripter.PumpState; - public class ReadPumpStateCommand extends BaseCommand { @Override - public CommandResult execute(PumpState initialPumpState) { + public CommandResult execute() { return new CommandResult().success(true).enacted(false).message("Returning pump state only"); } diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java index 38164cc116..efe61a4897 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; -import de.jotomo.ruffyscripter.PumpState; import de.jotomo.ruffyscripter.RuffyScripter; import static org.monkey.d.ruffy.ruffy.driver.display.MenuType.MAIN_MENU; @@ -60,7 +59,7 @@ public class SetTbrCommand extends BaseCommand { } @Override - public CommandResult execute(PumpState initialPumpState) { + public CommandResult execute() { try { log.debug("1. going from " + scripter.currentMenu + " to TBR_MENU"); int retries = 5; diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommandAlt.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommandAlt.java index 45f589c173..c42630f2a6 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommandAlt.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommandAlt.java @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; -import de.jotomo.ruffyscripter.PumpState; import de.jotomo.ruffyscripter.RuffyScripter; public class SetTbrCommandAlt extends BaseCommand { @@ -54,7 +53,7 @@ public class SetTbrCommandAlt extends BaseCommand { } @Override - public CommandResult execute(PumpState initialPumpState) { + public CommandResult execute() { try { enterTbrMenu(scripter); inputTbrPercentage(scripter);