CPP ic and isf data
This commit is contained in:
parent
8c93925865
commit
f815f7fce6
3 changed files with 54 additions and 73 deletions
|
@ -31,8 +31,6 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
EditText diaView;
|
EditText diaView;
|
||||||
RadioButton mgdlView;
|
RadioButton mgdlView;
|
||||||
RadioButton mmolView;
|
RadioButton mmolView;
|
||||||
EditText icView;
|
|
||||||
EditText isfView;
|
|
||||||
EditText carView;
|
EditText carView;
|
||||||
EditText targetlowView;
|
EditText targetlowView;
|
||||||
EditText targethighView;
|
EditText targethighView;
|
||||||
|
@ -48,8 +46,6 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
diaView = (EditText) layout.findViewById(R.id.simpleprofile_dia);
|
diaView = (EditText) layout.findViewById(R.id.simpleprofile_dia);
|
||||||
mgdlView = (RadioButton) layout.findViewById(R.id.simpleprofile_mgdl);
|
mgdlView = (RadioButton) layout.findViewById(R.id.simpleprofile_mgdl);
|
||||||
mmolView = (RadioButton) layout.findViewById(R.id.simpleprofile_mmol);
|
mmolView = (RadioButton) layout.findViewById(R.id.simpleprofile_mmol);
|
||||||
icView = (EditText) layout.findViewById(R.id.simpleprofile_ic);
|
|
||||||
isfView = (EditText) layout.findViewById(R.id.simpleprofile_isf);
|
|
||||||
carView = (EditText) layout.findViewById(R.id.simpleprofile_car);
|
carView = (EditText) layout.findViewById(R.id.simpleprofile_car);
|
||||||
targetlowView = (EditText) layout.findViewById(R.id.simpleprofile_targetlow);
|
targetlowView = (EditText) layout.findViewById(R.id.simpleprofile_targetlow);
|
||||||
targethighView = (EditText) layout.findViewById(R.id.simpleprofile_targethigh);
|
targethighView = (EditText) layout.findViewById(R.id.simpleprofile_targethigh);
|
||||||
|
@ -61,8 +57,6 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
mgdlView.setChecked(circadianPercentageProfilePlugin.mgdl);
|
mgdlView.setChecked(circadianPercentageProfilePlugin.mgdl);
|
||||||
mmolView.setChecked(circadianPercentageProfilePlugin.mmol);
|
mmolView.setChecked(circadianPercentageProfilePlugin.mmol);
|
||||||
diaView.setText(circadianPercentageProfilePlugin.dia.toString());
|
diaView.setText(circadianPercentageProfilePlugin.dia.toString());
|
||||||
icView.setText(circadianPercentageProfilePlugin.ic.toString());
|
|
||||||
isfView.setText(circadianPercentageProfilePlugin.isf.toString());
|
|
||||||
carView.setText(circadianPercentageProfilePlugin.car.toString());
|
carView.setText(circadianPercentageProfilePlugin.car.toString());
|
||||||
targetlowView.setText(circadianPercentageProfilePlugin.targetLow.toString());
|
targetlowView.setText(circadianPercentageProfilePlugin.targetLow.toString());
|
||||||
targethighView.setText(circadianPercentageProfilePlugin.targetHigh.toString());
|
targethighView.setText(circadianPercentageProfilePlugin.targetHigh.toString());
|
||||||
|
@ -106,8 +100,6 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
public void onTextChanged(CharSequence s, int start,
|
public void onTextChanged(CharSequence s, int start,
|
||||||
int before, int count) {
|
int before, int count) {
|
||||||
circadianPercentageProfilePlugin.dia = SafeParse.stringToDouble(diaView.getText().toString());
|
circadianPercentageProfilePlugin.dia = SafeParse.stringToDouble(diaView.getText().toString());
|
||||||
circadianPercentageProfilePlugin.ic = SafeParse.stringToDouble(icView.getText().toString());
|
|
||||||
circadianPercentageProfilePlugin.isf = SafeParse.stringToDouble(isfView.getText().toString());
|
|
||||||
circadianPercentageProfilePlugin.car = SafeParse.stringToDouble(carView.getText().toString());
|
circadianPercentageProfilePlugin.car = SafeParse.stringToDouble(carView.getText().toString());
|
||||||
circadianPercentageProfilePlugin.targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
|
circadianPercentageProfilePlugin.targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
|
||||||
circadianPercentageProfilePlugin.targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
|
circadianPercentageProfilePlugin.targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
|
||||||
|
@ -119,8 +111,6 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
};
|
};
|
||||||
|
|
||||||
diaView.addTextChangedListener(textWatch);
|
diaView.addTextChangedListener(textWatch);
|
||||||
icView.addTextChangedListener(textWatch);
|
|
||||||
isfView.addTextChangedListener(textWatch);
|
|
||||||
carView.addTextChangedListener(textWatch);
|
carView.addTextChangedListener(textWatch);
|
||||||
targetlowView.addTextChangedListener(textWatch);
|
targetlowView.addTextChangedListener(textWatch);
|
||||||
targethighView.addTextChangedListener(textWatch);
|
targethighView.addTextChangedListener(textWatch);
|
||||||
|
@ -131,9 +121,15 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateProfileInfo() {
|
private void updateProfileInfo() {
|
||||||
profileView.setText("Basal: " + circadianPercentageProfilePlugin.basalString());
|
profileView.setText("Active Profile:\n");
|
||||||
profileView.append("\n\n");
|
profileView.append("Basal: " + circadianPercentageProfilePlugin.basalString() + "\n");
|
||||||
profileView.append("Base-Basal: " + circadianPercentageProfilePlugin.baseBasalString());
|
profileView.append("IC: " + circadianPercentageProfilePlugin.icString() + "\n");
|
||||||
|
profileView.append("ISF: " + circadianPercentageProfilePlugin.isfString() + "\n");
|
||||||
|
profileView.append("\n");
|
||||||
|
profileView.append("Base Profile:\n");
|
||||||
|
profileView.append("Basal: " + circadianPercentageProfilePlugin.baseBasalString() + "\n");
|
||||||
|
profileView.append("IC: " + circadianPercentageProfilePlugin.baseIcString() + "\n");
|
||||||
|
profileView.append("ISF: " + circadianPercentageProfilePlugin.baseIsfString() + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,14 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
boolean mgdl;
|
boolean mgdl;
|
||||||
boolean mmol;
|
boolean mmol;
|
||||||
Double dia;
|
Double dia;
|
||||||
Double ic;
|
|
||||||
Double isf;
|
|
||||||
Double car;
|
Double car;
|
||||||
Double targetLow;
|
Double targetLow;
|
||||||
Double targetHigh;
|
Double targetHigh;
|
||||||
int percentage;
|
int percentage;
|
||||||
int timeshift;
|
int timeshift;
|
||||||
double[] basebasal = new double[]{1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d};
|
double[] basebasal = new double[]{1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d};
|
||||||
|
double[] baseisf = new double[]{35d, 35d, 35d, 35.1d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d};
|
||||||
|
double[] baseic = new double[]{4d, 4d, 4d, 4d, 4.1d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d};
|
||||||
|
|
||||||
public CircadianPercentageProfilePlugin() {
|
public CircadianPercentageProfilePlugin() {
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
@ -98,8 +98,6 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
editor.putBoolean(SETTINGS_PREFIX + "mmol", mmol);
|
editor.putBoolean(SETTINGS_PREFIX + "mmol", mmol);
|
||||||
editor.putBoolean(SETTINGS_PREFIX + "mgdl", mgdl);
|
editor.putBoolean(SETTINGS_PREFIX + "mgdl", mgdl);
|
||||||
editor.putString(SETTINGS_PREFIX + "dia", dia.toString());
|
editor.putString(SETTINGS_PREFIX + "dia", dia.toString());
|
||||||
editor.putString(SETTINGS_PREFIX + "ic", ic.toString());
|
|
||||||
editor.putString(SETTINGS_PREFIX + "isf", isf.toString());
|
|
||||||
editor.putString(SETTINGS_PREFIX + "car", car.toString());
|
editor.putString(SETTINGS_PREFIX + "car", car.toString());
|
||||||
editor.putString(SETTINGS_PREFIX + "targetlow", targetLow.toString());
|
editor.putString(SETTINGS_PREFIX + "targetlow", targetLow.toString());
|
||||||
editor.putString(SETTINGS_PREFIX + "targethigh", targetHigh.toString());
|
editor.putString(SETTINGS_PREFIX + "targethigh", targetHigh.toString());
|
||||||
|
@ -109,6 +107,8 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
|
|
||||||
for (int i = 0; i<24; i++) {
|
for (int i = 0; i<24; i++) {
|
||||||
editor.putString(SETTINGS_PREFIX + "basebasal" + i, DecimalFormatter.to2Decimal(basebasal[i]));
|
editor.putString(SETTINGS_PREFIX + "basebasal" + i, DecimalFormatter.to2Decimal(basebasal[i]));
|
||||||
|
editor.putString(SETTINGS_PREFIX + "baseisf" + i, DecimalFormatter.to2Decimal(baseisf[i]));
|
||||||
|
editor.putString(SETTINGS_PREFIX + "baseic" + i, DecimalFormatter.to2Decimal(baseic[i]));
|
||||||
}
|
}
|
||||||
editor.commit();
|
editor.commit();
|
||||||
createConvertedProfile();
|
createConvertedProfile();
|
||||||
|
@ -140,20 +140,6 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
log.debug(e.getMessage());
|
log.debug(e.getMessage());
|
||||||
}
|
}
|
||||||
else dia = 3d;
|
else dia = 3d;
|
||||||
if (settings.contains(SETTINGS_PREFIX + "ic"))
|
|
||||||
try {
|
|
||||||
ic = SafeParse.stringToDouble(settings.getString(SETTINGS_PREFIX + "ic", "20"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else ic = 20d;
|
|
||||||
if (settings.contains(SETTINGS_PREFIX + "isf"))
|
|
||||||
try {
|
|
||||||
isf = SafeParse.stringToDouble(settings.getString(SETTINGS_PREFIX + "isf", "200"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else isf = 200d;
|
|
||||||
if (settings.contains(SETTINGS_PREFIX + "car"))
|
if (settings.contains(SETTINGS_PREFIX + "car"))
|
||||||
try {
|
try {
|
||||||
car = SafeParse.stringToDouble(settings.getString(SETTINGS_PREFIX + "car", "20"));
|
car = SafeParse.stringToDouble(settings.getString(SETTINGS_PREFIX + "car", "20"));
|
||||||
|
@ -197,6 +183,16 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.debug(e.getMessage());
|
log.debug(e.getMessage());
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
baseic[i] = SafeParse.stringToDouble(settings.getString(SETTINGS_PREFIX + "baseic" + i, DecimalFormatter.to2Decimal(baseic[i])));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug(e.getMessage());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
baseisf[i] = SafeParse.stringToDouble(settings.getString(SETTINGS_PREFIX + "baseisf" + i, DecimalFormatter.to2Decimal(baseisf[i])));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -211,16 +207,25 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
json.put("defaultProfile", "CircadianPercentage");
|
json.put("defaultProfile", "CircadianPercentage");
|
||||||
json.put("store", store);
|
json.put("store", store);
|
||||||
profile.put("dia", dia);
|
profile.put("dia", dia);
|
||||||
profile.put("carbratio", new JSONArray().put(new JSONObject().put("timeAsSeconds", 0).put("value", ic)));
|
|
||||||
|
JSONArray icArray = new JSONArray();
|
||||||
|
for (int i = 0; i<24; i++){
|
||||||
|
icArray.put(new JSONObject().put("timeAsSeconds", ((i+timeshift)%24)*60*60).put("value", baseic[i]*percentage/100d));
|
||||||
|
}
|
||||||
|
profile.put("carbratio", icArray);
|
||||||
|
|
||||||
profile.put("carbs_hr", car);
|
profile.put("carbs_hr", car);
|
||||||
profile.put("sens", new JSONArray().put(new JSONObject().put("timeAsSeconds", 0).put("value", isf)));
|
|
||||||
|
JSONArray isfArray = new JSONArray();
|
||||||
|
for (int i = 0; i<24; i++){
|
||||||
|
isfArray.put(new JSONObject().put("timeAsSeconds", ((i+timeshift)%24)*60*60).put("value", baseisf[i]*percentage/100d));
|
||||||
|
}
|
||||||
|
profile.put("sens", isfArray);
|
||||||
|
|
||||||
JSONArray basalArray = new JSONArray();
|
JSONArray basalArray = new JSONArray();
|
||||||
|
|
||||||
for (int i = 0; i<24; i++){
|
for (int i = 0; i<24; i++){
|
||||||
basalArray.put(new JSONObject().put("timeAsSeconds", ((i+timeshift)%24)*60*60).put("value", basebasal[i]*percentage/100d));
|
basalArray.put(new JSONObject().put("timeAsSeconds", ((i+timeshift)%24)*60*60).put("value", basebasal[i]*percentage/100d));
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.put("basal", basalArray);
|
profile.put("basal", basalArray);
|
||||||
|
|
||||||
|
|
||||||
|
@ -239,11 +244,27 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
return convertedProfile;
|
return convertedProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String basalString(){
|
public String basalString() {
|
||||||
return profileString(basebasal, timeshift, percentage);
|
return profileString(basebasal, timeshift, percentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String baseBasalString(){
|
public String icString() {
|
||||||
|
return profileString(baseic, timeshift, percentage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String isfString() {
|
||||||
|
return profileString(baseisf, timeshift, percentage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String baseIcString() {
|
||||||
|
return profileString(baseic, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String baseIsfString() {
|
||||||
|
return profileString(baseisf, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String baseBasalString() {
|
||||||
return profileString(basebasal, 0, 100);
|
return profileString(basebasal, 0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,42 +70,6 @@
|
||||||
android:inputType="numberDecimal" />
|
android:inputType="numberDecimal" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="IC:"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/simpleprofile_ic"
|
|
||||||
android:layout_width="100dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_column="2"
|
|
||||||
android:inputType="numberDecimal" />
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="ISF:"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/simpleprofile_isf"
|
|
||||||
android:layout_width="100dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_column="2"
|
|
||||||
android:inputType="numberDecimal" />
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
Loading…
Reference in a new issue