Use target ranges from profile, rather than fixed values from prefs.

This commit is contained in:
Johannes Mockenhaupt 2017-07-15 02:17:37 +02:00
parent 26ebceb4d9
commit 7eacd5021c
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
6 changed files with 12 additions and 69 deletions

View file

@ -33,14 +33,6 @@ public class Constants {
public static final int CPP_MIN_PERCENTAGE = 50;
public static final int CPP_MAX_PERCENTAGE = 200;
// Defaults for settings
public static final Double MAX_BG_DEFAULT_MGDL = 180d;
public static final Double MAX_BG_DEFAULT_MMOL = 10d;
public static final Double MIN_BG_DEFAULT_MGDL = 100d;
public static final Double MIN_BG_DEFAULT_MMOL = 5d;
public static final Double TARGET_BG_DEFAULT_MGDL = 150d;
public static final Double TARGET_BG_DEFAULT_MMOL = 7d;
// Very Hard Limits Ranges
// First value is the Lowest and second value is the Highest a Limit can define
public static final int[] VERY_HARD_LIMIT_MIN_BG = {72,180};

View file

@ -158,22 +158,11 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
String units = profile.getUnits();
double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
double targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
if (!units.equals(Constants.MGDL)) {
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL;
}
Date now = new Date();
double maxIob = SP.getDouble("openapsma_max_iob", 1.5d);
double maxBasal = SP.getDouble("openapsma_max_basal", 1d);
double minBg = Profile.toMgdl(SP.getDouble("openapsma_min_bg", minBgDefault), units);
double maxBg = Profile.toMgdl(SP.getDouble("openapsma_max_bg", maxBgDefault), units);
double targetBg = Profile.toMgdl(SP.getDouble("openapsma_target_bg", targetBgDefault), units);
double minBg = profile.getTargetLow();
double maxBg = profile.getTargetHigh();
double targetBg = (minBg + maxBg) / 2;
minBg = Round.roundTo(minBg, 0.1d);
maxBg = Round.roundTo(maxBg, 0.1d);
@ -248,6 +237,8 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
determineBasalAdapterAMAJS.release();
Date now = new Date();
try {
determineBasalResultAMA.json.put("timestamp", DateUtil.toISOString(now));
} catch (JSONException e) {

View file

@ -156,22 +156,13 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
String units = profile.getUnits();
Double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
Double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
Double targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
if (!units.equals(Constants.MGDL)) {
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL;
}
Date now = new Date();
double maxIob = SP.getDouble("openapsma_max_iob", 1.5d);
double maxBasal = SafeParse.stringToDouble(SP.getString("openapsma_max_basal", "1"));
double minBg = Profile.toMgdl(SP.getDouble("openapsma_min_bg", minBgDefault), units);
double maxBg = Profile.toMgdl(SP.getDouble("openapsma_max_bg", maxBgDefault), units);
double targetBg = Profile.toMgdl(SP.getDouble("openapsma_target_bg", targetBgDefault), units);
double minBg = profile.getTargetLow();
double maxBg = profile.getTargetHigh();
double targetBg = (minBg + maxBg) / 2;
minBg = Round.roundTo(minBg, 0.1d);
maxBg = Round.roundTo(maxBg, 0.1d);

View file

@ -971,16 +971,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
else
tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, units), units) + " - " + Profile.toUnitsString(tempTarget.high, Profile.fromMgdlToUnits(tempTarget.high, units), units));
} else {
Double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
Double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
if (!units.equals(Constants.MGDL)) {
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
}
tempTargetView.setTextColor(Color.WHITE);
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground));
double low = SP.getDouble("openapsma_min_bg", minBgDefault);
double high = SP.getDouble("openapsma_max_bg", maxBgDefault);
double low = MainApp.getConfigBuilder().getProfile().getTargetLow();
double high = MainApp.getConfigBuilder().getProfile().getTargetHigh();
if (low == high)
tempTargetView.setText("" + low);
else

View file

@ -320,18 +320,9 @@ public class ActionStringHandler {
ret += "\n\n";
}
//Default Range/Target
Double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
Double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
Double targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
if (!profile.getUnits().equals(Constants.MGDL)) {
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL;
}
ret += "DEFAULT RANGE: ";
ret += SP.getDouble("openapsma_min_bg", minBgDefault) + " - " + SP.getDouble("openapsma_max_bg", maxBgDefault);
ret += " target: " + SP.getDouble("openapsma_target_bg", targetBgDefault);
ret += profile.getTargetLow() + " - " + profile.getTargetHigh();
ret += " target: " + (profile.getTargetLow() + profile.getTargetHigh()) / 2;
return ret;
}

View file

@ -3,22 +3,6 @@
<PreferenceCategory
android:key="openaps"
android:title="@string/openapsma">
<EditTextPreference
android:defaultValue=""
android:key="openapsma_min_bg"
android:numeric="decimal"
android:title="@string/openapsma_low_summary" />
<EditTextPreference
android:defaultValue=""
android:key="openapsma_max_bg"
android:numeric="decimal"
android:title="@string/openapsma_high_summary" />
<EditTextPreference
android:defaultValue=""
android:key="openapsma_target_bg"
android:numeric="decimal"
android:title="@string/openapsma_target_bg" />
<EditTextPreference
android:defaultValue="1"