Merge pull request #21 from MilosKozak/master

dev
This commit is contained in:
LadyViktoria 2016-06-25 00:02:37 +02:00 committed by GitHub
commit ffa3abbe6e
7 changed files with 57 additions and 38 deletions

View file

@ -906,11 +906,12 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
if (lastRun.lastAPSRun.getTime() < new Date().getTime() - 60 * 1000L) if (lastRun.lastAPSRun.getTime() < new Date().getTime() - 60 * 1000L)
return; // do not send if result is older than 1 min return; // do not send if result is older than 1 min
String openapsmaPluginName = MainApp.resources.getString(R.string.openapsma); APSResult apsResult = lastRun.request;
if (lastRun.source != null && lastRun.source.equals(openapsmaPluginName)) { apsResult.json().put("timestamp", DateUtil.toISOString(lastRun.lastAPSRun));
deviceStatus.suggested = apsResult.json();
if (lastRun.request instanceof DetermineBasalResult) {
DetermineBasalResult result = (DetermineBasalResult) lastRun.request; DetermineBasalResult result = (DetermineBasalResult) lastRun.request;
result.json.put("timestamp", DateUtil.toISOString(lastRun.lastAPSRun));
deviceStatus.suggested = result.json;
deviceStatus.iob = result.iob.json(); deviceStatus.iob = result.iob.json();
deviceStatus.iob.put("time", DateUtil.toISOString(lastRun.lastAPSRun)); deviceStatus.iob.put("time", DateUtil.toISOString(lastRun.lastAPSRun));
} }

View file

@ -375,18 +375,17 @@ import info.nightscout.androidaps.Services.Intents;
public class DeviceStatus { public class DeviceStatus {
private static Logger log = LoggerFactory.getLogger(DeviceStatus.class); private static Logger log = LoggerFactory.getLogger(DeviceStatus.class);
public static DeviceStatus deviceStatus;
public static String device = null; public String device = null;
public static JSONObject pump = null; public JSONObject pump = null;
public static JSONObject enacted = null; public JSONObject enacted = null;
public static JSONObject suggested = null; public JSONObject suggested = null;
public static JSONObject iob = null; public JSONObject iob = null;
public static String created_at = null; public String created_at = null;
public static JSONObject lowsuspend = null; public JSONObject lowsuspend = null;
public static JSONObject mongoRecord () { public JSONObject mongoRecord () {
JSONObject record = new JSONObject(); JSONObject record = new JSONObject();
try { try {

View file

@ -27,6 +27,7 @@ import com.squareup.otto.Subscribe;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
@ -45,6 +46,7 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTreatmentChange; import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewExtendedBolusDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.NewExtendedBolusDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTempBasalDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTempBasalDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog;
@ -59,6 +61,8 @@ public class OverviewFragment extends Fragment implements PluginBase {
TextView bgView; TextView bgView;
TextView timeAgoView; TextView timeAgoView;
TextView deltaView; TextView deltaView;
TextView runningTempView;
TextView iobView;
GraphView bgGraph; GraphView bgGraph;
LinearLayout cancelTempLayout; LinearLayout cancelTempLayout;
@ -149,6 +153,8 @@ public class OverviewFragment extends Fragment implements PluginBase {
bgView = (TextView) view.findViewById(R.id.overview_bg); bgView = (TextView) view.findViewById(R.id.overview_bg);
timeAgoView = (TextView) view.findViewById(R.id.overview_timeago); timeAgoView = (TextView) view.findViewById(R.id.overview_timeago);
deltaView = (TextView) view.findViewById(R.id.overview_delta); deltaView = (TextView) view.findViewById(R.id.overview_delta);
runningTempView = (TextView) view.findViewById(R.id.overview_runningtemp);
iobView = (TextView) view.findViewById(R.id.overview_iob);
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph); bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
cancelTempButton = (Button) view.findViewById(R.id.overview_canceltemp); cancelTempButton = (Button) view.findViewById(R.id.overview_canceltemp);
treatmentButton = (Button) view.findViewById(R.id.overview_treatment); treatmentButton = (Button) view.findViewById(R.id.overview_treatment);
@ -274,6 +280,7 @@ public class OverviewFragment extends Fragment implements PluginBase {
} }
public void updateGUI() { public void updateGUI() {
DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
BgReading actualBG = MainApp.getDbHelper().actualBg(); BgReading actualBG = MainApp.getDbHelper().actualBg();
BgReading lastBG = MainApp.getDbHelper().lastBg(); BgReading lastBG = MainApp.getDbHelper().lastBg();
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null) // app not initialized yet if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null) // app not initialized yet
@ -296,9 +303,12 @@ public class OverviewFragment extends Fragment implements PluginBase {
cancelTempLayout.setVisibility(View.VISIBLE); cancelTempLayout.setVisibility(View.VISIBLE);
setTempLayout.setVisibility(View.GONE); setTempLayout.setVisibility(View.GONE);
cancelTempButton.setText(MainApp.instance().getString(R.string.cancel) + ": " + activeTemp.toString()); cancelTempButton.setText(MainApp.instance().getString(R.string.cancel) + ": " + activeTemp.toString());
runningTempView.setText(activeTemp.toString());
} else { } else {
cancelTempLayout.setVisibility(View.GONE); cancelTempLayout.setVisibility(View.GONE);
setTempLayout.setVisibility(View.VISIBLE); setTempLayout.setVisibility(View.VISIBLE);
Double currentBasal = pump.getBaseBasalRate();
runningTempView.setText(formatNumber2decimalplaces.format(currentBasal) + " U/h");
} }
// **** BG value **** // **** BG value ****
@ -322,6 +332,18 @@ public class OverviewFragment extends Fragment implements PluginBase {
int agoMin = (int) (agoMsec / 60d / 1000d); int agoMin = (int) (agoMsec / 60d / 1000d);
timeAgoView.setText(agoMin + " " + getString(R.string.minago)); timeAgoView.setText(agoMin + " " + getString(R.string.minago));
// iob
MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB();
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation();
if (bolusIob == null) bolusIob = new IobTotal();
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB();
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation();
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)";
iobView.setText(iobtext);
// ****** GRAPH ******* // ****** GRAPH *******
// allign to hours // allign to hours

View file

@ -207,17 +207,6 @@ public class TempBasalsFragment extends Fragment implements PluginBase, TempBasa
TempBasal t = tempBasals.get(pos); TempBasal t = tempBasals.get(pos);
total.plus(t.iobCalc(now)); total.plus(t.iobCalc(now));
} }
final IobTotal finalTotal = total;
Activity activity = getActivity();
if (visibleNow && activity != null && recyclerView != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (iobTotal != null)
iobTotal.setText(formatNumber2decimalplaces.format(finalTotal.basaliob));
}
});
lastCalculationTimestamp = new Date().getTime(); lastCalculationTimestamp = new Date().getTime();
lastCalculation = total; lastCalculation = total;
@ -385,6 +374,9 @@ public class TempBasalsFragment extends Fragment implements PluginBase, TempBasa
@Override @Override
public void run() { public void run() {
recyclerView.swapAdapter(new RecyclerViewAdapter(tempBasals), false); recyclerView.swapAdapter(new RecyclerViewAdapter(tempBasals), false);
if (lastCalculation != null)
iobTotal.setText(formatNumber2decimalplaces.format(lastCalculation.basaliob));
} }
}); });
} }

