SMB options in preferences

This commit is contained in:
Milos Kozak 2018-01-27 14:47:04 +01:00
parent 4af8e14417
commit 296d5059d6
10 changed files with 78 additions and 10 deletions

View file

@ -4,4 +4,5 @@ package info.nightscout.androidaps.interfaces;
* Created by mike on 20.06.2016.
*/
public interface BgSourceInterface {
boolean advancedFilteringSupported();
}

View file

@ -27,6 +27,7 @@ import info.nightscout.androidaps.data.MealData;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback;
@ -243,11 +244,11 @@ public class DetermineBasalAdapterSMBJS {
mProfile.put("remainingCarbsCap", SMBDefaults.remainingCarbsCap);
mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false));
mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable);
mProfile.put("enableSMB_always", SP.getBoolean(R.string.key_use_smb, false) && (SourceDexcomG5Plugin.getPlugin().isEnabled(PluginBase.BGSOURCE) || SMBDefaults.enableSMB_always));
mProfile.put("enableSMB_with_COB", SP.getBoolean(R.string.key_use_smb, false) && SMBDefaults.enableSMB_with_COB);
mProfile.put("enableSMB_with_temptarget", SP.getBoolean(R.string.key_use_smb, false) && SMBDefaults.enableSMB_with_temptarget);
mProfile.put("enableSMB_after_carbs", SP.getBoolean(R.string.key_use_smb, false) && (SourceDexcomG5Plugin.getPlugin().isEnabled(PluginBase.BGSOURCE) || SMBDefaults.enableSMB_after_carbs));
mProfile.put("allowSMB_with_high_temptarget", SP.getBoolean(R.string.key_use_smb, false) && SMBDefaults.allowSMB_with_high_temptarget);
mProfile.put("enableSMB_with_COB", SP.getBoolean(R.string.key_use_smb, false) && SP.getBoolean(R.string.key_enableSMB_with_COB, false));
mProfile.put("enableSMB_with_temptarget", SP.getBoolean(R.string.key_use_smb, false) && SP.getBoolean(R.string.key_enableSMB_with_temptarget, false));
mProfile.put("allowSMB_with_high_temptarget", SP.getBoolean(R.string.key_use_smb, false) && SP.getBoolean(R.string.key_allowSMB_with_high_temptarget, false));
mProfile.put("enableSMB_always", SP.getBoolean(R.string.key_use_smb, false) && SP.getBoolean(R.string.key_enableSMB_always, false) && ConfigBuilderPlugin.getActiveBgSource().advancedFilteringSupported());
mProfile.put("enableSMB_after_carbs", SP.getBoolean(R.string.key_use_smb, false) && SP.getBoolean(R.string.key_enableSMB_after_carbs, false) && ConfigBuilderPlugin.getActiveBgSource().advancedFilteringSupported());
mProfile.put("maxSMBBasalMinutes", SP.getInt("key_smbmaxminutes", SMBDefaults.maxSMBBasalMinutes));
mProfile.put("carbsReqThreshold", SMBDefaults.carbsReqThreshold);

View file

@ -45,16 +45,16 @@ public class SMBDefaults {
// WARNING: use SMB with caution: it can and will automatically bolus up to max_iob worth of extra insulin
// enableUAM:true // enable detection of unannounced meal carb absorption
public final static boolean A52_risk_enable = false;
public final static boolean enableSMB_with_COB = true; // ***** default false in oref1 ***** enable supermicrobolus while COB is positive
public final static boolean enableSMB_with_temptarget = true; // ***** default false in oref1 ***** enable supermicrobolus for eating soon temp targets
//public final static boolean enableSMB_with_COB = true; // ***** default false in oref1 ***** enable supermicrobolus while COB is positive
//public final static boolean enableSMB_with_temptarget = true; // ***** default false in oref1 ***** enable supermicrobolus for eating soon temp targets
// *** WARNING *** DO NOT USE enableSMB_always or enableSMB_after_carbs with xDrip+, Libre, or similar
// xDrip+, LimiTTer, etc. do not properly filter out high-noise SGVs
// Using SMB overnight with such data sources risks causing a dangerous overdose of insulin
// if the CGM sensor reads falsely high and doesn't come down as actual BG does
public final static boolean enableSMB_always = false; // always enable supermicrobolus (unless disabled by high temptarget)
// public final static boolean enableSMB_always = false; // always enable supermicrobolus (unless disabled by high temptarget)
// *** WARNING *** DO NOT USE enableSMB_always or enableSMB_after_carbs with xDrip+, Libre, or similar
public final static boolean enableSMB_after_carbs = false; // enable supermicrobolus for 6h after carbs, even with 0 COB
public final static boolean allowSMB_with_high_temptarget = false; // allow supermicrobolus (if otherwise enabled) even with high temp targets
//public final static boolean enableSMB_after_carbs = false; // enable supermicrobolus for 6h after carbs, even with 0 COB
//public final static boolean allowSMB_with_high_temptarget = false; // allow supermicrobolus (if otherwise enabled) even with high temp targets
public final static int maxSMBBasalMinutes = 30; // maximum minutes of basal that can be delivered as a single SMB with uncovered COB
// curve:"rapid-acting" // Supported curves: "bilinear", "rapid-acting" (Novolog, Novorapid, Humalog, Apidra) and "ultra-rapid" (Fiasp)
// useCustomPeakTime:false // allows changing insulinPeakTime

View file

@ -82,4 +82,9 @@ public class SourceDexcomG5Plugin implements PluginBase, BgSourceInterface {
public int getPreferencesId() {
return R.xml.pref_dexcomg5;
}
@Override
public boolean advancedFilteringSupported() {
return true;
}
}

View file

@ -83,4 +83,8 @@ public class SourceGlimpPlugin implements PluginBase, BgSourceInterface {
}
@Override
public boolean advancedFilteringSupported() {
return false;
}
}

