com.eveningoutpost.dexdrip.ImportedLibraries.dexcom.records.SensorRecord Java Examples

The following examples show how to use com.eveningoutpost.dexdrip.ImportedLibraries.dexcom.records.SensorRecord. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static void create(SensorRecord sensorRecord, long addativeOffset, Context context) {
    Log.i(TAG, "create: gonna make some sensor records: " + sensorRecord.getUnfiltered());
    if (BgReading.is_new(sensorRecord, addativeOffset)) {
        BgReading bgReading = new BgReading();
        Sensor sensor = Sensor.currentSensor();
        Calibration calibration = Calibration.getForTimestamp(sensorRecord.getSystemTime().getTime() + addativeOffset);
        if (sensor != null && calibration != null) {
            bgReading.sensor = sensor;
            bgReading.sensor_uuid = sensor.uuid;
            bgReading.calibration = calibration;
            bgReading.calibration_uuid = calibration.uuid;
            bgReading.raw_data = (sensorRecord.getUnfiltered() / 1000);
            bgReading.filtered_data = (sensorRecord.getFiltered() / 1000);
            bgReading.timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset;
            if (bgReading.timestamp > new Date().getTime()) {
                return;
            }
            bgReading.uuid = UUID.randomUUID().toString();
            bgReading.time_since_sensor_started = bgReading.timestamp - sensor.started_at;
            bgReading.calculateAgeAdjustedRawValue();
            bgReading.save();
        }
    }
}
 
Example #2
Source File: ReadData.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public SensorRecord[] getRecentSensorRecords(int numOfRecentPages) {
    if (numOfRecentPages < 1) {
        throw new IllegalArgumentException("Number of pages must be greater than 1.");
    }
    Log.d(TAG, "Reading Sensor page range...");
    int recordType = Constants.RECORD_TYPES.SENSOR_DATA.ordinal();
    int endPage = readDataBasePageRange(recordType);
    Log.d(TAG, "Reading " + numOfRecentPages + " Sensor page(s)...");
    numOfRecentPages = numOfRecentPages - 1;
    SensorRecord[] allPages = new SensorRecord[0];
    for (int i = Math.min(numOfRecentPages,endPage); i >= 0; i--) {
        int nextPage = endPage - i;
        Log.d(TAG, "Reading #" + i + " Sensor pages (page number " + nextPage + ")");
        SensorRecord[] ithSensorRecordPage = readDataBasePage(recordType, nextPage);
        SensorRecord[] result = Arrays.copyOf(allPages, allPages.length + ithSensorRecordPage.length);
        System.arraycopy(ithSensorRecordPage, 0, result, allPages.length, ithSensorRecordPage.length);
        allPages = result;
    }
    Log.d(TAG, "Read complete of Sensor pages.");
    return allPages;
}
 
Example #3
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static boolean is_new(SensorRecord sensorRecord, long addativeOffset) {
    double timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset;
    Sensor sensor = Sensor.currentSensor();
    if(sensor != null) {
        BgReading bgReading = new Select()
                .from(BgReading.class)
                .where("Sensor = ? ", sensor.getId())
                .where("timestamp <= ?",  (timestamp + (60*1000))) // 1 minute padding (should never be that far off, but why not)
                .orderBy("timestamp desc")
                .executeSingle();
        if(bgReading != null && Math.abs(bgReading.timestamp - timestamp) < (3*60*1000)) { //cool, so was it actually within 4 minutes of that bg reading?
            Log.w(TAG, "Old Reading");
            return false;
        }
    }
    Log.w(TAG, "New Reading");
    return true;
}
 
