From a153b59d5d754ba28d61e81234b8b5656cd35123 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 22 Jul 2017 11:34:28 +0200 Subject: [PATCH] Increase timeouts. 90s until timeout due to no menu updates 60s timeout for operations (waitForMenuToBeLeft, verifyMenuIsDisplayed). --- .../java/de/jotomo/ruffyscripter/RuffyScripter.java | 11 ++++++----- .../jotomo/ruffyscripter/commands/BolusCommand.java | 6 +++++- .../jotomo/ruffyscripter/commands/SetTbrCommand.java | 5 +++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index 9bbb4dbca5..87000131a7 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -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) { diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java index 706925985c..acf88c36c0 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java @@ -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(); diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java index 7a687b2331..26f70a4e7d 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java @@ -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