public static Sensor create(long started_at) { Sensor sensor = new Sensor(); sensor.started_at = started_at; sensor.uuid = UUID.randomUUID().toString(); sensor.save(); SensorSendQueue.addToQueue(sensor); Log.d("SENSOR MODEL:", sensor.toString()); return sensor; }
public static Sensor create(long started_at) { Sensor sensor = new Sensor(); sensor.started_at = started_at; sensor.uuid = UUID.randomUUID().toString(); sensor.save(); SensorSendQueue.addToQueue(sensor); Log.d("SENSOR MODEL:", sensor.toString()); return sensor; }
public static Sensor create(long started_at) { Sensor sensor = new Sensor(); sensor.started_at = started_at; sensor.uuid = UUID.randomUUID().toString(); sensor.save(); SensorSendQueue.addToQueue(sensor); Log.d("SENSOR MODEL:", sensor.toString()); return sensor; }
private Sensor createMockSensor() { Sensor mockSensor = new Sensor(); mockSensor.started_at = System.currentTimeMillis() - (1000 * 60 * 20); mockSensor.uuid = UUID.randomUUID().toString(); mockSensor.save(); return mockSensor; }
private Sensor createMockSensor() { Sensor mockSensor = new Sensor(); mockSensor.started_at = System.currentTimeMillis() - (1000 * 60 * 20); mockSensor.uuid = UUID.randomUUID().toString(); mockSensor.save(); return mockSensor; }
public static Sensor create(long started_at, String uuid) {//KS Sensor sensor = new Sensor(); sensor.started_at = started_at; sensor.uuid = uuid; sensor.save(); SensorSendQueue.addToQueue(sensor); Log.d("SENSOR MODEL:", sensor.toString()); return sensor; }
public static Sensor create(long started_at, String uuid) {//KS Sensor sensor = new Sensor(); sensor.started_at = started_at; sensor.uuid = uuid; sensor.save(); SensorSendQueue.addToQueue(sensor); Log.d("SENSOR MODEL:", sensor.toString()); return sensor; }
public static void createUpdate(long started_at, long stopped_at, int latest_battery_level, String uuid) { Sensor sensor = getByTimestamp(started_at); if (sensor != null) { Log.d("SENSOR", "updating an existing sensor"); } else { Log.d("SENSOR", "creating a new sensor"); sensor = new Sensor(); } sensor.started_at = started_at; sensor.stopped_at = stopped_at; sensor.latest_battery_level = latest_battery_level; sensor.uuid = uuid; sensor.save(); }
public static void createUpdate(long started_at, long stopped_at, int latest_battery_level, String sensor_location, String uuid) {//KS Sensor sensor = currentSensor(); if (sensor != null) { Log.d("SENSOR", "updating an existing sensor"); } else { Log.d("SENSOR", "creating a new sensor"); sensor = new Sensor(); } sensor.started_at = started_at; sensor.stopped_at = stopped_at; sensor.latest_battery_level = latest_battery_level; sensor.sensor_location = sensor_location; sensor.uuid = uuid; sensor.save(); }
public static void createUpdate(long started_at, long stopped_at, int latest_battery_level, String uuid) { Sensor sensor = getByTimestamp(started_at); if (sensor != null) { Log.d("SENSOR", "updatinga an existing sensor"); } else { Log.d("SENSOR", "creating a new sensor"); sensor = new Sensor(); } sensor.started_at = started_at; sensor.stopped_at = stopped_at; sensor.latest_battery_level = latest_battery_level; sensor.uuid = uuid; sensor.save(); }
public static void createUpdate(long started_at, long stopped_at, int latest_battery_level, String uuid) { Sensor sensor = getByTimestamp(started_at); if (sensor != null) { Log.d("SENSOR", "updatinga an existing sensor"); } else { Log.d("SENSOR", "creating a new sensor"); sensor = new Sensor(); } sensor.started_at = started_at; sensor.stopped_at = stopped_at; sensor.latest_battery_level = latest_battery_level; sensor.uuid = uuid; sensor.save(); }
public static Sensor create(long started_at, String uuid) {//KS try { Sensor sensor = new Sensor(); sensor.started_at = started_at; sensor.uuid = uuid; sensor.save(); SensorSendQueue.addToQueue(sensor); Log.d("SENSOR MODEL:", sensor.toString()); return sensor; } catch (Exception e) { Log.d("SENSOR create new error ", uuid); return null; } }
@Test public void initialCalibration_fallingBg_OK() { // :: Setup // Add mock sensor Sensor mockSensor = new Sensor(); mockSensor.started_at = System.currentTimeMillis() - (1000 * 60 * 20); mockSensor.uuid = UUID.randomUUID().toString(); mockSensor.save(); // Add mock bg readings addMockBgReading(135, 11, mockSensor); addMockBgReading(130, 6, mockSensor); addMockBgReading(125, 1, mockSensor); // :: Act Calibration.initialCalibration(145, 140, RuntimeEnvironment.application); // :: Verify List<Calibration> calibrations = Calibration.getCalibrationsForSensor(Sensor.currentSensor(), 3); assertThat(calibrations).hasSize(2); Calibration calibration1 = calibrations.get(0); assertThat(calibration1.bg).isWithin(0.01).of(145); assertThat(calibration1.raw_value).isWithin(0.01).of(130); assertThat(calibration1.slope).isWithin(0.001).of(1); assertThat(calibration1.intercept).isWithin(0.001).of(14.9); Calibration calibration2 = calibrations.get(1); assertThat(calibration2.bg).isWithin(0.01).of(140); assertThat(calibration2.raw_value).isWithin(0.01).of(125); assertThat(calibration2.slope).isWithin(0.001).of(1); assertThat(calibration2.intercept).isWithin(0.001).of(15); }
@Test public void initialCalibration_fallingBg_OK() { // :: Setup // Add mock sensor Sensor mockSensor = new Sensor(); mockSensor.started_at = System.currentTimeMillis() - (1000 * 60 * 20); mockSensor.uuid = UUID.randomUUID().toString(); mockSensor.save(); // Add mock bg readings addMockBgReading(135, 11, mockSensor); addMockBgReading(130, 6, mockSensor); addMockBgReading(125, 1, mockSensor); // :: Act Calibration.initialCalibration(145, 140, RuntimeEnvironment.application); // :: Verify List<Calibration> calibrations = Calibration.getCalibrationsForSensor(Sensor.currentSensor(), 3); assertThat(calibrations).hasSize(2); Calibration calibration1 = calibrations.get(0); assertThat(calibration1.bg).isWithin(0.01).of(145); assertThat(calibration1.raw_value).isWithin(0.01).of(130); assertThat(calibration1.slope).isWithin(0.001).of(1); assertThat(calibration1.intercept).isWithin(0.001).of(14.9); Calibration calibration2 = calibrations.get(1); assertThat(calibration2.bg).isWithin(0.01).of(140); assertThat(calibration2.raw_value).isWithin(0.01).of(125); assertThat(calibration2.slope).isWithin(0.001).of(1); assertThat(calibration2.intercept).isWithin(0.001).of(15); }
@Test public void initialCalibration_raisingBg_OK() { // :: Setup // Add mock sensor Sensor mockSensor = new Sensor(); mockSensor.started_at = System.currentTimeMillis() - (1000 * 60 * 20); mockSensor.uuid = UUID.randomUUID().toString(); mockSensor.save(); // Add mock bg readings addMockBgReading(125, 11, mockSensor); addMockBgReading(130, 6, mockSensor); addMockBgReading(135, 1, mockSensor); // :: Act Calibration.initialCalibration(140, 145, RuntimeEnvironment.application.getApplicationContext()); // :: Verify List<Calibration> calibrations = Calibration.getCalibrationsForSensor(Sensor.currentSensor(), 3); assertThat(calibrations).hasSize(2); Calibration calibration1 = calibrations.get(0); assertThat(calibration1.bg).isWithin(0.01).of(145); assertThat(calibration1.raw_value).isWithin(0.01).of(135); assertThat(calibration1.slope).isWithin(0.001).of(1); assertThat(calibration1.intercept).isWithin(0.001).of(9.9); Calibration calibration2 = calibrations.get(1); assertThat(calibration2.bg).isWithin(0.01).of(140); assertThat(calibration2.raw_value).isWithin(0.01).of(130); assertThat(calibration2.slope).isWithin(0.001).of(1); assertThat(calibration2.intercept).isWithin(0.001).of(10); }
@Test public void initialCalibration_raisingBg_OK() { // :: Setup // Add mock sensor Sensor mockSensor = new Sensor(); mockSensor.started_at = System.currentTimeMillis() - (1000 * 60 * 20); mockSensor.uuid = UUID.randomUUID().toString(); mockSensor.save(); // Add mock bg readings addMockBgReading(125, 11, mockSensor); addMockBgReading(130, 6, mockSensor); addMockBgReading(135, 1, mockSensor); // :: Act Calibration.initialCalibration(140, 145, RuntimeEnvironment.application.getApplicationContext()); // :: Verify List<Calibration> calibrations = Calibration.getCalibrationsForSensor(Sensor.currentSensor(), 3); assertThat(calibrations).hasSize(2); Calibration calibration1 = calibrations.get(0); assertThat(calibration1.bg).isWithin(0.01).of(145); assertThat(calibration1.raw_value).isWithin(0.01).of(135); assertThat(calibration1.slope).isWithin(0.001).of(1); assertThat(calibration1.intercept).isWithin(0.001).of(9.9); Calibration calibration2 = calibrations.get(1); assertThat(calibration2.bg).isWithin(0.01).of(140); assertThat(calibration2.raw_value).isWithin(0.01).of(130); assertThat(calibration2.slope).isWithin(0.001).of(1); assertThat(calibration2.intercept).isWithin(0.001).of(10); }