public static BloodTest create(long timestamp_ms, double mgdl, String source) { return create(timestamp_ms, mgdl, source, null); }
public static BloodTest createFromCal(double bg, double timeoffset, String source) { return createFromCal(bg, timeoffset, source, null); }
public Long saveit() { fixUpTable(); return save(); }
private static void processFromMessage(BloodTestMessage btm) { if ((btm != null) && (btm.uuid != null) && (btm.uuid.length() == 36)) { boolean is_new = false; BloodTest bt = byUUID(btm.uuid); if (bt == null) { bt = getForPreciseTimestamp(Wire.get(btm.timestamp, BloodTestMessage.DEFAULT_TIMESTAMP), CLOSEST_READING_MS); if (bt != null) { UserError.Log.wtf(TAG, "Error matches a different uuid with the same timestamp: " + bt.uuid + " vs " + btm.uuid + " skipping!"); return; bt = new BloodTest(); is_new = true; } else { bt.source = Wire.get(btm.source, BloodTestMessage.DEFAULT_SOURCE); bt.uuid = btm.uuid; bt.saveit(); // de-dupe by uuid if (is_new) { // cannot handle updates yet if (UploaderQueue.newEntry(is_new ? "insert" : "update", bt) != null) {
final BloodTest match = getForPreciseTimestamp(timestamp_ms, CLOSEST_READING_MS); if (match == null) { final BloodTest bt = new BloodTest(); bt.timestamp = timestamp_ms; bt.mgdl = mgdl; bt.state = STATE_VALID; bt.source = source; bt.saveit(); UserError.Log.d(TAG, "Created BloodTest uuid=" + bt.uuid + " mgdl=" + bt.mgdl + " timestamp=" + JoH.dateTimeText(bt.timestamp));
public static List<BloodTest> latest(int number) { try { return new Select() .from(BloodTest.class) .orderBy("timestamp desc") .limit(number) .execute(); } catch (android.database.sqlite.SQLiteException e) { fixUpTable(); return new ArrayList<>(); } }
continue; final BloodTest existing = BloodTest.byUUID(uuid); if (existing == null) { final long timestamp = DateUtil.tolerantFromISODateString(tr.getString("created_at")).getTime(); if (tr.getString("units").equals("mmol")) mgdl = mgdl * Constants.MMOLL_TO_MGDL; final BloodTest bt = BloodTest.create(timestamp, mgdl, tr.getString("enteredBy") + " " + VIA_NIGHTSCOUT_TAG); if (bt != null) { bt.saveit(); new_data = true; Log.ueh(TAG, "Received new Bloodtest data from Nightscout: " + BgGraphBuilder.unitized_string_with_units_static(mgdl) + " @ " + JoH.dateTimeText(timestamp));
BloodTest last = list != null && list.size() > 0 ? list.get(0) : BloodTest.last(); if (last != null) { Log.d(TAG, "sendWearBloodTestData last.timestamp:" + JoH.dateTimeText(last.timestamp)); graph = list; else if (startTime == 0) graph = BloodTest.last(count); else graph = BloodTest.latestForGraph(count, startTime); if (!graph.isEmpty()) { Log.d(TAG, "sendWearBloodTestData graph size=" + graph.size());
final BloodTest bt = BloodTest.create((gtb.time - ct.timediff) + gtb.offsetMs(), gtb.mgdl, BLUETOOTH_GLUCOSE_METER_TAG + ":\n" + mLastManufacturer + " " + mLastConnectedDeviceAddress, gtb.getUuid().toString()); if (bt != null) { UserError.Log.d(TAG, "Successfully created new BloodTest: " + bt.toS());
public static List<BloodTest> latestForGraph(int number, double startTime) { return latestForGraph(number, (long) startTime, Long.MAX_VALUE); }
if (record != null) { BloodTest data = gson.fromJson(record, BloodTest.class); BloodTest exists = BloodTest.byUUID(data.uuid); if (exists != null) { Log.d(TAG, "syncBloodTestData save existing BloodTest for uuid=" + data.uuid + " timestamp=" + data.timestamp + " timeString=" + JoH.dateTimeText(data.timestamp) + " mgdl=" + data.mgdl + " state=" + data.state); exists.state = data.state; exists.timestamp = data.timestamp; exists.save(); data.save(); Log.d(TAG, "syncBloodTestData create new BloodTest for uuid=" + data.uuid + " timestamp=" + data.timestamp + " timeString=" + JoH.dateTimeText(data.timestamp) + " mgdl=" + data.mgdl + " state=" + data.state);
public synchronized static void syncBloodTests() { Log.d(TAG, "syncBloodTests called"); if (Home.get_master_or_follower()) { if (JoH.ratelimit("gcm-btmm-send", 4)) { final byte[] this_btmm = BloodTest.toMultiMessage(BloodTest.last(12)); if (JoH.differentBytes("gcm-btmm-last-send", this_btmm)) { sendMessage("btmm", JoH.compressBytesforPayload(this_btmm)); Home.staticRefreshBGCharts(); } else { Log.d(TAG, "btmm message is identical to previously sent"); } } } }
final List<BloodTest> bloodTests = latestForGraph(1000, JoH.tsl() - period, JoH.tsl() - AddCalibration.estimatedInterstitialLagSeconds); final List<Double> difference = new ArrayList<>(); final List<Double> plugin_difference = new ArrayList<>(); Log.d(TAG, "Average accuracy: " + accuracyAsString(avg) + " (" + JoH.qs(avg, 5) + ")"); Log.d(TAG, "Plugin Average accuracy: " + accuracyAsString(plugin_avg) + " (" + JoH.qs(plugin_avg, 5) + ")"); return accuracyAsString(plugin_avg) + " / " + accuracyAsString(avg); return accuracyAsString(avg);
public static BloodTest lastValid() { final List<BloodTest> btl = lastValid(1); if ((btl != null) && (btl.size() > 0)) { return btl.get(0); } else { return null; } }
public static BloodTest last() { final List<BloodTest> btl = last(1); if ((btl != null) && (btl.size() > 0)) { return btl.get(0); } else { return null; } }
Pref.setString("selected_bluetooth_meter_address", ""); } else if (allWords.contentEquals("delete all finger stick data") || (allWords.contentEquals("delete all fingerstick data"))) { BloodTest.cleanup(-100000); } else if (allWords.contentEquals("delete all persistent store")) { SdcardImportExport.deletePersistentStore();
final BloodTest dupe = BloodTest.getForPreciseTimestamp(record.timestamp, 60000); if (dupe == null) {
final String bt_uuid = bundle.getString(Home.BLOOD_TEST_ACTION + "2"); if (bt_uuid != null) { final BloodTest bt = BloodTest.byUUID(bt_uuid); if (bt != null) { builder.setNeutralButton("Nothing", new DialogInterface.OnClickListener() {
private static void processFromMessage(BloodTestMessage btm) { if ((btm != null) && (btm.uuid != null) && (btm.uuid.length() == 36)) { boolean is_new = false; BloodTest bt = byUUID(btm.uuid); if (bt == null) { bt = getForPreciseTimestamp(Wire.get(btm.timestamp, BloodTestMessage.DEFAULT_TIMESTAMP), CLOSEST_READING_MS); if (bt != null) { UserError.Log.wtf(TAG, "Error matches a different uuid with the same timestamp: " + bt.uuid + " vs " + btm.uuid + " skipping!"); return; bt = new BloodTest(); is_new = true; } else { bt.source = Wire.get(btm.source, BloodTestMessage.DEFAULT_SOURCE); bt.uuid = btm.uuid; bt.saveit(); // de-dupe by uuid if (is_new) { // cannot handle updates yet if (UploaderQueue.newEntry(is_new ? "insert" : "update", bt) != null) {
final BloodTest match = getForPreciseTimestamp(timestamp_ms, CLOSEST_READING_MS); if (match == null) { final BloodTest bt = new BloodTest(); bt.timestamp = timestamp_ms; bt.mgdl = mgdl; bt.state = STATE_VALID; bt.source = source; bt.saveit(); if (UploaderQueue.newEntry("insert", bt) != null) { SyncService.startSyncService(3000); // sync in 3 seconds