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:
parent
6019323740
commit
81b97b5278
3 changed files with 24 additions and 2 deletions
|
@ -67,6 +67,8 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
|
|
||||||
private ComboPump pump = new ComboPump();
|
private ComboPump pump = new ComboPump();
|
||||||
|
|
||||||
|
private boolean ignoreLastSetTbrFailure = false;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private volatile BolusCommand runningBolusCommand;
|
private volatile BolusCommand runningBolusCommand;
|
||||||
|
|
||||||
|
@ -98,7 +100,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
pumpDescription.isTempBasalCapable = true;
|
pumpDescription.isTempBasalCapable = true;
|
||||||
pumpDescription.tempBasalStyle = PumpDescription.PERCENT;
|
pumpDescription.tempBasalStyle = PumpDescription.PERCENT;
|
||||||
|
|
||||||
pumpDescription.maxTempPercent = SP.getInt(COMBO_MAX_TEMP_PERCENT_SP, 500);
|
pumpDescription.maxTempPercent = 500;
|
||||||
pumpDescription.tempPercentStep = 10;
|
pumpDescription.tempPercentStep = 10;
|
||||||
|
|
||||||
pumpDescription.tempDurationStep = 15;
|
pumpDescription.tempDurationStep = 15;
|
||||||
|
@ -139,7 +141,8 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
long fiveMinutesSinceLastAlarm = lastAlarmTime + (5 * 60 * 1000) + (15 * 1000);
|
long fiveMinutesSinceLastAlarm = lastAlarmTime + (5 * 60 * 1000) + (15 * 1000);
|
||||||
boolean loopEnabled = ConfigBuilderPlugin.getActiveLoop() != null;
|
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 failed: " + localLastCmd);
|
||||||
log.error("Command result: " + localLastCmdResult);
|
log.error("Command result: " + localLastCmdResult);
|
||||||
PumpState localPumpState = pump.state;
|
PumpState localPumpState = pump.state;
|
||||||
|
@ -505,6 +508,19 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
log.error("Exception received from pump", commandResult.exception);
|
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.lastCmd = command;
|
||||||
pump.lastCmdTime = new Date();
|
pump.lastCmdTime = new Date();
|
||||||
pump.lastCmdResult = commandResult;
|
pump.lastCmdResult = commandResult;
|
||||||
|
|
|
@ -718,5 +718,7 @@
|
||||||
<string name="combo_enable_experimental_bolus">Experimental bolus</string>
|
<string name="combo_enable_experimental_bolus">Experimental bolus</string>
|
||||||
<string name="key_combo_enable_experimental_split_bolus">combo_experimental_split_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="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>
|
</resources>
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="@string/key_combo_enable_experimental_split_bolus"
|
android:key="@string/key_combo_enable_experimental_split_bolus"
|
||||||
android:title="@string/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>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue