public static BgReading getForPreciseTimestamp(long timestamp, long precision) { return getForPreciseTimestamp(timestamp, precision, true); }
public static BgReading getForPreciseTimestamp(long timestamp, double precision) { return getForPreciseTimestamp(timestamp, precision, true); }
public static BgReading getForPreciseTimestamp(long timestamp, double precision) { return getForPreciseTimestamp(timestamp, precision, true); }
public static BgReading getForPreciseTimestamp(long timestamp, double precision) { return getForPreciseTimestamp(timestamp, precision, true); }
public static BgReading getForPreciseTimestamp(long timestamp, long precision) { return getForPreciseTimestamp(timestamp, precision, true); }
final BgReading existing = getForPreciseTimestamp(timestamp, Constants.MINUTE_IN_MS); if (existing == null) { final BgReading bgr = new BgReading();
final BgReading existing = getForPreciseTimestamp(timestamp, Constants.MINUTE_IN_MS); if (existing == null) { final BgReading bgr = new BgReading();
final BgReading existing = getForPreciseTimestamp(timestamp, Constants.MINUTE_IN_MS); if (existing == null) { final BgReading bgr = new BgReading();
final BgReading existing = getForPreciseTimestamp(timestamp, Constants.MINUTE_IN_MS); if (existing == null) { final BgReading bgr = new BgReading();
private static void processFromMessage(BgReadingMessage btm) { if ((btm != null) && (btm.uuid != null) && (btm.uuid.length() == 36)) { BgReading bg = byUUID(btm.uuid); if (bg != null) { // we already have this uuid and we don't have a circumstance to update the record, so quick return here return; } if (bg == null) { bg = getForPreciseTimestamp(Wire.get(btm.timestamp, BgReadingMessage.DEFAULT_TIMESTAMP), CLOSEST_READING_MS, false); if (bg != null) { UserError.Log.wtf(TAG, "Error matches a different uuid with the same timestamp: " + bg.uuid + " vs " + btm.uuid + " skipping!"); return; } bg = new BgReading(); } bg.timestamp = Wire.get(btm.timestamp, BgReadingMessage.DEFAULT_TIMESTAMP); bg.calculated_value = Wire.get(btm.calculated_value, BgReadingMessage.DEFAULT_CALCULATED_VALUE); bg.filtered_calculated_value = Wire.get(btm.filtered_calculated_value, BgReadingMessage.DEFAULT_FILTERED_CALCULATED_VALUE); bg.calibration_flag = Wire.get(btm.calibration_flag, BgReadingMessage.DEFAULT_CALIBRATION_FLAG); bg.raw_calculated = Wire.get(btm.raw_calculated, BgReadingMessage.DEFAULT_RAW_CALCULATED); bg.raw_data = Wire.get(btm.raw_data, BgReadingMessage.DEFAULT_RAW_DATA); bg.calculated_value_slope = Wire.get(btm.calculated_value_slope, BgReadingMessage.DEFAULT_CALCULATED_VALUE_SLOPE); bg.calibration_uuid = btm.calibration_uuid; bg.uuid = btm.uuid; bg.save(); } else { UserError.Log.wtf(TAG, "processFromMessage uuid is null or invalid"); } }
private static void processFromMessage(BgReadingMessage btm) { if ((btm != null) && (btm.uuid != null) && (btm.uuid.length() == 36)) { BgReading bg = byUUID(btm.uuid); if (bg != null) { // we already have this uuid and we don't have a circumstance to update the record, so quick return here return; } if (bg == null) { bg = getForPreciseTimestamp(Wire.get(btm.timestamp, BgReadingMessage.DEFAULT_TIMESTAMP), CLOSEST_READING_MS, false); if (bg != null) { UserError.Log.wtf(TAG, "Error matches a different uuid with the same timestamp: " + bg.uuid + " vs " + btm.uuid + " skipping!"); return; } bg = new BgReading(); } bg.timestamp = Wire.get(btm.timestamp, BgReadingMessage.DEFAULT_TIMESTAMP); bg.calculated_value = Wire.get(btm.calculated_value, BgReadingMessage.DEFAULT_CALCULATED_VALUE); bg.filtered_calculated_value = Wire.get(btm.filtered_calculated_value, BgReadingMessage.DEFAULT_FILTERED_CALCULATED_VALUE); bg.calibration_flag = Wire.get(btm.calibration_flag, BgReadingMessage.DEFAULT_CALIBRATION_FLAG); bg.raw_calculated = Wire.get(btm.raw_calculated, BgReadingMessage.DEFAULT_RAW_CALCULATED); bg.raw_data = Wire.get(btm.raw_data, BgReadingMessage.DEFAULT_RAW_DATA); bg.calculated_value_slope = Wire.get(btm.calculated_value_slope, BgReadingMessage.DEFAULT_CALCULATED_VALUE_SLOPE); bg.calibration_uuid = btm.calibration_uuid; bg.uuid = btm.uuid; bg.save(); } else { UserError.Log.wtf(TAG, "processFromMessage uuid is null or invalid"); } }
private static void processFromMessage(BgReadingMessage btm) { if ((btm != null) && (btm.uuid != null) && (btm.uuid.length() == 36)) { BgReading bg = byUUID(btm.uuid); if (bg != null) { // we already have this uuid and we don't have a circumstance to update the record, so quick return here return; } if (bg == null) { bg = getForPreciseTimestamp(Wire.get(btm.timestamp, BgReadingMessage.DEFAULT_TIMESTAMP), CLOSEST_READING_MS, false); if (bg != null) { UserError.Log.wtf(TAG, "Error matches a different uuid with the same timestamp: " + bg.uuid + " vs " + btm.uuid + " skipping!"); return; } bg = new BgReading(); } bg.timestamp = Wire.get(btm.timestamp, BgReadingMessage.DEFAULT_TIMESTAMP); bg.calculated_value = Wire.get(btm.calculated_value, BgReadingMessage.DEFAULT_CALCULATED_VALUE); bg.filtered_calculated_value = Wire.get(btm.filtered_calculated_value, BgReadingMessage.DEFAULT_FILTERED_CALCULATED_VALUE); bg.calibration_flag = Wire.get(btm.calibration_flag, BgReadingMessage.DEFAULT_CALIBRATION_FLAG); bg.raw_calculated = Wire.get(btm.raw_calculated, BgReadingMessage.DEFAULT_RAW_CALCULATED); bg.raw_data = Wire.get(btm.raw_data, BgReadingMessage.DEFAULT_RAW_DATA); bg.calculated_value_slope = Wire.get(btm.calculated_value_slope, BgReadingMessage.DEFAULT_CALCULATED_VALUE_SLOPE); bg.calibration_uuid = btm.calibration_uuid; bg.uuid = btm.uuid; bg.save(); } else { UserError.Log.wtf(TAG, "processFromMessage uuid is null or invalid"); } }
private static void createBGfromGD(GlucoseData gd, boolean quick) { final double converted; if (gd.glucoseLevelRaw > 0) { converted = convert_for_dex(gd.glucoseLevelRaw); } else { converted = 12; // RF error message - might be something else like unconstrained spline } if (gd.realDate > 0) { // Log.d(TAG, "Raw debug: " + JoH.dateTimeText(gd.realDate) + " raw: " + gd.glucoseLevelRaw + " converted: " + converted); if ((newest_cmp == -1) || (oldest_cmp == -1) || (gd.realDate < oldest_cmp) || (gd.realDate > newest_cmp)) { // if (BgReading.readingNearTimeStamp(gd.realDate) == null) { if ((gd.realDate < oldest) || (oldest == -1)) oldest = gd.realDate; if ((gd.realDate > newest) || (newest == -1)) newest = gd.realDate; if (BgReading.getForPreciseTimestamp(gd.realDate, segmentation_timeslice) == null) { Log.d(TAG, "Creating bgreading at: " + JoH.dateTimeText(gd.realDate)); BgReading.create(converted, converted, xdrip.getAppContext(), gd.realDate, quick); // quick lite insert } else { if (d) Log.d(TAG, "Ignoring duplicate timestamp for: " + JoH.dateTimeText(gd.realDate)); } } else { if (d) Log.d(TAG, "Already processed from date range: " + JoH.dateTimeText(gd.realDate)); } } else { Log.e(TAG, "Fed a zero or negative date"); } if (d) Log.d(TAG, "Oldest : " + JoH.dateTimeText(oldest_cmp) + " Newest : " + JoH.dateTimeText(newest_cmp)); }
private static void createBGfromGD(GlucoseData gd, boolean quick) { final double converted; if (gd.glucoseLevelRaw > 0) { converted = convert_for_dex(gd.glucoseLevelRaw); } else { converted = 12; // RF error message - might be something else like unconstrained spline } if (gd.realDate > 0) { // Log.d(TAG, "Raw debug: " + JoH.dateTimeText(gd.realDate) + " raw: " + gd.glucoseLevelRaw + " converted: " + converted); if ((newest_cmp == -1) || (oldest_cmp == -1) || (gd.realDate < oldest_cmp) || (gd.realDate > newest_cmp)) { // if (BgReading.readingNearTimeStamp(gd.realDate) == null) { if ((gd.realDate < oldest) || (oldest == -1)) oldest = gd.realDate; if ((gd.realDate > newest) || (newest == -1)) newest = gd.realDate; if (BgReading.getForPreciseTimestamp(gd.realDate, segmentation_timeslice) == null) { Log.d(TAG, "Creating bgreading at: " + JoH.dateTimeText(gd.realDate)); BgReading.create(converted, converted, xdrip.getAppContext(), gd.realDate, quick); // quick lite insert } else { if (d) Log.d(TAG, "Ignoring duplicate timestamp for: " + JoH.dateTimeText(gd.realDate)); } } else { if (d) Log.d(TAG, "Already processed from date range: " + JoH.dateTimeText(gd.realDate)); } } else { Log.e(TAG, "Fed a zero or negative date"); } if (d) Log.d(TAG, "Oldest : " + JoH.dateTimeText(oldest_cmp) + " Newest : " + JoH.dateTimeText(newest_cmp)); }
private static void createBGfromGD(GlucoseData gd, boolean quick) { final double converted; if (gd.glucoseLevelRaw > 0) { converted = convert_for_dex(gd.glucoseLevelRaw); } else { converted = 12; // RF error message - might be something else like unconstrained spline } if (gd.realDate > 0) { // Log.d(TAG, "Raw debug: " + JoH.dateTimeText(gd.realDate) + " raw: " + gd.glucoseLevelRaw + " converted: " + converted); if ((newest_cmp == -1) || (oldest_cmp == -1) || (gd.realDate < oldest_cmp) || (gd.realDate > newest_cmp)) { // if (BgReading.readingNearTimeStamp(gd.realDate) == null) { if ((gd.realDate < oldest) || (oldest == -1)) oldest = gd.realDate; if ((gd.realDate > newest) || (newest == -1)) newest = gd.realDate; if (BgReading.getForPreciseTimestamp(gd.realDate, segmentation_timeslice) == null) { Log.d(TAG, "Creating bgreading at: " + JoH.dateTimeText(gd.realDate)); BgReading.create(converted, converted, xdrip.getAppContext(), gd.realDate, quick); // quick lite insert } else { if (d) Log.d(TAG, "Ignoring duplicate timestamp for: " + JoH.dateTimeText(gd.realDate)); } } else { if (d) Log.d(TAG, "Already processed from date range: " + JoH.dateTimeText(gd.realDate)); } } else { Log.e(TAG, "Fed a zero or negative date"); } if (d) Log.d(TAG, "Oldest : " + JoH.dateTimeText(oldest_cmp) + " Newest : " + JoH.dateTimeText(newest_cmp)); }
private static void processBacksies(List<BackFillStream.Backsie> backsies) { boolean changed = false; for (BackFillStream.Backsie backsie : backsies) { final long time = DexTimeKeeper.fromDexTime(getTransmitterID(), backsie.getDextime()); final long since = JoH.msSince(time); if ((since > HOUR_IN_MS * 6) || (since < 0)) { UserError.Log.wtf(TAG, "Backfill timestamp unrealistic: " + JoH.dateTimeText(time) + " (ignored)"); } else { if (BgReading.getForPreciseTimestamp(time, Constants.MINUTE_IN_MS * 4) == null) { final BgReading bgr = BgReading.bgReadingInsertFromG5(backsie.getGlucose(), time, "Backfill"); lastGlucoseBgReading = bgr; UserError.Log.d(TAG, "Adding backfilled reading: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose())); changed = true; } UserError.Log.d(TAG, "Backsie: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose())); } } if (changed) { updateStreamedTillTimeForBackfill(); } }
private static void processBacksies(List<BackFillStream.Backsie> backsies) { boolean changed = false; for (BackFillStream.Backsie backsie : backsies) { final long time = DexTimeKeeper.fromDexTime(getTransmitterID(), backsie.getDextime()); final long since = JoH.msSince(time); if ((since > HOUR_IN_MS * 6) || (since < 0)) { UserError.Log.wtf(TAG, "Backfill timestamp unrealistic: " + JoH.dateTimeText(time) + " (ignored)"); } else { if (BgReading.getForPreciseTimestamp(time, Constants.MINUTE_IN_MS * 4) == null) { final BgReading bgr = BgReading.bgReadingInsertFromG5(backsie.getGlucose(), time, "Backfill"); lastGlucoseBgReading = bgr; UserError.Log.d(TAG, "Adding backfilled reading: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose())); changed = true; } UserError.Log.d(TAG, "Backsie: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose())); } } if (changed) { updateStreamedTillTimeForBackfill(); } }
private static void processBacksies(List<BackFillStream.Backsie> backsies) { boolean changed = false; for (BackFillStream.Backsie backsie : backsies) { final long time = DexTimeKeeper.fromDexTime(getTransmitterID(), backsie.getDextime()); final long since = JoH.msSince(time); if ((since > HOUR_IN_MS * 6) || (since < 0)) { UserError.Log.wtf(TAG, "Backfill timestamp unrealistic: " + JoH.dateTimeText(time) + " (ignored)"); } else { if (BgReading.getForPreciseTimestamp(time, Constants.MINUTE_IN_MS * 4) == null) { final BgReading bgr = BgReading.bgReadingInsertFromG5(backsie.getGlucose(), time, "Backfill"); lastGlucoseBgReading = bgr; UserError.Log.d(TAG, "Adding backfilled reading: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose())); changed = true; } UserError.Log.d(TAG, "Backsie: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose())); } } if (changed) { updateStreamedTillTimeForBackfill(); } }
final BgReading existing = BgReading.getForPreciseTimestamp(recordTimestamp, 10000); if (existing == null) { UserError.Log.d(TAG, "NEW NEW NEW New entry: " + entry.toS());
final BgReading existing = BgReading.getForPreciseTimestamp(recordTimestamp, 10000); if (existing == null) { UserError.Log.d(TAG, "NEW NEW NEW New entry: " + entry.toS());