Example #4
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static void create(SensorRecord sensorRecord, long addativeOffset, Context context) {
    Log.w(TAG, "gonna make some sensor records: " + sensorRecord.getUnfiltered());
    if(BgReading.is_new(sensorRecord, addativeOffset)) {
        BgReading bgReading = new BgReading();
        Sensor sensor = Sensor.currentSensor();
        Calibration calibration = Calibration.getForTimestamp(sensorRecord.getSystemTime().getTime() + addativeOffset);
        if(sensor != null && calibration != null) {
            bgReading.sensor = sensor;
            bgReading.sensor_uuid = sensor.uuid;
            bgReading.calibration = calibration;
            bgReading.calibration_uuid = calibration.uuid;
            bgReading.raw_data = (sensorRecord.getUnfiltered() / 1000);
            bgReading.filtered_data = (sensorRecord.getFiltered() / 1000);
            bgReading.timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset;
            if(bgReading.timestamp > new Date().getTime()) { return; }
            bgReading.uuid = UUID.randomUUID().toString();
            bgReading.time_since_sensor_started = bgReading.timestamp - sensor.started_at;
            bgReading.synced = false;
            bgReading.calculateAgeAdjustedRawValue();
            bgReading.save();
        }
    }
}
 
Example #5
Source File: ReadData.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
public SensorRecord[] getRecentSensorRecords(int numOfRecentPages) {
    if (numOfRecentPages < 1) {
        throw new IllegalArgumentException("Number of pages must be greater than 1.");
    }
    Log.d(TAG, "Reading Sensor page range...");
    int recordType = Constants.RECORD_TYPES.SENSOR_DATA.ordinal();
    int endPage = readDataBasePageRange(recordType);
    Log.d(TAG, "Reading " + numOfRecentPages + " Sensor page(s)...");
    numOfRecentPages = numOfRecentPages - 1;
    SensorRecord[] allPages = new SensorRecord[0];
    for (int i = Math.min(numOfRecentPages,endPage); i >= 0; i--) {
        int nextPage = endPage - i;
        Log.d(TAG, "Reading #" + i + " Sensor pages (page number " + nextPage + ")");
        SensorRecord[] ithSensorRecordPage = readDataBasePage(recordType, nextPage);
        SensorRecord[] result = Arrays.copyOf(allPages, allPages.length + ithSensorRecordPage.length);
        System.arraycopy(ithSensorRecordPage, 0, result, allPages.length, ithSensorRecordPage.length);
        allPages = result;
    }
    Log.d(TAG, "Read complete of Sensor pages.");
    return allPages;
}
 
Example #6
Source File: BgReading.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
public static boolean is_new(SensorRecord sensorRecord, long addativeOffset) {
    double timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset;
    Sensor sensor = Sensor.currentSensor();
    if(sensor != null) {
        BgReading bgReading = new Select()
                .from(BgReading.class)
                .where("Sensor = ? ", sensor.getId())
                .where("timestamp <= ?",  (timestamp + (60*1000))) // 1 minute padding (should never be that far off, but why not)
                .orderBy("timestamp desc")
                .executeSingle();
        if(bgReading != null && Math.abs(bgReading.timestamp - timestamp) < (3*60*1000)) { //cool, so was it actually within 4 minutes of that bg reading?
            Log.i(TAG, "isNew; Old Reading");
            return false;
        }
    }
    Log.i(TAG, "isNew: New Reading");
    return true;
}
 
Example #7
Source File: BgReading.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
public static void create(SensorRecord sensorRecord, long addativeOffset, Context context) {
    Log.i(TAG, "create: gonna make some sensor records: " + sensorRecord.getUnfiltered());
    if(BgReading.is_new(sensorRecord, addativeOffset)) {
        BgReading bgReading = new BgReading();
        Sensor sensor = Sensor.currentSensor();
        Calibration calibration = Calibration.getForTimestamp(sensorRecord.getSystemTime().getTime() + addativeOffset);
        if(sensor != null && calibration != null) {
            bgReading.sensor = sensor;
            bgReading.sensor_uuid = sensor.uuid;
            bgReading.calibration = calibration;
            bgReading.calibration_uuid = calibration.uuid;
            bgReading.raw_data = (sensorRecord.getUnfiltered() / 1000);
            bgReading.filtered_data = (sensorRecord.getFiltered() / 1000);
            bgReading.timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset;
            if(bgReading.timestamp > new Date().getTime()) { return; }
            bgReading.uuid = UUID.randomUUID().toString();
            bgReading.time_since_sensor_started = bgReading.timestamp - sensor.started_at;
            bgReading.calculateAgeAdjustedRawValue(context);
            bgReading.save();
        }
    }
}
 