View file

@ -154,20 +154,6 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
total.bolussnooze += bIOB.iobContrib; total.bolussnooze += bIOB.iobContrib;
} }
final IobTotal finalTotal = total;
Activity activity = getActivity();
if (visibleNow && activity != null && recyclerView != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (iobTotal != null)
iobTotal.setText(formatNumber2decimalplaces.format(finalTotal.iob));
if (activityTotal != null)
activityTotal.setText(formatNumber3decimalplaces.format(finalTotal.activity));
}
});
lastCalculationTimestamp = new Date().getTime(); lastCalculationTimestamp = new Date().getTime();
lastCalculation = total; lastCalculation = total;
} }
@ -346,6 +332,10 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
@Override @Override
public void run() { public void run() {
recyclerView.swapAdapter(new RecyclerViewAdapter(treatments), false); recyclerView.swapAdapter(new RecyclerViewAdapter(treatments), false);
if (lastCalculation != null)
iobTotal.setText(formatNumber2decimalplaces.format(lastCalculation.iob));
if (lastCalculation != null)
activityTotal.setText(formatNumber3decimalplaces.format(lastCalculation.activity));
} }
}); });
} }

View file

@ -43,6 +43,20 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/overview_runningtemp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/overview_iob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -139,6 +139,7 @@
<string name="confirmation">Confirmation</string> <string name="confirmation">Confirmation</string>
<string name="entertreatmentquestion">Enter new treatment:</string> <string name="entertreatmentquestion">Enter new treatment:</string>
<string name="bolus">Bolus</string> <string name="bolus">Bolus</string>
<string name="basal">Basal</string>
<string name="carbs">Carbs</string> <string name="carbs">Carbs</string>
<string name="changeyourinput">Change your input!</string> <string name="changeyourinput">Change your input!</string>
<string name="setextendedbolusquestion">Set new extended bolus:</string> <string name="setextendedbolusquestion">Set new extended bolus:</string>