IOB display & upload fix

This commit is contained in:
Milos Kozak 2016-08-05 00:32:48 +02:00
parent abe04502c7
commit 7cc0fb593d
4 changed files with 70 additions and 50 deletions

View file

@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" /> <ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" /> <ConfirmationsSetting value="0" id="Remove" />
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View file

@ -64,12 +64,10 @@ public class IobTotal {
public JSONObject json() { public JSONObject json() {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
try { try {
json.put("iob", iob); json.put("iob", iob + basaliob);
json.put("bolussnooze", bolussnooze); json.put("basaliob", basaliob);
json.put("basaliob", iob);
json.put("activity", activity); json.put("activity", activity);
json.put("hightempinsulin", hightempinsulin); json.put("time", DateUtil.toISOString(new Date()));
json.put("netbasalinsulin", netbasalinsulin);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -415,14 +415,13 @@ public class OverviewFragment extends Fragment implements PluginBase {
// iob // iob
MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB(); MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB();
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation(); IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round();
if (bolusIob == null) bolusIob = new IobTotal(); if (bolusIob == null) bolusIob = new IobTotal();
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB(); MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB();
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation(); IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round();
if (basalIob == null) basalIob = new IobTotal(); if (basalIob == null) basalIob = new IobTotal();
IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob).round();
String iobtext = getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(iobTotal.iob) + "U (" String iobtext = getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
+ getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U " + getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
+ getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)"; + getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
iobView.setText(iobtext); iobView.setText(iobtext);
@ -455,6 +454,20 @@ public class OverviewFragment extends Fragment implements PluginBase {
// remove old data from graph // remove old data from graph
bgGraph.removeAllSeries(); bgGraph.removeAllSeries();
// **** HIGH and LOW targets graph ****
DataPoint[] lowDataPoints = new DataPoint[]{
new DataPoint(fromTime, lowLine),
new DataPoint(toTime, lowLine)
};
DataPoint[] highDataPoints = new DataPoint[]{
new DataPoint(fromTime, highLine),
new DataPoint(toTime, highLine)
};
bgGraph.addSeries(seriesLow = new LineGraphSeries<DataPoint>(lowDataPoints));
seriesLow.setColor(Color.RED);
bgGraph.addSeries(seriesHigh = new LineGraphSeries<DataPoint>(highDataPoints));
seriesHigh.setColor(Color.RED);
// **** TEMP BASALS graph **** // **** TEMP BASALS graph ****
class BarDataPoint extends DataPoint { class BarDataPoint extends DataPoint {
public BarDataPoint(double x, double y, boolean isTempBasal) { public BarDataPoint(double x, double y, boolean isTempBasal) {
@ -537,20 +550,6 @@ public class OverviewFragment extends Fragment implements PluginBase {
seriesOutOfRange.setColor(Color.RED); seriesOutOfRange.setColor(Color.RED);
} }
// **** HIGH and LOW targets graph ****
DataPoint[] lowDataPoints = new DataPoint[]{
new DataPoint(fromTime, lowLine),
new DataPoint(toTime, lowLine)
};
DataPoint[] highDataPoints = new DataPoint[]{
new DataPoint(fromTime, highLine),
new DataPoint(toTime, highLine)
};
bgGraph.addSeries(seriesLow = new LineGraphSeries<DataPoint>(lowDataPoints));
seriesLow.setColor(Color.RED);
bgGraph.addSeries(seriesHigh = new LineGraphSeries<DataPoint>(highDataPoints));
seriesHigh.setColor(Color.RED);
// **** NOW line **** // **** NOW line ****
DataPoint[] nowPoints = new DataPoint[]{ DataPoint[] nowPoints = new DataPoint[]{
new DataPoint(now, 0), new DataPoint(now, 0),

View file

@ -19,43 +19,45 @@
android:id="@+id/overview_bg" android:id="@+id/overview_bg"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="left|top" android:layout_gravity="top|left"
android:gravity="center_vertical"
android:text="00.0"
android:textSize="80dp" android:textSize="80dp"
android:textStyle="bold" android:textStyle="bold" />
android:text="00.0" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="top" android:layout_gravity="top"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView <TextView
android:id="@+id/overview_timeago" android:id="@+id/overview_timeago"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:textAppearance="?android:attr/textAppearanceMedium" android:layout_weight="0.5"
android:layout_weight="0.5" /> android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView <TextView
android:id="@+id/overview_apsmode"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Medium Text"
android:id="@+id/overview_apsmode"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:layout_weight="0.5"
android:background="@drawable/loopmodeborder" android:background="@drawable/loopmodeborder"
android:gravity="center_vertical|center_horizontal"
android:paddingLeft="5dp" android:paddingLeft="5dp"
android:paddingRight="5dp" android:paddingRight="5dp"
android:gravity="center_vertical|center_horizontal" android:text="Medium Text"
android:layout_weight="0.5" /> android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout> </LinearLayout>
@ -73,15 +75,17 @@
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
<TextView <TextView
android:id="@+id/overview_iob" android:id="@+id/overview_iob"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
<com.jjoe64.graphview.GraphView <com.jjoe64.graphview.GraphView
android:id="@+id/overview_bggraph" android:id="@+id/overview_bggraph"
@ -89,16 +93,20 @@
android:layout_height="160dip" /> android:layout_height="160dip" />
<LinearLayout <LinearLayout
android:id="@+id/overview_accepttemplayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal">
android:id="@+id/overview_accepttemplayout">
<Button <Button
android:id="@+id/overview_accepttempbutton" android:id="@+id/overview_accepttempbutton"
style="?android:attr/buttonStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="10dp" android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:layout_weight="0.5" android:layout_weight="0.5"
android:text="Accept new temp\n0.25U/h" android:text="Accept new temp\n0.25U/h"
android:textColor="@color/colorAcceptTempButton" /> android:textColor="@color/colorAcceptTempButton" />
@ -115,7 +123,10 @@
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="10dp" android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:layout_weight="0.5" android:layout_weight="0.5"
android:text="Cancel temp basal" android:text="Cancel temp basal"
android:textColor="@color/colorCancelTempButton" /> android:textColor="@color/colorCancelTempButton" />
@ -133,7 +144,10 @@
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="10dp" android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:layout_weight="0.5" android:layout_weight="0.5"
android:text="@string/overview_tempbasal_button" android:text="@string/overview_tempbasal_button"
android:textColor="@color/colorSetTempButton" /> android:textColor="@color/colorSetTempButton" />
@ -143,7 +157,10 @@
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="10dp" android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:layout_weight="0.5" android:layout_weight="0.5"
android:text="@string/overview_extendedbolus_button" android:text="@string/overview_extendedbolus_button"
android:textColor="@color/colorSetExtendedButton" /> android:textColor="@color/colorSetExtendedButton" />
@ -159,7 +176,10 @@
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="10dp" android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:layout_weight="0.5" android:layout_weight="0.5"
android:text="@string/overview_bolus_label" android:text="@string/overview_bolus_label"
android:textColor="@color/colorTreatmentButton" /> android:textColor="@color/colorTreatmentButton" />
@ -169,7 +189,10 @@
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="10dp" android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:layout_weight="0.5" android:layout_weight="0.5"
android:text="@string/overview_calculator_label" android:text="@string/overview_calculator_label"
android:textColor="@color/colorWizardButton" /> android:textColor="@color/colorWizardButton" />