From ef650b80a18265fd55d08eb55f8b310070a40647 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Mon, 18 Jun 2018 15:39:39 +0200 Subject: [PATCH] Combo: show notification on broken setup. --- .../nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java | 5 +++++ .../plugins/PumpCombo/ruffyscripter/CommandResult.java | 3 ++- .../plugins/PumpCombo/ruffyscripter/RuffyScripter.java | 5 +++-- app/src/main/res/values/strings.xml | 3 ++- 4 files changed, 12 insertions(+), 4 deletions(-) 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 e591551f55..442e7bdd9f 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 @@ -354,6 +354,11 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint // trigger a connect, which will update state and check history CommandResult stateResult = runCommand(null, 1, ruffyScripter::readPumpState); + if (stateResult.invalidSetup) { + MainApp.bus().post(new EventNewNotification( + new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_invalid_setup), Notification.URGENT))); + return; + } if (!stateResult.success) { return; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/CommandResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/CommandResult.java index 9da5d4d6fa..b595d13d28 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/CommandResult.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/CommandResult.java @@ -5,10 +5,11 @@ import android.support.annotation.Nullable; import java.util.LinkedList; import java.util.List; -import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistory; public class CommandResult { + /** True if a condition indicating a broken pump setup/configuration is detected */ + public boolean invalidSetup; /** Whether the command was executed successfully. */ public boolean success; /** State of the pump *after* command execution. */ diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/RuffyScripter.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/RuffyScripter.java index 1e7e542e5f..5b569e479e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/RuffyScripter.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/RuffyScripter.java @@ -281,10 +281,10 @@ public class RuffyScripter implements RuffyCommands { log.debug("Executing " + cmd + " took " + (cmdEndTime - cmdStartTime) + "ms"); } catch (CommandException e) { log.error("CommandException running command", e); - activeCmd.getResult().success = false; + cmd.getResult().success = false; } catch (Exception e) { log.error("Unexpected exception running cmd", e); - activeCmd.getResult().success = false; + cmd.getResult().success = false; } }, cmd.getClass().getSimpleName()); long executionStart = System.currentTimeMillis(); @@ -328,6 +328,7 @@ public class RuffyScripter implements RuffyCommands { if (unparsableMenuEncountered) { log.error("UnparsableMenuEncountered flagged, aborting command"); cmdThread.interrupt(); + activeCmd.getResult().invalidSetup = true; activeCmd.getResult().success = false; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cffe9a2421..4dbb471618 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1162,7 +1162,8 @@ %1$d. Objective Poctech Receive BG values from Poctech app - + Invalid pump setup, check the docs and verify that the Quick Info menu is named "QUICK INFO" using the 360 configuration software. + %d day %d days