From 46fdd47ac067a24675c1e4dd4c7f32bcddd43e2b Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 18 Nov 2017 19:37:31 +0100 Subject: [PATCH] Fixes and cleanups. --- .../androidaps/plugins/PumpCombo/ComboFragment.java | 4 ---- .../androidaps/plugins/PumpCombo/ComboPlugin.java | 4 +--- .../androidaps/plugins/PumpCombo/ComboPump.java | 1 - app/src/main/res/values-de/strings.xml | 2 +- .../main/java/de/jotomo/ruffyscripter/RuffyScripter.java | 9 +++++---- .../de/jotomo/ruffyscripter/commands/BolusCommand.java | 1 - .../de/jotomo/ruffyscripter/commands/SetTbrCommand.java | 2 -- .../androidaps/interaction/actions/BolusActivity.java | 2 +- .../interaction/actions/TempTargetActivity.java | 2 +- 9 files changed, 9 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java index e317432fd2..9ee23dac7a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java @@ -142,10 +142,6 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis } else if (plugin.getPump().lastSuccessfulCmdTime + 30 * 60 * 1000 < System.currentTimeMillis()) { lastConnectionView.setText(getString(R.string.combo_no_pump_connection, min)); lastConnectionView.setTextColor(Color.RED); - } else if (plugin.getPump().lastCmdTime > plugin.getPump().lastSuccessfulCmdTime) { - String lastFailed = minAgo + "\n" + getString(R.string.combo_connect_attempt_failed); - lastConnectionView.setText(lastFailed); - lastConnectionView.setTextColor(Color.YELLOW); } else { lastConnectionView.setText(minAgo); lastConnectionView.setTextColor(Color.WHITE); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index 89c00947f5..f1bd80e207 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -631,8 +631,6 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf * NO history, reservoir level fields are updated, this make be done separately if desired. */ private synchronized CommandResult runCommand(String activity, int retries, CommandExecution commandExecution) { - pump.lastCmdTime = System.currentTimeMillis(); - CommandResult commandResult; try { if (activity != null) { @@ -661,7 +659,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf } if (commandResult.success) { - pump.lastSuccessfulCmdTime = pump.lastCmdTime; + pump.lastSuccessfulCmdTime = System.currentTimeMillis(); } pump.lastCmdResult = commandResult; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java index 12c84d877d..be862e318e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java @@ -12,7 +12,6 @@ import de.jotomo.ruffy.spi.history.PumpHistory; class ComboPump { boolean initialized = false; volatile long lastSuccessfulCmdTime; - volatile long lastCmdTime; @Nullable volatile CommandResult lastCmdResult; diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 0124a850ad..6934f628ea 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -678,7 +678,7 @@ %d%% (%d verbleibend) Accu-Chek Combo settings Einstellungen Verbindungsaufbau fehlgeschlagen - Keine Verbindung zur Pumpe seit %s + Keine Verbindung zur Pumpe seit %d min Bolusabgabe gestopped Bolusabgabe wird abgebrochen Fehlerprotokol diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index 8468f2810a..1613857938 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -415,6 +415,7 @@ public class RuffyScripter implements RuffyCommands { MenuType type = menu.getType(); if (type != MenuType.WARNING_OR_ERROR && type != MenuType.MAIN_MENU) { try { + log.debug("Command execution yielded an error, returning to main menu"); returnToRootMenu(); } catch (Exception e) { log.warn("Error returning to main menu, when trying to recover from command failure", e); @@ -617,17 +618,17 @@ public class RuffyScripter implements RuffyCommands { } public void navigateToMenu(MenuType desiredMenu) { - int moviesLeft = 20; + int retries = 20; while (getCurrentMenu().getType() != desiredMenu) { - moviesLeft--; MenuType currentMenuType = getCurrentMenu().getType(); log.debug("Navigating to menu " + desiredMenu + ", current menu: " + currentMenuType); - if (moviesLeft == 0) { + retries--; + if (retries == 0) { throw new CommandException("Menu not found searching for " + desiredMenu + ". Check menu settings on your pump to ensure it's not hidden."); } pressMenuKey(); - waitForScreenUpdate(); + SystemClock.sleep(200); } } 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 febd4661e4..02a53e1fe2 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java @@ -158,7 +158,6 @@ public class BolusCommand extends BaseCommand { scripter.navigateToMenu(MenuType.BOLUS_MENU); scripter.verifyMenuIsDisplayed(MenuType.BOLUS_MENU); scripter.pressCheckKey(); - scripter.waitForScreenUpdate(); scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER); } 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 b82e73177f..117af2d302 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java @@ -70,7 +70,6 @@ public class SetTbrCommand extends BaseCommand { // switch to TBR_DURATION menu by pressing menu key scripter.verifyMenuIsDisplayed(MenuType.TBR_SET); scripter.pressMenuKey(); - scripter.waitForScreenUpdate(); scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION); boolean increasingDuration = inputTbrDuration(); @@ -88,7 +87,6 @@ public class SetTbrCommand extends BaseCommand { scripter.navigateToMenu(MenuType.TBR_MENU); scripter.verifyMenuIsDisplayed(MenuType.TBR_MENU); scripter.pressCheckKey(); - scripter.waitForScreenUpdate(); scripter.verifyMenuIsDisplayed(MenuType.TBR_SET); } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java index 814020d742..ed716b3bef 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java @@ -80,7 +80,7 @@ public class BolusActivity extends ViewSelectorActivity { if (editCarbs != null){ def = SafeParse.stringToDouble(editCarbs.editText.getText().toString()); } - editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), false); + editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 5d, new DecimalFormat("0"), false); setLabelToPlusMinusView(view, "carbs"); container.addView(view); return view; diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java index 4b04a72cdc..5c367fc0cb 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java @@ -96,7 +96,7 @@ public class TempTargetActivity extends ViewSelectorActivity { if (lowRange != null){ def = SafeParse.stringToDouble(lowRange.editText.getText().toString()); } - lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 72d, 180d, 1d, new DecimalFormat("0"), false); + lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 72d, 180d, 10d, new DecimalFormat("0"), false); } else { double def = 5.5; if (lowRange != null){