Add prefernces.json switch to SafeParse
This commit is contained in:
parent
2a0968eba9
commit
c01488e7a9
6 changed files with 21 additions and 17 deletions
|
@ -10,6 +10,7 @@ import android.preference.PreferenceActivity;
|
|||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.SwitchPreference;
|
||||
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
|
@ -53,11 +54,11 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
|||
}
|
||||
if (pref instanceof EditTextPreference) {
|
||||
EditTextPreference editTextPref = (EditTextPreference) pref;
|
||||
if (pref.getTitle().toString().toLowerCase().contains("password"))
|
||||
{
|
||||
if (pref.getTitle().toString().toLowerCase().contains("password")) {
|
||||
pref.setSummary("******");
|
||||
} else if (editTextPref.getText() != null && !editTextPref.getText().equals("")){
|
||||
pref.setSummary("Value is set to: " +editTextPref.getText() + "\n" + editTextPref.getSummary());
|
||||
} else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) {
|
||||
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
|
||||
pref.setSummary(editTextPref.getText());
|
||||
}
|
||||
}
|
||||
if (pref instanceof MultiSelectListPreference) {
|
||||
|
|
|
@ -17,6 +17,7 @@ import info.nightscout.androidaps.data.IobTotal;
|
|||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.utils.Round;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
|
||||
public class Autosens {
|
||||
|
@ -131,7 +132,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, Double.parseDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0")));
|
||||
double ci = Math.max(deviation, SafeParse.stringToDouble(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;
|
||||
|
@ -176,8 +177,8 @@ public class Autosens {
|
|||
|
||||
// don't adjust more than 1.5x
|
||||
double rawRatio = ratio;
|
||||
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")));
|
||||
ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7")));
|
||||
ratio = Math.min(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_max", "1.2")));
|
||||
|
||||
String ratioLimit = "";
|
||||
if (ratio != rawRatio) {
|
||||
|
|
|
@ -26,6 +26,7 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
|||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
public class DetermineBasalAdapterAMAJS {
|
||||
private static Logger log = LoggerFactory.getLogger(DetermineBasalAdapterAMAJS.class);
|
||||
|
@ -231,13 +232,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", 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("max_daily_safety_multiplier", SafeParse.stringToInt(preferences.getString("openapsama_max_daily_safety_multiplier", "3")));
|
||||
mProfile.add("current_basal_safety_multiplier", SafeParse.stringToInt(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", preferences.getBoolean("openapsama_autosens_adjusttargets", true));
|
||||
mProfile.add("min_5m_carbimpact", Double.parseDouble(preferences.getString("openapsama_min_5m_carbimpact", "3.0")));
|
||||
mProfile.add("min_5m_carbimpact", SafeParse.stringToDouble(preferences.getString("openapsama_min_5m_carbimpact", "3.0")));
|
||||
mV8rt.add(PARAM_profile, mProfile);
|
||||
|
||||
mCurrentTemp = new V8Object(mV8rt);
|
||||
|
|
|
@ -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,
|
||||
Double.parseDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0"))//min_5m_carbimpact
|
||||
SafeParse.stringToDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0"))//min_5m_carbimpact
|
||||
);
|
||||
|
||||
|
||||
|
|
|
@ -103,8 +103,8 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
|||
if (profile == null) return absoluteRate;
|
||||
if (absoluteRate < 0) absoluteRate = 0d;
|
||||
|
||||
Integer maxBasalMult = Integer.parseInt(SP.getString("openapsama_max_basal_safety_multiplier", "4"));
|
||||
Integer maxBasalFromDaily = Integer.parseInt(SP.getString("openapsama_max_daily_safety_multiplier", "3"));
|
||||
Integer maxBasalMult = SafeParse.stringToInt(SP.getString("openapsama_max_basal_safety_multiplier", "4"));
|
||||
Integer maxBasalFromDaily = SafeParse.stringToInt(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 = Integer.parseInt(SP.getString("openapsama_max_basal_safety_multiplier", "4"));
|
||||
Integer maxBasalFromDaily = Integer.parseInt(SP.getString("openapsama_max_daily_safety_multiplier", "3"));
|
||||
Integer maxBasalMult = SafeParse.stringToInt(SP.getString("openapsama_max_basal_safety_multiplier", "4"));
|
||||
Integer maxBasalFromDaily = SafeParse.stringToInt(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) {
|
||||
|
@ -191,7 +191,7 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
|||
public Integer applyCarbsConstraints(Integer carbs) {
|
||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||
try {
|
||||
Integer maxCarbs = Integer.parseInt(SP.getString("treatmentssafety_maxcarbs", "48"));
|
||||
Integer maxCarbs = SafeParse.stringToInt(SP.getString("treatmentssafety_maxcarbs", "48"));
|
||||
|
||||
if (carbs < 0) carbs = 0;
|
||||
if (carbs > maxCarbs) carbs = maxCarbs;
|
||||
|
|
|
@ -29,6 +29,7 @@ import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
|||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
|
@ -142,7 +143,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 / Integer.parseInt(SP.getString("openapsama_bolussnooze_dia_divisor", "2")));
|
||||
Iob bIOB = t.iobCalc(now, dia / SafeParse.stringToInt(SP.getString("openapsama_bolussnooze_dia_divisor", "2")));
|
||||
total.bolussnooze += bIOB.iobContrib;
|
||||
}
|
||||
return total;
|
||||
|
|
Loading…
Reference in a new issue