Make code more robust against sluggish screen updates.

Pump might take longer than a screen refresh to react to a button press,
so call waitForScreenUpdate() until we see the next desired screen has
actually arrived (used to work previously with fixed times, but that's
even less desirable).
This commit is contained in:
Johannes Mockenhaupt 2017-11-22 20:46:36 +01:00
parent 1897051782
commit 1f14f37373
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
3 changed files with 28 additions and 7 deletions

View file

@ -16,4 +16,11 @@ public class ConfirmAlertCommand extends BaseCommand {
public boolean needsRunMode() {
return false;
}
@Override
public String toString() {
return "ConfirmAlertCommand{" +
"warningCode=" + warningCode +
'}';
}
}

View file

@ -1,5 +1,6 @@
package de.jotomo.ruffyscripter.commands;
import org.monkey.d.ruffy.ruffy.driver.display.Menu;
import org.monkey.d.ruffy.ruffy.driver.display.MenuAttribute;
import org.monkey.d.ruffy.ruffy.driver.display.MenuType;
import org.monkey.d.ruffy.ruffy.driver.display.menu.MenuTime;
@ -25,7 +26,12 @@ public class ReadBasalProfileCommand extends BaseCommand {
scripter.verifyMenuIsDisplayed(MenuType.BASAL_TOTAL);
for (int i = 0; i < 24; i++) {
scripter.pressMenuKey();
Menu menu = scripter.getCurrentMenu();
while (menu.getType() != MenuType.BASAL_SET
|| ((MenuTime) scripter.getCurrentMenu().getAttribute(MenuAttribute.BASAL_START)).getHour() != i) {
scripter.waitForScreenUpdate();
menu = scripter.getCurrentMenu();
}
scripter.verifyMenuIsDisplayed(MenuType.BASAL_SET);
MenuTime startTime = (MenuTime) scripter.getCurrentMenu().getAttribute(MenuAttribute.BASAL_START);
if (i != startTime.getHour()) {

View file

@ -149,7 +149,9 @@ public class ReadHistoryCommand extends BaseCommand {
break;
}
scripter.pressDownKey();
while (record == (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD)) {
scripter.waitForScreenUpdate();
}
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
}
}
@ -185,7 +187,9 @@ public class ReadHistoryCommand extends BaseCommand {
break;
}
scripter.pressDownKey();
while (record == (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD)) {
scripter.waitForScreenUpdate();
}
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
}
}
@ -215,7 +219,9 @@ public class ReadHistoryCommand extends BaseCommand {
break;
}
scripter.pressDownKey();
while (record == (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD)) {
scripter.waitForScreenUpdate();
}
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
}
}
@ -245,7 +251,9 @@ public class ReadHistoryCommand extends BaseCommand {
break;
}
scripter.pressDownKey();
while (record == (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD)) {
scripter.waitForScreenUpdate();
}
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
}
}