Search in sources :

Example 1 with RecordRx

use of com.eveningoutpost.dexdrip.insulin.inpen.messages.RecordRx in project xDrip-plus by jamorham.

the class InPenService method processRecordsQueue.

private synchronized void processRecordsQueue() {
    boolean newRecord = false;
    while (!records.isEmpty()) {
        final byte[] record = records.poll();
        if (record != null) {
            final RecordRx recordRx = new RecordRx(currentPenTime).fromBytes(record);
            if (recordRx != null) {
                UserError.Log.d(TAG, "RECORD RECORD: " + recordRx.toS());
                final PenData penData = PenData.create(I.address, ID_INPEN, recordRx.index, recordRx.units, recordRx.getRealTimeStamp(), recordRx.temperature, record);
                if (penData == null) {
                    UserError.Log.wtf(TAG, "Error creating PenData record from " + HexDump.dumpHexString(record));
                } else {
                    penData.battery = recordRx.battery;
                    penData.flags = recordRx.flags;
                    UserError.Log.d(TAG, "Saving Record index: " + penData.index);
                    penData.save();
                    newRecord = true;
                    gotIndex = (int) penData.index;
                    gotAll = lastIndex == gotIndex;
                    if (InPen.soundsEnabled() && JoH.ratelimit("pen_data_in", 1)) {
                        JoH.playResourceAudio(R.raw.bt_meter_data_in);
                    }
                    lastPenData = penData;
                }
            } else {
                UserError.Log.e(TAG, "Error creating record from: " + HexDump.dumpHexString(record));
            }
        }
    }
    if (newRecord) {
        Inevitable.task("process-inpen-data", 1000, ProcessPenData::process);
    }
}
Also used : RecordRx(com.eveningoutpost.dexdrip.insulin.inpen.messages.RecordRx) ProcessPenData(com.eveningoutpost.dexdrip.insulin.shared.ProcessPenData) PenData(com.eveningoutpost.dexdrip.Models.PenData) ProcessPenData(com.eveningoutpost.dexdrip.insulin.shared.ProcessPenData)

Example 2 with RecordRx

use of com.eveningoutpost.dexdrip.insulin.inpen.messages.RecordRx in project xDrip by NightscoutFoundation.

the class InPenService method processRecordsQueue.

private synchronized void processRecordsQueue() {
    boolean newRecord = false;
    while (!records.isEmpty()) {
        final byte[] record = records.poll();
        if (record != null) {
            final RecordRx recordRx = new RecordRx(currentPenTime).fromBytes(record);
            if (recordRx != null) {
                UserError.Log.d(TAG, "RECORD RECORD: " + recordRx.toS());
                final PenData penData = PenData.create(I.address, ID_INPEN, recordRx.index, recordRx.units, recordRx.getRealTimeStamp(), recordRx.temperature, record);
                if (penData == null) {
                    UserError.Log.wtf(TAG, "Error creating PenData record from " + HexDump.dumpHexString(record));
                } else {
                    penData.battery = recordRx.battery;
                    penData.flags = recordRx.flags;
                    UserError.Log.d(TAG, "Saving Record index: " + penData.index);
                    penData.save();
                    newRecord = true;
                    gotIndex = (int) penData.index;
                    gotAll = lastIndex == gotIndex;
                    if (InPen.soundsEnabled() && JoH.ratelimit("pen_data_in", 1)) {
                        JoH.playResourceAudio(R.raw.bt_meter_data_in);
                    }
                    lastPenData = penData;
                }
            } else {
                UserError.Log.e(TAG, "Error creating record from: " + HexDump.dumpHexString(record));
            }
        }
    }
    if (newRecord) {
        Inevitable.task("process-inpen-data", 1000, ProcessPenData::process);
    }
}
Also used : RecordRx(com.eveningoutpost.dexdrip.insulin.inpen.messages.RecordRx) ProcessPenData(com.eveningoutpost.dexdrip.insulin.shared.ProcessPenData) PenData(com.eveningoutpost.dexdrip.Models.PenData) ProcessPenData(com.eveningoutpost.dexdrip.insulin.shared.ProcessPenData)

Aggregations

PenData (com.eveningoutpost.dexdrip.Models.PenData)2 RecordRx (com.eveningoutpost.dexdrip.insulin.inpen.messages.RecordRx)2 ProcessPenData (com.eveningoutpost.dexdrip.insulin.shared.ProcessPenData)2