BolusCommand: remove retry logic, add extra checks for final bolus.
This commit is contained in:
parent
e1b63a4a74
commit
da69e69570
1 changed files with 13 additions and 19 deletions
|
@ -39,25 +39,8 @@ public class BolusCommand implements Command {
|
||||||
try {
|
try {
|
||||||
enterBolusMenu(scripter);
|
enterBolusMenu(scripter);
|
||||||
|
|
||||||
boolean bolusAmountInputSuccess = false;
|
|
||||||
int bolusAmountInputRetries = 2;
|
|
||||||
// see SetTbrCommand.execute for an explanation why we're looping here
|
|
||||||
while (!bolusAmountInputSuccess) {
|
|
||||||
try {
|
|
||||||
inputBolusAmount(scripter);
|
inputBolusAmount(scripter);
|
||||||
// TODO v2 this call can probably be removed by now
|
|
||||||
SystemClock.sleep(750);
|
|
||||||
verifyDisplayedBolusAmount(scripter);
|
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);
|
||||||
|
@ -112,6 +95,9 @@ public class BolusCommand implements Command {
|
||||||
scripter.pressUpKey();
|
scripter.pressUpKey();
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
}
|
}
|
||||||
|
// Give the pump time to finish any scrolling that might still be going on, can take
|
||||||
|
// up to 1100s. Plus some extra time to be sure
|
||||||
|
SystemClock.sleep(2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyDisplayedBolusAmount(RuffyScripter scripter) {
|
private void verifyDisplayedBolusAmount(RuffyScripter scripter) {
|
||||||
|
@ -121,6 +107,14 @@ public class BolusCommand implements Command {
|
||||||
if (Math.abs(displayedBolus - bolus) > 0.05) {
|
if (Math.abs(displayedBolus - bolus) > 0.05) {
|
||||||
throw new CommandException().message("Failed to set correct bolus. Expected: " + bolus + ", actual: " + displayedBolus);
|
throw new CommandException().message("Failed to set correct bolus. Expected: " + bolus + ", actual: " + displayedBolus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check again to ensure the displayed value hasn't change due to due scrolling taking extremely long
|
||||||
|
SystemClock.sleep(2000);
|
||||||
|
double refreshedDisplayedBolus = readDisplayedBolusAmount(scripter);
|
||||||
|
if (Math.abs(displayedBolus - refreshedDisplayedBolus) > 0.05) {
|
||||||
|
throw new CommandException().message("Failed to set bolus: bolus changed after input stopped from "
|
||||||
|
+ displayedBolus + " -> " + refreshedDisplayedBolus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double readDisplayedBolusAmount(RuffyScripter scripter) {
|
private double readDisplayedBolusAmount(RuffyScripter scripter) {
|
||||||
|
|
Loading…
Reference in a new issue