BolusCommand: deal with blinking values.

How did this not trigger with all the  boluses I've issued so far?
This commit is contained in:
Johannes Mockenhaupt 2017-07-18 01:51:52 +02:00
parent 7fe9ad7910
commit ebe14fb0cf
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -110,14 +110,23 @@ public class BolusCommand implements Command {
}
private void verifyDisplayedBolusAmount(RuffyScripter scripter) {
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
double displayedBolus = (double) scripter.currentMenu.getAttribute(MenuAttribute.BOLUS);
double displayedBolus = readDisplayedBolusAmount(scripter);
log.debug("Final bolus: " + displayedBolus);
if (Math.abs(displayedBolus - bolus) > 0.05) {
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
public String toString() {
return "BolusCommand{" +