Java Code Examples for com.eveningoutpost.dexdrip.Models.BgReading#getForPreciseTimestamp()
The following examples show how to use
com.eveningoutpost.dexdrip.Models.BgReading#getForPreciseTimestamp() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Ob1G5StateMachine.java From xDrip with GNU General Public License v3.0 | 6 votes |
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(); } }
Example 2
Source File: Ob1G5StateMachine.java From xDrip with GNU General Public License v3.0 | 6 votes |
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(); } }
Example 3
Source File: Ob1G5StateMachine.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
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(); } }
Example 4
Source File: Ob1G5StateMachine.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
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(); } }
Example 5
Source File: LibreAlarmReceiver.java From xDrip with GNU General Public License v3.0 | 5 votes |
private static void createBGfromGD(GlucoseData gd, boolean use_smoothed_data, boolean quick) { final double converted; if (gd.glucoseLevelRaw > 0) { if(use_smoothed_data) { converted = convert_for_dex(gd.glucoseLevelRawSmoothed); Log.e(TAG,"Using smoothed value " + converted + " instead of " + convert_for_dex(gd.glucoseLevelRaw) ); } else { 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, false) == 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)); }
Example 6
Source File: LibreAlarmReceiver.java From xDrip with GNU General Public License v3.0 | 5 votes |
private static void createBGfromGD(GlucoseData gd, boolean use_smoothed_data, boolean quick) { final double converted; if (gd.glucoseLevelRaw > 0) { if(use_smoothed_data) { converted = convert_for_dex(gd.glucoseLevelRawSmoothed); Log.e(TAG,"Using smoothed value " + converted + " instead of " + convert_for_dex(gd.glucoseLevelRaw) ); } else { 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, false) == 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)); }
Example 7
Source File: LibreAlarmReceiver.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
private static void createBGfromGD(GlucoseData gd, boolean use_smoothed_data, boolean quick) { final double converted; if (gd.glucoseLevelRaw > 0) { if(use_smoothed_data) { converted = convert_for_dex(gd.glucoseLevelRawSmoothed); Log.e(TAG,"Using smoothed value " + converted + " instead of " + convert_for_dex(gd.glucoseLevelRaw) ); } else { 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, false) == 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)); }
Example 8
Source File: LibreAlarmReceiver.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
private static void createBGfromGD(GlucoseData gd, boolean use_smoothed_data, boolean quick) { final double converted; if (gd.glucoseLevelRaw > 0) { if(use_smoothed_data) { converted = convert_for_dex(gd.glucoseLevelRawSmoothed); Log.e(TAG,"Using smoothed value " + converted + " instead of " + convert_for_dex(gd.glucoseLevelRaw) ); } else { 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, false) == 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)); }
Example 9
Source File: BlueJayService.java From xDrip with GNU General Public License v3.0 | 4 votes |
public void processPushRxActions(final PushRx pushRx) { switch (pushRx.type) { case LongPress1: lastLongPress1 = JoH.tsl(); if (JoH.msSince(awaiting_easy_auth) < Constants.MINUTE_IN_MS * 5) { addToLog("Processing easy auth"); awaiting_easy_auth = 0; easyAuth(); } else { AlertPlayer.getPlayer().OpportunisticSnooze(); BroadcastSnooze.send(); BlueJayEmit.sendButtonPress(1); } // TODO cancel any alert queue break; case BackFill: boolean changed = false; for (val backsie : pushRx.backfills) { final long since = JoH.msSince(backsie.timestamp); if ((since > HOUR_IN_MS * 6) || (since < 0)) { UserError.Log.wtf(TAG, "Backfill timestamp unrealistic: " + JoH.dateTimeText(backsie.timestamp) + " (ignored)"); } else { if (backsie.mgdl > 12) { // TODO check this cut off if (BgReading.getForPreciseTimestamp(backsie.timestamp, Constants.MINUTE_IN_MS * 4, false) == null) { try { final BgReading bgr = BgReading.bgReadingInsertFromG5(backsie.mgdl, backsie.timestamp, "Backfill").appendSourceInfo("BlueJay"); // TODO bluejay UserError.Log.d(TAG, "Adding backfilled reading: " + JoH.dateTimeText(backsie.timestamp) + " " + Unitized.unitized_string_static(backsie.mgdl)); changed = true; } catch (NullPointerException e) { UserError.Log.e(TAG, "Got null pointer when trying to add backfilled data"); } } } else { // } UserError.Log.d(TAG, "Backsie: " + JoH.dateTimeText(backsie.timestamp) + " " + Unitized.unitized_string_static(backsie.mgdl)); } } if (changed) { Home.staticRefreshBGChartsOnIdle(); } if (JoH.quietratelimit("bluejay-backfill-received", 20)) { backFillReceived(); } break; case Choice: UserError.Log.d(TAG, "Push Choice: " + pushRx.value + " :: " + pushRx.text); BlueJayEmit.sendChoice(pushRx.value, pushRx.text); break; } }
Example 10
Source File: MedtrumCollectionService.java From xDrip with GNU General Public License v3.0 | 4 votes |
private void processBackFillPacket(final byte[] packet) { final BackFillRx backFillRx = new BackFillRx(packet); UserError.Log.d(TAG, backFillRx.toS()); if (backFillRx.isOk()) { boolean changed = false; final List<Integer> backsies = backFillRx.getRawList(); if (backsies != null) { for (int index = 0; index < backsies.size(); index++) { final long timestamp = timeStampFromTickCounter(serial, backFillRx.sequenceStart + index); UserError.Log.d(TAG, "Backsie: id:" + (backFillRx.sequenceStart + index) + " raw:" + backsies.get(index) + " @ " + JoH.dateTimeText(timestamp)); final long since = msSince(timestamp); if ((since > HOUR_IN_MS * 6) || (since < 0)) { UserError.Log.wtf(TAG, "Backfill timestamp unrealistic: " + JoH.dateTimeText(timestamp) + " (ignored)"); } else { final double glucose = backFillRx.getGlucose(backsies.get(index)); final int scaled_raw_data = backFillRx.getSensorRawEmulateDex(backsies.get(index)); if (BgReading.getForPreciseTimestamp(timestamp, (long)(Constants.MINUTE_IN_MS * 2.5)) == null) { if (isNative()) { // Native version if (glucose > 0) { BgReading.bgReadingInsertMedtrum(glucose, timestamp, "Backfill", scaled_raw_data); UserError.Log.d(TAG, "Adding native backfilled reading: " + JoH.dateTimeText(timestamp) + " " + BgGraphBuilder.unitized_string_static(glucose)); } final BgReading bgReadingTemp = BgReading.createFromRawNoSave(null, null, scaled_raw_data, scaled_raw_data, timestamp); if (bgReadingTemp.calculated_value > 0) { Prediction.create(bgReadingTemp.timestamp, (int) bgReadingTemp.calculated_value, "Medtrum2nd").save(); } } else { if (glucose > 0) { Prediction.create(timestamp, (int) glucose, "Medtrum2nd").save(); } // xDrip as primary final BgReading bgreading = BgReading.create(scaled_raw_data, scaled_raw_data, xdrip.getAppContext(), timestamp); if (bgreading != null) { UserError.Log.d(TAG, "Backfilled BgReading created: " + bgreading.uuid + " " + JoH.dateTimeText(bgreading.timestamp)); } else { UserError.Log.d(TAG, "BgReading null!"); } } Inevitable.task("backfill-ui-update", 3000, Home::staticRefreshBGChartsOnIdle); changed = true; } } } if (!changed && backsies.size() < requestedBackfillSize) { if (JoH.ratelimit("mt-backfill-repeat", 60)) { UserError.Log.d(TAG, "Requesting additional backfill with offset: " + backsies.size()); backFillIfNeeded(lastAnnex, backsies.size()); } } } } else { UserError.Log.e(TAG, "Backfill data reports not ok"); } }
Example 11
Source File: EntryProcessor.java From xDrip with GNU General Public License v3.0 | 4 votes |
static synchronized void processEntries(final List<Entry> entries, final boolean live) { if (entries == null) return; final Sensor sensor = Sensor.createDefaultIfMissing(); for (final Entry entry : entries) { if (entry != null) { UserError.Log.d(TAG, "ENTRY: " + entry.toS()); UserError.Log.d(TAG, "Glucose value: " + Unitized.unitized_string_static(entry.sgv)); final long recordTimestamp = entry.getTimeStamp(); if (recordTimestamp > 0) { final BgReading existing = BgReading.getForPreciseTimestamp(recordTimestamp, 10000); if (existing == null) { UserError.Log.d(TAG, "NEW NEW NEW New entry: " + entry.toS()); if (live) { final BgReading bg = new BgReading(); bg.timestamp = recordTimestamp; bg.calculated_value = entry.sgv; bg.raw_data = entry.unfiltered != 0 ? entry.unfiltered : SPECIAL_FOLLOWER_PLACEHOLDER; bg.filtered_data = entry.filtered; bg.noise = entry.noise + ""; // TODO need to handle slope?? bg.sensor = sensor; bg.sensor_uuid = sensor.uuid; bg.source_info = "Nightscout Follow"; bg.save(); Inevitable.task("entry-proc-post-pr",500, () -> bg.postProcess(false)); } } else { // break; // stop if we have this reading TODO are entries always in order? } } else { UserError.Log.e(TAG, "Could not parse a timestamp from: " + entry.toS()); } } else { UserError.Log.d(TAG, "Entry is null"); } } }
Example 12
Source File: BlueJayService.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public void processPushRxActions(final PushRx pushRx) { switch (pushRx.type) { case LongPress1: lastLongPress1 = JoH.tsl(); if (JoH.msSince(awaiting_easy_auth) < Constants.MINUTE_IN_MS * 5) { addToLog("Processing easy auth"); awaiting_easy_auth = 0; easyAuth(); } else { AlertPlayer.getPlayer().OpportunisticSnooze(); BroadcastSnooze.send(); BlueJayEmit.sendButtonPress(1); } // TODO cancel any alert queue break; case BackFill: boolean changed = false; for (val backsie : pushRx.backfills) { final long since = JoH.msSince(backsie.timestamp); if ((since > HOUR_IN_MS * 6) || (since < 0)) { UserError.Log.wtf(TAG, "Backfill timestamp unrealistic: " + JoH.dateTimeText(backsie.timestamp) + " (ignored)"); } else { if (backsie.mgdl > 12) { // TODO check this cut off if (BgReading.getForPreciseTimestamp(backsie.timestamp, Constants.MINUTE_IN_MS * 4, false) == null) { try { final BgReading bgr = BgReading.bgReadingInsertFromG5(backsie.mgdl, backsie.timestamp, "Backfill").appendSourceInfo("BlueJay"); // TODO bluejay UserError.Log.d(TAG, "Adding backfilled reading: " + JoH.dateTimeText(backsie.timestamp) + " " + Unitized.unitized_string_static(backsie.mgdl)); changed = true; } catch (NullPointerException e) { UserError.Log.e(TAG, "Got null pointer when trying to add backfilled data"); } } } else { // } UserError.Log.d(TAG, "Backsie: " + JoH.dateTimeText(backsie.timestamp) + " " + Unitized.unitized_string_static(backsie.mgdl)); } } if (changed) { Home.staticRefreshBGChartsOnIdle(); } if (JoH.quietratelimit("bluejay-backfill-received", 20)) { backFillReceived(); } break; case Choice: UserError.Log.d(TAG, "Push Choice: " + pushRx.value + " :: " + pushRx.text); BlueJayEmit.sendChoice(pushRx.value, pushRx.text); break; } }
Example 13
Source File: MedtrumCollectionService.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private void processBackFillPacket(final byte[] packet) { final BackFillRx backFillRx = new BackFillRx(packet); UserError.Log.d(TAG, backFillRx.toS()); if (backFillRx.isOk()) { boolean changed = false; final List<Integer> backsies = backFillRx.getRawList(); if (backsies != null) { for (int index = 0; index < backsies.size(); index++) { final long timestamp = timeStampFromTickCounter(serial, backFillRx.sequenceStart + index); UserError.Log.d(TAG, "Backsie: id:" + (backFillRx.sequenceStart + index) + " raw:" + backsies.get(index) + " @ " + JoH.dateTimeText(timestamp)); final long since = msSince(timestamp); if ((since > HOUR_IN_MS * 6) || (since < 0)) { UserError.Log.wtf(TAG, "Backfill timestamp unrealistic: " + JoH.dateTimeText(timestamp) + " (ignored)"); } else { final double glucose = backFillRx.getGlucose(backsies.get(index)); final int scaled_raw_data = backFillRx.getSensorRawEmulateDex(backsies.get(index)); if (BgReading.getForPreciseTimestamp(timestamp, (long)(Constants.MINUTE_IN_MS * 2.5)) == null) { if (isNative()) { // Native version if (glucose > 0) { BgReading.bgReadingInsertMedtrum(glucose, timestamp, "Backfill", scaled_raw_data); UserError.Log.d(TAG, "Adding native backfilled reading: " + JoH.dateTimeText(timestamp) + " " + BgGraphBuilder.unitized_string_static(glucose)); } final BgReading bgReadingTemp = BgReading.createFromRawNoSave(null, null, scaled_raw_data, scaled_raw_data, timestamp); if (bgReadingTemp.calculated_value > 0) { Prediction.create(bgReadingTemp.timestamp, (int) bgReadingTemp.calculated_value, "Medtrum2nd").save(); } } else { if (glucose > 0) { Prediction.create(timestamp, (int) glucose, "Medtrum2nd").save(); } // xDrip as primary final BgReading bgreading = BgReading.create(scaled_raw_data, scaled_raw_data, xdrip.getAppContext(), timestamp); if (bgreading != null) { UserError.Log.d(TAG, "Backfilled BgReading created: " + bgreading.uuid + " " + JoH.dateTimeText(bgreading.timestamp)); } else { UserError.Log.d(TAG, "BgReading null!"); } } Inevitable.task("backfill-ui-update", 3000, Home::staticRefreshBGChartsOnIdle); changed = true; } } } if (!changed && backsies.size() < requestedBackfillSize) { if (JoH.ratelimit("mt-backfill-repeat", 60)) { UserError.Log.d(TAG, "Requesting additional backfill with offset: " + backsies.size()); backFillIfNeeded(lastAnnex, backsies.size()); } } } } else { UserError.Log.e(TAG, "Backfill data reports not ok"); } }
Example 14
Source File: EntryProcessor.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
static synchronized void processEntries(final List<Entry> entries, final boolean live) { if (entries == null) return; final Sensor sensor = Sensor.createDefaultIfMissing(); for (final Entry entry : entries) { if (entry != null) { UserError.Log.d(TAG, "ENTRY: " + entry.toS()); UserError.Log.d(TAG, "Glucose value: " + Unitized.unitized_string_static(entry.sgv)); final long recordTimestamp = entry.getTimeStamp(); if (recordTimestamp > 0) { final BgReading existing = BgReading.getForPreciseTimestamp(recordTimestamp, 10000); if (existing == null) { UserError.Log.d(TAG, "NEW NEW NEW New entry: " + entry.toS()); if (live) { final BgReading bg = new BgReading(); bg.timestamp = recordTimestamp; bg.calculated_value = entry.sgv; bg.raw_data = entry.unfiltered != 0 ? entry.unfiltered : SPECIAL_FOLLOWER_PLACEHOLDER; bg.filtered_data = entry.filtered; bg.noise = entry.noise + ""; // TODO need to handle slope?? bg.sensor = sensor; bg.sensor_uuid = sensor.uuid; bg.source_info = "Nightscout Follow"; bg.save(); Inevitable.task("entry-proc-post-pr",500, () -> bg.postProcess(false)); } } else { // break; // stop if we have this reading TODO are entries always in order? } } else { UserError.Log.e(TAG, "Could not parse a timestamp from: " + entry.toS()); } } else { UserError.Log.d(TAG, "Entry is null"); } } }