use of com.eveningoutpost.dexdrip.Models.TransmitterData in project xDrip-plus by jamorham.
the class WixelReader method setSerialDataToTransmitterRawData.
private void setSerialDataToTransmitterRawData(int raw_data, int filtered_data, int sensor_battery_leve, Long CaptureTime) {
final TransmitterData transmitterData = TransmitterData.create(raw_data, filtered_data, sensor_battery_leve, CaptureTime);
if (transmitterData != null) {
final Sensor sensor = Sensor.currentSensor();
if (sensor != null) {
BgReading bgReading = BgReading.create(transmitterData.raw_data, filtered_data, null, CaptureTime);
// sensor.latest_battery_level = (sensor.latest_battery_level!=0)?Math.min(sensor.latest_battery_level, transmitterData.sensor_battery_level):transmitterData.sensor_battery_level;
// don't lock it only going downwards
sensor.latest_battery_level = transmitterData.sensor_battery_level;
sensor.save();
} else {
Log.d(TAG, "No Active Sensor, Data only stored in Transmitter Data");
}
}
}
use of com.eveningoutpost.dexdrip.Models.TransmitterData in project xDrip-plus by jamorham.
the class WatchUpdaterService method syncTransmitterData.
private synchronized void syncTransmitterData(DataMap dataMap, boolean bBenchmark) {
// KS
Log.d(TAG, "syncTransmitterData");
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
long timeOfLastBG = 0;
Log.d(TAG, "syncTransmitterData add BgReading Table");
if (entries != null) {
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().registerTypeAdapter(Date.class, new DateTypeAdapter()).serializeSpecialFloatingPointValues().create();
int idx = 0;
int count = entries.size();
Log.d(TAG, "syncTransmitterData add BgReading Table entries count=" + count);
for (DataMap entry : entries) {
if (entry != null) {
// Log.d(TAG, "syncTransmitterData add BgReading Table entry=" + entry);
idx++;
String bgrecord = entry.getString("bgs");
if (bgrecord != null) {
// for (TransmitterData bgData : bgs) {
// Log.d(TAG, "syncTransmitterData add TransmitterData Table bgrecord=" + bgrecord);
TransmitterData bgData = gson.fromJson(bgrecord, TransmitterData.class);
// TransmitterData bgData = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().fromJson(bgrecord, TransmitterData.class);
TransmitterData exists = TransmitterData.getForTimestamp(bgData.timestamp);
TransmitterData uuidexists = TransmitterData.findByUuid(bgData.uuid);
timeOfLastBG = bgData.timestamp + 1;
if (exists != null || uuidexists != null) {
Log.d(TAG, "syncTransmitterData BG already exists for uuid=" + bgData.uuid + " timestamp=" + bgData.timestamp + " timeString=" + JoH.dateTimeText(bgData.timestamp) + " raw_data=" + bgData.raw_data);
} else {
Log.d(TAG, "syncTransmitterData add BG; does NOT exist for uuid=" + bgData.uuid + " timestamp=" + bgData.timestamp + " timeString=" + JoH.dateTimeText(bgData.timestamp) + " raw_data=" + bgData.raw_data);
if (!bBenchmark) {
bgData.save();
// Check
if (TransmitterData.findByUuid(bgData.uuid) != null)
Log.d(TAG, "syncTransmitterData: TransmitterData was saved for uuid:" + bgData.uuid);
else {
Log.e(TAG, "syncTransmitterData: TransmitterData was NOT saved for uuid:" + bgData.uuid);
return;
}
// KS the following is from G5CollectionService processNewTransmitterData()
Sensor sensor = Sensor.currentSensor();
if (sensor == null) {
Log.e(TAG, "syncTransmitterData: No Active Sensor, Data only stored in Transmitter Data");
return;
}
// TODO : LOG if unfiltered or filtered values are zero
Sensor.updateBatteryLevel(sensor, bgData.sensor_battery_level);
// android.util.Log.i
Log.i(TAG, "syncTransmitterData: BG timestamp create " + Long.toString(bgData.timestamp));
BgReading bgExists;
// KS TODO wear implements limited alerts, therefore continue to process all alerts on phone for last entry
if (count > 1 && idx < count) {
// Disable Notifications for bulk insert
bgExists = BgReading.create(bgData.raw_data, bgData.filtered_data, this, bgData.timestamp, true);
} else {
bgExists = BgReading.create(bgData.raw_data, bgData.filtered_data, this, bgData.timestamp);
}
if (bgExists != null)
Log.d(TAG, "syncTransmitterData BG GSON saved BG: " + bgExists.toS());
else
Log.e(TAG, "syncTransmitterData BG GSON NOT saved");
}
}
}
}
}
sendDataReceived(DATA_ITEM_RECEIVED_PATH, "DATA_RECEIVED_BGS count=" + entries.size(), timeOfLastBG, bBenchmark ? "BM" : "BG", -1);
}
}
use of com.eveningoutpost.dexdrip.Models.TransmitterData in project xDrip-plus by jamorham.
the class SystemStatus method setTransmitterStatus.
private void setTransmitterStatus() {
if (prefs.getString("dex_collection_method", "BluetoothWixel").equals("DexcomShare")) {
transmitter_status_view.setText("See Share Receiver");
return;
}
TransmitterData td = TransmitterData.last();
if (td == null || td.sensor_battery_level == 0) {
transmitter_status_view.setText("not available");
GcmActivity.requestSensorBatteryUpdate();
} else if ((System.currentTimeMillis() - td.timestamp) > 1000 * 60 * 60 * 24) {
transmitter_status_view.setText("no data in 24 hours");
GcmActivity.requestSensorBatteryUpdate();
} else {
transmitter_status_view.setText("" + td.sensor_battery_level);
// always ask
GcmActivity.requestSensorBatteryUpdate();
if (td.sensor_battery_level <= Dex_Constants.TRANSMITTER_BATTERY_EMPTY) {
transmitter_status_view.append(" - very low");
} else if (td.sensor_battery_level <= Dex_Constants.TRANSMITTER_BATTERY_LOW) {
transmitter_status_view.append(" - low");
transmitter_status_view.append("\n(experimental interpretation)");
} else {
transmitter_status_view.append(" - ok");
}
}
}
use of com.eveningoutpost.dexdrip.Models.TransmitterData in project xDrip-plus by jamorham.
the class SystemStatusFragment method setTransmitterStatus.
private void setTransmitterStatus() {
if (prefs.getString("dex_collection_method", "BluetoothWixel").equals("DexcomShare")) {
transmitter_status_view.setText("See Share Receiver");
return;
}
TransmitterData td = TransmitterData.last();
if (td == null || td.sensor_battery_level == 0) {
transmitter_status_view.setText("not available");
GcmActivity.requestSensorBatteryUpdate();
} else if ((System.currentTimeMillis() - td.timestamp) > 1000 * 60 * 60 * 24) {
transmitter_status_view.setText("no data in 24 hours");
GcmActivity.requestSensorBatteryUpdate();
} else {
transmitter_status_view.setText("" + td.sensor_battery_level);
// always ask
GcmActivity.requestSensorBatteryUpdate();
if (td.sensor_battery_level <= Dex_Constants.TRANSMITTER_BATTERY_EMPTY) {
transmitter_status_view.append(" - very low");
} else if (td.sensor_battery_level <= Dex_Constants.TRANSMITTER_BATTERY_LOW) {
transmitter_status_view.append(" - low");
transmitter_status_view.append("\n(experimental interpretation)");
} else {
transmitter_status_view.append(" - ok");
}
}
}
use of com.eveningoutpost.dexdrip.Models.TransmitterData in project xDrip-plus by jamorham.
the class DexCollectionService method setWatchStatus.
public static void setWatchStatus(DataMap dataMap) {
lastStateWatch = dataMap.getString("lastState", "");
last_transmitter_DataWatch = new TransmitterData();
last_transmitter_DataWatch.timestamp = dataMap.getLong("timestamp", 0);
mStaticStateWatch = dataMap.getInt("mStaticState", 0);
last_battery_level_watch = dataMap.getInt("last_battery_level", -1);
retry_time_watch = dataMap.getLong("retry_time", 0);
failover_time_watch = dataMap.getLong("failover_time", 0);
static_last_hexdump_watch = dataMap.getString("static_last_hexdump", "");
static_last_sent_hexdump_watch = dataMap.getString("static_last_sent_hexdump", "");
}
Aggregations