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:
parent
1897051782
commit
1f14f37373
|
@ -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 +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -12,7 +13,7 @@ import de.jotomo.ruffy.spi.BasalProfile;
|
||||||
|
|
||||||
public class ReadBasalProfileCommand extends BaseCommand {
|
public class ReadBasalProfileCommand extends BaseCommand {
|
||||||
private static final Logger log = LoggerFactory.getLogger(ReadBasalProfileCommand.class);
|
private static final Logger log = LoggerFactory.getLogger(ReadBasalProfileCommand.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
scripter.navigateToMenu(MenuType.BASAL_1_MENU);
|
scripter.navigateToMenu(MenuType.BASAL_1_MENU);
|
||||||
|
@ -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()) {
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue