public static void addToQueue(Calibration calibration, Context context) { // TODO support for various insert/update/delete functions // CalibrationSendQueue calibrationSendQueue = new CalibrationSendQueue(); // calibrationSendQueue.calibration = calibration; // calibrationSendQueue.success = false; // calibrationSendQueue.mongo_success = false; // calibrationSendQueue.save(); UploaderQueue.newEntry("create", calibration); Log.i(TAG, "calling SensorSendQueue.SendToFollower"); SensorSendQueue.SendToFollower(Sensor.getByUuid(calibration.sensor_uuid)); }
public static void addToQueue(Calibration calibration, Context context) { // TODO support for various insert/update/delete functions // CalibrationSendQueue calibrationSendQueue = new CalibrationSendQueue(); // calibrationSendQueue.calibration = calibration; // calibrationSendQueue.success = false; // calibrationSendQueue.mongo_success = false; // calibrationSendQueue.save(); UploaderQueue.newEntry("create", calibration); Log.i(TAG, "calling SensorSendQueue.SendToFollower"); SensorSendQueue.SendToFollower(Sensor.getByUuid(calibration.sensor_uuid)); }
public static void upsertFromMaster(Sensor jsonSensor) { if (jsonSensor == null) { Log.wtf(TAG,"Got null sensor from json"); return; } try { Sensor existingSensor = getByUuid(jsonSensor.uuid); if (existingSensor == null) { Log.d(TAG, "saving new sensor record."); jsonSensor.save(); } else { Log.d(TAG, "updating existing sensor record."); existingSensor.started_at = jsonSensor.started_at; existingSensor.stopped_at = jsonSensor.stopped_at; existingSensor.latest_battery_level = jsonSensor.latest_battery_level; existingSensor.sensor_location = jsonSensor.sensor_location; existingSensor.save(); } } catch (Exception e) { Log.e(TAG, "Could not save Sensor: " + e.toString()); } }
public static void upsertFromMaster(Sensor jsonSensor) { if (jsonSensor == null) { Log.wtf(TAG,"Got null sensor from json"); return; } try { Sensor existingSensor = getByUuid(jsonSensor.uuid); if (existingSensor == null) { Log.d(TAG, "saving new sensor record."); jsonSensor.save(); } else { Log.d(TAG, "updating existing sensor record."); existingSensor.started_at = jsonSensor.started_at; existingSensor.stopped_at = jsonSensor.stopped_at; existingSensor.latest_battery_level = jsonSensor.latest_battery_level; existingSensor.sensor_location = jsonSensor.sensor_location; existingSensor.save(); } } catch (Exception e) { Log.e(TAG, "Could not save Sensor: " + e.toString()); } }
Sensor sensor = Sensor.getByUuid(jsonCalibration.sensor_uuid); if (sensor == null) { Log.e(TAG, "No sensor found, ignoring cailbration " + jsonCalibration.sensor_uuid);
Sensor sensor = Sensor.getByUuid(jsonCalibration.sensor_uuid); if (sensor == null) { Log.e(TAG, "No sensor found, ignoring cailbration " + jsonCalibration.sensor_uuid);
Sensor sensor = Sensor.getByUuid(jsonCalibration.sensor_uuid); if (sensor == null) { Log.e(TAG, "No sensor found, ignoring cailbration " + jsonCalibration.sensor_uuid);
private void syncSensorData(DataMap dataMap, Context context) {//KS Log.d(TAG, "syncSensorData"); if (dataMap != null) { String uuid = dataMap.getString("uuid"); Log.d(TAG, "syncSensorData add Sensor for uuid=" + uuid); long started_at = dataMap.getLong("started_at"); Integer latest_battery_level = dataMap.getInt("latest_battery_level"); String sensor_location = dataMap.getString("sensor_location"); Sensor.InitDb(context);//ensure database has already been initialized if (uuid != null && !uuid.isEmpty()) { Log.d(TAG, "syncSensorData add Sensor for uuid=" + uuid + " timestamp=" + started_at + " timeString=" + JoH.dateTimeText(started_at)); Sensor sensor = Sensor.getByUuid(uuid); if (sensor == null) { Log.d(TAG, "syncSensorData createUpdate new Sensor..."); Sensor.createUpdate(started_at, 0, latest_battery_level, sensor_location, uuid); Sensor newsensor = Sensor.currentSensor(); if (newsensor != null) { Log.d(TAG, "syncSensorData createUpdate Sensor with uuid=" + uuid + " started at=" + started_at); } else Log.d(TAG, "syncSensorData Failed to createUpdate new Sensor for uuid=" + uuid); } else Log.d(TAG, "syncSensorData Sensor already exists with uuid=" + uuid); } } }