Remove pumpState arg from Command.execute.
This commit is contained in:
parent
fe7f831429
commit
3238cf9c35
9 changed files with 15 additions and 22 deletions
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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<String> validateArguments();
|
||||
void setScripter(RuffyScripter scripter);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<Integer,Double> rate = new HashMap<>();
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue