com.eveningoutpost.dexdrip.ImportedLibraries.dexcom.records.CalSubrecord Java Examples
The following examples show how to use
com.eveningoutpost.dexdrip.ImportedLibraries.dexcom.records.CalSubrecord.
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: Calibration.java From xDrip with GNU General Public License v3.0 | 6 votes |
public static boolean is_new(CalSubrecord calSubrecord, long addativeOffset) { Sensor sensor = Sensor.currentSensor(); Calibration calibration = new Select() .from(Calibration.class) .where("Sensor = ? ", sensor.getId()) .where("timestamp <= ?", calSubrecord.getDateEntered().getTime() + addativeOffset + (1000 * 60 * 2)) .orderBy("timestamp desc") .executeSingle(); if (calibration != null && Math.abs(calibration.timestamp - (calSubrecord.getDateEntered().getTime() + addativeOffset)) < (4 * 60 * 1000)) { Log.d("CAL CHECK IN ", "Already have that calibration!"); return false; } else { Log.d("CAL CHECK IN ", "Looks like a new calibration!"); return true; } }
Example #2
Source File: Calibration.java From xDrip with GNU General Public License v3.0 | 6 votes |
public static boolean is_new(CalSubrecord calSubrecord, long addativeOffset) { Sensor sensor = Sensor.currentSensor(); Calibration calibration = new Select() .from(Calibration.class) .where("Sensor = ? ", sensor.getId()) .where("timestamp <= ?", calSubrecord.getDateEntered().getTime() + addativeOffset + (1000 * 60 * 2)) .orderBy("timestamp desc") .executeSingle(); if (calibration != null && Math.abs(calibration.timestamp - (calSubrecord.getDateEntered().getTime() + addativeOffset)) < (4 * 60 * 1000)) { Log.d("CAL CHECK IN ", "Already have that calibration!"); return false; } else { Log.d("CAL CHECK IN ", "Looks like a new calibration!"); return true; } }
Example #3
Source File: Calibration.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
public static boolean is_new(CalSubrecord calSubrecord, long addativeOffset) { Sensor sensor = Sensor.currentSensor(); Calibration calibration = new Select() .from(Calibration.class) .where("Sensor = ? ", sensor.getId()) .where("timestamp <= ?", calSubrecord.getDateEntered().getTime() + addativeOffset + (1000 * 60 * 2)) .orderBy("timestamp desc") .executeSingle(); if (calibration != null && Math.abs(calibration.timestamp - (calSubrecord.getDateEntered().getTime() + addativeOffset)) < (4 * 60 * 1000)) { Log.d("CAL CHECK IN ", "Already have that calibration!"); return false; } else { Log.d("CAL CHECK IN ", "Looks like a new calibration!"); return true; } }
Example #4
Source File: Calibration.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
public static boolean is_new(CalSubrecord calSubrecord, long addativeOffset) { Sensor sensor = Sensor.currentSensor(); Calibration calibration = new Select() .from(Calibration.class) .where("Sensor = ? ", sensor.getId()) .where("timestamp <= ?", calSubrecord.getDateEntered().getTime() + addativeOffset + (1000 * 60 * 2)) .orderBy("timestamp desc") .executeSingle(); if (calibration != null && Math.abs(calibration.timestamp - (calSubrecord.getDateEntered().getTime() + addativeOffset)) < (4 * 60 * 1000)) { Log.d("CAL CHECK IN ", "Already have that calibration!"); return false; } else { Log.d("CAL CHECK IN ", "Looks like a new calibration!"); return true; } }
Example #5
Source File: Calibration.java From xDrip-Experimental with GNU General Public License v3.0 | 6 votes |
public static boolean is_new(CalSubrecord calSubrecord, long addativeOffset) { Sensor sensor = Sensor.currentSensor(); Calibration calibration = new Select() .from(Calibration.class) .where("Sensor = ? ", sensor.getId()) .where("timestamp <= ?", calSubrecord.getDateEntered().getTime() + addativeOffset + (1000 * 60 * 2)) .orderBy("timestamp desc") .executeSingle(); if(calibration != null && Math.abs(calibration.timestamp - (calSubrecord.getDateEntered().getTime() + addativeOffset)) < (4*60*1000)) { Log.d("CAL CHECK IN ", "Already have that calibration!"); return false; } else { Log.d("CAL CHECK IN ", "Looks like a new calibration!"); return true; } }
Example #6
Source File: Calibration.java From xDrip with GNU General Public License v3.0 | 6 votes |
public static boolean is_new(CalSubrecord calSubrecord, long addativeOffset) { Sensor sensor = Sensor.currentSensor(); Calibration calibration = new Select() .from(Calibration.class) .where("Sensor = ? ", sensor.getId()) .where("timestamp <= ?", calSubrecord.getDateEntered().getTime() + addativeOffset + (1000 * 60 * 2)) .orderBy("timestamp desc") .executeSingle(); if(calibration != null && Math.abs(calibration.timestamp - (calSubrecord.getDateEntered().getTime() + addativeOffset)) < (4*60*1000)) { Log.d("CAL CHECK IN ", "Already have that calibration!"); return false; } else { Log.d("CAL CHECK IN ", "Looks like a new calibration!"); return true; } }
Example #7
Source File: Calibration.java From xDrip with GNU General Public License v3.0 | 4 votes |
public static void create(CalRecord[] calRecords, Context context, boolean override, long addativeOffset) { //TODO: Change calibration.last and other queries to order calibrations by timestamp rather than ID Log.i("CALIBRATION-CHECK-IN: ", "Creating Calibration Record"); Sensor sensor = Sensor.currentSensor(); CalRecord firstCalRecord = calRecords[0]; CalRecord secondCalRecord = calRecords[0]; // CalRecord secondCalRecord = calRecords[calRecords.length - 1]; //TODO: Figgure out how the ratio between the two is determined double calSlope = ((secondCalRecord.getScale() / secondCalRecord.getSlope()) + (3 * firstCalRecord.getScale() / firstCalRecord.getSlope())) * 250; double calIntercept = (((secondCalRecord.getScale() * secondCalRecord.getIntercept()) / secondCalRecord.getSlope()) + ((3 * firstCalRecord.getScale() * firstCalRecord.getIntercept()) / firstCalRecord.getSlope())) / -4; if (sensor != null) { for (int i = 0; i < firstCalRecord.getCalSubrecords().length - 1; i++) { if (((firstCalRecord.getCalSubrecords()[i] != null && Calibration.is_new(firstCalRecord.getCalSubrecords()[i], addativeOffset))) || (i == 0 && override)) { CalSubrecord calSubrecord = firstCalRecord.getCalSubrecords()[i]; Calibration calibration = new Calibration(); calibration.bg = calSubrecord.getCalBGL(); calibration.timestamp = calSubrecord.getDateEntered().getTime() + addativeOffset; calibration.raw_timestamp = calibration.timestamp; if (calibration.timestamp > new Date().getTime()) { Log.d(TAG, "ERROR - Calibration timestamp is from the future, wont save!"); return; } calibration.raw_value = calSubrecord.getCalRaw() / 1000; calibration.slope = calSlope; calibration.intercept = calIntercept; calibration.sensor_confidence = ((-0.0018 * calibration.bg * calibration.bg) + (0.6657 * calibration.bg) + 36.7505) / 100; if (calibration.sensor_confidence <= 0) { calibration.sensor_confidence = 0; } calibration.slope_confidence = 0.8; //TODO: query backwards to find this value near the timestamp calibration.estimate_raw_at_time_of_calibration = calSubrecord.getCalRaw() / 1000; calibration.sensor = sensor; calibration.sensor_age_at_time_of_estimation = calibration.timestamp - sensor.started_at; calibration.uuid = UUID.randomUUID().toString(); calibration.sensor_uuid = sensor.uuid; calibration.check_in = true; calibration.first_decay = firstCalRecord.getDecay(); calibration.second_decay = secondCalRecord.getDecay(); calibration.first_slope = firstCalRecord.getSlope(); calibration.second_slope = secondCalRecord.getSlope(); calibration.first_scale = firstCalRecord.getScale(); calibration.second_scale = secondCalRecord.getScale(); calibration.first_intercept = firstCalRecord.getIntercept(); calibration.second_intercept = secondCalRecord.getIntercept(); calibration.save(); CalibrationSendQueue.addToQueue(calibration, context); Calibration.requestCalibrationIfRangeTooNarrow(); //KS newFingerStickData(); } } if (firstCalRecord.getCalSubrecords()[0] != null && firstCalRecord.getCalSubrecords()[2] == null) { if (Calibration.latest(2).size() == 1) { Calibration.create(calRecords, context, true, 0); } } context.startService(new Intent(context, Notifications.class)); } }
Example #8
Source File: Calibration.java From xDrip with GNU General Public License v3.0 | 4 votes |
public static void create(CalRecord[] calRecords, Context context, boolean override, long addativeOffset) { //TODO: Change calibration.last and other queries to order calibrations by timestamp rather than ID Log.i("CALIBRATION-CHECK-IN: ", "Creating Calibration Record"); Sensor sensor = Sensor.currentSensor(); CalRecord firstCalRecord = calRecords[0]; CalRecord secondCalRecord = calRecords[0]; // CalRecord secondCalRecord = calRecords[calRecords.length - 1]; //TODO: Figgure out how the ratio between the two is determined double calSlope = ((secondCalRecord.getScale() / secondCalRecord.getSlope()) + (3 * firstCalRecord.getScale() / firstCalRecord.getSlope())) * 250; double calIntercept = (((secondCalRecord.getScale() * secondCalRecord.getIntercept()) / secondCalRecord.getSlope()) + ((3 * firstCalRecord.getScale() * firstCalRecord.getIntercept()) / firstCalRecord.getSlope())) / -4; if (sensor != null) { for (int i = 0; i < firstCalRecord.getCalSubrecords().length - 1; i++) { if (((firstCalRecord.getCalSubrecords()[i] != null && Calibration.is_new(firstCalRecord.getCalSubrecords()[i], addativeOffset))) || (i == 0 && override)) { CalSubrecord calSubrecord = firstCalRecord.getCalSubrecords()[i]; Calibration calibration = new Calibration(); calibration.bg = calSubrecord.getCalBGL(); calibration.timestamp = calSubrecord.getDateEntered().getTime() + addativeOffset; calibration.raw_timestamp = calibration.timestamp; if (calibration.timestamp > new Date().getTime()) { Log.d(TAG, "ERROR - Calibration timestamp is from the future, wont save!"); return; } calibration.raw_value = calSubrecord.getCalRaw() / 1000; calibration.slope = calSlope; calibration.intercept = calIntercept; calibration.sensor_confidence = ((-0.0018 * calibration.bg * calibration.bg) + (0.6657 * calibration.bg) + 36.7505) / 100; if (calibration.sensor_confidence <= 0) { calibration.sensor_confidence = 0; } calibration.slope_confidence = 0.8; //TODO: query backwards to find this value near the timestamp calibration.estimate_raw_at_time_of_calibration = calSubrecord.getCalRaw() / 1000; calibration.sensor = sensor; calibration.sensor_age_at_time_of_estimation = calibration.timestamp - sensor.started_at; calibration.uuid = UUID.randomUUID().toString(); calibration.sensor_uuid = sensor.uuid; calibration.check_in = true; calibration.first_decay = firstCalRecord.getDecay(); calibration.second_decay = secondCalRecord.getDecay(); calibration.first_slope = firstCalRecord.getSlope(); calibration.second_slope = secondCalRecord.getSlope(); calibration.first_scale = firstCalRecord.getScale(); calibration.second_scale = secondCalRecord.getScale(); calibration.first_intercept = firstCalRecord.getIntercept(); calibration.second_intercept = secondCalRecord.getIntercept(); calibration.save(); CalibrationSendQueue.addToQueue(calibration, context); Calibration.requestCalibrationIfRangeTooNarrow(); newFingerStickData(); } } if (firstCalRecord.getCalSubrecords()[0] != null && firstCalRecord.getCalSubrecords()[2] == null) { if (Calibration.latest(2).size() == 1) { Calibration.create(calRecords, context, true, 0); } } Notifications.start(); } }
Example #9
Source File: Calibration.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public static void create(CalRecord[] calRecords, Context context, boolean override, long addativeOffset) { //TODO: Change calibration.last and other queries to order calibrations by timestamp rather than ID Log.i("CALIBRATION-CHECK-IN: ", "Creating Calibration Record"); Sensor sensor = Sensor.currentSensor(); CalRecord firstCalRecord = calRecords[0]; CalRecord secondCalRecord = calRecords[0]; // CalRecord secondCalRecord = calRecords[calRecords.length - 1]; //TODO: Figgure out how the ratio between the two is determined double calSlope = ((secondCalRecord.getScale() / secondCalRecord.getSlope()) + (3 * firstCalRecord.getScale() / firstCalRecord.getSlope())) * 250; double calIntercept = (((secondCalRecord.getScale() * secondCalRecord.getIntercept()) / secondCalRecord.getSlope()) + ((3 * firstCalRecord.getScale() * firstCalRecord.getIntercept()) / firstCalRecord.getSlope())) / -4; if (sensor != null) { for (int i = 0; i < firstCalRecord.getCalSubrecords().length - 1; i++) { if (((firstCalRecord.getCalSubrecords()[i] != null && Calibration.is_new(firstCalRecord.getCalSubrecords()[i], addativeOffset))) || (i == 0 && override)) { CalSubrecord calSubrecord = firstCalRecord.getCalSubrecords()[i]; Calibration calibration = new Calibration(); calibration.bg = calSubrecord.getCalBGL(); calibration.timestamp = calSubrecord.getDateEntered().getTime() + addativeOffset; calibration.raw_timestamp = calibration.timestamp; if (calibration.timestamp > new Date().getTime()) { Log.d(TAG, "ERROR - Calibration timestamp is from the future, wont save!"); return; } calibration.raw_value = calSubrecord.getCalRaw() / 1000; calibration.slope = calSlope; calibration.intercept = calIntercept; calibration.sensor_confidence = ((-0.0018 * calibration.bg * calibration.bg) + (0.6657 * calibration.bg) + 36.7505) / 100; if (calibration.sensor_confidence <= 0) { calibration.sensor_confidence = 0; } calibration.slope_confidence = 0.8; //TODO: query backwards to find this value near the timestamp calibration.estimate_raw_at_time_of_calibration = calSubrecord.getCalRaw() / 1000; calibration.sensor = sensor; calibration.sensor_age_at_time_of_estimation = calibration.timestamp - sensor.started_at; calibration.uuid = UUID.randomUUID().toString(); calibration.sensor_uuid = sensor.uuid; calibration.check_in = true; calibration.first_decay = firstCalRecord.getDecay(); calibration.second_decay = secondCalRecord.getDecay(); calibration.first_slope = firstCalRecord.getSlope(); calibration.second_slope = secondCalRecord.getSlope(); calibration.first_scale = firstCalRecord.getScale(); calibration.second_scale = secondCalRecord.getScale(); calibration.first_intercept = firstCalRecord.getIntercept(); calibration.second_intercept = secondCalRecord.getIntercept(); calibration.save(); CalibrationSendQueue.addToQueue(calibration, context); Calibration.requestCalibrationIfRangeTooNarrow(); //KS newFingerStickData(); } } if (firstCalRecord.getCalSubrecords()[0] != null && firstCalRecord.getCalSubrecords()[2] == null) { if (Calibration.latest(2).size() == 1) { Calibration.create(calRecords, context, true, 0); } } context.startService(new Intent(context, Notifications.class)); } }
Example #10
Source File: Calibration.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public static void create(CalRecord[] calRecords, Context context, boolean override, long addativeOffset) { //TODO: Change calibration.last and other queries to order calibrations by timestamp rather than ID Log.i("CALIBRATION-CHECK-IN: ", "Creating Calibration Record"); Sensor sensor = Sensor.currentSensor(); CalRecord firstCalRecord = calRecords[0]; CalRecord secondCalRecord = calRecords[0]; // CalRecord secondCalRecord = calRecords[calRecords.length - 1]; //TODO: Figgure out how the ratio between the two is determined double calSlope = ((secondCalRecord.getScale() / secondCalRecord.getSlope()) + (3 * firstCalRecord.getScale() / firstCalRecord.getSlope())) * 250; double calIntercept = (((secondCalRecord.getScale() * secondCalRecord.getIntercept()) / secondCalRecord.getSlope()) + ((3 * firstCalRecord.getScale() * firstCalRecord.getIntercept()) / firstCalRecord.getSlope())) / -4; if (sensor != null) { for (int i = 0; i < firstCalRecord.getCalSubrecords().length - 1; i++) { if (((firstCalRecord.getCalSubrecords()[i] != null && Calibration.is_new(firstCalRecord.getCalSubrecords()[i], addativeOffset))) || (i == 0 && override)) { CalSubrecord calSubrecord = firstCalRecord.getCalSubrecords()[i]; Calibration calibration = new Calibration(); calibration.bg = calSubrecord.getCalBGL(); calibration.timestamp = calSubrecord.getDateEntered().getTime() + addativeOffset; calibration.raw_timestamp = calibration.timestamp; if (calibration.timestamp > new Date().getTime()) { Log.d(TAG, "ERROR - Calibration timestamp is from the future, wont save!"); return; } calibration.raw_value = calSubrecord.getCalRaw() / 1000; calibration.slope = calSlope; calibration.intercept = calIntercept; calibration.sensor_confidence = ((-0.0018 * calibration.bg * calibration.bg) + (0.6657 * calibration.bg) + 36.7505) / 100; if (calibration.sensor_confidence <= 0) { calibration.sensor_confidence = 0; } calibration.slope_confidence = 0.8; //TODO: query backwards to find this value near the timestamp calibration.estimate_raw_at_time_of_calibration = calSubrecord.getCalRaw() / 1000; calibration.sensor = sensor; calibration.sensor_age_at_time_of_estimation = calibration.timestamp - sensor.started_at; calibration.uuid = UUID.randomUUID().toString(); calibration.sensor_uuid = sensor.uuid; calibration.check_in = true; calibration.first_decay = firstCalRecord.getDecay(); calibration.second_decay = secondCalRecord.getDecay(); calibration.first_slope = firstCalRecord.getSlope(); calibration.second_slope = secondCalRecord.getSlope(); calibration.first_scale = firstCalRecord.getScale(); calibration.second_scale = secondCalRecord.getScale(); calibration.first_intercept = firstCalRecord.getIntercept(); calibration.second_intercept = secondCalRecord.getIntercept(); calibration.save(); CalibrationSendQueue.addToQueue(calibration, context); Calibration.requestCalibrationIfRangeTooNarrow(); newFingerStickData(); } } if (firstCalRecord.getCalSubrecords()[0] != null && firstCalRecord.getCalSubrecords()[2] == null) { if (Calibration.latest(2).size() == 1) { Calibration.create(calRecords, context, true, 0); } } Notifications.start(); } }
Example #11
Source File: Calibration.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
public static void create(CalRecord[] calRecords, Context context, boolean override, long addativeOffset) { //TODO: Change calibration.last and other queries to order calibrations by timestamp rather than ID Log.i("CALIBRATION-CHECK-IN: ", "Creating Calibration Record"); Sensor sensor = Sensor.currentSensor(); CalRecord firstCalRecord = calRecords[0]; CalRecord secondCalRecord = calRecords[0]; // CalRecord secondCalRecord = calRecords[calRecords.length - 1]; //TODO: Figgure out how the ratio between the two is determined double calSlope = ((secondCalRecord.getScale() / secondCalRecord.getSlope()) + (3 * firstCalRecord.getScale() / firstCalRecord.getSlope())) * 250; double calIntercept = (((secondCalRecord.getScale() * secondCalRecord.getIntercept()) / secondCalRecord.getSlope()) + ((3 * firstCalRecord.getScale() * firstCalRecord.getIntercept()) / firstCalRecord.getSlope())) / -4; if (sensor != null) { for(int i = 0; i < firstCalRecord.getCalSubrecords().length - 1; i++) { if (((firstCalRecord.getCalSubrecords()[i] != null && Calibration.is_new(firstCalRecord.getCalSubrecords()[i], addativeOffset))) || (i == 0 && override)) { CalSubrecord calSubrecord = firstCalRecord.getCalSubrecords()[i]; Calibration calibration = new Calibration(); calibration.bg = calSubrecord.getCalBGL(); calibration.timestamp = calSubrecord.getDateEntered().getTime() + addativeOffset; calibration.raw_timestamp = calibration.timestamp; if (calibration.timestamp > new Date().getTime()) { Log.d(TAG, "ERROR - Calibration timestamp is from the future, wont save!"); return; } calibration.raw_value = calSubrecord.getCalRaw() / 1000; calibration.slope = calSlope; calibration.intercept = calIntercept; calibration.sensor_confidence = ((-0.0018 * calibration.bg * calibration.bg) + (0.6657 * calibration.bg) + 36.7505) / 100; if (calibration.sensor_confidence <= 0) { calibration.sensor_confidence = 0; } calibration.slope_confidence = 0.8; //TODO: query backwards to find this value near the timestamp calibration.estimate_raw_at_time_of_calibration = calSubrecord.getCalRaw() / 1000; calibration.sensor = sensor; calibration.sensor_age_at_time_of_estimation = calibration.timestamp - sensor.started_at; calibration.uuid = UUID.randomUUID().toString(); calibration.sensor_uuid = sensor.uuid; calibration.check_in = true; calibration.first_decay = firstCalRecord.getDecay(); calibration.second_decay = secondCalRecord.getDecay(); calibration.first_slope = firstCalRecord.getSlope(); calibration.second_slope = secondCalRecord.getSlope(); calibration.first_scale = firstCalRecord.getScale(); calibration.second_scale = secondCalRecord.getScale(); calibration.first_intercept = firstCalRecord.getIntercept(); calibration.second_intercept = secondCalRecord.getIntercept(); calibration.save(); CalibrationSendQueue.addToQueue(calibration, context); Calibration.requestCalibrationIfRangeTooNarrow(); } } if(firstCalRecord.getCalSubrecords()[0] != null && firstCalRecord.getCalSubrecords()[2] == null) { if(Calibration.latest(2).size() == 1) { Calibration.create(calRecords, context, true, 0); } } context.startService(new Intent(context, Notifications.class)); } }
Example #12
Source File: Calibration.java From xDrip with GNU General Public License v3.0 | 4 votes |
public static void create(CalRecord[] calRecords, Context context, boolean override, long addativeOffset) { //TODO: Change calibration.last and other queries to order calibrations by timestamp rather than ID Log.w("CALIBRATION-CHECK-IN: ", "Creating Calibration Record"); Sensor sensor = Sensor.currentSensor(); CalRecord firstCalRecord = calRecords[0]; CalRecord secondCalRecord = calRecords[0]; // CalRecord secondCalRecord = calRecords[calRecords.length - 1]; //TODO: Figgure out how the ratio between the two is determined double calSlope = ((secondCalRecord.getScale() / secondCalRecord.getSlope()) + (3 * firstCalRecord.getScale() / firstCalRecord.getSlope())) * 250; double calIntercept = (((secondCalRecord.getScale() * secondCalRecord.getIntercept()) / secondCalRecord.getSlope()) + ((3 * firstCalRecord.getScale() * firstCalRecord.getIntercept()) / firstCalRecord.getSlope())) / -4; if (sensor != null) { for(int i = 0; i < firstCalRecord.getCalSubrecords().length - 1; i++) { if (((firstCalRecord.getCalSubrecords()[i] != null && Calibration.is_new(firstCalRecord.getCalSubrecords()[i], addativeOffset))) || (i == 0 && override)) { CalSubrecord calSubrecord = firstCalRecord.getCalSubrecords()[i]; Calibration calibration = new Calibration(); calibration.bg = calSubrecord.getCalBGL(); calibration.timestamp = calSubrecord.getDateEntered().getTime() + addativeOffset; if (calibration.timestamp > new Date().getTime()) { Log.e(TAG, "ERROR - Calibration timestamp is from the future, wont save!"); return; } calibration.raw_value = calSubrecord.getCalRaw() / 1000; calibration.slope = calSlope; calibration.intercept = calIntercept; calibration.sensor_confidence = ((-0.0018 * calibration.bg * calibration.bg) + (0.6657 * calibration.bg) + 36.7505) / 100; if (calibration.sensor_confidence <= 0) { calibration.sensor_confidence = 0; } calibration.slope_confidence = 0.8; //TODO: query backwards to find this value near the timestamp calibration.estimate_raw_at_time_of_calibration = calSubrecord.getCalRaw() / 1000; calibration.sensor = sensor; calibration.sensor_age_at_time_of_estimation = calibration.timestamp - sensor.started_at; calibration.uuid = UUID.randomUUID().toString(); calibration.sensor_uuid = sensor.uuid; calibration.check_in = true; calibration.first_decay = firstCalRecord.getDecay(); calibration.second_decay = secondCalRecord.getDecay(); calibration.first_slope = firstCalRecord.getSlope(); calibration.second_slope = secondCalRecord.getSlope(); calibration.first_scale = firstCalRecord.getScale(); calibration.second_scale = secondCalRecord.getScale(); calibration.first_intercept = firstCalRecord.getIntercept(); calibration.second_intercept = secondCalRecord.getIntercept(); calibration.save(); CalibrationSendQueue.addToQueue(calibration, context); Calibration.requestCalibrationIfRangeTooNarrow(); } } if(firstCalRecord.getCalSubrecords()[0] != null && firstCalRecord.getCalSubrecords()[2] == null) { if(Calibration.latest(2).size() == 1) { Calibration.create(calRecords, context, true, 0); } } Notifications.notificationSetter(context); } }