diff --git a/app/src/main/java/de/jotomo/ruffyscripter/PumpState.java b/app/src/main/java/de/jotomo/ruffyscripter/PumpState.java index 80a77a952a..910f421a14 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/PumpState.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/PumpState.java @@ -12,6 +12,7 @@ public class PumpState { public double tbrRate = -1; public int tbrRemainingDuration = -1; public String errorMsg; + public boolean suspended; public PumpState tbrActive(boolean tbrActive) { this.tbrActive = tbrActive; @@ -38,6 +39,11 @@ public class PumpState { return this; } + public PumpState suspended(boolean suspended) { + this.suspended = suspended; + return this; + } + @Override public String toString() { return "PumpState{" + @@ -46,6 +52,7 @@ public class PumpState { ", tbrRate=" + tbrRate + ", tbrRemainingDuration=" + tbrRemainingDuration + ", errorMsg=" + errorMsg + + ", suspended=" + suspended + ", timestamp=" + timestamp + '}'; } diff --git a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index 8f3ddf4773..dbfb66d755 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -195,6 +195,11 @@ public class RuffyScripter { return; } } + // don't execute anything if STOP menu is shown (pump is noisy already and user is probably changing the cartridge) + if (currentMenu == null || currentMenu.getType() == MenuType.STOP) { + returnable.cmdResult = new CommandResult().success(true).enacted(false); + return; + } log.debug("Cmd execution: connection ready, executing cmd " + cmd); returnable.cmdResult = cmd.execute(scripter); } catch (CommandException e) { @@ -401,6 +406,8 @@ public class RuffyScripter { } } else if (menuType == MenuType.WARNING_OR_ERROR) { state.errorMsg = (String) menu.getAttribute(MenuAttribute.MESSAGE); + } else if (menuType == MenuType.STOP) { + state.suspended = true; } else { StringBuilder sb = new StringBuilder(); for (MenuAttribute menuAttribute : menu.attributes()) { 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 ffab6d9c31..793e06168e 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 @@ -129,7 +129,8 @@ public class ComboPlugin implements PluginBase, PumpInterface { int id = 1000; long lastAlarmTime = 0; while (true) { - String errorMsg = pumpState.errorMsg; + PumpState ps = ComboPlugin.this.pumpState; + String errorMsg = ps.errorMsg; if (errorMsg != null) { long now = System.currentTimeMillis(); long fiveMinutesSinceLastAlarm = lastAlarmTime + (5 * 60 * 1000) + (15 * 1000); @@ -155,7 +156,7 @@ public class ComboPlugin implements PluginBase, PumpInterface { log.warn("Pump still in error state, but alarm raised recently, so not triggering again: " + errorMsg); } } else { - log.trace("Pump state normal"); + log.trace("Pump state: " + (ps.suspended ? "suspended" : "normal")); } SystemClock.sleep(5 * 1000); }