Trim combo prefs.

This commit is contained in:
Johannes Mockenhaupt 2017-10-17 19:37:32 +02:00
parent 64ecf84174
commit f33d55b092
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
3 changed files with 9 additions and 67 deletions

View file

@ -324,39 +324,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
if (detailedBolusInfo.insulin > 0) {
// bolus needed, ask pump to deliver it
if (!(SP.getBoolean(R.string.key_combo_enable_experimental_features, false)
&& SP.getBoolean(R.string.key_combo_enable_experimental_split_bolus, false))) {
return deliverBolus(detailedBolusInfo);
} else {
// split up bolus into 2 U parts
PumpEnactResult pumpEnactResult = new PumpEnactResult();
pumpEnactResult.success = true;
pumpEnactResult.enacted = true;
pumpEnactResult.bolusDelivered = 0d;
pumpEnactResult.carbsDelivered = detailedBolusInfo.carbs;
double remainingBolus = detailedBolusInfo.insulin;
int split = 1;
while (remainingBolus > 0.05) {
double bolus = remainingBolus > 2 ? 2 : remainingBolus;
DetailedBolusInfo bolusInfo = new DetailedBolusInfo();
bolusInfo.insulin = bolus;
bolusInfo.isValid = false;
log.debug("Delivering split bolus #" + split + " with " + bolus + " U");
PumpEnactResult bolusResult = deliverBolus(bolusInfo);
if (!bolusResult.success) {
return bolusResult;
}
pumpEnactResult.bolusDelivered += bolus;
remainingBolus -= 2;
split++;
// Programming the pump for 2 U takes ~20, so wait 20s more so the
// boluses are spaced 40s apart.
SystemClock.sleep(20 * 1000);
}
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
return pumpEnactResult;
}
} else {
// no bolus required, carb only treatment
@ -438,19 +406,6 @@ public class ComboPlugin implements PluginBase, PumpInterface {
log.debug("Rounded requested rate " + unroundedPercentage + "% -> " + roundedPercentage + "%");
}
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (!force && activeTemp != null) {
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 "
+ activeTemp.percentRate + " -> " + roundedPercentage + " is below the delta threshold of " + minRequiredDelta);
PumpEnactResult pumpEnactResult = new PumpEnactResult();
pumpEnactResult.success = true;
pumpEnactResult.enacted = false;
return pumpEnactResult;
}
}
return setTempBasalPercent(roundedPercentage, durationInMinutes);
}

View file

@ -754,15 +754,12 @@
<string name="key_combo_enable_experimental_features" translatable="false">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_split_bolus" translatable="false">combo_experimental_split_bolus</string>
<string name="combo_enable_experimental_split_bolus">Experimental split bolus feature</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_skip_tbr_changes_below_delta" translatable="false">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_experimental_ignore_transient_errors" translatable="false">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 a connect failure for a background operation untless the next attempt also fails.</string>
<string name="key_combo_disable_alerts" translatable="false">combo_disable_alerts</string>
<string name="combo_disable_alerts">Disable alerts</string>
<string name="combo_disable_alerts_summary">Ignore all errors encountered while communicating with the pump. Alerts raised by the pump (including those caused by AAPS) will still be raised.</string>
<string name="combo_disable_alerts_summary">Ignore all errors encountered while communicating with the pump. Alerts raised by the pump (including those caused by AndroidAPS) will still be raised on the pump.</string>
<string name="bolusprogramming">Programming pump for bolusing</string>
</resources>

View file

@ -12,25 +12,15 @@
<SwitchPreference
android:dependency="@string/key_combo_enable_experimental_features"
android:defaultValue="false"
android:key="@string/key_combo_enable_experimental_split_bolus"
android:title="@string/combo_enable_experimental_split_bolus"
android:summary="@string/combo_enable_experimental_split_bolus_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_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_skip_tbr_changes_below_delta_summary"/>
android:key="@string/key_combo_experimental_ignore_transient_errors"
android:summary="@string/combo_experimental_ignore_transient_errors_summary"
android:title="@string/combo_experimental_ignore_transient_errors" />
<SwitchPreference
android:dependency="@string/key_combo_enable_experimental_features"
android:defaultValue="false"
android:key="@string/key_combo_disable_alerts"
android:title="@string/combo_disable_alerts"
android:summary="@string/combo_disable_alerts_summary"/>
</PreferenceCategory>
</PreferenceScreen>