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_MIN_PERCENTAGE = 50;
public static final int CPP_MAX_PERCENTAGE = 200; 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 // Very Hard Limits Ranges
// First value is the Lowest and second value is the Highest a Limit can define // 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}; 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(); 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 maxIob = SP.getDouble("openapsma_max_iob", 1.5d);
double maxBasal = SP.getDouble("openapsma_max_basal", 1d); double maxBasal = SP.getDouble("openapsma_max_basal", 1d);
double minBg = Profile.toMgdl(SP.getDouble("openapsma_min_bg", minBgDefault), units); double minBg = profile.getTargetLow();
double maxBg = Profile.toMgdl(SP.getDouble("openapsma_max_bg", maxBgDefault), units); double maxBg = profile.getTargetHigh();
double targetBg = Profile.toMgdl(SP.getDouble("openapsma_target_bg", targetBgDefault), units); double targetBg = (minBg + maxBg) / 2;
minBg = Round.roundTo(minBg, 0.1d); minBg = Round.roundTo(minBg, 0.1d);
maxBg = Round.roundTo(maxBg, 0.1d); maxBg = Round.roundTo(maxBg, 0.1d);
@ -248,6 +237,8 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
determineBasalAdapterAMAJS.release(); determineBasalAdapterAMAJS.release();
Date now = new Date();
try { try {
determineBasalResultAMA.json.put("timestamp", DateUtil.toISOString(now)); determineBasalResultAMA.json.put("timestamp", DateUtil.toISOString(now));
} catch (JSONException e) { } catch (JSONException e) {

View file

@ -156,22 +156,13 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
String units = profile.getUnits(); 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(); Date now = new Date();
double maxIob = SP.getDouble("openapsma_max_iob", 1.5d); double maxIob = SP.getDouble("openapsma_max_iob", 1.5d);
double maxBasal = SafeParse.stringToDouble(SP.getString("openapsma_max_basal", "1")); double maxBasal = SafeParse.stringToDouble(SP.getString("openapsma_max_basal", "1"));
double minBg = Profile.toMgdl(SP.getDouble("openapsma_min_bg", minBgDefault), units); double minBg = profile.getTargetLow();
double maxBg = Profile.toMgdl(SP.getDouble("openapsma_max_bg", maxBgDefault), units); double maxBg = profile.getTargetHigh();
double targetBg = Profile.toMgdl(SP.getDouble("openapsma_target_bg", targetBgDefault), units); double targetBg = (minBg + maxBg) / 2;
minBg = Round.roundTo(minBg, 0.1d); minBg = Round.roundTo(minBg, 0.1d);
maxBg = Round.roundTo(maxBg, 0.1d); maxBg = Round.roundTo(maxBg, 0.1d);

View file

@ -971,16 +971,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
else else
tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, units), units) + " - " + Profile.toUnitsString(tempTarget.high, Profile.fromMgdlToUnits(tempTarget.high, units), units)); tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, units), units) + " - " + Profile.toUnitsString(tempTarget.high, Profile.fromMgdlToUnits(tempTarget.high, units), units));
} else { } 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.setTextColor(Color.WHITE);
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground)); tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground));
double low = SP.getDouble("openapsma_min_bg", minBgDefault); double low = MainApp.getConfigBuilder().getProfile().getTargetLow();
double high = SP.getDouble("openapsma_max_bg", maxBgDefault); double high = MainApp.getConfigBuilder().getProfile().getTargetHigh();
if (low == high) if (low == high)
tempTargetView.setText("" + low); tempTargetView.setText("" + low);
else else

View file

@ -320,18 +320,9 @@ public class ActionStringHandler {
ret += "\n\n"; 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 += "DEFAULT RANGE: ";
ret += SP.getDouble("openapsma_min_bg", minBgDefault) + " - " + SP.getDouble("openapsma_max_bg", maxBgDefault); ret += profile.getTargetLow() + " - " + profile.getTargetHigh();
ret += " target: " + SP.getDouble("openapsma_target_bg", targetBgDefault); ret += " target: " + (profile.getTargetLow() + profile.getTargetHigh()) / 2;
return ret; return ret;
} }

View file

@ -3,22 +3,6 @@
<PreferenceCategory <PreferenceCategory
android:key="openaps" android:key="openaps"
android:title="@string/openapsma"> 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 <EditTextPreference
android:defaultValue="1" android:defaultValue="1"