Add prefernces.json to advanced settings

This commit is contained in:
LadyViktoria 2017-01-25 15:18:01 +01:00
parent 044547b594
commit b898fc044e
9 changed files with 101 additions and 34 deletions

View file

@ -25,19 +25,8 @@ public class Constants {
public static final long keepAliveMsecs = 5 * 60 * 1000L;
// SMS COMMUNICATOR
public static final long remoteBolusMinDistance = 15 * 60 * 1000L;
// AMA
public static final int MAX_DAILY_SAFETY_MULTIPLIER = 3;
public static final int CURRENT_BASAL_SAFETY_MULTIPLIER = 4;
public static final int BOLUSSNOOZE_DIA_ADVISOR = 2;
public static final double AUTOSENS_MAX = 1.2d;
public static final double AUTOSENS_MIN = 0.7d;
public static final double MIN_5M_CARBIMPACT = 3d;
// Circadian Percentage Profile
public static final int CPP_MIN_PERCENTAGE = 50;
public static final int CPP_MAX_PERCENTAGE = 200;

View file

@ -1,5 +1,8 @@
package info.nightscout.androidaps.plugins.OpenAPSAMA;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -20,7 +23,7 @@ public class Autosens {
private static Logger log = LoggerFactory.getLogger(Autosens.class);
public static AutosensResult detectSensitivityandCarbAbsorption(List<BgReading> glucose_data, long mealTime) {
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
//console.error(mealTime);
@ -128,7 +131,7 @@ public class Autosens {
if (bgTime > mealTime) {
// figure out how many carbs that represents
// but always assume at least 3mg/dL/5m (default) absorption
double ci = Math.max(deviation, Constants.MIN_5M_CARBIMPACT);
double ci = Math.max(deviation, Double.parseDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0")));
double absorbed = ci * profile.getIc(secondsFromMidnight) / sens;
// and add that to the running total carbsAbsorbed
carbsAbsorbed += absorbed;
@ -173,8 +176,8 @@ public class Autosens {
// don't adjust more than 1.5x
double rawRatio = ratio;
ratio = Math.max(ratio, Constants.AUTOSENS_MIN);
ratio = Math.min(ratio, Constants.AUTOSENS_MAX);
ratio = Math.max(ratio, Double.parseDouble(SP.getString("openapsama_autosens_min", "0.7")));
ratio = Math.min(ratio, Double.parseDouble(SP.getString("openapsama_autosens_max", "1.2")));
String ratioLimit = "";
if (ratio != rawRatio) {

View file

@ -218,7 +218,6 @@ public class DetermineBasalAdapterAMAJS {
String units = profile.getUnits();
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
boolean autosensAdustTargets = preferences.getBoolean("openapsama_autosens_adjusttargets", false);
mProfile = new V8Object(mV8rt);
mProfile.add("max_iob", maxIob);
@ -232,13 +231,13 @@ public class DetermineBasalAdapterAMAJS {
mProfile.add("target_bg", targetBg);
mProfile.add("carb_ratio", profile.getIc(profile.secondsFromMidnight()));
mProfile.add("sens", NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()).doubleValue(), units));
mProfile.add("max_daily_safety_multiplier", Constants.MAX_DAILY_SAFETY_MULTIPLIER);
mProfile.add("current_basal_safety_multiplier", Constants.CURRENT_BASAL_SAFETY_MULTIPLIER);
mProfile.add("skip_neutral_temps", true);
mProfile.add("max_daily_safety_multiplier", Integer.parseInt(preferences.getString("openapsama_max_daily_safety_multiplier", "3")));
mProfile.add("current_basal_safety_multiplier", Integer.parseInt(preferences.getString("openapsama_max_basal_safety_multiplier", "4")));
mProfile.add("skip_neutral_temps", preferences.getBoolean("openapsama_skip_neutral_temps", false));
mProfile.add("current_basal", pump.getBaseBasalRate());
mProfile.add("temptargetSet", tempTargetSet);
mProfile.add("autosens_adjust_targets", autosensAdustTargets);
mProfile.add("min_5m_carbimpact", min_5m_carbimpact);
mProfile.add("autosens_adjust_targets", preferences.getBoolean("openapsama_autosens_adjusttargets", true));
mProfile.add("min_5m_carbimpact", Double.parseDouble(preferences.getString("openapsama_min_5m_carbimpact", "3.0")));
mV8rt.add(PARAM_profile, mProfile);
mCurrentTemp = new V8Object(mV8rt);

View file

@ -224,7 +224,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobArray, glucoseStatus, mealData,
lastAutosensResult.ratio, //autosensDataRatio
isTempTarget,
Constants.MIN_5M_CARBIMPACT //min_5m_carbimpact
Double.parseDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0"))//min_5m_carbimpact
);

View file

@ -103,8 +103,8 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
if (profile == null) return absoluteRate;
if (absoluteRate < 0) absoluteRate = 0d;
Integer maxBasalMult = Constants.CURRENT_BASAL_SAFETY_MULTIPLIER;
Integer maxBasalFromDaily = Constants.MAX_DAILY_SAFETY_MULTIPLIER;
Integer maxBasalMult = Integer.parseInt(SP.getString("openapsama_max_basal_safety_multiplier", "4"));
Integer maxBasalFromDaily = Integer.parseInt(SP.getString("openapsama_max_daily_safety_multiplier", "3"));
// Check percentRate but absolute rate too, because we know real current basal in pump
Double origRate = absoluteRate;
if (absoluteRate > maxBasal) {
@ -142,8 +142,8 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
if (absoluteRate < 0) absoluteRate = 0d;
Integer maxBasalMult = Constants.CURRENT_BASAL_SAFETY_MULTIPLIER;
Integer maxBasalFromDaily = Constants.MAX_DAILY_SAFETY_MULTIPLIER;
Integer maxBasalMult = Integer.parseInt(SP.getString("openapsama_max_basal_safety_multiplier", "4"));
Integer maxBasalFromDaily = Integer.parseInt(SP.getString("openapsama_max_daily_safety_multiplier", "3"));
// Check percentRate but absolute rate too, because we know real current basal in pump
Double origRate = absoluteRate;
if (absoluteRate > maxBasal) {

View file

@ -1,5 +1,8 @@
package info.nightscout.androidaps.plugins.Treatments;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder;
@ -121,6 +124,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override
public IobTotal getCalculationToTime(long time) {
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
IobTotal total = new IobTotal(time);
if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet
@ -138,7 +142,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
Iob tIOB = t.iobCalc(now, dia);
total.iob += tIOB.iobContrib;
total.activity += tIOB.activityContrib;
Iob bIOB = t.iobCalc(now, dia / Constants.BOLUSSNOOZE_DIA_ADVISOR);
Iob bIOB = t.iobCalc(now, dia / Integer.parseInt(SP.getString("openapsama_bolussnooze_dia_divisor", "2")));
total.bolussnooze += bIOB.iobContrib;
}
return total;

View file

@ -429,6 +429,7 @@
<string name="initializing">Initializing ...</string>
<string name="careportal_temptarget">Temporary Target</string>
<string name="openapsama_autosens_adjusttargets">Allow autosens to adjust targets</string>
<string name="openapsama_autosens_adjusttargets_summary">This is used to allow autosens to adjust BG targets, in addition to ISF and basals.</string>
<string name="actions_shortname">ACT</string>
<string name="configbuilder_shortname">CONF</string>
<string name="loop_shortname">LOOP</string>
@ -452,4 +453,19 @@
<string name="always_use_shortavg">Always use short average delta instead of simple delta</string>
<string name="always_use_shortavg_summary">Useful when data from unfiltered sources like xDrip gets noisy.</string>
<string name="advancedsettings_title">Advanced Settings</string>
<string name="openapsama_max_daily_safety_multiplier">max_daily_safety_multiplier</string>
<string name="openapsama_max_daily_safety_multiplier_summary">This is a key OpenAPS safety cap. What this does is limit your basals to be 3x (in this people) your biggest basal rate. You likely will not need to change this, but you should be aware thats what is discussed about “3x max daily; 4x current” for safety caps.</string>
<string name="openapsama_current_basal_safety_multiplier">current_basal_safety_multiplier</string>
<string name="openapsama_current_basal_safety_multiplier_summary">This is the other half of the key OpenAPS safety caps, and the other half of “3x max daily; 4x current” of the safety caps. This means your basal, regardless of max basal set on your pump, cannot be any higher than this number times the current level of your basal. This is to prevent people from getting into dangerous territory by setting excessively high max basals before understanding how the algorithm works. Again, the default is 4x; most people will never need to adjust this and are instead more likely to need to adjust other settings if they feel like they are “running into” this safety cap.</string>
<string name="openapsama_autosens_max">autosens_max</string>
<string name="openapsama_autosens_max_summary">This is a multiplier cap for autosens (and soon autotune) to set a 20% max limit on how high the autosens ratio can be, which in turn determines how high autosens can adjust basals, how low it can adjust ISF, and how low it can set the BG target.</string>
<string name="openapsama_autosens_min">autosens_min</string>
<string name="openapsama_autosens_min_summary">The other side of the autosens safety limits, putting a cap on how low autosens can adjust basals, and how high it can adjust ISF and BG targets.</string>
<string name="openapsama_skip_neutral_temps">skip_neutral_temps</string>
<string name="openapsama_skip_neutral_temps_summary">Defaults to false, so that OpenAPS will set temps whenever it can, so it will be easier to see if the system is working, even when you are offline. This means OpenAPS will set a “neutral” temp (same as your default basal) if no adjustments are needed. If you are a light sleeper and the “on the hour” buzzing or beeping wakes you up (even in vibrate mode), you may want to turn this to “true” to skip this setting. However, we recommend it for most people who will be using this system on the go and out of constant connectivity.</string>
<string name="openapsama_bolussnooze_dia_divisor">bolussnooze_dia_divisor</string>
<string name="openapsama_bolussnooze_dia_divisor_summary">Bolus snooze is enacted after you do a meal bolus, so the loop wont counteract with low temps when youve just eaten. The example here and default is 2; so a 3 hour DIA means that bolus snooze will be gradually phased out over 1.5 hours (3DIA/2).</string>
<string name="openapsama_min_5m_carbimpact">min_5m_carbimpact</string>
<string name="openapsama_min_5m_carbimpact_summary">This is a setting for default carb absorption impact per 5 minutes. The default is an expected 3mg/dl/5min. This affects how fast COB are decayed, and how much carb absorption is assumed in calculating future predicted BG, when BG is falling more than expected, or not rising as much as expected.</string>
</resources>

View file

@ -25,6 +25,69 @@
android:title="@string/always_use_shortavg"
android:summary="@string/always_use_shortavg_summary"/>
</PreferenceCategory>
<PreferenceCategory
android:title="OpenAPS preferences.json">
<EditTextPreference
android:defaultValue="3"
android:selectAllOnFocus="true"
android:inputType="number"
android:title="@string/openapsama_max_daily_safety_multiplier"
android:summary="@string/openapsama_max_daily_safety_multiplier_summary"
android:key="openapsama_max_daily_safety_multiplier" />
<EditTextPreference
android:defaultValue="4"
android:selectAllOnFocus="true"
android:singleLine="true"
android:inputType="number"
android:title="@string/openapsama_current_basal_safety_multiplier"
android:summary="@string/openapsama_max_daily_safety_multiplier_summary"
android:key="openapsama_current_basal_safety_multiplier" />
<EditTextPreference
android:defaultValue="1.2"
android:selectAllOnFocus="true"
android:singleLine="true"
android:inputType="numberDecimal"
android:title="@string/openapsama_autosens_max"
android:summary="@string/openapsama_autosens_max_summary"
android:key="openapsama_autosens_max"
android:dependency="openapsama_useautosens"/>
<EditTextPreference
android:defaultValue="0.7"
android:selectAllOnFocus="true"
android:singleLine="true"
android:inputType="numberDecimal"
android:title="@string/openapsama_autosens_min"
android:summary="@string/openapsama_autosens_min_summary"
android:key="openapsama_autosens_min"
android:dependency="openapsama_useautosens"/>
<SwitchPreference
android:defaultValue="true"
android:key="openapsama_autosens_adjusttargets"
android:dependency="openapsama_useautosens"
android:title="@string/openapsama_autosens_adjusttargets"
android:summary="@string/openapsama_autosens_adjusttargets_summary" />
<SwitchPreference
android:defaultValue="false"
android:title="@string/openapsama_skip_neutral_temps"
android:summary="@string/openapsama_skip_neutral_temps_summary"
android:key="openapsama_skip_neutral_temps" />
<EditTextPreference
android:defaultValue="2"
android:selectAllOnFocus="true"
android:singleLine="true"
android:inputType="number"
android:title="@string/openapsama_bolussnooze_dia_divisor"
android:summary="@string/openapsama_bolussnooze_dia_divisor_summary"
android:key="openapsama_bolussnooze_dia_divisor" />
<EditTextPreference
android:defaultValue="3"
android:selectAllOnFocus="true"
android:singleLine="true"
android:inputType="numberDecimal"
android:title="@string/openapsama_min_5m_carbimpact"
android:summary="@string/openapsama_min_5m_carbimpact_summary"
android:key="openapsama_min_5m_carbimpact" />
</PreferenceCategory>
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -9,13 +9,6 @@
android:key="openapsama_useautosens"
android:title="@string/openapsama_useautosens" />
<SwitchPreference
android:defaultValue="false"
android:key="openapsama_autosens_adjusttargets"
android:dependency="openapsama_useautosens"
android:title="@string/openapsama_autosens_adjusttargets"/>
</PreferenceCategory>
</PreferenceScreen>