add Logger logs
This commit is contained in:
parent
92ca9aaede
commit
59ee67a353
|
@ -58,12 +58,12 @@ public class SetTbrCommand implements Command {
|
|||
|
||||
return violations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(RuffyScripter scripter, PumpState initialPumpState) {
|
||||
|
||||
try {
|
||||
Log.v("SetTbrCommand","1. going from "+scripter.currentMenu+" to TBR_MENU");
|
||||
log.debug("1. going from "+scripter.currentMenu+" to TBR_MENU");
|
||||
int retries = 5;
|
||||
while(!scripter.goToMainMenuScreen(TBR_MENU,3000))
|
||||
{
|
||||
|
@ -79,6 +79,7 @@ public class SetTbrCommand implements Command {
|
|||
throw new Exception("not able to find TBR_MENU: stuck in "+scripter.currentMenu);
|
||||
|
||||
Log.v("SetTbrCommand","2. entering "+scripter.currentMenu);
|
||||
log.debug("2. entering "+scripter.currentMenu);
|
||||
retries = 5;
|
||||
while(!scripter.enterMenu(TBR_MENU,MenuType.TBR_SET, RuffyScripter.Key.CHECK,2000))
|
||||
{
|
||||
|
@ -96,6 +97,7 @@ public class SetTbrCommand implements Command {
|
|||
}
|
||||
|
||||
Log.v("SetTbrCommand","3. getting/setting basal in "+scripter.currentMenu);
|
||||
log.debug("SetTbrCommand: 3. getting/setting basal in "+scripter.currentMenu);
|
||||
retries = 30;
|
||||
|
||||
double currentPercentage = -100;
|
||||
|
@ -111,6 +113,7 @@ public class SetTbrCommand implements Command {
|
|||
int actualPercentage = (int) currentPercentage;
|
||||
int steps = (requestedPercentage - actualPercentage) / 10;
|
||||
Log.v("SetTbrCommand", "Adjusting basal(" + requestedPercentage + "/" + actualPercentage + ") with " + steps + " steps and " + retries + " retries left");
|
||||
log.debug("Adjusting basal(" + requestedPercentage + "/" + actualPercentage + ") with " + steps + " steps and " + retries + " retries left");
|
||||
scripter.step(steps, (steps < 0 ? RuffyScripter.Key.DOWN : RuffyScripter.Key.UP), 500);
|
||||
scripter.waitScreen(1000);
|
||||
}
|
||||
|
@ -124,6 +127,7 @@ public class SetTbrCommand implements Command {
|
|||
throw new Exception("unable to set basalrate");
|
||||
|
||||
Log.v("SetTbrCommand","4. checking basal in "+scripter.currentMenu);
|
||||
log.debug("4. checking basal in "+scripter.currentMenu);
|
||||
scripter.waitScreen(1000);
|
||||
currentPercentage= -1000;
|
||||
retries=10;
|
||||
|
@ -143,6 +147,7 @@ public class SetTbrCommand implements Command {
|
|||
|
||||
if(currentPercentage!=100) {
|
||||
Log.v("SetTbrCommand", "5. change to TBR_DURATION from " + scripter.currentMenu);
|
||||
log.debug("5. change to TBR_DURATION from " + scripter.currentMenu);
|
||||
retries = 5;
|
||||
while (retries >=0 && !scripter.enterMenu(TBR_SET, MenuType.TBR_DURATION, RuffyScripter.Key.MENU, 2000)) {
|
||||
retries--;
|
||||
|
@ -158,6 +163,7 @@ public class SetTbrCommand implements Command {
|
|||
}
|
||||
|
||||
Log.v("SetTbrCommand", "6. getting/setting duration in " + scripter.currentMenu);
|
||||
log.debug("6. getting/setting duration in " + scripter.currentMenu);
|
||||
retries = 30;
|
||||
|
||||
double currentDuration = -100;
|
||||
|
@ -165,6 +171,7 @@ public class SetTbrCommand implements Command {
|
|||
retries--;
|
||||
Object durationObj = scripter.currentMenu.getAttribute(MenuAttribute.RUNTIME);
|
||||
Log.v("SetTbrCommand", "Requested time: " + duration + " actual time: " + durationObj);
|
||||
log.debug("Requested time: " + duration + " actual time: " + durationObj);
|
||||
if (durationObj != null && durationObj instanceof MenuTime) {
|
||||
MenuTime time = (MenuTime) durationObj;
|
||||
currentDuration = (time.getHour() * 60) + time.getMinute();
|
||||
|
@ -177,6 +184,7 @@ public class SetTbrCommand implements Command {
|
|||
else if (currentDuration + (steps * 15) > requestedDuration)
|
||||
steps--;
|
||||
Log.v("SetTbrCommand", "Adjusting duration(" + requestedDuration + "/" + actualDuration + ") with " + steps + " steps and " + retries + " retries left");
|
||||
log.debug("Adjusting duration(" + requestedDuration + "/" + actualDuration + ") with " + steps + " steps and " + retries + " retries left");
|
||||
scripter.step(steps, (steps > 0 ? RuffyScripter.Key.UP : RuffyScripter.Key.DOWN), 500);
|
||||
scripter.waitScreen(1000);
|
||||
}
|
||||
|
@ -187,6 +195,7 @@ public class SetTbrCommand implements Command {
|
|||
throw new Exception("unable to set duration");
|
||||
|
||||
Log.v("SetTbrCommand", "7. checking time in " + scripter.currentMenu);
|
||||
log.debug("7. checking time in " + scripter.currentMenu);
|
||||
scripter.waitScreen(1000);
|
||||
currentDuration = -1000;
|
||||
retries = 10;
|
||||
|
@ -206,6 +215,7 @@ public class SetTbrCommand implements Command {
|
|||
}
|
||||
|
||||
Log.v("SetTbrCommand", "8. setting from " + scripter.currentMenu);
|
||||
log.debug("8. setting from " + scripter.currentMenu);
|
||||
retries=5;
|
||||
while(retries>= 0 && (scripter.currentMenu.getType()==TBR_DURATION ||scripter.currentMenu.getType()==TBR_SET))
|
||||
{
|
||||
|
@ -260,6 +270,7 @@ public class SetTbrCommand implements Command {
|
|||
String.format(Locale.US, "TBR set to %d%% for %d min", percentage, duration));
|
||||
} catch (Exception e) {
|
||||
Log.e("SetTbrCommand", "got exception: ", e);
|
||||
log.error("got exception: ", e);
|
||||
return new CommandResult().success(false).message("failed to wait: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue