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
2 changed files with 54 additions and 10 deletions
|
@ -37,9 +37,24 @@ public class BolusCommand implements Command {
|
|||
public CommandResult execute(RuffyScripter scripter) {
|
||||
try {
|
||||
enterBolusMenu(scripter);
|
||||
|
||||
boolean bolusAmountInputSuccess = false;
|
||||
int bolusAmountInputRetries = 2;
|
||||
while (!bolusAmountInputSuccess) {
|
||||
try {
|
||||
inputBolusAmount(scripter);
|
||||
SystemClock.sleep(500);
|
||||
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
|
||||
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
||||
|
|
|
@ -56,9 +56,24 @@ public class SetTbrCommand implements Command {
|
|||
public CommandResult execute(RuffyScripter scripter) {
|
||||
try {
|
||||
enterTbrMenu(scripter);
|
||||
|
||||
boolean tbrPercentInputSuccess = false;
|
||||
int tbrPercentInputRetries = 2;
|
||||
while (!tbrPercentInputSuccess) {
|
||||
try {
|
||||
inputTbrPercentage(scripter);
|
||||
SystemClock.sleep(500);
|
||||
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) {
|
||||
cancelTbrAndConfirmCancellationWarning(scripter);
|
||||
|
@ -69,9 +84,23 @@ public class SetTbrCommand implements Command {
|
|||
scripter.waitForMenuUpdate();
|
||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
||||
|
||||
boolean tbrDurationSuccess = false;
|
||||
int tbrDurationRetries = 2;
|
||||
while (!tbrDurationSuccess) {
|
||||
try {
|
||||
inputTbrDuration(scripter);
|
||||
SystemClock.sleep(500);
|
||||
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
|
||||
scripter.pressCheckKey();
|
||||
|
|
Loading…
Reference in a new issue