unify target calculation
This commit is contained in:
parent
5f614b4072
commit
768f61bc07
4 changed files with 11 additions and 3 deletions
|
@ -442,6 +442,14 @@ public class Profile {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getTarget(){
|
||||||
|
return getTarget(secondsFromMidnight(System.currentTimeMillis()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getTarget(Integer time) {
|
||||||
|
return (getTargetLow(time) + getTargetHigh(time))/2;
|
||||||
|
}
|
||||||
|
|
||||||
public Double getTargetLow() {
|
public Double getTargetLow() {
|
||||||
return getTargetLow(secondsFromMidnight(System.currentTimeMillis()));
|
return getTargetLow(secondsFromMidnight(System.currentTimeMillis()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
double maxBasal = SP.getDouble("openapsma_max_basal", 1d);
|
double maxBasal = SP.getDouble("openapsma_max_basal", 1d);
|
||||||
double minBg = Profile.toMgdl(profile.getTargetLow(), units);
|
double minBg = Profile.toMgdl(profile.getTargetLow(), units);
|
||||||
double maxBg = Profile.toMgdl(profile.getTargetHigh(), units);
|
double maxBg = Profile.toMgdl(profile.getTargetHigh(), units);
|
||||||
double targetBg = (minBg + maxBg) / 2;
|
double targetBg = Profile.toMgdl(profile.getTarget(), units);
|
||||||
|
|
||||||
minBg = Round.roundTo(minBg, 0.1d);
|
minBg = Round.roundTo(minBg, 0.1d);
|
||||||
maxBg = Round.roundTo(maxBg, 0.1d);
|
maxBg = Round.roundTo(maxBg, 0.1d);
|
||||||
|
|
|
@ -179,7 +179,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
double maxBasal = SafeParse.stringToDouble(SP.getString("openapsma_max_basal", "1"));
|
double maxBasal = SafeParse.stringToDouble(SP.getString("openapsma_max_basal", "1"));
|
||||||
double minBg = Profile.toMgdl(profile.getTargetLow(), units);
|
double minBg = Profile.toMgdl(profile.getTargetLow(), units);
|
||||||
double maxBg = Profile.toMgdl(profile.getTargetHigh(), units);
|
double maxBg = Profile.toMgdl(profile.getTargetHigh(), units);
|
||||||
double targetBg = (minBg + maxBg) / 2;
|
double targetBg = Profile.toMgdl(profile.getTarget(), units);
|
||||||
|
|
||||||
minBg = Round.roundTo(minBg, 0.1d);
|
minBg = Round.roundTo(minBg, 0.1d);
|
||||||
maxBg = Round.roundTo(maxBg, 0.1d);
|
maxBg = Round.roundTo(maxBg, 0.1d);
|
||||||
|
|
|
@ -181,7 +181,7 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface {
|
||||||
double maxBasal = SP.getDouble("openapsma_max_basal", 1d);
|
double maxBasal = SP.getDouble("openapsma_max_basal", 1d);
|
||||||
double minBg = Profile.toMgdl(profile.getTargetLow(), units);
|
double minBg = Profile.toMgdl(profile.getTargetLow(), units);
|
||||||
double maxBg = Profile.toMgdl(profile.getTargetHigh(), units);
|
double maxBg = Profile.toMgdl(profile.getTargetHigh(), units);
|
||||||
double targetBg = (minBg + maxBg) / 2;
|
double targetBg = Profile.toMgdl(profile.getTarget(), units);
|
||||||
|
|
||||||
minBg = Round.roundTo(minBg, 0.1d);
|
minBg = Round.roundTo(minBg, 0.1d);
|
||||||
maxBg = Round.roundTo(maxBg, 0.1d);
|
maxBg = Round.roundTo(maxBg, 0.1d);
|
||||||
|
|
Loading…
Reference in a new issue