fix counting and displaying iob
This commit is contained in:
parent
228c8b4f9f
commit
5dfddfdfee
6 changed files with 44 additions and 33 deletions
|
@ -20,28 +20,34 @@ public class DetermineBasalResult extends APSResult {
|
|||
|
||||
public DetermineBasalResult(V8Object result, JSONObject j) {
|
||||
json = j;
|
||||
reason = result.getString("reason");
|
||||
eventualBG = result.getDouble("eventualBG");
|
||||
snoozeBG = result.getDouble("snoozeBG");
|
||||
if (result.contains("rate")) {
|
||||
rate = result.getDouble("rate");
|
||||
if (rate < 0d) rate = 0d;
|
||||
changeRequested = true;
|
||||
} else {
|
||||
if (result.contains("error")) {
|
||||
reason = result.getString("error");
|
||||
changeRequested = false;
|
||||
rate = -1;
|
||||
changeRequested = false;
|
||||
}
|
||||
if (result.contains("duration")) {
|
||||
duration = result.getInteger("duration");
|
||||
changeRequested = changeRequested;
|
||||
} else {
|
||||
duration = -1;
|
||||
changeRequested = false;
|
||||
mealAssist = "";
|
||||
} else {
|
||||
eventualBG = result.getDouble("eventualBG");
|
||||
snoozeBG = result.getDouble("snoozeBG");
|
||||
if (result.contains("rate")) {
|
||||
rate = result.getDouble("rate");
|
||||
if (rate < 0d) rate = 0d;
|
||||
changeRequested = true;
|
||||
} else {
|
||||
rate = -1;
|
||||
changeRequested = false;
|
||||
}
|
||||
if (result.contains("duration")) {
|
||||
duration = result.getInteger("duration");
|
||||
changeRequested = changeRequested;
|
||||
} else {
|
||||
duration = -1;
|
||||
changeRequested = false;
|
||||
}
|
||||
if (result.contains("mealAssist")) {
|
||||
mealAssist = result.getString("mealAssist");
|
||||
} else mealAssist = "";
|
||||
}
|
||||
if (result.contains("mealAssist")) {
|
||||
mealAssist = result.getString("mealAssist");
|
||||
} else mealAssist = "";
|
||||
|
||||
result.release();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ public class IobTotal {
|
|||
|
||||
public IobTotal plus(IobTotal other) {
|
||||
iob += other.iob;
|
||||
activity = other.activity;
|
||||
bolussnooze = other.bolussnooze;
|
||||
basaliob = other.iob;
|
||||
netbasalinsulin = other.netbasalinsulin;
|
||||
hightempinsulin = other.hightempinsulin;
|
||||
activity += other.activity;
|
||||
bolussnooze += other.bolussnooze;
|
||||
basaliob += other.basaliob;
|
||||
netbasalinsulin += other.netbasalinsulin;
|
||||
hightempinsulin += other.hightempinsulin;
|
||||
netInsulin += other.netInsulin;
|
||||
netRatio += other.netRatio;
|
||||
return this;
|
||||
|
|
|
@ -341,7 +341,9 @@ public class OverviewFragment extends Fragment implements PluginBase {
|
|||
if (basalIob == null) basalIob = new IobTotal();
|
||||
IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob).round();
|
||||
|
||||
String iobtext = getString(R.string.treatments_iob_label_string) + " " + formatNumber2decimalplaces.format(iobTotal.iob) + "U (" + getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(bolusIob.iob) + "U " + getString(R.string.basal) + ": " + formatNumber2decimalplaces.format(basalIob.iob) + "U)";
|
||||
String iobtext = getString(R.string.treatments_iob_label_string) + " " + formatNumber2decimalplaces.format(iobTotal.iob) + "U ("
|
||||
+ getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(bolusIob.iob) + "U "
|
||||
+ getString(R.string.basal) + ": " + formatNumber2decimalplaces.format(basalIob.basaliob) + "U)";
|
||||
iobView.setText(iobtext);
|
||||
|
||||
// ****** GRAPH *******
|
||||
|
|
|
@ -44,7 +44,7 @@ public class TempBasalsFragment extends Fragment implements PluginBase, TempBasa
|
|||
RecyclerView recyclerView;
|
||||
LinearLayoutManager llm;
|
||||
|
||||
TextView iobTotal;
|
||||
TextView tempBasalTotalView;
|
||||
|
||||
public long lastCalculationTimestamp = 0;
|
||||
public IobTotal lastCalculation;
|
||||
|
@ -205,7 +205,8 @@ public class TempBasalsFragment extends Fragment implements PluginBase, TempBasa
|
|||
IobTotal total = new IobTotal();
|
||||
for (Integer pos = 0; pos < tempBasals.size(); pos++) {
|
||||
TempBasal t = tempBasals.get(pos);
|
||||
total.plus(t.iobCalc(now));
|
||||
IobTotal calc = t.iobCalc(now);
|
||||
total.plus(calc);
|
||||
}
|
||||
|
||||
lastCalculationTimestamp = new Date().getTime();
|
||||
|
@ -348,8 +349,8 @@ public class TempBasalsFragment extends Fragment implements PluginBase, TempBasa
|
|||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(tempBasals);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
iobTotal = (TextView) view.findViewById(R.id.tempbasals_iobtotal);
|
||||
|
||||
tempBasalTotalView = (TextView) view.findViewById(R.id.tempbasals_totaltempiob);
|
||||
updateGUI();
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -374,9 +375,10 @@ public class TempBasalsFragment extends Fragment implements PluginBase, TempBasa
|
|||
@Override
|
||||
public void run() {
|
||||
recyclerView.swapAdapter(new RecyclerViewAdapter(tempBasals), false);
|
||||
if (lastCalculation != null)
|
||||
iobTotal.setText(formatNumber2decimalplaces.format(lastCalculation.basaliob));
|
||||
|
||||
if (lastCalculation != null) {
|
||||
String totalText = formatNumber2decimalplaces.format(lastCalculation.basaliob) + "U";
|
||||
tempBasalTotalView.setText(totalText);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -284,6 +284,7 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
|||
refreshFromNS = (Button) view.findViewById(R.id.treatments_reshreshfromnightscout);
|
||||
refreshFromNS.setOnClickListener(this);
|
||||
|
||||
updateGUI();
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tempbasals_iobtotal"
|
||||
android:id="@+id/tempbasals_totaltempiob"
|
||||
android:paddingLeft="10dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in a new issue