View file

@ -83,4 +83,8 @@ public class SourceMM640gPlugin implements PluginBase, BgSourceInterface {
}
@Override
public boolean advancedFilteringSupported() {
return false;
}
}

View file

@ -85,4 +85,8 @@ public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
}
@Override
public boolean advancedFilteringSupported() {
return false;
}
}

View file

@ -84,4 +84,8 @@ public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
}
@Override
public boolean advancedFilteringSupported() {
return false;
}
}

View file

@ -872,5 +872,20 @@
<string name="combo_error_bolus_recovery_progress">Recovering from connection loss</string>
<string name="combo_reservoir_level_insufficient_for_bolus">Not enough insulin for bolus left in reservoir</string>
<string name="extendedbolusdeliveryerror">Extended bolus delivery error</string>
<string name="key_enableSMB_always" translatable="false">enableSMB_always</string>
<string name="key_enableSMB_with_COB" translatable="false">enableSMB_with_COB</string>
<string name="key_enableSMB_with_temptarget" translatable="false">enableSMB_with_temptarget</string>
<string name="key_enableSMB_after_carbs" translatable="false">enableSMB_after_carbs</string>
<string name="key_allowSMB_with_high_temptarget" translatable="false">enableSMB_with_high_temptarget</string>
<string name="enablesmbalways">Enable SMB always</string>
<string name="enablesmbalways_summary">Enable SMB always independently to boluses. Possible only with BG source with nice filtering of data like G5</string>
<string name="enablesmbaftercarbs">Enable SMB after carbs</string>
<string name="enablesmbaftercarbs_summary">Enable SMB for 6h after carbs, even with 0 COB. Possible only with BG source with nice filtering of data like G5</string>
<string name="enablesmbwithcob">Enable SMB with COB</string>
<string name="enablesmbwithcob_summary">Enable SMB when there is COB active.</string>
<string name="enablesmbwithtemptarget">Enable SMB with temp targets</string>
<string name="enablesmbwithtemptarget_summary">Enable SMB when there is temp target active (eating soon, exercise)</string>
<string name="enablesmbwithhightemptarget">Enable SMB with high temp targets</string>
<string name="enablesmbwithhightemptarget_summary">Enable SMB when there is high temp target active (exercise)</string>
</resources>

View file

@ -25,6 +25,36 @@
android:key="@string/key_use_smb"
android:summary="@string/enablesmb_summary"
android:title="@string/enablesmb" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_enableSMB_with_COB"
android:summary="@string/enablesmbwithcob_summary"
android:title="@string/enablesmbwithcob"
android:dependency="@string/key_use_smb"/>
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_enableSMB_with_temptarget"
android:summary="@string/enablesmbwithtemptarget_summary"
android:title="@string/enablesmbwithtemptarget"
android:dependency="@string/key_use_smb"/>
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_allowSMB_with_high_temptarget"
android:summary="@string/enablesmbwithhightemptarget_summary"
android:title="@string/enablesmbwithhightemptarget"
android:dependency="@string/key_use_smb"/>
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_enableSMB_always"
android:summary="@string/enablesmbalways_summary"
android:title="@string/enablesmbalways"
android:dependency="@string/key_use_smb"/>
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_enableSMB_after_carbs"
android:summary="@string/enablesmbaftercarbs_summary"
android:title="@string/enablesmbaftercarbs"
android:dependency="@string/key_use_smb"/>
<com.andreabaccega.widget.ValidatingEditTextPreference
android:defaultValue="30"
android:dialogMessage="@string/smbmaxminutes"