Add option to ignore setting a TBR as long as it does't occur twice in a row.

(cherry picked from commit 238e85c)
This commit is contained in:
Johannes Mockenhaupt 2017-08-31 23:26:55 +02:00
parent 6019323740
commit 81b97b5278
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
3 changed files with 24 additions and 2 deletions

View file

@ -67,6 +67,8 @@ public class ComboPlugin implements PluginBase, PumpInterface {
private ComboPump pump = new ComboPump();
private boolean ignoreLastSetTbrFailure = false;
@Nullable
private volatile BolusCommand runningBolusCommand;
@ -98,7 +100,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
pumpDescription.isTempBasalCapable = true;
pumpDescription.tempBasalStyle = PumpDescription.PERCENT;
pumpDescription.maxTempPercent = SP.getInt(COMBO_MAX_TEMP_PERCENT_SP, 500);
pumpDescription.maxTempPercent = 500;
pumpDescription.tempPercentStep = 10;
pumpDescription.tempDurationStep = 15;
@ -139,7 +141,8 @@ public class ComboPlugin implements PluginBase, PumpInterface {
long now = System.currentTimeMillis();
long fiveMinutesSinceLastAlarm = lastAlarmTime + (5 * 60 * 1000) + (15 * 1000);
boolean loopEnabled = ConfigBuilderPlugin.getActiveLoop() != null;
if (now > fiveMinutesSinceLastAlarm && loopEnabled) {
if (now > fiveMinutesSinceLastAlarm && loopEnabled
&& !(SP.getBoolean(R.string.key_combo_ignore_transient_tbr_errors, false) && localLastCmd instanceof SetTbrCommand && ignoreLastSetTbrFailure)) {
log.error("Command failed: " + localLastCmd);
log.error("Command result: " + localLastCmdResult);
PumpState localPumpState = pump.state;
@ -505,6 +508,19 @@ public class ComboPlugin implements PluginBase, PumpInterface {
log.error("Exception received from pump", commandResult.exception);
}
// error tolerance
if (commandResult.success) ignoreLastSetTbrFailure = false;
if (command instanceof SetTbrCommand) {
if (!commandResult.success && !ignoreLastSetTbrFailure) {
// ignore this once
ignoreLastSetTbrFailure = true;
} else {
// second failure in a row
ignoreLastSetTbrFailure = false;
}
}
pump.lastCmd = command;
pump.lastCmdTime = new Date();
pump.lastCmdResult = commandResult;

View file

@ -718,5 +718,7 @@
<string name="combo_enable_experimental_bolus">Experimental bolus</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_ignore_transient_tbr_errors">combo_ignore_transient_tbr_errors</string>
<string name="combo_ignore_transient_tbr_errors">Ignore transient TBR errors</string>
</resources>

View file

@ -18,6 +18,10 @@
android:defaultValue="false"
android:key="@string/key_combo_enable_experimental_split_bolus"
android:title="@string/combo_enable_experimental_split_bolus" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_combo_ignore_transient_tbr_errors"
android:title="@string/combo_ignore_transient_tbr_errors" />
</PreferenceCategory>