Example #8
Source File: ReadData.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public SensorRecord[] getRecentSensorRecords(int numOfRecentPages) {
    if (numOfRecentPages < 1) {
        throw new IllegalArgumentException("Number of pages must be greater than 1.");
    }
    Log.d(TAG, "Reading Sensor page range...");
    int recordType = Dex_Constants.RECORD_TYPES.SENSOR_DATA.ordinal();
    int endPage = readDataBasePageRange(recordType);
    Log.d(TAG, "Reading " + numOfRecentPages + " Sensor page(s)...");
    numOfRecentPages = numOfRecentPages - 1;
    SensorRecord[] allPages = new SensorRecord[0];
    for (int i = Math.min(numOfRecentPages,endPage); i >= 0; i--) {
        int nextPage = endPage - i;
        Log.d(TAG, "Reading #" + i + " Sensor pages (page number " + nextPage + ")");
        SensorRecord[] ithSensorRecordPage = readDataBasePage(recordType, nextPage);
        SensorRecord[] result = Arrays.copyOf(allPages, allPages.length + ithSensorRecordPage.length);
        System.arraycopy(ithSensorRecordPage, 0, result, allPages.length, ithSensorRecordPage.length);
        allPages = result;
    }
    Log.d(TAG, "Read complete of Sensor pages.");
    return allPages;
}
 
Example #9
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static boolean is_new(SensorRecord sensorRecord, long addativeOffset) {
    double timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset;
    Sensor sensor = Sensor.currentSensor();
    if (sensor != null) {
        BgReading bgReading = new Select()
                .from(BgReading.class)
                .where("Sensor = ? ", sensor.getId())
                .where("timestamp <= ?", (timestamp + (60 * 1000))) // 1 minute padding (should never be that far off, but why not)
                .orderBy("timestamp desc")
                .executeSingle();
        if (bgReading != null && Math.abs(bgReading.timestamp - timestamp) < (3 * 60 * 1000)) { //cool, so was it actually within 4 minutes of that bg reading?
            Log.i(TAG, "isNew; Old Reading");
            return false;
        }
    }
    Log.i(TAG, "isNew: New Reading");
    return true;
}
 
Example #10
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static void create(SensorRecord sensorRecord, long addativeOffset, Context context) {
    Log.i(TAG, "create: gonna make some sensor records: " + sensorRecord.getUnfiltered());
    if (BgReading.is_new(sensorRecord, addativeOffset)) {
        BgReading bgReading = new BgReading();
        Sensor sensor = Sensor.currentSensor();
        Calibration calibration = Calibration.getForTimestamp(sensorRecord.getSystemTime().getTime() + addativeOffset);
        if (sensor != null && calibration != null) {
            bgReading.sensor = sensor;
            bgReading.sensor_uuid = sensor.uuid;
            bgReading.calibration = calibration;
            bgReading.calibration_uuid = calibration.uuid;
            bgReading.raw_data = (sensorRecord.getUnfiltered() / 1000);
            bgReading.filtered_data = (sensorRecord.getFiltered() / 1000);
            bgReading.timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset;
            if (bgReading.timestamp > new Date().getTime()) {
                return;
            }
            bgReading.uuid = UUID.randomUUID().toString();
            bgReading.time_since_sensor_started = bgReading.timestamp - sensor.started_at;
            bgReading.calculateAgeAdjustedRawValue();
            bgReading.save();
        }
    }
}
 
