use of com.eveningoutpost.dexdrip.Models.TransmitterData in project xDrip by NightscoutFoundation.
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 by NightscoutFoundation.
the class WixelReader method timeForNextRead.
static Long timeForNextRead() {
TransmitterData lastTransmitterData = TransmitterData.last();
if (lastTransmitterData == null) {
// We did not receive a packet, well someone hopefully is looking at data, return relatively fast
Log.e(TAG, "lastTransmitterData == null returning 60000");
return 60 * 1000L;
}
Long gapTime = new Date().getTime() - lastTransmitterData.timestamp;
Log.d(TAG, "gapTime = " + gapTime);
if (gapTime < 0) {
// There is some confusion here (clock was readjusted?)
Log.e(TAG, "gapTime <= null returning 60000");
return 60 * 1000L;
}
if (gapTime < DEXCOM_PERIOD) {
// 300000 - gaptime is when we expect to have the next packet.
return (DEXCOM_PERIOD - gapTime) + 2000;
}
gapTime = gapTime % DEXCOM_PERIOD;
Log.d(TAG, "modulus gapTime = " + gapTime);
if (gapTime < 10000) {
// A new packet should arrive any second now
return 10000L;
}
if (gapTime < 60000) {
// A new packet should arrive but chance is we have missed it...
return 30000L;
}
if (httpClient == null) {
return (DEXCOM_PERIOD - gapTime) + 2000;
} else {
// compensate for parakeet gprs lag
return (DEXCOM_PERIOD - gapTime) + 12000;
}
}
use of com.eveningoutpost.dexdrip.Models.TransmitterData in project xDrip by NightscoutFoundation.
the class G5CollectionService method processNewTransmitterData.
private synchronized void processNewTransmitterData(int raw_data, int filtered_data, int sensor_battery_level, long captureTime) {
final TransmitterData transmitterData = TransmitterData.create(raw_data, filtered_data, sensor_battery_level, captureTime);
if (transmitterData == null) {
Log.e(TAG, "TransmitterData.create failed: Duplicate packet");
return;
} else {
timeInMillisecondsOfLastSuccessfulSensorRead = captureTime;
}
Sensor sensor = Sensor.currentSensor();
if (sensor == null) {
Log.e(TAG, "setSerialDataToTransmitterRawData: No Active Sensor, Data only stored in Transmitter Data");
return;
}
// TODO : LOG if unfiltered or filtered values are zero
Sensor.updateBatteryLevel(sensor, transmitterData.sensor_battery_level);
Log.i(TAG, "timestamp create: " + Long.toString(transmitterData.timestamp));
BgReading.create(transmitterData.raw_data, transmitterData.filtered_data, this, transmitterData.timestamp);
// KS
Log.d(TAG, "Dex raw_data " + Double.toString(transmitterData.raw_data));
// KS
Log.d(TAG, "Dex filtered_data " + Double.toString(transmitterData.filtered_data));
// KS
Log.d(TAG, "Dex sensor_battery_level " + Double.toString(transmitterData.sensor_battery_level));
// KS
Log.d(TAG, "Dex timestamp " + JoH.dateTimeText(transmitterData.timestamp));
static_last_timestamp = transmitterData.timestamp;
}
use of com.eveningoutpost.dexdrip.Models.TransmitterData in project xDrip by NightscoutFoundation.
the class Ob1G5StateMachine method processNewTransmitterData.
// Save/process the data in xDrip style
private static synchronized void processNewTransmitterData(int raw_data, int filtered_data, int sensor_battery_level, long captureTime) {
final TransmitterData transmitterData = TransmitterData.create(raw_data, filtered_data, sensor_battery_level, captureTime);
if (transmitterData == null) {
UserError.Log.e(TAG, "TransmitterData.create failed: Duplicate packet");
return;
} else {
UserError.Log.d(TAG, "Created transmitter data " + transmitterData.uuid + " " + JoH.dateTimeText(transmitterData.timestamp));
// TODO timeInMillisecondsOfLastSuccessfulSensorRead = captureTime;
}
Sensor sensor = Sensor.currentSensor();
if (sensor == null) {
UserError.Log.e(TAG, "setSerialDataToTransmitterRawData: No Active Sensor, Data only stored in Transmitter Data");
return;
}
// TODO : LOG if unfiltered or filtered values are zero
Sensor.updateBatteryLevel(sensor, transmitterData.sensor_battery_level);
if (d)
UserError.Log.i(TAG, "timestamp create: " + Long.toString(transmitterData.timestamp));
BgReading bgreading = BgReading.create(transmitterData.raw_data, transmitterData.filtered_data, xdrip.getAppContext(), transmitterData.timestamp);
// KS
UserError.Log.d(TAG, "Dex raw_data " + Double.toString(transmitterData.raw_data));
// KS
UserError.Log.d(TAG, "Dex filtered_data " + Double.toString(transmitterData.filtered_data));
// KS
UserError.Log.d(TAG, "Dex sensor_battery_level " + Double.toString(transmitterData.sensor_battery_level));
// KS
UserError.Log.d(TAG, "Dex timestamp " + JoH.dateTimeText(transmitterData.timestamp));
UserError.Log.d(TAG, "BgReading created: " + bgreading.uuid + " " + JoH.dateTimeText(bgreading.timestamp));
// TODO static_last_timestamp = transmitterData.timestamp;
}
use of com.eveningoutpost.dexdrip.Models.TransmitterData in project xDrip-plus by jamorham.
the class WixelReader method timeForNextRead.
static Long timeForNextRead() {
TransmitterData lastTransmitterData = TransmitterData.last();
if (lastTransmitterData == null) {
// We did not receive a packet, well someone hopefully is looking at data, return relatively fast
Log.e(TAG, "lastTransmitterData == null returning 60000");
return 60 * 1000L;
}
Long gapTime = new Date().getTime() - lastTransmitterData.timestamp;
Log.d(TAG, "gapTime = " + gapTime);
if (gapTime < 0) {
// There is some confusion here (clock was readjusted?)
Log.e(TAG, "gapTime <= null returning 60000");
return 60 * 1000L;
}
if (gapTime < DEXCOM_PERIOD) {
// 300000 - gaptime is when we expect to have the next packet.
return (DEXCOM_PERIOD - gapTime) + 2000;
}
gapTime = gapTime % DEXCOM_PERIOD;
Log.d(TAG, "modulus gapTime = " + gapTime);
if (gapTime < 10000) {
// A new packet should arrive any second now
return 10000L;
}
if (gapTime < 60000) {
// A new packet should arrive but chance is we have missed it...
return 30000L;
}
if (httpClient == null) {
return (DEXCOM_PERIOD - gapTime) + 2000;
} else {
// compensate for parakeet gprs lag
return (DEXCOM_PERIOD - gapTime) + 12000;
}
}
Aggregations