From e8d169f0784a7f60750479b2a74769402a9b820d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 10 Nov 2016 23:32:58 +0100 Subject: [PATCH] allow automated actions only whem pump is initialized --- .../androidaps/interfaces/PumpInterface.java | 2 ++ .../ConfigBuilder/ConfigBuilderPlugin.java | 20 +++++++++++++++---- .../androidaps/plugins/DanaR/DanaRPlugin.java | 5 +++++ .../plugins/MM640g/MM640gPlugin.java | 5 +++++ .../VirtualPump/VirtualPumpPlugin.java | 5 +++++ app/src/main/res/values/strings.xml | 1 + 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java index c9159e6177..2b413fbe43 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java @@ -16,6 +16,8 @@ import info.nightscout.client.data.NSProfile; */ public interface PumpInterface { + boolean isInitialized(); + boolean isTempBasalInProgress(); boolean isExtendedBoluslInProgress(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index b6da667701..e3df07d326 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -294,10 +294,15 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain } /* - * Pump interface - * - * Config builder return itself as a pump and check constraints before it passes command to pump driver - */ + * Pump interface + * + * Config builder return itself as a pump and check constraints before it passes command to pump driver + */ + @Override + public boolean isInitialized() { + return activePump.isInitialized(); + } + @Override public boolean isTempBasalInProgress() { return activePump.isTempBasalInProgress(); @@ -527,6 +532,13 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain request.rate = applyBasalConstraints(request.rate); PumpEnactResult result; + if (!isInitialized()) { + result = new PumpEnactResult(); + result.comment = MainApp.sResources.getString(R.string.pumpNotInitialized); + result.enacted = false; + result.success = false; + } + if (Config.logCongigBuilderActions) log.debug("applyAPSRequest: " + request.toString()); if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - getBaseBasalRate()) < 0.05) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java index d5d7966a56..5501319e99 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java @@ -150,6 +150,11 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf this.fragmentPumpVisible = fragmentVisible; } + @Override + public boolean isInitialized() { + return getDanaRPump().lastConnection.getTime() > 0; + } + // Pump interface @Override public boolean isTempBasalInProgress() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/MM640g/MM640gPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/MM640g/MM640gPlugin.java index 6fd3ea5493..7361054a3e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/MM640g/MM640gPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/MM640g/MM640gPlugin.java @@ -94,6 +94,11 @@ public class MM640gPlugin implements PluginBase, PumpInterface, BgSourceInterfac * Pump Interface */ + @Override + public boolean isInitialized() { + return false; + } + @Override public boolean isTempBasalInProgress() { return false; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/VirtualPump/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/VirtualPump/VirtualPumpPlugin.java index a5f05acbc6..99508d2c7e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/VirtualPump/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/VirtualPump/VirtualPumpPlugin.java @@ -77,6 +77,11 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface { return PluginBase.PUMP; } + @Override + public boolean isInitialized() { + return true; + } + @Override public boolean isTempBasalInProgress() { return getTempBasal() != null; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9e05a98082..096df23039 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -339,4 +339,5 @@ NS upload only (disabled sync) NS upload only. Not effective on SGV unless a local source like xDrip is selected. Not effective on Profiles while NS-Profiles is used. Please deactivate "NS upload only" to use this feature. + Pump not initialized!