Add retries for inputing values.
Rarely there seem to be timing issues and e.g. 10 button down presses to go from 100% to 0% only goes down to 20%. Retry two more times in that case, restarting the input process on the active screen (bolus input, tbr percent/duration input).
This commit is contained in:
parent
e52c2a857c
commit
7fe9ad7910
|
@ -37,9 +37,24 @@ public class BolusCommand implements Command {
|
||||||
public CommandResult execute(RuffyScripter scripter) {
|
public CommandResult execute(RuffyScripter scripter) {
|
||||||
try {
|
try {
|
||||||
enterBolusMenu(scripter);
|
enterBolusMenu(scripter);
|
||||||
inputBolusAmount(scripter);
|
|
||||||
SystemClock.sleep(500);
|
boolean bolusAmountInputSuccess = false;
|
||||||
verifyDisplayedBolusAmount(scripter);
|
int bolusAmountInputRetries = 2;
|
||||||
|
while (!bolusAmountInputSuccess) {
|
||||||
|
try {
|
||||||
|
inputBolusAmount(scripter);
|
||||||
|
SystemClock.sleep(750);
|
||||||
|
verifyDisplayedBolusAmount(scripter);
|
||||||
|
bolusAmountInputSuccess = true;
|
||||||
|
} catch (CommandException e) {
|
||||||
|
if (bolusAmountInputRetries >= 0) {
|
||||||
|
log.warn("Failed to set bolus amount, retrying", e);
|
||||||
|
bolusAmountInputRetries--;
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// confirm bolus
|
// confirm bolus
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
||||||
|
|
|
@ -49,16 +49,31 @@ public class SetTbrCommand implements Command {
|
||||||
violations.add("Max allowed zero-temp duration is 2h");
|
violations.add("Max allowed zero-temp duration is 2h");
|
||||||
}
|
}
|
||||||
|
|
||||||
return violations;
|
return violations;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(RuffyScripter scripter) {
|
public CommandResult execute(RuffyScripter scripter) {
|
||||||
try {
|
try {
|
||||||
enterTbrMenu(scripter);
|
enterTbrMenu(scripter);
|
||||||
inputTbrPercentage(scripter);
|
|
||||||
SystemClock.sleep(500);
|
boolean tbrPercentInputSuccess = false;
|
||||||
verifyDisplayedTbrPercentage(scripter);
|
int tbrPercentInputRetries = 2;
|
||||||
|
while (!tbrPercentInputSuccess) {
|
||||||
|
try {
|
||||||
|
inputTbrPercentage(scripter);
|
||||||
|
SystemClock.sleep(750);
|
||||||
|
verifyDisplayedTbrPercentage(scripter);
|
||||||
|
tbrPercentInputSuccess = true;
|
||||||
|
} catch (CommandException e) {
|
||||||
|
if (tbrPercentInputRetries >= 0) {
|
||||||
|
log.warn("Setting TBR percentage failed, retrying", e);
|
||||||
|
tbrPercentInputRetries--;
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (percentage == 100) {
|
if (percentage == 100) {
|
||||||
cancelTbrAndConfirmCancellationWarning(scripter);
|
cancelTbrAndConfirmCancellationWarning(scripter);
|
||||||
|
@ -69,9 +84,23 @@ public class SetTbrCommand implements Command {
|
||||||
scripter.waitForMenuUpdate();
|
scripter.waitForMenuUpdate();
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
||||||
|
|
||||||
inputTbrDuration(scripter);
|
boolean tbrDurationSuccess = false;
|
||||||
SystemClock.sleep(500);
|
int tbrDurationRetries = 2;
|
||||||
verifyDisplayedTbrDuration(scripter);
|
while (!tbrDurationSuccess) {
|
||||||
|
try {
|
||||||
|
inputTbrDuration(scripter);
|
||||||
|
SystemClock.sleep(750);
|
||||||
|
verifyDisplayedTbrDuration(scripter);
|
||||||
|
tbrDurationSuccess = true;
|
||||||
|
} catch (CommandException e) {
|
||||||
|
if (tbrDurationRetries >= 0) {
|
||||||
|
log.warn("Setting TBR duration failed, retrying", e);
|
||||||
|
tbrDurationRetries--;
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// confirm TBR
|
// confirm TBR
|
||||||
scripter.pressCheckKey();
|
scripter.pressCheckKey();
|
||||||
|
|
Loading…
Reference in a new issue