Example #11
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static boolean is_new(SensorRecord sensorRecord, long addativeOffset) {
    double timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset;
    Sensor sensor = Sensor.currentSensor();
    if (sensor != null) {
        BgReading bgReading = new Select()
                .from(BgReading.class)
                .where("Sensor = ? ", sensor.getId())
                .where("timestamp <= ?", (timestamp + (60 * 1000))) // 1 minute padding (should never be that far off, but why not)
                .orderBy("timestamp desc")
                .executeSingle();
        if (bgReading != null && Math.abs(bgReading.timestamp - timestamp) < (3 * 60 * 1000)) { //cool, so was it actually within 4 minutes of that bg reading?
            Log.i(TAG, "isNew; Old Reading");
            return false;
        }
    }
    Log.i(TAG, "isNew: New Reading");
    return true;
}
 
Example #12
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static void create(SensorRecord sensorRecord, long addativeOffset, Context context) {
    Log.i(TAG, "create: gonna make some sensor records: " + sensorRecord.getUnfiltered());
    if (BgReading.is_new(sensorRecord, addativeOffset)) {
        BgReading bgReading = new BgReading();
        Sensor sensor = Sensor.currentSensor();
        Calibration calibration = Calibration.getForTimestamp(sensorRecord.getSystemTime().getTime() + addativeOffset);
        if (sensor != null && calibration != null) {
            bgReading.sensor = sensor;
            bgReading.sensor_uuid = sensor.uuid;
            bgReading.calibration = calibration;
            bgReading.calibration_uuid = calibration.uuid;
            bgReading.raw_data = (sensorRecord.getUnfiltered() / 1000);
            bgReading.filtered_data = (sensorRecord.getFiltered() / 1000);
            bgReading.timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset;
            if (bgReading.timestamp > new Date().getTime()) {
                return;
            }
            bgReading.uuid = UUID.randomUUID().toString();
            bgReading.time_since_sensor_started = bgReading.timestamp - sensor.started_at;
            bgReading.calculateAgeAdjustedRawValue();
            bgReading.save();
        }
    }
}
 
Example #13
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static boolean is_new(SensorRecord sensorRecord, long addativeOffset) {
    double timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset;
    Sensor sensor = Sensor.currentSensor();
    if (sensor != null) {
        BgReading bgReading = new Select()
                .from(BgReading.class)
                .where("Sensor = ? ", sensor.getId())
                .where("timestamp <= ?", (timestamp + (60 * 1000))) // 1 minute padding (should never be that far off, but why not)
                .orderBy("timestamp desc")
                .executeSingle();
        if (bgReading != null && Math.abs(bgReading.timestamp - timestamp) < (3 * 60 * 1000)) { //cool, so was it actually within 4 minutes of that bg reading?
            Log.i(TAG, "isNew; Old Reading");
            return false;
        }
    }
    Log.i(TAG, "isNew: New Reading");
    return true;
}
 
Example #14
Source File: ReadData.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public SensorRecord[] getRecentSensorRecords(int numOfRecentPages) {
    if (numOfRecentPages < 1) {
        throw new IllegalArgumentException("Number of pages must be greater than 1.");
    }
    Log.d(TAG, "Reading Sensor page range...");
    int recordType = Dex_Constants.RECORD_TYPES.SENSOR_DATA.ordinal();
    int endPage = readDataBasePageRange(recordType);
    Log.d(TAG, "Reading " + numOfRecentPages + " Sensor page(s)...");
    numOfRecentPages = numOfRecentPages - 1;
    SensorRecord[] allPages = new SensorRecord[0];
    for (int i = Math.min(numOfRecentPages,endPage); i >= 0; i--) {
        int nextPage = endPage - i;
        Log.d(TAG, "Reading #" + i + " Sensor pages (page number " + nextPage + ")");
        SensorRecord[] ithSensorRecordPage = readDataBasePage(recordType, nextPage);
        SensorRecord[] result = Arrays.copyOf(allPages, allPages.length + ithSensorRecordPage.length);
        System.arraycopy(ithSensorRecordPage, 0, result, allPages.length, ithSensorRecordPage.length);
        allPages = result;
    }
    Log.d(TAG, "Read complete of Sensor pages.");
    return allPages;
}
 
