public void onClick(View v) { if (futureReadings != null && futureReadings.size() > 0) { for (BgReading bgReading : futureReadings) { bgReading.calculated_value = 0; bgReading.raw_data = 0; bgReading.timestamp = 0; bgReading.save(); } } if (futureCalibrations != null && futureCalibrations.size() > 0) { for (Calibration calibration : futureCalibrations) { calibration.slope_confidence = 0; calibration.sensor_confidence = 0; calibration.timestamp = 0; calibration.save(); } } } });
public void onClick(View v) { if(futureReadings != null && futureReadings.size() > 0) { for (BgReading bgReading : futureReadings) { bgReading.calculated_value = 0; bgReading.raw_data = 0; bgReading.timestamp = 0; bgReading.save(); } } if(futureCalibrations != null && futureCalibrations.size() > 0) { for (Calibration calibration : futureCalibrations) { calibration.slope_confidence = 0; calibration.sensor_confidence = 0; calibration.timestamp = 0; calibration.save(); } } } });
public void onClick(View v) { if (futureReadings != null && futureReadings.size() > 0) { for (BgReading bgReading : futureReadings) { bgReading.calculated_value = 0; bgReading.raw_data = 0; bgReading.timestamp = 0; bgReading.save(); } } if (futureCalibrations != null && futureCalibrations.size() > 0) { for (Calibration calibration : futureCalibrations) { calibration.slope_confidence = 0; calibration.sensor_confidence = 0; calibration.timestamp = 0; calibration.save(); } } } });
public void onClick(View v) { if(futureReadings != null && futureReadings.size() > 0) { for (BgReading bgReading : futureReadings) { bgReading.calculated_value = 0; bgReading.raw_data = 0; bgReading.timestamp = 0; bgReading.save(); } } if(futureCalibrations != null && futureCalibrations.size() > 0) { for (Calibration calibration : futureCalibrations) { calibration.slope_confidence = 0; calibration.sensor_confidence = 0; calibration.timestamp = 0; calibration.save(); } } } });
public void find_slope() { List<BgReading> last_2 = BgReading.latest(2); // FYI: By default, assertions are disabled at runtime. Add "-ea" to commandline to enable. // https://docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html assert last_2.get(0).uuid.equals(this.uuid) : "Invariant condition not fulfilled: calculating slope and current reading wasn't saved before"; if ((last_2 != null) && (last_2.size() == 2)) { calculated_value_slope = calculateSlope(this, last_2.get(1)); save(); } else if ((last_2 != null) && (last_2.size() == 1)) { calculated_value_slope = 0; save(); } else { if (JoH.ratelimit("no-bg-couldnt-find-slope", 15)) { Log.w(TAG, "NO BG? COULDNT FIND SLOPE!"); } } }
public void find_slope() { List<BgReading> last_2 = BgReading.latest(2); // FYI: By default, assertions are disabled at runtime. Add "-ea" to commandline to enable. // https://docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html assert last_2.get(0).uuid.equals(this.uuid) : "Invariant condition not fulfilled: calculating slope and current reading wasn't saved before"; if ((last_2 != null) && (last_2.size() == 2)) { calculated_value_slope = calculateSlope(this, last_2.get(1)); save(); } else if ((last_2 != null) && (last_2.size() == 1)) { calculated_value_slope = 0; save(); } else { if (JoH.ratelimit("no-bg-couldnt-find-slope", 15)) { Log.w(TAG, "NO BG? COULDNT FIND SLOPE!"); } } }
public void find_slope() { List<BgReading> last_2 = BgReading.latest(2); // FYI: By default, assertions are disabled at runtime. Add "-ea" to commandline to enable. // https://docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html assert last_2.get(0).uuid.equals(this.uuid) : "Invariant condition not fulfilled: calculating slope and current reading wasn't saved before"; if ((last_2 != null) && (last_2.size() == 2)) { calculated_value_slope = calculateSlope(this, last_2.get(1)); save(); } else if ((last_2 != null) && (last_2.size() == 1)) { calculated_value_slope = 0; save(); } else { if (JoH.ratelimit("no-bg-couldnt-find-slope", 15)) { Log.w(TAG, "NO BG? COULDNT FIND SLOPE!"); } } }
public BgReading injectNoise(boolean save) { final BgReading bgReading = this; if (JoH.msSince(bgReading.timestamp) > Constants.MINUTE_IN_MS * 20) { bgReading.noise = "0"; } else { BgGraphBuilder.refreshNoiseIfOlderThan(bgReading.timestamp); if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_HIGH) { bgReading.noise = "4"; } else if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TOO_HIGH_FOR_PREDICT) { bgReading.noise = "3"; } else if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TRIGGER) { bgReading.noise = "2"; } } if (save) bgReading.save(); return bgReading; }
public BgReading injectNoise(boolean save) { final BgReading bgReading = this; if (JoH.msSince(bgReading.timestamp) > Constants.MINUTE_IN_MS * 20) { bgReading.noise = "0"; } else { BgGraphBuilder.refreshNoiseIfOlderThan(bgReading.timestamp); if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_HIGH) { bgReading.noise = "4"; } else if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TOO_HIGH_FOR_PREDICT) { bgReading.noise = "3"; } else if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TRIGGER) { bgReading.noise = "2"; } } if (save) bgReading.save(); return bgReading; }
public BgReading injectNoise(boolean save) { final BgReading bgReading = this; if (JoH.msSince(bgReading.timestamp) > Constants.MINUTE_IN_MS * 20) { bgReading.noise = "0"; } else { BgGraphBuilder.refreshNoiseIfOlderThan(bgReading.timestamp); if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_HIGH) { bgReading.noise = "4"; } else if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TOO_HIGH_FOR_PREDICT) { bgReading.noise = "3"; } else if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TRIGGER) { bgReading.noise = "2"; } } if (save) bgReading.save(); return bgReading; }
private void addMockBgReading(int raw_data, int minutes, Sensor sensor) { BgReading mockReading = new BgReading(); mockReading.raw_data = raw_data; mockReading.timestamp = System.currentTimeMillis() - (1000 * 60 * minutes); mockReading.sensor = sensor; mockReading.age_adjusted_raw_value = raw_data + 0.1; mockReading.save(); } }
private void addMockBgReading(int raw_data, int minutes, Sensor sensor) { BgReading mockReading = new BgReading(); mockReading.raw_data = raw_data; mockReading.calculated_value = raw_data; mockReading.timestamp = System.currentTimeMillis() - (1000 * 60 * minutes); mockReading.sensor = sensor; mockReading.age_adjusted_raw_value = raw_data + 0.1; mockReading.save(); } }
private void addMockBgReading(int raw_data, int minutes, Sensor sensor) { BgReading mockReading = new BgReading(); mockReading.raw_data = raw_data; mockReading.timestamp = System.currentTimeMillis() - (1000 * 60 * minutes); mockReading.sensor = sensor; mockReading.age_adjusted_raw_value = raw_data + 0.1; mockReading.save(); } }
private void addMockBgReading(int raw_data, int minutes, Sensor sensor) { BgReading mockReading = new BgReading(); mockReading.raw_data = raw_data; mockReading.calculated_value = raw_data; mockReading.timestamp = System.currentTimeMillis() - (1000 * 60 * minutes); mockReading.sensor = sensor; mockReading.age_adjusted_raw_value = raw_data + 0.1; mockReading.save(); } }
public void injectDisplayGlucose(BestGlucose.DisplayGlucose displayGlucose) { //displayGlucose can be null. E.g. when out of order values come in if (displayGlucose != null) { if (Math.abs(displayGlucose.timestamp - timestamp) < Constants.MINUTE_IN_MS * 10) { dg_mgdl = displayGlucose.mgdl; dg_slope = displayGlucose.slope; dg_delta_name = displayGlucose.delta_name; // TODO we probably should reflect the display glucose delta here as well for completeness this.save(); } else { if (JoH.ratelimit("cannotinjectdg", 30)) { UserError.Log.e(TAG, "Cannot inject display glucose value as time difference too great: " + JoH.dateTimeText(displayGlucose.timestamp) + " vs " + JoH.dateTimeText(timestamp)); } } } }
public void injectDisplayGlucose(BestGlucose.DisplayGlucose displayGlucose) { //displayGlucose can be null. E.g. when out of order values come in if (displayGlucose != null) { if (Math.abs(displayGlucose.timestamp - timestamp) < Constants.MINUTE_IN_MS * 10) { dg_mgdl = displayGlucose.mgdl; dg_slope = displayGlucose.slope; dg_delta_name = displayGlucose.delta_name; // TODO we probably should reflect the display glucose delta here as well for completeness this.save(); } else { if (JoH.ratelimit("cannotinjectdg", 30)) { UserError.Log.e(TAG, "Cannot inject display glucose value as time difference too great: " + JoH.dateTimeText(displayGlucose.timestamp) + " vs " + JoH.dateTimeText(timestamp)); } } } }
public void injectDisplayGlucose(BestGlucose.DisplayGlucose displayGlucose) { //displayGlucose can be null. E.g. when out of order values come in if (displayGlucose != null) { if (Math.abs(displayGlucose.timestamp - timestamp) < Constants.MINUTE_IN_MS * 10) { dg_mgdl = displayGlucose.mgdl; dg_slope = displayGlucose.slope; dg_delta_name = displayGlucose.delta_name; // TODO we probably should reflect the display glucose delta here as well for completeness this.save(); } else { if (JoH.ratelimit("cannotinjectdg", 30)) { UserError.Log.e(TAG, "Cannot inject display glucose value as time difference too great: " + JoH.dateTimeText(displayGlucose.timestamp) + " vs " + JoH.dateTimeText(timestamp)); } } } }
public static void create(SensorRecord sensorRecord, long addativeOffset, Context context) { Log.i(TAG, "create: gonna make some sensor records: " + sensorRecord.getUnfiltered()); if (BgReading.is_new(sensorRecord, addativeOffset)) { BgReading bgReading = new BgReading(); Sensor sensor = Sensor.currentSensor(); Calibration calibration = Calibration.getForTimestamp(sensorRecord.getSystemTime().getTime() + addativeOffset); if (sensor != null && calibration != null) { bgReading.sensor = sensor; bgReading.sensor_uuid = sensor.uuid; bgReading.calibration = calibration; bgReading.calibration_uuid = calibration.uuid; bgReading.raw_data = (sensorRecord.getUnfiltered() / 1000); bgReading.filtered_data = (sensorRecord.getFiltered() / 1000); bgReading.timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset; if (bgReading.timestamp > new Date().getTime()) { return; } bgReading.uuid = UUID.randomUUID().toString(); bgReading.time_since_sensor_started = bgReading.timestamp - sensor.started_at; bgReading.calculateAgeAdjustedRawValue(); bgReading.save(); } } }
public static void create(SensorRecord sensorRecord, long addativeOffset, Context context) { Log.i(TAG, "create: gonna make some sensor records: " + sensorRecord.getUnfiltered()); if (BgReading.is_new(sensorRecord, addativeOffset)) { BgReading bgReading = new BgReading(); Sensor sensor = Sensor.currentSensor(); Calibration calibration = Calibration.getForTimestamp(sensorRecord.getSystemTime().getTime() + addativeOffset); if (sensor != null && calibration != null) { bgReading.sensor = sensor; bgReading.sensor_uuid = sensor.uuid; bgReading.calibration = calibration; bgReading.calibration_uuid = calibration.uuid; bgReading.raw_data = (sensorRecord.getUnfiltered() / 1000); bgReading.filtered_data = (sensorRecord.getFiltered() / 1000); bgReading.timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset; if (bgReading.timestamp > new Date().getTime()) { return; } bgReading.uuid = UUID.randomUUID().toString(); bgReading.time_since_sensor_started = bgReading.timestamp - sensor.started_at; bgReading.calculateAgeAdjustedRawValue(); bgReading.save(); } } }
public static void create(SensorRecord sensorRecord, long addativeOffset, Context context) { Log.i(TAG, "create: gonna make some sensor records: " + sensorRecord.getUnfiltered()); if (BgReading.is_new(sensorRecord, addativeOffset)) { BgReading bgReading = new BgReading(); Sensor sensor = Sensor.currentSensor(); Calibration calibration = Calibration.getForTimestamp(sensorRecord.getSystemTime().getTime() + addativeOffset); if (sensor != null && calibration != null) { bgReading.sensor = sensor; bgReading.sensor_uuid = sensor.uuid; bgReading.calibration = calibration; bgReading.calibration_uuid = calibration.uuid; bgReading.raw_data = (sensorRecord.getUnfiltered() / 1000); bgReading.filtered_data = (sensorRecord.getFiltered() / 1000); bgReading.timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset; if (bgReading.timestamp > new Date().getTime()) { return; } bgReading.uuid = UUID.randomUUID().toString(); bgReading.time_since_sensor_started = bgReading.timestamp - sensor.started_at; bgReading.calculateAgeAdjustedRawValue(); bgReading.save(); } } }