Remove dead commands.

This commit is contained in:
Johannes Mockenhaupt 2017-10-19 21:19:48 +02:00
parent e1c1f4b996
commit 523de96c8c
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 0 additions and 293 deletions

View file

@ -1,123 +0,0 @@
package de.jotomo.ruffyscripter.commands;
import android.util.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.jotomo.ruffyscripter.RuffyScripter;
import de.jotomo.ruffy.spi.CommandResult;
public class GetBasalRateProfileCommand extends BaseCommand {
private static final Logger log = LoggerFactory.getLogger(GetBasalRateProfileCommand.class);
private RuffyScripter scripter;
public GetBasalRateProfileCommand() {}
@Override
public List<String> validateArguments() {
List<String> violations = new ArrayList<>();
return violations;
}
// private void tick()
// {
// switch (state)
// {
// case BEFORE:
// if(scripter.currentMenu!=null && scripter.currentMenu.getType()==MenuType.MAIN_MENU)
// {
// updateState(MAIN,120);
// lastMenu = MenuType.MAIN_MENU;
// log.debug("found MAIN_MENU -> state:MAIN");
// retries=3;
// }
// break;
// case MAIN:
// if(retries>0)
// if(scripter.goToMainTypeScreen(MenuType.BASAL_1_MENU,30000))
// {
// if(scripter.enterMenu(MenuType.BASAL_1_MENU,MenuType.BASAL_TOTAL, RuffyScripter.Key.CHECK,2000))
// {
// updateState(BASAL_OVERVIEW, 30);
// retries=0;
// }
// }
// else
// retries--;
// else
// updateState(ERROR,30);
// break;
// case BASAL_OVERVIEW:
// if(scripter.currentMenu.getType()==MenuType.BASAL_TOTAL && scripter.currentMenu.getAttribute(MenuAttribute.BASAL_TOTAL)!=null && (Integer)scripter.currentMenu.getAttribute(MenuAttribute.BASAL_SELECTED)==1)
// {
// basalTotal = (Double)scripter.currentMenu.getAttribute(MenuAttribute.BASAL_TOTAL);
// if(scripter.enterMenu(MenuType.BASAL_TOTAL,MenuType.BASAL_SET, RuffyScripter.Key.MENU,3000))
// {
// updateState(READ_BASAL,30);
// retries = 96;
// }
// }
// break;
// case READ_BASAL:
// if(scripter.currentMenu.getType()==MenuType.BASAL_SET && scripter.currentMenu.getAttribute(MenuAttribute.BASAL_START)!=null) {
// Object rateObj = scripter.currentMenu.getAttribute(MenuAttribute.BASAL_RATE);
// MenuTime time = (MenuTime) scripter.currentMenu.getAttribute(MenuAttribute.BASAL_START);
// if (rateObj instanceof Double) {
// rate.put(time.getHour(), (Double) rateObj);
// }
// boolean complete = true;
// for (int t = 0; t < 24; t++) {
// if (rate.get(t) == null)
// complete = false;
// }
// if (retries > 0) {
// if (complete) {
// scripter.pressBackKey();
// updateState(AFTER, 30);
// } else {
// retries--;
// scripter.pressMenuKey();
// scripter.waitForScreenUpdate(250);
// }
// } else {
// updateState(ERROR, 30);
// }
// }
// break;
// case ERROR:
// case AFTER:
// scripter.goToMainMenuScreen(MenuType.MAIN_MENU,2000);
// synchronized(GetBasalRateProfileCommand.this) {
// GetBasalRateProfileCommand.this.notify();
// }
// break;
// }
// }
@Override
public CommandResult execute() {
try {
Map<Integer, Double> rate = new HashMap<>();
for (int i = 0; i < 24; i++) {
Log.v("BASAL_RATE", "BASAL_RATE from " + String.format("%02d", i) + ":00 = " + rate.get(i));
}
} catch (Exception e) {
log.error("failed to get basal", e);
return new CommandResult().success(false).message("failed to get basal: " + e.getMessage());
}
return new CommandResult().success(true).enacted(true).message("Basal Rate was read");
}
@Override
public String toString() {
return "GetTbrCommand{}";
}
}

