BolusCommand: deal with blinking values.
How did this not trigger with all the boluses I've issued so far?
This commit is contained in:
parent
7fe9ad7910
commit
ebe14fb0cf
|
@ -110,14 +110,23 @@ public class BolusCommand implements Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyDisplayedBolusAmount(RuffyScripter scripter) {
|
private void verifyDisplayedBolusAmount(RuffyScripter scripter) {
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
double displayedBolus = readDisplayedBolusAmount(scripter);
|
||||||
double displayedBolus = (double) scripter.currentMenu.getAttribute(MenuAttribute.BOLUS);
|
|
||||||
log.debug("Final bolus: " + displayedBolus);
|
log.debug("Final bolus: " + displayedBolus);
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double readDisplayedBolusAmount(RuffyScripter scripter) {
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
||||||
|
Object amountObj = scripter.currentMenu.getAttribute(MenuAttribute.BOLUS);
|
||||||
|
while (!(amountObj instanceof Double)) {
|
||||||
|
scripter.waitForMenuUpdate();
|
||||||
|
amountObj = scripter.currentMenu.getAttribute(MenuAttribute.BOLUS);
|
||||||
|
}
|
||||||
|
return (double) amountObj;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "BolusCommand{" +
|
return "BolusCommand{" +
|
||||||
|
|
Loading…
Reference in a new issue