Option to ignore TBR failures: also ignore errors when reading pump state.

(cherry picked from commit 82052e8)
This commit is contained in:
Johannes Mockenhaupt 2017-09-03 22:05:44 +02:00
parent a33d7db471
commit fd7f4ae145
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
3 changed files with 25 additions and 24 deletions

View file

@ -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 "

View file

@ -714,19 +714,19 @@
<string name="bolusstopped">Bolus delivery stopped</string>
<string name="key_combo_enable_experimental_features">combo_enable_experimental_features</string>
<string name="combo_enable_experimental_features">Enable experimental features</string>
<string name="combo_enable_experimental_features_summary">Unlocks experimental features which are in development and might be broken entirely.</string>
<string name="key_combo_enable_experimental_bolus">combo_enable_experimental_bolus</string>
<string name="combo_enable_experimental_bolus">Experimental bolus</string>
<string name="combo_enable_experimental_bolus_summary">Enables the in-development bolus with progress report and cancel option.</string>
<string name="key_combo_enable_experimental_split_bolus">combo_experimental_split_bolus</string>
<string name="combo_enable_experimental_split_bolus">Experimental split bolus feature</string>
<string name="key_combo_experimental_ignore_transient_tbr_errors">combo_ignore_transient_tbr_errors</string>
<string name="combo_experimental_ignore_transient_tbr_errors">Ignore transient TBR errors</string>
<string name="key_combo_experimental_reject_tbr_changes_below_delta">combo_experimental_reject_tbr_changes_below_delta</string>
<string name="combo_experimental_reject_tbr_changes_below_delta">Reject TBR changes below threshold (%)</string>
<string name="combo_experimental_reject_tbr_changes_below_delta_summary">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.</string>
<string name="combo_experimental_ignore_transient_tbr_errors_summary">Ignore failures when setting a TBR, unless setting the next TBR also fails.</string>
<string name="combo_enable_experimental_split_bolus_summary">Splits boluses into 2 U parts and waits around 45 after each to slow down bolus delivery (only active with non-experimental bolus).</string>
<string name="combo_enable_experimental_bolus_summary">Enables the in-development bolus with progress report and cancel option.</string>
<string name="combo_enable_experimental_features_summary">Unlocks experimental features which are in development and might be broken entirely.</string>
<string name="combo_enable_experimental_split_bolus_summary">Splits boluses into 2 U parts and waits around 45s after each to slow down bolus delivery (only active with non-experimental bolus).</string>
<string name="key_combo_experimental_ignore_transient_errors">combo_ignore_transient_tbr_errors</string>
<string name="combo_experimental_ignore_transient_errors">Ignore transient errors</string>
<string name="combo_experimental_ignore_transient_errors_summary">Ignore failures when setting a TBR or reading pump state, unless the next attempt also fails.</string>
<string name="key_combo_experimental_skip_tbr_changes_below_delta">combo_experimental_reject_tbr_changes_below_delta</string>
<string name="combo_experimental_skip_tbr_changes_below_delta">Skip TBR changes below threshold (%).</string>
<string name="combo_experimental_skip_tbr_changes_below_delta_summary">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.</string>
<string name="key_combo_disable_alerts">combo_disable_alerts</string>
<string name="combo_disable_alerts">Dentist appointment mode</string>
<string name="combo_disable_alerts_summary">Ignore all errors encountered while communicating with the pump.</string>

View file

@ -25,18 +25,18 @@
<SwitchPreference
android:dependency="@string/key_combo_enable_experimental_features"
android:defaultValue="false"
android:key="@string/key_combo_experimental_ignore_transient_tbr_errors"
android:title="@string/combo_experimental_ignore_transient_tbr_errors"
android:summary="@string/combo_experimental_ignore_transient_tbr_errors_summary"/>
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"/>
<!-- TODO add validation, to restrict values to rang 0-100, see pref_absorption_oref0.xml -->
<EditTextPreference
android:dependency="@string/key_combo_enable_experimental_features"
android:key="@string/key_combo_experimental_reject_tbr_changes_below_delta"
android:title="@string/combo_experimental_reject_tbr_changes_below_delta"
android:key="@string/key_combo_experimental_skip_tbr_changes_below_delta"
android:title="@string/combo_experimental_skip_tbr_changes_below_delta"
android:defaultValue="0"
android:numeric="decimal"
android:dialogMessage="@string/combo_experimental_reject_tbr_changes_below_delta_summary"/>
android:dialogMessage="@string/combo_experimental_skip_tbr_changes_below_delta_summary"/>
<SwitchPreference
android:defaultValue="false"