View file

@ -1,170 +0,0 @@
package de.jotomo.ruffyscripter.commands;
import org.monkey.d.ruffy.ruffy.driver.display.MenuType;
import java.util.Collections;
import java.util.List;
import de.jotomo.ruffy.spi.CommandResult;
import static de.jotomo.ruffyscripter.commands.GetPumpStateCommand.Stepper.runStep;
public class GetPumpStateCommand extends BaseCommand {
interface Step {
void doStep();
}
static boolean cancelRequested;
public static class Stepper {
public static void runStep(int retries, String desc, Step step) {
runStep(retries, desc, step, null, null);
}
public static void runStep(int retries, String desc, Step step, String recoveryDesc, Step recovery) {
// pre-checks here
if (cancelRequested) {
// runStep(0, "return to neutral state", () -> scripter.navigateToMainMenu());
// if (recovery != null) recovery.doStep();
// throw new CommandAbortedException(true);
}
if (true /*conectionLost*/) {
// either try to reconnect and deal with raised alarms (corfirm them and forward to AAPS)
// or let RS know he should reconnect and handle it (if that routine handles
// recovery in a generic way
}
/*boolean success/result =*/ step.doStep();
if (true /*successful*/) {
//
} else {
runStep(retries - 1, desc, step, recoveryDesc, recovery);
}
}
}
static class StepBuilder {
public StepBuilder(String desc) {}
public String result;
Step cancel = new Step() {
@Override
public void doStep() {
// default recovery
}
};
public StepBuilder retries(int retries) { return this; }
public StepBuilder description(Step step) {
return this;
}
public StepBuilder step(Step step) {
return this;
}
public StepBuilder recover(Step step) {
return this;
}
public StepBuilder cancel(Step step) {
return this;
}
public StepBuilder failure(Step step) { return this; }
public StepBuilder run() {
return this;
}
}
// state/info on whether an abort in that situtaion will raise a pump alert that we need
// to connect to the pump for quickly and dismiss it
// void step(String description, Code c) {
// c.run();
//
// exception/unexpected state
// user requested cancel
// disconnect info from ruffy
//
// }
public CommandResult execute2() {
new StepBuilder("Navigate to bolus menu") // turn into a method createStep() or so, which has access to the scripter
.step(new Step() {
@Override
public void doStep() {
System.out.println("something");
}
})
.recover(new Step() {
@Override
public void doStep() {
System.out.println("default impl: navigate back to main menu, no alarms");
}
})
.run();
new StepBuilder("Input bolus") // turn into a method createStep() or so, which has access to the scripter
.retries(5)
.failure(new Step() {
@Override
public void doStep() {
System.out.println("retry command");
}
})
.step(new Step() {
@Override
public void doStep() {
System.out.println("something");
}
})
.recover(new Step() {
@Override
public void doStep() {
System.out.println("navigate back and cancel 'bolus cancelled' alert");
}
})
.run();
// ^^ would allow overriding a default recovery or abort method
// vv below code as well, with varargs and overloading or simply more methods like runStepWithCustomRecovery
runStep(0, "check things", new Step() {
@Override
public void doStep() {
scripter.navigateToMenu(MenuType.MY_DATA_MENU);
}
});
runStep(0, "check things", new Step() {
@Override
public void doStep() {
scripter.navigateToMenu(MenuType.MY_DATA_MENU);
}
}, "recover by doing x", new Step() {
@Override
public void doStep() {
// recover
}
});
return null;
}
@Override
public CommandResult execute() {
return new CommandResult().success(true).enacted(false).message("Returning pump state only");
}
// @Override
// public CommandResult execute() {
// return new CommandResult().success(true).enacted(false).message("Returning pump state only");
// }
@Override
public List<String> validateArguments() {
return Collections.emptyList();
}
@Override
public String toString() {
return "ReadPumpStateCommand{}";
}
}