CPP add sum to basal rate representation
This commit is contained in:
parent
545a9135a3
commit
505a135ac8
2 changed files with 26 additions and 6 deletions
|
@ -242,6 +242,9 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
sb.append("</h3>");
|
sb.append("</h3>");
|
||||||
sb.append("<h4>");
|
sb.append("<h4>");
|
||||||
sb.append(getString(R.string.nsprofileview_basal_label));
|
sb.append(getString(R.string.nsprofileview_basal_label));
|
||||||
|
sb.append( " ( ∑");
|
||||||
|
sb.append(DecimalFormatter.to2Decimal(circadianPercentageProfilePlugin.percentageBasalSum()));
|
||||||
|
sb.append("U )");
|
||||||
sb.append("</h4> " + circadianPercentageProfilePlugin.basalString());
|
sb.append("</h4> " + circadianPercentageProfilePlugin.basalString());
|
||||||
sb.append("<h4>");
|
sb.append("<h4>");
|
||||||
sb.append(getString(R.string.nsprofileview_ic_label));
|
sb.append(getString(R.string.nsprofileview_ic_label));
|
||||||
|
@ -251,7 +254,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
sb.append("</h4> " + circadianPercentageProfilePlugin.isfString());
|
sb.append("</h4> " + circadianPercentageProfilePlugin.isfString());
|
||||||
profileView.setText(Html.fromHtml(sb.toString()));
|
profileView.setText(Html.fromHtml(sb.toString()));
|
||||||
|
|
||||||
baseprofileBasal.setText(Html.fromHtml("<h3>" + getString(R.string.base_profile_label) + "</h3>" +
|
baseprofileBasal.setText(Html.fromHtml("<h3>" + getString(R.string.base_profile_label) + " ( ∑" + DecimalFormatter.to2Decimal(circadianPercentageProfilePlugin.baseBasalSum()) + "U )</h3>" +
|
||||||
"<h4>" + getString(R.string.nsprofileview_basal_label) + "</h4>" + circadianPercentageProfilePlugin.baseBasalString()));
|
"<h4>" + getString(R.string.nsprofileview_basal_label) + "</h4>" + circadianPercentageProfilePlugin.baseBasalString()));
|
||||||
baseprofileIC.setText(Html.fromHtml("<h4>" + getString(R.string.nsprofileview_ic_label) + "</h4>" + circadianPercentageProfilePlugin.baseIcString()));
|
baseprofileIC.setText(Html.fromHtml("<h4>" + getString(R.string.nsprofileview_ic_label) + "</h4>" + circadianPercentageProfilePlugin.baseIcString()));
|
||||||
baseprofileISF.setText(Html.fromHtml("<h4>" + getString(R.string.nsprofileview_isf_label) + "</h4>" + circadianPercentageProfilePlugin.baseIsfString()));
|
baseprofileISF.setText(Html.fromHtml("<h4>" + getString(R.string.nsprofileview_isf_label) + "</h4>" + circadianPercentageProfilePlugin.baseIsfString()));
|
||||||
|
|
|
@ -207,11 +207,7 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
JSONObject profile = new JSONObject();
|
JSONObject profile = new JSONObject();
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
double sum = 0d;
|
stringBuilder.append(DecimalFormatter.to2Decimal(sum(basebasal)));
|
||||||
for (int i = 0; i < 24; i++) {
|
|
||||||
sum += basebasal[i];
|
|
||||||
}
|
|
||||||
stringBuilder.append(DecimalFormatter.to2Decimal(sum));
|
|
||||||
stringBuilder.append("U@");
|
stringBuilder.append("U@");
|
||||||
stringBuilder.append(percentage);
|
stringBuilder.append(percentage);
|
||||||
stringBuilder.append("%>");
|
stringBuilder.append("%>");
|
||||||
|
@ -298,6 +294,27 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
|
|
||||||
String baseBasalString() {return profileString(basebasal, 0, 100, true);}
|
String baseBasalString() {return profileString(basebasal, 0, 100, true);}
|
||||||
|
|
||||||
|
public double baseBasalSum(){
|
||||||
|
return sum(basebasal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double percentageBasalSum(){
|
||||||
|
double result = 0;
|
||||||
|
for (int i = 0; i < basebasal.length; i++) {
|
||||||
|
result += SafeParse.stringToDouble(DecimalFormatter.to2Decimal(basebasal[i] * percentage / 100d));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static double sum(double values[]){
|
||||||
|
double result = 0;
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
result += values[i];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String profileString(double[] values, int timeshift, int percentage, boolean inc) {
|
private static String profileString(double[] values, int timeshift, int percentage, boolean inc) {
|
||||||
timeshift = -(timeshift % 24) + 24;
|
timeshift = -(timeshift % 24) + 24;
|
||||||
|
|
Loading…
Reference in a new issue