Example #15
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static void create(SensorRecord sensorRecord, long addativeOffset, Context context) {
    Log.i(TAG, "create: gonna make some sensor records: " + sensorRecord.getUnfiltered());
    if (BgReading.is_new(sensorRecord, addativeOffset)) {
        BgReading bgReading = new BgReading();
        Sensor sensor = Sensor.currentSensor();
        Calibration calibration = Calibration.getForTimestamp(sensorRecord.getSystemTime().getTime() + addativeOffset);
        if (sensor != null && calibration != null) {
            bgReading.sensor = sensor;
            bgReading.sensor_uuid = sensor.uuid;
            bgReading.calibration = calibration;
            bgReading.calibration_uuid = calibration.uuid;
            bgReading.raw_data = (sensorRecord.getUnfiltered() / 1000);
            bgReading.filtered_data = (sensorRecord.getFiltered() / 1000);
            bgReading.timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset;
            if (bgReading.timestamp > new Date().getTime()) {
                return;
            }
            bgReading.uuid = UUID.randomUUID().toString();
            bgReading.time_since_sensor_started = bgReading.timestamp - sensor.started_at;
            bgReading.calculateAgeAdjustedRawValue();
            bgReading.save();
        }
    }
}
 
Example #16
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static boolean is_new(SensorRecord sensorRecord, long addativeOffset) {
    double timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset;
    Sensor sensor = Sensor.currentSensor();
    if (sensor != null) {
        BgReading bgReading = new Select()
                .from(BgReading.class)
                .where("Sensor = ? ", sensor.getId())
                .where("timestamp <= ?", (timestamp + (60 * 1000))) // 1 minute padding (should never be that far off, but why not)
                .orderBy("timestamp desc")
                .executeSingle();
        if (bgReading != null && Math.abs(bgReading.timestamp - timestamp) < (3 * 60 * 1000)) { //cool, so was it actually within 4 minutes of that bg reading?
            Log.i(TAG, "isNew; Old Reading");
            return false;
        }
    }
    Log.i(TAG, "isNew: New Reading");
    return true;
}
 
Example #17
Source File: Utils.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static GlucoseDataSet[] mergeGlucoseDataRecords(EGVRecord[] egvRecords,
                                                       SensorRecord[] sensorRecords) {
    int egvLength = egvRecords.length;
    int sensorLength = sensorRecords.length;
    int smallerLength = egvLength < sensorLength ? egvLength : sensorLength;
    GlucoseDataSet[] glucoseDataSets = new GlucoseDataSet[smallerLength];
    for (int i = 1; i <= smallerLength; i++) {
        glucoseDataSets[smallerLength - i] = new GlucoseDataSet(egvRecords[egvLength - i], sensorRecords[sensorLength - i]);
    }
    return glucoseDataSets;
}
 
Example #18
Source File: Utils.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static GlucoseDataSet[] mergeGlucoseDataRecords(EGVRecord[] egvRecords,
                                                       SensorRecord[] sensorRecords) {
    int egvLength = egvRecords.length;
    int sensorLength = sensorRecords.length;
    int smallerLength = egvLength < sensorLength ? egvLength : sensorLength;
    GlucoseDataSet[] glucoseDataSets = new GlucoseDataSet[smallerLength];
    for (int i = 1; i <= smallerLength; i++) {
        glucoseDataSets[smallerLength - i] = new GlucoseDataSet(egvRecords[egvLength - i], sensorRecords[sensorLength - i]);
    }
    return glucoseDataSets;
}
 
