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."); }
double calIntercept = ((calibration.first_scale * calibration.first_intercept) / firstAdjSlope) * -1; bgReading.calculated_value = (((calSlope * bgReading.raw_data) + calIntercept) - 5); bgReading.filtered_calculated_value = (((calSlope * bgReading.ageAdjustedFiltered()) + calIntercept) - 5); Log.d(TAG, "USING CALIBRATION PLUGIN AS PRIMARY!!!"); bgReading.calculated_value = (pcalibration.slope * bgReading.age_adjusted_raw_value) + pcalibration.intercept; bgReading.filtered_calculated_value = (pcalibration.slope * bgReading.ageAdjustedFiltered()) + calibration.intercept; } else { bgReading.calculated_value = ((calibration.slope * bgReading.age_adjusted_raw_value) + calibration.intercept); bgReading.filtered_calculated_value = ((calibration.slope * bgReading.ageAdjustedFiltered()) + calibration.intercept);
double calIntercept = ((calibration.first_scale * calibration.first_intercept) / firstAdjSlope) * -1; bgReading.calculated_value = (((calSlope * bgReading.raw_data) + calIntercept) - 5); bgReading.filtered_calculated_value = (((calSlope * bgReading.ageAdjustedFiltered()) + calIntercept) - 5); Log.d(TAG, "USING CALIBRATION PLUGIN AS PRIMARY!!!"); bgReading.calculated_value = (pcalibration.slope * bgReading.age_adjusted_raw_value) + pcalibration.intercept; bgReading.filtered_calculated_value = (pcalibration.slope * bgReading.ageAdjustedFiltered()) + calibration.intercept; } else { bgReading.calculated_value = ((calibration.slope * bgReading.age_adjusted_raw_value) + calibration.intercept); bgReading.filtered_calculated_value = ((calibration.slope * bgReading.ageAdjustedFiltered()) + calibration.intercept);
double calIntercept = ((calibration.first_scale * calibration.first_intercept) / firstAdjSlope) * -1; bgReading.calculated_value = (((calSlope * bgReading.raw_data) + calIntercept) - 5); bgReading.filtered_calculated_value = (((calSlope * bgReading.ageAdjustedFiltered()) + calIntercept) - 5); Log.d(TAG, "USING CALIBRATION PLUGIN AS PRIMARY!!!"); bgReading.calculated_value = (pcalibration.slope * bgReading.age_adjusted_raw_value) + pcalibration.intercept; bgReading.filtered_calculated_value = (pcalibration.slope * bgReading.ageAdjustedFiltered()) + calibration.intercept; } else { bgReading.calculated_value = ((calibration.slope * bgReading.age_adjusted_raw_value) + calibration.intercept); bgReading.filtered_calculated_value = ((calibration.slope * bgReading.ageAdjustedFiltered()) + calibration.intercept);
filtered = bgReading.ageAdjustedFiltered() * 1000;
filtered = bgReading.ageAdjustedFiltered() * 1000;
filtered = bgReading.ageAdjustedFiltered() * 1000;
private Point createGlucosePoint(BgReading record) { // TODO DisplayGlucose option final BigDecimal delta = new BigDecimal(record.calculated_value_slope * 5 * 60 * 1000) .setScale(3, BigDecimal.ROUND_HALF_UP); return Point.measurement("glucose") .time(record.getEpochTimestamp(), TimeUnit.MILLISECONDS) .addField("value_mmol", record.calculated_value_mmol()) .addField("value_mgdl", record.getMgdlValue()) .addField("direction", record.slopeName()) .addField("filtered", record.ageAdjustedFiltered() * 1000) .addField("unfiltered", record.usedRaw() * 1000) .addField("rssi", 100) .addField("noise", record.noiseValue()) .addField("delta", delta) .build(); }
private Point createGlucosePoint(BgReading record) { // TODO DisplayGlucose option final BigDecimal delta = new BigDecimal(record.calculated_value_slope * 5 * 60 * 1000) .setScale(3, BigDecimal.ROUND_HALF_UP); return Point.measurement("glucose") .time(record.getEpochTimestamp(), TimeUnit.MILLISECONDS) .addField("value_mmol", record.calculated_value_mmol()) .addField("value_mgdl", record.getMgdlValue()) .addField("direction", record.slopeName()) .addField("filtered", record.ageAdjustedFiltered() * 1000) .addField("unfiltered", record.usedRaw() * 1000) .addField("rssi", 100) .addField("noise", record.noiseValue()) .addField("delta", delta) .build(); }
testData.put("direction", record.slopeName()); testData.put("type", "sgv"); testData.put("filtered", record.ageAdjustedFiltered() * 1000); testData.put("unfiltered", record.usedRaw() * 1000); testData.put("rssi", 100);
testData.put("direction", record.slopeName()); testData.put("type", "sgv"); testData.put("filtered", record.ageAdjustedFiltered() * 1000); testData.put("unfiltered", record.usedRaw() * 1000); testData.put("rssi", 100);