Remove pumpState arg from Command.execute.

This commit is contained in:
Johannes Mockenhaupt 2017-08-23 12:13:52 +02:00
parent fe7f831429
commit 3238cf9c35
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
9 changed files with 15 additions and 22 deletions

View file

@ -305,7 +305,7 @@ public class RuffyScripter {
log.debug("Pump state before running command: " + pumpState); log.debug("Pump state before running command: " + pumpState);
long cmdStartTime = System.currentTimeMillis(); long cmdStartTime = System.currentTimeMillis();
cmd.setScripter(scripter); cmd.setScripter(scripter);
returnable.cmdResult = cmd.execute(pumpState); returnable.cmdResult = cmd.execute();
long cmdEndTime = System.currentTimeMillis(); long cmdEndTime = System.currentTimeMillis();
returnable.cmdResult.completionTime = cmdEndTime; returnable.cmdResult.completionTime = cmdEndTime;
log.debug("Executing " + cmd + " took " + (cmdEndTime - cmdStartTime) + "ms"); 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, /** This reads the state of the, which is whatever is currently displayed on the display,
* no actions are performed. */ * no actions are performed. */
private PumpState readPumpState() { public PumpState readPumpState() {
PumpState state = new PumpState(); PumpState state = new PumpState();
Menu menu = currentMenu; Menu menu = currentMenu;
if (menu == null) { if (menu == null) {

View file

@ -11,7 +11,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import de.jotomo.ruffyscripter.PumpState;
import de.jotomo.ruffyscripter.RuffyScripter; import de.jotomo.ruffyscripter.RuffyScripter;
public class BolusCommand extends BaseCommand { public class BolusCommand extends BaseCommand {
@ -35,7 +34,7 @@ public class BolusCommand extends BaseCommand {
} }
@Override @Override
public CommandResult execute(PumpState initialPumpState) { public CommandResult execute() {
try { try {
enterBolusMenu(scripter); enterBolusMenu(scripter);

View file

@ -22,10 +22,11 @@ public class CancelTbrCommand extends BaseCommand {
} }
@Override @Override
public CommandResult execute(PumpState initialPumpState) { public CommandResult execute() {
try { try {
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU); scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
if (!initialPumpState.tbrActive) { PumpState pumpState = scripter.readPumpState();
if (!pumpState.tbrActive) {
log.debug("active temp basal 90s ago: " + log.debug("active temp basal 90s ago: " +
MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis() - 90 * 1000)); MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis() - 90 * 1000));
log.debug("active temp basal 60s ago: " + log.debug("active temp basal 60s ago: " +
@ -46,9 +47,9 @@ public class CancelTbrCommand extends BaseCommand {
.enacted(true) .enacted(true)
.message("No TBR active"); .message("No TBR active");
} }
log.debug("Cancelling active TBR of " + initialPumpState.tbrPercent log.debug("Cancelling active TBR of " + pumpState.tbrPercent
+ "% with " + initialPumpState.tbrRemainingDuration + " min remaining"); + "% with " + pumpState.tbrRemainingDuration + " min remaining");
return new SetTbrCommand(100, 0).execute(initialPumpState); return new SetTbrCommand(100, 0).execute();
} catch (CommandException e) { } catch (CommandException e) {
return e.toCommandResult(); return e.toCommandResult();
} }

View file

@ -2,7 +2,6 @@ package de.jotomo.ruffyscripter.commands;
import java.util.List; import java.util.List;
import de.jotomo.ruffyscripter.PumpState;
import de.jotomo.ruffyscripter.RuffyScripter; import de.jotomo.ruffyscripter.RuffyScripter;
/** /**
@ -13,7 +12,7 @@ import de.jotomo.ruffyscripter.RuffyScripter;
* sequence, letting the methods take care of waits. * sequence, letting the methods take care of waits.
*/ */
public interface Command { public interface Command {
CommandResult execute(PumpState initialPumpState); CommandResult execute();
List<String> validateArguments(); List<String> validateArguments();
void setScripter(RuffyScripter scripter); void setScripter(RuffyScripter scripter);
} }

View file

@ -12,7 +12,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import de.jotomo.ruffyscripter.PumpCapabilities; import de.jotomo.ruffyscripter.PumpCapabilities;
import de.jotomo.ruffyscripter.PumpState;
import de.jotomo.ruffyscripter.RuffyScripter; import de.jotomo.ruffyscripter.RuffyScripter;
@ -27,7 +26,7 @@ public class DetermineCapabilitiesCommand extends BaseCommand {
} }
@Override @Override
public CommandResult execute(PumpState initialPumpState) { public CommandResult execute() {
try { try {
//read main menu 100% or TBR? Read remaining duration. //read main menu 100% or TBR? Read remaining duration.

View file

@ -10,7 +10,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import de.jotomo.ruffyscripter.PumpState;
import de.jotomo.ruffyscripter.RuffyScripter; import de.jotomo.ruffyscripter.RuffyScripter;
public class GetBasalCommand extends BaseCommand { public class GetBasalCommand extends BaseCommand {
@ -102,7 +101,7 @@ public class GetBasalCommand extends BaseCommand {
// } // }
// } // }
@Override @Override
public CommandResult execute(PumpState initialPumpState) { public CommandResult execute() {
try { try {
Map<Integer,Double> rate = new HashMap<>(); Map<Integer,Double> rate = new HashMap<>();

View file

@ -3,11 +3,9 @@ package de.jotomo.ruffyscripter.commands;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import de.jotomo.ruffyscripter.PumpState;
public class ReadPumpStateCommand extends BaseCommand { public class ReadPumpStateCommand extends BaseCommand {
@Override @Override
public CommandResult execute(PumpState initialPumpState) { public CommandResult execute() {
return new CommandResult().success(true).enacted(false).message("Returning pump state only"); return new CommandResult().success(true).enacted(false).message("Returning pump state only");
} }

View file

@ -12,7 +12,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import de.jotomo.ruffyscripter.PumpState;
import de.jotomo.ruffyscripter.RuffyScripter; import de.jotomo.ruffyscripter.RuffyScripter;
import static org.monkey.d.ruffy.ruffy.driver.display.MenuType.MAIN_MENU; import static org.monkey.d.ruffy.ruffy.driver.display.MenuType.MAIN_MENU;
@ -60,7 +59,7 @@ public class SetTbrCommand extends BaseCommand {
} }
@Override @Override
public CommandResult execute(PumpState initialPumpState) { public CommandResult execute() {
try { try {
log.debug("1. going from " + scripter.currentMenu + " to TBR_MENU"); log.debug("1. going from " + scripter.currentMenu + " to TBR_MENU");
int retries = 5; int retries = 5;

View file

@ -12,7 +12,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import de.jotomo.ruffyscripter.PumpState;
import de.jotomo.ruffyscripter.RuffyScripter; import de.jotomo.ruffyscripter.RuffyScripter;
public class SetTbrCommandAlt extends BaseCommand { public class SetTbrCommandAlt extends BaseCommand {
@ -54,7 +53,7 @@ public class SetTbrCommandAlt extends BaseCommand {
} }
@Override @Override
public CommandResult execute(PumpState initialPumpState) { public CommandResult execute() {
try { try {
enterTbrMenu(scripter); enterTbrMenu(scripter);
inputTbrPercentage(scripter); inputTbrPercentage(scripter);