public String getDg_deltaName(){ if(dg_mgdl != 0 && dg_delta_name != null) return dg_delta_name; return slopeName(); }
public String getDg_deltaName(){ if(dg_mgdl != 0 && dg_delta_name != null) return dg_delta_name; return slopeName(); }
public String getDg_deltaName(){ if(dg_mgdl != 0 && dg_delta_name != null) return dg_delta_name; return slopeName(); }
private RequestBody populateLegacyAPIEntry(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)); json.put("date", record.timestamp); json.put("dateString", format.format(record.timestamp)); json.put("sgv", (int)record.calculated_value); json.put("direction", record.slopeName()); return RequestBody.create(MediaType.parse("application/json"), json.toString()); }
private RequestBody populateLegacyAPIEntry(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)); json.put("date", record.timestamp); json.put("dateString", format.format(record.timestamp)); json.put("sgv", (int)record.calculated_value); json.put("direction", record.slopeName()); return RequestBody.create(MediaType.parse("application/json"), json.toString()); }
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."); }
public static void speakNow(long grace) { final BgReading bgReading = BgReading.last(); if (bgReading != null) { final BestGlucose.DisplayGlucose dg = BestGlucose.getDisplayGlucose(); if (dg != null) { BgToSpeech.realSpeakNow(dg.mgdl, dg.timestamp + grace, dg.delta_name); } else { BgToSpeech.realSpeakNow(bgReading.calculated_value, bgReading.timestamp + grace, bgReading.slopeName()); } } }
public static void speakNow(long grace) { final BgReading bgReading = BgReading.last(); if (bgReading != null) { final BestGlucose.DisplayGlucose dg = BestGlucose.getDisplayGlucose(); if (dg != null) { BgToSpeech.realSpeakNow(dg.mgdl, dg.timestamp + grace, dg.delta_name); } else { BgToSpeech.realSpeakNow(bgReading.calculated_value, bgReading.timestamp + grace, bgReading.slopeName()); } } }
private static void textToSpeech(BgReading bgReading, BestGlucose.DisplayGlucose dg) { //Text to speech if (Pref.getBooleanDefaultFalse("bg_to_speech") || VehicleMode.shouldSpeak()) { if (dg == null) dg = BestGlucose.getDisplayGlucose(); if (dg != null) { BgToSpeech.speak(dg.mgdl, dg.timestamp, dg.delta_name); } else { BgToSpeech.speak(bgReading.calculated_value, bgReading.timestamp, bgReading.slopeName()); } } }
private static void textToSpeech(BgReading bgReading, BestGlucose.DisplayGlucose dg) { //Text to speech if (Pref.getBooleanDefaultFalse("bg_to_speech") || VehicleMode.shouldSpeak()) { if (dg == null) dg = BestGlucose.getDisplayGlucose(); if (dg != null) { BgToSpeech.speak(dg.mgdl, dg.timestamp, dg.delta_name); } else { BgToSpeech.speak(bgReading.calculated_value, bgReading.timestamp, bgReading.slopeName()); } } }
slope_name = BgReading.slopeName(estimated_delta_by_minute); extrastring = "\u26A0"; // warning symbol ! warning_level = 1; dg.slope = slope; slope_arrow = BgReading.slopeToArrowSymbol(slope * 60000); // slope by minute slope_name = BgReading.slopeName(slope * 60000); Log.d(TAG, "No noise option slope by minute: " + JoH.qs(slope * 60000, 5));
slope_name = BgReading.slopeName(estimated_delta_by_minute); extrastring = "\u26A0"; // warning symbol ! warning_level = 1; dg.slope = slope; slope_arrow = BgReading.slopeToArrowSymbol(slope * 60000); // slope by minute slope_name = BgReading.slopeName(slope * 60000); Log.d(TAG, "No noise option slope by minute: " + JoH.qs(slope * 60000, 5));
bundle.putString(Intents.EXTRA_BG_SLOPE_NAME, "9"); // not sure if this is right but has been this way for a long time } else { bundle.putString(Intents.EXTRA_BG_SLOPE_NAME, bgReading.slopeName());
bundle.putString(Intents.EXTRA_BG_SLOPE_NAME, "9"); // not sure if this is right but has been this way for a long time } else { bundle.putString(Intents.EXTRA_BG_SLOPE_NAME, bgReading.slopeName());
bundle.putString(Intents.EXTRA_BG_SLOPE_NAME, "9"); // not sure if this is right but has been this way for a long time } else { bundle.putString(Intents.EXTRA_BG_SLOPE_NAME, bgReading.slopeName());
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(); }
@Test public void bgReadingInsertFromDataTest() throws JSONException { // test data courtesy of philipgo - thanks final JSONObject json_object = new JSONObject(); json_object.put("date", 1526717691000.0); json_object.put("sgv", 148); json_object.put("direction", "SingleUp"); final BgReading result = NSEmulatorReceiver.bgReadingInsertFromData(json_object.getLong("date"), json_object.getDouble("sgv"), BgReading.slopefromName(json_object.getString("direction")), true); assertWithMessage("result not null").that(result).isNotNull(); assertWithMessage("direction matches").that(result.slopeName()).isEqualTo("SingleUp"); assertWithMessage("timestamp matches").that(result.timestamp).isEqualTo(1526717691000L); assertWithMessage("sgv matches 1").that(result.calculated_value).isEqualTo(148d); assertWithMessage("sgv matches 2").that(result.filtered_calculated_value).isEqualTo(148d); assertWithMessage("sgv matches 3").that(result.raw_data).isEqualTo(148d); assertWithMessage("sgv matches 4").that(result.filtered_data).isEqualTo(148d); //System.out.println(result.toJSON(true)); //System.out.println(result.slopeName()); } }
@Test public void bgReadingInsertFromDataTest() throws JSONException { // test data courtesy of philipgo - thanks final JSONObject json_object = new JSONObject(); json_object.put("date", 1526717691000.0); json_object.put("sgv", 148); json_object.put("direction", "SingleUp"); final BgReading result = NSEmulatorReceiver.bgReadingInsertFromData(json_object.getLong("date"), json_object.getDouble("sgv"), BgReading.slopefromName(json_object.getString("direction")), true); assertWithMessage("result not null").that(result).isNotNull(); assertWithMessage("direction matches").that(result.slopeName()).isEqualTo("SingleUp"); assertWithMessage("timestamp matches").that(result.timestamp).isEqualTo(1526717691000L); assertWithMessage("sgv matches 1").that(result.calculated_value).isEqualTo(148d); assertWithMessage("sgv matches 2").that(result.filtered_calculated_value).isEqualTo(148d); assertWithMessage("sgv matches 3").that(result.raw_data).isEqualTo(148d); assertWithMessage("sgv matches 4").that(result.filtered_data).isEqualTo(148d); //System.out.println(result.toJSON(true)); //System.out.println(result.slopeName()); } }