Increase timeouts.

90s until timeout due to no menu updates
60s timeout for operations (waitForMenuToBeLeft, verifyMenuIsDisplayed).
This commit is contained in:
Johannes Mockenhaupt 2017-07-22 11:34:28 +02:00
parent b3a7585a52
commit a153b59d5d
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
3 changed files with 16 additions and 6 deletions

View file

@ -236,8 +236,9 @@ public class RuffyScripter {
}, cmd.toString());
cmdThread.start();
// time out if nothing has been happening for more than 30s or after 4m
long dynamicTimeout = System.currentTimeMillis() + 30 * 1000;
// time out if nothing has been happening for more than 90s or after 4m
// (to fail before the next loop iteration issues the next command)
long dynamicTimeout = System.currentTimeMillis() + 90 * 1000;
long overallTimeout = System.currentTimeMillis() + 4 * 60 * 1000;
while (cmdThread.isAlive()) {
log.trace("Waiting for running command to complete");
@ -394,7 +395,7 @@ public class RuffyScripter {
* Wait till a menu changed has completed, "away" from the menu provided as argument.
*/
public void waitForMenuToBeLeft(MenuType menuType) {
long timeout = System.currentTimeMillis() + 30 * 1000;
long timeout = System.currentTimeMillis() + 60 * 1000;
while (currentMenu.getType() == menuType) {
if (System.currentTimeMillis() > timeout) {
throw new CommandException().message("Timeout waiting for menu " + menuType + " to be left");
@ -408,10 +409,10 @@ public class RuffyScripter {
}
public void verifyMenuIsDisplayed(MenuType expectedMenu, String failureMessage) {
int retries = 5;
int retries = 600;
while (currentMenu.getType() != expectedMenu) {
if (retries > 0) {
SystemClock.sleep(200);
SystemClock.sleep(100);
retries = retries - 1;
} else {
if (failureMessage == null) {

View file

@ -45,6 +45,7 @@ public class BolusCommand implements Command {
while (!bolusAmountInputSuccess) {
try {
inputBolusAmount(scripter);
// TODO v2 this call can probably be removed by now
SystemClock.sleep(750);
verifyDisplayedBolusAmount(scripter);
bolusAmountInputSuccess = true;
@ -69,7 +70,8 @@ public class BolusCommand implements Command {
"Pump did not return to MAIN_MEU from BOLUS_ENTER to deliver bolus. "
+ "Check pump manually, the bolus might not have been delivered.");
// wait for bolus delivery to complete
// wait for bolus delivery to complete; the remaining units to deliver are counted
// down and are displayed on the main menu.
Double bolusRemaining = (Double) scripter.currentMenu.getAttribute(MenuAttribute.BOLUS_REMAINING);
while (bolusRemaining != null) {
log.debug("Delivering bolus, remaining: " + bolusRemaining);
@ -122,7 +124,9 @@ public class BolusCommand implements Command {
}
private double readDisplayedBolusAmount(RuffyScripter scripter) {
// TODO v2 add timeout? Currently the command execution timeout would trigger if exceeded
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
// bolus amount is blinking, so we need to make sure we catch it at the right moment
Object amountObj = scripter.currentMenu.getAttribute(MenuAttribute.BOLUS);
while (!(amountObj instanceof Double)) {
scripter.waitForMenuUpdate();

View file

@ -72,6 +72,7 @@ public class SetTbrCommand implements Command {
while (!tbrPercentInputSuccess) {
try {
inputTbrPercentage(scripter);
// TODO v2 this can probably be removed by now
SystemClock.sleep(750);
verifyDisplayedTbrPercentage(scripter);
tbrPercentInputSuccess = true;
@ -96,9 +97,11 @@ public class SetTbrCommand implements Command {
boolean tbrDurationSuccess = false;
int tbrDurationRetries = 2;
// see above why we loop here
while (!tbrDurationSuccess) {
try {
inputTbrDuration(scripter);
// TODO v2 this can probably be removed by now
SystemClock.sleep(750);
verifyDisplayedTbrDuration(scripter);
tbrDurationSuccess = true;
@ -176,6 +179,7 @@ public class SetTbrCommand implements Command {
}
private long readDisplayedTbrPercentage(RuffyScripter scripter) {
// TODO v2 add timeout? Currently the command execution timeout would trigger if exceeded
Object percentageObj = scripter.currentMenu.getAttribute(MenuAttribute.BASAL_RATE);
// this as a bit hacky, the display value is blinking, so we might catch that, so
// keep trying till we get the Double we want
@ -228,6 +232,7 @@ public class SetTbrCommand implements Command {
}
private long readDisplayedTbrDuration(RuffyScripter scripter) {
// TODO v2 add timeout? Currently the command execution timeout would trigger if exceeded
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
Object durationObj = scripter.currentMenu.getAttribute(MenuAttribute.RUNTIME);
// this as a bit hacky, the display value is blinking, so we might catch that, so