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() { public boolean needsRunMode() {
return false; return false;
} }
@Override
public String toString() {
return "ConfirmAlertCommand{" +
"warningCode=" + warningCode +
'}';
}
} }

View file

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

View file

@ -149,7 +149,9 @@ public class ReadHistoryCommand extends BaseCommand {
break; break;
} }
scripter.pressDownKey(); scripter.pressDownKey();
scripter.waitForScreenUpdate(); while (record == (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD)) {
scripter.waitForScreenUpdate();
}
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD); record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
} }
} }
@ -185,7 +187,9 @@ public class ReadHistoryCommand extends BaseCommand {
break; break;
} }
scripter.pressDownKey(); scripter.pressDownKey();
scripter.waitForScreenUpdate(); while (record == (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD)) {
scripter.waitForScreenUpdate();
}
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD); record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
} }
} }
@ -215,7 +219,9 @@ public class ReadHistoryCommand extends BaseCommand {
break; break;
} }
scripter.pressDownKey(); scripter.pressDownKey();
scripter.waitForScreenUpdate(); while (record == (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD)) {
scripter.waitForScreenUpdate();
}
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD); record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
} }
} }
@ -224,7 +230,7 @@ public class ReadHistoryCommand extends BaseCommand {
private Bolus readBolusRecord() { private Bolus readBolusRecord() {
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_DATA); scripter.verifyMenuIsDisplayed(MenuType.BOLUS_DATA);
BolusType bolusType = (BolusType) scripter.getCurrentMenu().getAttribute(MenuAttribute.BOLUS_TYPE); BolusType bolusType = (BolusType) scripter.getCurrentMenu().getAttribute(MenuAttribute.BOLUS_TYPE);
boolean isValid = bolusType == BolusType.NORMAL; boolean isValid = bolusType == BolusType.NORMAL;
Double bolus = (Double) scripter.getCurrentMenu().getAttribute(MenuAttribute.BOLUS); Double bolus = (Double) scripter.getCurrentMenu().getAttribute(MenuAttribute.BOLUS);
long recordDate = readRecordDate(); long recordDate = readRecordDate();
return new Bolus(recordDate, bolus, isValid); return new Bolus(recordDate, bolus, isValid);
@ -245,7 +251,9 @@ public class ReadHistoryCommand extends BaseCommand {
break; break;
} }
scripter.pressDownKey(); scripter.pressDownKey();
scripter.waitForScreenUpdate(); while (record == (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD)) {
scripter.waitForScreenUpdate();
}
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD); record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
} }
} }