Example #19
Source File: Utils.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public static GlucoseDataSet[] mergeGlucoseDataRecords(EGVRecord[] egvRecords,
                                                       SensorRecord[] sensorRecords) {
    int egvLength = egvRecords.length;
    int sensorLength = sensorRecords.length;
    int smallerLength = egvLength < sensorLength ? egvLength : sensorLength;
    GlucoseDataSet[] glucoseDataSets = new GlucoseDataSet[smallerLength];
    for (int i = 1; i <= smallerLength; i++) {
        glucoseDataSets[smallerLength - i] = new GlucoseDataSet(egvRecords[egvLength - i], sensorRecords[sensorLength - i]);
    }
    return glucoseDataSets;
}
 
Example #20
Source File: Utils.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static GlucoseDataSet[] mergeGlucoseDataRecords(EGVRecord[] egvRecords,
                                                       SensorRecord[] sensorRecords) {
    int egvLength = egvRecords.length;
    int sensorLength = sensorRecords.length;
    int smallerLength = egvLength < sensorLength ? egvLength : sensorLength;
    GlucoseDataSet[] glucoseDataSets = new GlucoseDataSet[smallerLength];
    for (int i = 1; i <= smallerLength; i++) {
        glucoseDataSets[smallerLength - i] = new GlucoseDataSet(egvRecords[egvLength - i], sensorRecords[sensorLength - i]);
    }
    return glucoseDataSets;
}
 
Example #21
Source File: Utils.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static GlucoseDataSet[] mergeGlucoseDataRecords(EGVRecord[] egvRecords,
                                                       SensorRecord[] sensorRecords) {
    int egvLength = egvRecords.length;
    int sensorLength = sensorRecords.length;
    int smallerLength = egvLength < sensorLength ? egvLength : sensorLength;
    GlucoseDataSet[] glucoseDataSets = new GlucoseDataSet[smallerLength];
    for (int i = 1; i <= smallerLength; i++) {
        glucoseDataSets[smallerLength - i] = new GlucoseDataSet(egvRecords[egvLength - i], sensorRecords[sensorLength - i]);
    }
    return glucoseDataSets;
}
 
Example #22
Source File: Utils.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static GlucoseDataSet[] mergeGlucoseDataRecords(EGVRecord[] egvRecords,
                                                       SensorRecord[] sensorRecords) {
    int egvLength = egvRecords.length;
    int sensorLength = sensorRecords.length;
    int smallerLength = egvLength < sensorLength ? egvLength : sensorLength;
    GlucoseDataSet[] glucoseDataSets = new GlucoseDataSet[smallerLength];
    for (int i = 1; i <= smallerLength; i++) {
        glucoseDataSets[smallerLength - i] = new GlucoseDataSet(egvRecords[egvLength - i], sensorRecords[sensorLength - i]);
    }
    return glucoseDataSets;
}
 
Example #23
Source File: BgReading.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
public static void create(SensorRecord[] sensorRecords, long addativeOffset, Context context) {
    for(SensorRecord sensorRecord : sensorRecords) { BgReading.create(sensorRecord, addativeOffset, context); }
}
 
Example #24
Source File: ShareTest.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public void attemptRead() {
    final ReadDataShare readData = new ReadDataShare(this);
    final Action1<Long> systemTimeListener = new Action1<Long>() {
        @Override
        public void call(Long s) {

            Log.d(TAG, "Made the full round trip, got " + s + " as the system time");
            Log.d("SYSTTIME", "Made the full round trip, got " + s + " as the system time");
            final long addativeSystemTimeOffset = new Date().getTime() - s;
            Log.d(TAG, "Made the full round trip, got " + addativeSystemTimeOffset + " offset");
            Log.d("SYSTTIME", "Made the full round trip, got " + addativeSystemTimeOffset + " offset");

            final Action1<CalRecord[]> calRecordListener = new Action1<CalRecord[]>() {
                @Override
                public void call(CalRecord[] calRecords) {
                    Log.d(TAG, "Made the full round trip, got " + calRecords.length + " Cal Records");
                    Calibration.create(calRecords, addativeSystemTimeOffset, getApplicationContext());

                    final Action1<SensorRecord[]> sensorRecordListener = new Action1<SensorRecord[]>() {
                        @Override
                        public void call(SensorRecord[] sensorRecords) {
                            Log.d(TAG, "Made the full round trip, got " + sensorRecords.length + " Sensor Records");
                            BgReading.create(sensorRecords, addativeSystemTimeOffset, getApplicationContext());

                            final Action1<EGVRecord[]> evgRecordListener = new Action1<EGVRecord[]>() {
                                @Override
                                public void call(EGVRecord[] egvRecords) {
                                    Log.d(TAG, "Made the full round trip, got " + egvRecords.length + " EVG Records");
                                    BgReading.create(egvRecords, addativeSystemTimeOffset, getApplicationContext());
                                }
                            };
                            readData.getRecentEGVs(evgRecordListener);
                        }
                    };
                    readData.getRecentSensorRecords(sensorRecordListener);
                }
            };
            readData.getRecentCalRecords(calRecordListener);
        }
    };
    readData.readSystemTime(systemTimeListener);
}
 
