From fd7f4ae1450c1c19617d3ddcd4b5b9a1f64fc156 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 3 Sep 2017 22:05:44 +0200 Subject: [PATCH] Option to ignore TBR failures: also ignore errors when reading pump state. (cherry picked from commit 82052e8) --- .../plugins/PumpCombo/ComboPlugin.java | 19 ++++++++++--------- app/src/main/res/values/strings.xml | 18 +++++++++--------- app/src/main/res/xml/pref_combo.xml | 12 ++++++------ 3 files changed, 25 insertions(+), 24 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 abf29a5acd..0203708d87 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 @@ -67,7 +67,7 @@ public class ComboPlugin implements PluginBase, PumpInterface { private ComboPump pump = new ComboPump(); - private boolean ignoreLastSetTbrFailure = false; + private boolean ignoreLastSetTbrOrReadStateFailure = false; @Nullable private volatile BolusCommand runningBolusCommand; @@ -143,8 +143,9 @@ public class ComboPlugin implements PluginBase, PumpInterface { long fiveMinutesSinceLastAlarm = lastAlarmTime + (5 * 60 * 1000) + (15 * 1000); boolean loopEnabled = ConfigBuilderPlugin.getActiveLoop() != null; boolean ignoreLastFailedTbrCmd = SP.getBoolean(R.string.key_combo_enable_experimental_features, false) - && SP.getBoolean(R.string.key_combo_experimental_ignore_transient_tbr_errors, false) - && localLastCmd instanceof SetTbrCommand && ignoreLastSetTbrFailure; + && SP.getBoolean(R.string.key_combo_experimental_ignore_transient_errors, false) + && (localLastCmd instanceof SetTbrCommand || localLastCmd instanceof GetPumpStateCommand) + && ignoreLastSetTbrOrReadStateFailure; if (now > fiveMinutesSinceLastAlarm && loopEnabled && !ignoreLastFailedTbrCmd) { log.error("Command failed: " + localLastCmd); log.error("Command result: " + localLastCmdResult); @@ -514,15 +515,15 @@ public class ComboPlugin implements PluginBase, PumpInterface { } // error tolerance - if (commandResult.success) ignoreLastSetTbrFailure = false; + if (commandResult.success) ignoreLastSetTbrOrReadStateFailure = false; - if (command instanceof SetTbrCommand) { - if (!commandResult.success && !ignoreLastSetTbrFailure) { + if (command instanceof SetTbrCommand || command instanceof GetPumpStateCommand) { + if (!commandResult.success && !ignoreLastSetTbrOrReadStateFailure) { // ignore this once - ignoreLastSetTbrFailure = true; + ignoreLastSetTbrOrReadStateFailure = true; } else { // second failure in a row - ignoreLastSetTbrFailure = false; + ignoreLastSetTbrOrReadStateFailure = false; } } @@ -559,7 +560,7 @@ public class ComboPlugin implements PluginBase, PumpInterface { TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()); if (!force && activeTemp != null) { - int minRequiredDelta = SP.getInt(R.string.key_combo_experimental_reject_tbr_changes_below_delta, 0); + int minRequiredDelta = SP.getInt(R.string.key_combo_experimental_skip_tbr_changes_below_delta, 0); boolean deltaBelowThreshold = Math.abs(activeTemp.percentRate - roundedPercentage) < minRequiredDelta; if (deltaBelowThreshold) { log.debug("Skipping setting APS-requested TBR change, since the requested change from " diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 470b827667..14ff96af76 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -714,19 +714,19 @@ Bolus delivery stopped combo_enable_experimental_features Enable experimental features + Unlocks experimental features which are in development and might be broken entirely. combo_enable_experimental_bolus Experimental bolus + Enables the in-development bolus with progress report and cancel option. combo_experimental_split_bolus Experimental split bolus feature - combo_ignore_transient_tbr_errors - Ignore transient TBR errors - combo_experimental_reject_tbr_changes_below_delta - Reject TBR changes below threshold (%) - Don\'t set a TBR if the difference between the new and a running TBR is below this threshold in percent. Specifying 0 disables this option. - Ignore failures when setting a TBR, unless setting the next TBR also fails. - Splits boluses into 2 U parts and waits around 45 after each to slow down bolus delivery (only active with non-experimental bolus). - Enables the in-development bolus with progress report and cancel option. - Unlocks experimental features which are in development and might be broken entirely. + Splits boluses into 2 U parts and waits around 45s after each to slow down bolus delivery (only active with non-experimental bolus). + combo_ignore_transient_tbr_errors + Ignore transient errors + Ignore failures when setting a TBR or reading pump state, unless the next attempt also fails. + combo_experimental_reject_tbr_changes_below_delta + Skip TBR changes below threshold (%). + Don\'t set a TBR if the difference between the new and a running TBR is below this threshold in percent. Specifying 0 disables this option. combo_disable_alerts Dentist appointment mode Ignore all errors encountered while communicating with the pump. diff --git a/app/src/main/res/xml/pref_combo.xml b/app/src/main/res/xml/pref_combo.xml index 9e2927d4cf..052f7e0d49 100644 --- a/app/src/main/res/xml/pref_combo.xml +++ b/app/src/main/res/xml/pref_combo.xml @@ -25,18 +25,18 @@ + android:key="@string/key_combo_experimental_ignore_transient_errors" + android:title="@string/combo_experimental_ignore_transient_errors" + android:summary="@string/combo_experimental_ignore_transient_errors_summary"/> + android:dialogMessage="@string/combo_experimental_skip_tbr_changes_below_delta_summary"/>