static double interpolateCalculatedValue(BgReading first, BgReading second, long timestamp) { return interpolate(first.timestamp, first.getDg_mgdl(), second.timestamp, second.getDg_mgdl(), timestamp); } }
static double interpolateCalculatedValue(BgReading first, BgReading second, long timestamp) { return interpolate(first.timestamp, first.getDg_mgdl(), second.timestamp, second.getDg_mgdl(), timestamp); } }
public String displayValue(Context context) { final String unit = Pref.getString("units", "mgdl"); final DecimalFormat df = new DecimalFormat("#"); final double this_value = getDg_mgdl(); if (this_value >= 400) { return "HIGH"; } else if (this_value >= 40) { if (unit.equals("mgdl")) { df.setMaximumFractionDigits(0); return df.format(this_value); } else { df.setMaximumFractionDigits(1); return df.format(mmolConvert(this_value)); } } else { return "LOW"; // TODO doesn't understand special low values } }
public String displayValue(Context context) { final String unit = Pref.getString("units", "mgdl"); final DecimalFormat df = new DecimalFormat("#"); final double this_value = getDg_mgdl(); if (this_value >= 400) { return "HIGH"; } else if (this_value >= 40) { if (unit.equals("mgdl")) { df.setMaximumFractionDigits(0); return df.format(this_value); } else { df.setMaximumFractionDigits(1); return df.format(mmolConvert(this_value)); } } else { return "LOW"; // TODO doesn't understand special low values } }
public String displayValue(Context context) { final String unit = Pref.getString("units", "mgdl"); final DecimalFormat df = new DecimalFormat("#"); final double this_value = getDg_mgdl(); if (this_value >= 400) { return "HIGH"; } else if (this_value >= 40) { if (unit.equals("mgdl")) { df.setMaximumFractionDigits(0); return df.format(this_value); } else { df.setMaximumFractionDigits(1); return df.format(mmolConvert(this_value)); } } else { return "LOW"; // TODO doesn't understand special low values } }
private void populateV1APIBGEntry(JSONArray array, BgReading record) throws Exception { JSONObject json = new JSONObject(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US); format.setTimeZone(TimeZone.getDefault()); json.put("device", getDeviceString(record)); if (record != null) {//KS json.put("date", record.timestamp); json.put("dateString", format.format(record.timestamp)); if(prefs.getBoolean("cloud_storage_api_use_best_glucose", false)){ json.put("sgv", (int) record.getDg_mgdl()); json.put("delta", new BigDecimal(record.getDg_slope() * 5 * 60 * 1000).setScale(3, BigDecimal.ROUND_HALF_UP)); json.put("direction", record.getDg_deltaName()); } else { json.put("sgv", (int) record.calculated_value); json.put("delta", new BigDecimal(record.currentSlope() * 5 * 60 * 1000).setScale(3, BigDecimal.ROUND_HALF_UP)); // jamorham for automation json.put("direction", record.slopeName()); } json.put("type", "sgv"); json.put("filtered", record.ageAdjustedFiltered() * 1000); json.put("unfiltered", record.usedRaw() * 1000); json.put("rssi", 100); json.put("noise", record.noiseValue()); json.put("sysTime", format.format(record.timestamp)); array.put(json); } else Log.e(TAG, "doRESTUploadTo BG record is null."); }
private void populateV1APIBGEntry(JSONArray array, BgReading record) throws Exception { JSONObject json = new JSONObject(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US); format.setTimeZone(TimeZone.getDefault()); json.put("device", getDeviceString(record)); if (record != null) {//KS json.put("date", record.timestamp); json.put("dateString", format.format(record.timestamp)); if(prefs.getBoolean("cloud_storage_api_use_best_glucose", false)){ json.put("sgv", (int) record.getDg_mgdl()); json.put("delta", new BigDecimal(record.getDg_slope() * 5 * 60 * 1000).setScale(3, BigDecimal.ROUND_HALF_UP)); json.put("direction", record.getDg_deltaName()); } else { json.put("sgv", (int) record.calculated_value); json.put("delta", new BigDecimal(record.currentSlope() * 5 * 60 * 1000).setScale(3, BigDecimal.ROUND_HALF_UP)); // jamorham for automation json.put("direction", record.slopeName()); } json.put("type", "sgv"); json.put("filtered", record.ageAdjustedFiltered() * 1000); json.put("unfiltered", record.usedRaw() * 1000); json.put("rssi", 100); json.put("noise", record.noiseValue()); json.put("sysTime", format.format(record.timestamp)); array.put(json); } else Log.e(TAG, "doRESTUploadTo BG record is null."); }
item.put("sgv", (int) reading.getDg_mgdl()); try { item.put("delta", new BigDecimal(reading.getDg_slope() * 5 * 60 * 1000).setScale(3, BigDecimal.ROUND_HALF_UP));
item.put("sgv", (int) reading.getDg_mgdl()); try { item.put("delta", new BigDecimal(reading.getDg_slope() * 5 * 60 * 1000).setScale(3, BigDecimal.ROUND_HALF_UP));
if (last.get(0).getDg_mgdl() > highMarkMgDl) {
if (last.get(0).getDg_mgdl() > highMarkMgDl) {
if (last.get(0).getDg_mgdl() > highMarkMgDl) {
if (bgr.getDg_mgdl() < highMarkMgDl) { Log.e(TAG, "High not persistent as reading at: " + JoH.dateTimeText(bgr.timestamp) + " does not exceed " + JoH.qs(highMarkMgDl) + " mgdl / high mark"); return false;
if (bgr.getDg_mgdl() < highMarkMgDl) { Log.e(TAG, "High not persistent as reading at: " + JoH.dateTimeText(bgr.timestamp) + " does not exceed " + JoH.qs(highMarkMgDl) + " mgdl / high mark"); return false;
if (bgr.getDg_mgdl() < highMarkMgDl) { Log.e(TAG, "High not persistent as reading at: " + JoH.dateTimeText(bgr.timestamp) + " does not exceed " + JoH.qs(highMarkMgDl) + " mgdl / high mark"); return false;
private void sendBG() { // TODO use DisplayGlucose 100% and avoid rounding errors final BgReading last = BgReading.last(); FunAlmanac.Reply rep; if (last == null || last.isStale()) { rep = FunAlmanac.getRepresentation(0); } else { final double mmol_value = roundDouble(mmolConvert(last.getDg_mgdl()), 1); rep = FunAlmanac.getRepresentation(mmol_value); } UserError.Log.uel(TAG, "Representation for: " + rep.input); probeModelTypeIfUnknown(); new QueueMe() .setBytes(new TxSetTime(rep.timestamp, rep.zeroMonth, rep.zeroDay).getBytes()) .setDescription("Set display for: " + rep.input) .expectReply().expireInSeconds(290) .send(); }
private void sendBG() { // TODO use DisplayGlucose 100% and avoid rounding errors final BgReading last = BgReading.last(); FunAlmanac.Reply rep; if (last == null || last.isStale()) { rep = FunAlmanac.getRepresentation(0); } else { final double mmol_value = roundDouble(mmolConvert(last.getDg_mgdl()), 1); rep = FunAlmanac.getRepresentation(mmol_value); } UserError.Log.uel(TAG, "Representation for: " + rep.input); probeModelTypeIfUnknown(); new QueueMe() .setBytes(new TxSetTime(rep.timestamp, rep.zeroMonth, rep.zeroDay).getBytes()) .setDescription("Set display for: " + rep.input) .expectReply().expireInSeconds(290) .send(); }