Example #25
Source File: ShareTest.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public void attemptRead() {
    final ReadDataShare readData = new ReadDataShare(this);
    final Action1<Long> systemTimeListener = new Action1<Long>() {
        @Override
        public void call(Long s) {

            Log.d(TAG, "Made the full round trip, got " + s + " as the system time");
            Log.d("SYSTTIME", "Made the full round trip, got " + s + " as the system time");
            final long addativeSystemTimeOffset = new Date().getTime() - s;
            Log.d(TAG, "Made the full round trip, got " + addativeSystemTimeOffset + " offset");
            Log.d("SYSTTIME", "Made the full round trip, got " + addativeSystemTimeOffset + " offset");

            final Action1<CalRecord[]> calRecordListener = new Action1<CalRecord[]>() {
                @Override
                public void call(CalRecord[] calRecords) {
                    Log.d(TAG, "Made the full round trip, got " + calRecords.length + " Cal Records");
                    Calibration.create(calRecords, addativeSystemTimeOffset, getApplicationContext());

                    final Action1<SensorRecord[]> sensorRecordListener = new Action1<SensorRecord[]>() {
                        @Override
                        public void call(SensorRecord[] sensorRecords) {
                            Log.d(TAG, "Made the full round trip, got " + sensorRecords.length + " Sensor Records");
                            BgReading.create(sensorRecords, addativeSystemTimeOffset, getApplicationContext());

                            final Action1<EGVRecord[]> evgRecordListener = new Action1<EGVRecord[]>() {
                                @Override
                                public void call(EGVRecord[] egvRecords) {
                                    Log.d(TAG, "Made the full round trip, got " + egvRecords.length + " EVG Records");
                                    BgReading.create(egvRecords, addativeSystemTimeOffset, getApplicationContext());
                                }
                            };
                            readData.getRecentEGVs(evgRecordListener);
                        }
                    };
                    readData.getRecentSensorRecords(sensorRecordListener);
                }
            };
            readData.getRecentCalRecords(calRecordListener);
        }
    };
    readData.readSystemTime(systemTimeListener);
}
 
