use of com.eveningoutpost.dexdrip.Models.Calibration in project xDrip-plus by jamorham.
the class CalibrationGraph method getCalibrationsLine.
@NonNull
public List<Line> getCalibrationsLine(List<Calibration> calibrations, int color) {
if (calibrations == null)
return new ArrayList<>();
List<PointValue> values = new ArrayList<PointValue>();
List<PointValue> valuesb = new ArrayList<PointValue>();
List<PointValue> valuesc = new ArrayList<PointValue>();
for (Calibration calibration : calibrations) {
if (calibration.estimate_raw_at_time_of_calibration > end_x) {
end_x = calibration.estimate_raw_at_time_of_calibration;
}
PointValue point = new PointValue((float) calibration.estimate_raw_at_time_of_calibration, doMgdl ? (float) calibration.bg : ((float) calibration.bg) * (float) Constants.MGDL_TO_MMOLL);
PointValue pointb = new PointValue((float) calibration.raw_value, doMgdl ? (float) calibration.bg : ((float) calibration.bg) * (float) Constants.MGDL_TO_MMOLL);
PointValue pointc = new PointValue((float) calibration.adjusted_raw_value, doMgdl ? (float) calibration.bg : ((float) calibration.bg) * (float) Constants.MGDL_TO_MMOLL);
String time;
if (show_days_since) {
final int days_ago = daysAgo(calibration.raw_timestamp);
time = (days_ago > 0) ? Integer.toString(days_ago) + "d " : "";
time = time + (JoH.hourMinuteString(calibration.raw_timestamp));
} else {
time = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date((long) calibration.raw_timestamp));
}
point.setLabel(time);
values.add(point);
// extra points showing real raw and age_adjusted raw for each calbration point
valuesb.add(pointb);
valuesc.add(pointc);
}
Line line = new Line(values);
line.setColor(color);
line.setHasLines(false);
line.setPointRadius(4);
line.setHasPoints(true);
line.setHasLabels(true);
List<Line> lines = new ArrayList<>();
lines.add(line);
if (Pref.getBooleanDefaultFalse("engineering_mode")) {
// actual raw
Line lineb = new Line(valuesb);
lineb.setColor(Color.RED);
lineb.setHasLines(false);
lineb.setPointRadius(1);
lineb.setHasPoints(true);
lineb.setHasLabels(false);
// age adjusted raw
Line linec = new Line(valuesc);
linec.setColor(Color.YELLOW);
linec.setHasLines(false);
linec.setPointRadius(1);
linec.setHasPoints(true);
linec.setHasLabels(false);
lines.add(lineb);
lines.add(linec);
}
return lines;
}
use of com.eveningoutpost.dexdrip.Models.Calibration in project xDrip-plus by jamorham.
the class CalibrationGraph method overWriteIntercept.
private void overWriteIntercept() {
final EditText editText = new EditText(this);
editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL);
new AlertDialog.Builder(this).setTitle("Ovewrite Intercept").setMessage("Overwrite Intercept").setView(editText).setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String text = editText.getText().toString();
if (!TextUtils.isEmpty(text)) {
double doubleValue = JoH.tolerantParseDouble(text);
Calibration calibration = Calibration.lastValid();
calibration.intercept = doubleValue;
calibration.save();
CalibrationSendQueue.addToQueue(calibration, getApplicationContext());
recreate();
} else {
JoH.static_toast_long("Input not found! Cancelled!");
}
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
JoH.static_toast_long("Cancelled!");
}
}).show();
}
use of com.eveningoutpost.dexdrip.Models.Calibration in project xDrip-plus by jamorham.
the class CalibrationGraph method overWriteSlope.
private void overWriteSlope() {
final EditText editText = new EditText(this);
editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
new AlertDialog.Builder(this).setTitle("Ovewrite Slope").setMessage("Overwrite Slope").setView(editText).setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String text = editText.getText().toString();
if (!TextUtils.isEmpty(text)) {
double doubleValue = JoH.tolerantParseDouble(text);
Calibration calibration = Calibration.lastValid();
calibration.slope = doubleValue;
calibration.save();
CalibrationSendQueue.addToQueue(calibration, getApplicationContext());
recreate();
} else {
JoH.static_toast_long("Input not found! Cancelled!");
}
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
JoH.static_toast_long("Cancelled!");
}
}).show();
}
use of com.eveningoutpost.dexdrip.Models.Calibration in project xDrip-plus by jamorham.
the class NewCalibration method upsertSensorCalibratonsFromJson.
static void upsertSensorCalibratonsFromJson(String json) {
Log.i(TAG, "upsertSensorCalibratonsFromJson called");
SensorCalibrations[] sensorCalibrations = getSensorCalibrations(json);
for (SensorCalibrations SensorCalibration : sensorCalibrations) {
Sensor.upsertFromMaster(SensorCalibration.sensor);
for (Calibration calibration : SensorCalibration.calibrations) {
Log.d(TAG, "upsertSensorCalibratonsFromJson updating calibration " + calibration.uuid);
Calibration.upsertFromMaster(calibration);
}
}
}
Aggregations