From 01def4c9b31cfb52bba51f5c0c2c70da2e8b3a90 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Mon, 23 Oct 2017 02:21:35 +0200 Subject: [PATCH] Optimize programming TBR and bolus. --- .../main/java/de/jotomo/ruffyscripter/RuffyScripter.java | 2 +- .../de/jotomo/ruffyscripter/commands/BolusCommand.java | 7 ++----- .../de/jotomo/ruffyscripter/commands/SetTbrCommand.java | 7 ++++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index 3c69906ea2..82fefab469 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -723,7 +723,7 @@ public class RuffyScripter implements RuffyCommands { private void pressKey(final byte key) { try { ruffyService.rtSendKey(key, true); - SystemClock.sleep(200); + SystemClock.sleep(150); ruffyService.rtSendKey(Key.NO_KEY, true); } catch (Exception e) { throw new CommandException().exception(e).message("Error while pressing buttons"); diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java index ab69d59dfd..e286bd6406 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java @@ -227,17 +227,14 @@ public class BolusCommand extends BaseCommand { for (int i = 0; i < steps; i++) { scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER); scripter.pressUpKey(); - SystemClock.sleep(100); + SystemClock.sleep(50); } - // Give the pump time to finish any scrolling that might still be going on, can take - // up to 1100ms. Plus some extra time to be sure - SystemClock.sleep(2000); } private void verifyDisplayedBolusAmount() { scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER); - // wait up to 5s for any scrolling to finish + // wait up to 10s for any scrolling to finish double displayedBolus = scripter.readBlinkingValue(Double.class, MenuAttribute.BOLUS); long timeout = System.currentTimeMillis() + 10 * 1000; while (timeout > System.currentTimeMillis() && bolus - displayedBolus > 0.05) { diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java index 18b39feeff..fd0016533b 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java @@ -117,9 +117,10 @@ public class SetTbrCommand extends BaseCommand { for (int i = 0; i < Math.abs(percentageSteps); i++) { scripter.verifyMenuIsDisplayed(MenuType.TBR_SET); log.debug("Push #" + (i + 1)); + log.debug("Push #" + (i + 1) + "/" + Math.abs(percentageSteps)); if (increasePercentage) scripter.pressUpKey(); else scripter.pressDownKey(); - SystemClock.sleep(100); + SystemClock.sleep(50); } return increasePercentage; } @@ -163,10 +164,10 @@ public class SetTbrCommand extends BaseCommand { log.debug("Pressing " + (increaseDuration ? "up" : "down") + " " + durationSteps + " times"); for (int i = 0; i < Math.abs(durationSteps); i++) { scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION); - log.debug("Push #" + (i + 1) + "/" + durationSteps); + log.debug("Push #" + (i + 1) + "/" + Math.abs(durationSteps)); if (increaseDuration) scripter.pressUpKey(); else scripter.pressDownKey(); - SystemClock.sleep(100); + SystemClock.sleep(50); } return increaseDuration; }