Example #26
Source File: ShareTest.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
public void attemptRead() {
    final ReadDataShare readData = new ReadDataShare(this);
    final Action1<Long> systemTimeListener = new Action1<Long>() {
        @Override
        public void call(Long s) {

            Log.d(TAG, "Made the full round trip, got " + s + " as the system time");
            Log.d("SYSTTIME", "Made the full round trip, got " + s + " as the system time");
            final long addativeSystemTimeOffset = new Date().getTime() - s;
            Log.d(TAG, "Made the full round trip, got " + addativeSystemTimeOffset + " offset");
            Log.d("SYSTTIME", "Made the full round trip, got " + addativeSystemTimeOffset + " offset");

            final Action1<CalRecord[]> calRecordListener = new Action1<CalRecord[]>() {
                @Override
                public void call(CalRecord[] calRecords) {
                    Log.d(TAG, "Made the full round trip, got " + calRecords.length + " Cal Records");
                    Calibration.create(calRecords, addativeSystemTimeOffset, getApplicationContext());

                    final Action1<SensorRecord[]> sensorRecordListener = new Action1<SensorRecord[]>() {
                        @Override
                        public void call(SensorRecord[] sensorRecords) {
                            Log.d(TAG, "Made the full round trip, got " + sensorRecords.length + " Sensor Records");
                            BgReading.create(sensorRecords, addativeSystemTimeOffset, getApplicationContext());

                            final Action1<EGVRecord[]> evgRecordListener = new Action1<EGVRecord[]>() {
                                @Override
                                public void call(EGVRecord[] egvRecords) {
                                    Log.d(TAG, "Made the full round trip, got " + egvRecords.length + " EVG Records");
                                    BgReading.create(egvRecords, addativeSystemTimeOffset, getApplicationContext());
                                }
                            };
                            readData.getRecentEGVs(evgRecordListener);
                        }
                    };
                    readData.getRecentSensorRecords(sensorRecordListener);
                }
            };
            readData.getRecentCalRecords(calRecordListener);
        }
    };
    readData.readSystemTime(systemTimeListener);
}
 
Example #27
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static void create(SensorRecord[] sensorRecords, long addativeOffset, Context context) {
    for (SensorRecord sensorRecord : sensorRecords) {
        BgReading.create(sensorRecord, addativeOffset, context);
    }
}
 
Example #28
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static void create(SensorRecord[] sensorRecords, long addativeOffset, Context context) {
    for(SensorRecord sensorRecord : sensorRecords) { BgReading.create(sensorRecord, addativeOffset, context); }
}
 
Example #29
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static void create(SensorRecord[] sensorRecords, long addativeOffset, Context context) {
    for (SensorRecord sensorRecord : sensorRecords) {
        BgReading.create(sensorRecord, addativeOffset, context);
    }
}
 
Example #30
Source File: ShareTest.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public void attemptRead() {
    final ReadDataShare readData = new ReadDataShare(this);
    final Action1<Long> systemTimeListener = new Action1<Long>() {
        @Override
        public void call(Long s) {

            Log.d(TAG, "Made the full round trip, got " + s + " as the system time");
            Log.d("SYSTTIME", "Made the full round trip, got " + s + " as the system time");
            final long addativeSystemTimeOffset = new Date().getTime() - s;
            Log.d(TAG, "Made the full round trip, got " + addativeSystemTimeOffset + " offset");
            Log.d("SYSTTIME", "Made the full round trip, got " + addativeSystemTimeOffset + " offset");

            final Action1<CalRecord[]> calRecordListener = new Action1<CalRecord[]>() {
                @Override
                public void call(CalRecord[] calRecords) {
                    Log.d(TAG, "Made the full round trip, got " + calRecords.length + " Cal Records");
                    Calibration.create(calRecords, addativeSystemTimeOffset, getApplicationContext());

                    final Action1<SensorRecord[]> sensorRecordListener = new Action1<SensorRecord[]>() {
                        @Override
                        public void call(SensorRecord[] sensorRecords) {
                            Log.d(TAG, "Made the full round trip, got " + sensorRecords.length + " Sensor Records");
                            BgReading.create(sensorRecords, addativeSystemTimeOffset, getApplicationContext());

                            final Action1<EGVRecord[]> evgRecordListener = new Action1<EGVRecord[]>() {
                                @Override
                                public void call(EGVRecord[] egvRecords) {
                                    Log.d(TAG, "Made the full round trip, got " + egvRecords.length + " EVG Records");
                                    BgReading.create(egvRecords, addativeSystemTimeOffset, getApplicationContext());
                                }
                            };
                            readData.getRecentEGVs(evgRecordListener);
                        }
                    };
                    readData.getRecentSensorRecords(sensorRecordListener);
                }
            };
            readData.getRecentCalRecords(calRecordListener);
        }
    };
    readData.readSystemTime(systemTimeListener);
}