Search in sources :

Example 1 with PebbleMovement

use of com.eveningoutpost.dexdrip.Models.PebbleMovement in project xDrip by NightscoutFoundation.

the class ListenerService method getWearStepSensorData.

private synchronized DataMap getWearStepSensorData(int count, long last_send_time, int min_count) {
    // final int sensorType, final int accuracy, final long timestamp, final float[] values) {
    forceGoogleApiConnect();
    Log.d(TAG, "getWearStepSensorData last_send_time:" + JoH.dateTimeText(last_send_time));
    PebbleMovement last_log = PebbleMovement.last();
    if (last_log != null) {
        Log.d(TAG, "getWearStepSensorData last_log.timestamp:" + JoH.dateTimeText((long) last_log.timestamp));
    } else {
        Log.d(TAG, "getWearStepSensorData PebbleMovement.last() = null:");
    }
    if (last_log != null && last_send_time <= last_log.timestamp) {
        // startTime
        long last_send_success = last_send_time;
        Log.d(TAG, "getWearStepSensorData last_send_time < last_bg.timestamp:" + JoH.dateTimeText((long) last_log.timestamp));
        List<PebbleMovement> logs = PebbleMovement.latestForGraph(count, last_send_time);
        if (!logs.isEmpty() && logs.size() > min_count) {
            // Log.d(TAG, "getWearStepSensorData count = " + logs.size());
            DataMap entries = dataMap(last_log);
            final ArrayList<DataMap> dataMaps = new ArrayList<>(logs.size());
            for (PebbleMovement log : logs) {
                dataMaps.add(dataMap(log));
                last_send_success = (long) log.timestamp;
            // Log.d(TAG, "getWearStepSensorData set last_send_sucess:" + JoH.dateTimeText(last_send_success) + " pw.metric: " + log.metric + " pw.timestamp: " + JoH.dateTimeText(log.timestamp));
            }
            // MOST IMPORTANT LINE FOR TIMESTAMP
            entries.putLong("time", new Date().getTime());
            entries.putDataMapArrayList("entries", dataMaps);
            // Log.d(TAG, "getWearStepSensorData  entries:" + entries);
            Log.i(TAG, "getWearStepSensorData SYNCED steps up to " + JoH.dateTimeText(last_send_success) + " count = " + logs.size());
            return entries;
        } else
            Log.i(TAG, "getWearStepSensorData SYNCED steps up to " + JoH.dateTimeText(last_send_success) + " count = 0");
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) PebbleMovement(com.eveningoutpost.dexdrip.Models.PebbleMovement) Date(java.util.Date) DataMap(com.google.android.gms.wearable.DataMap)

Example 2 with PebbleMovement

use of com.eveningoutpost.dexdrip.Models.PebbleMovement in project xDrip by NightscoutFoundation.

the class ListenerService method resetCounters.

private void resetCounters() {
    // initCounters();
    mSteps = (int) PersistentStore.getLong(pref_msteps);
    last_movement_timestamp = (int) PersistentStore.getLong(pref_last_movement_timestamp);
    Log.d(TAG, "resetCounters Sensor Enter PersistentStore mSteps = " + mSteps + " mCounterSteps = " + mCounterSteps + " mPreviousCounterSteps = " + mPreviousCounterSteps + " last_movement_timestamp = " + JoH.dateTimeText(last_movement_timestamp));
    PebbleMovement last = PebbleMovement.last();
    boolean sameDay = last != null ? ListenerService.isSameDay(System.currentTimeMillis(), last.timestamp) : false;
    if (!sameDay) {
        initCounters();
        Log.d(TAG, "resetCounters Sensor isSameDay=false initCounters mSteps = " + mSteps + " mCounterSteps = " + mCounterSteps + " mPreviousCounterSteps = " + mPreviousCounterSteps + " last_movement_timestamp = " + JoH.dateTimeText(last_movement_timestamp));
    } else {
        mCounterSteps = 0;
        mPreviousCounterSteps = mSteps;
        Log.d(TAG, "resetCounters Sensor isSameDay=true PersistentStore mSteps = " + mSteps + " mCounterSteps = " + mCounterSteps + " mPreviousCounterSteps = " + mPreviousCounterSteps + " last_movement_timestamp = " + JoH.dateTimeText(last_movement_timestamp));
    }
}
Also used : PebbleMovement(com.eveningoutpost.dexdrip.Models.PebbleMovement)

Example 3 with PebbleMovement

use of com.eveningoutpost.dexdrip.Models.PebbleMovement in project xDrip by NightscoutFoundation.

the class ListenerService method initCounters.

private synchronized void initCounters() {
    long t = System.currentTimeMillis();
    final PebbleMovement pm = PebbleMovement.createEfficientRecord(t, 0);
    Log.d(TAG, "initCounters Saving First Movement: " + pm.toS() + " at midnight t=" + JoH.dateTimeText(t));
    mSteps = 0;
    mCounterSteps = 0;
    mPreviousCounterSteps = 0;
}
Also used : PebbleMovement(com.eveningoutpost.dexdrip.Models.PebbleMovement)

Example 4 with PebbleMovement

use of com.eveningoutpost.dexdrip.Models.PebbleMovement in project xDrip-plus by jamorham.

the class ListenerService method getWearStepSensorData.

private synchronized DataMap getWearStepSensorData(int count, long last_send_time, int min_count) {
    // final int sensorType, final int accuracy, final long timestamp, final float[] values) {
    forceGoogleApiConnect();
    Log.d(TAG, "getWearStepSensorData last_send_time:" + JoH.dateTimeText(last_send_time));
    PebbleMovement last_log = PebbleMovement.last();
    if (last_log != null) {
        Log.d(TAG, "getWearStepSensorData last_log.timestamp:" + JoH.dateTimeText((long) last_log.timestamp));
    } else {
        Log.d(TAG, "getWearStepSensorData PebbleMovement.last() = null:");
    }
    if (last_log != null && last_send_time <= last_log.timestamp) {
        // startTime
        long last_send_success = last_send_time;
        Log.d(TAG, "getWearStepSensorData last_send_time < last_bg.timestamp:" + JoH.dateTimeText((long) last_log.timestamp));
        List<PebbleMovement> logs = PebbleMovement.latestForGraph(count, last_send_time);
        if (!logs.isEmpty() && logs.size() > min_count) {
            // Log.d(TAG, "getWearStepSensorData count = " + logs.size());
            DataMap entries = dataMap(last_log);
            final ArrayList<DataMap> dataMaps = new ArrayList<>(logs.size());
            for (PebbleMovement log : logs) {
                dataMaps.add(dataMap(log));
                last_send_success = (long) log.timestamp;
            // Log.d(TAG, "getWearStepSensorData set last_send_sucess:" + JoH.dateTimeText(last_send_success) + " pw.metric: " + log.metric + " pw.timestamp: " + JoH.dateTimeText(log.timestamp));
            }
            // MOST IMPORTANT LINE FOR TIMESTAMP
            entries.putLong("time", new Date().getTime());
            entries.putDataMapArrayList("entries", dataMaps);
            // Log.d(TAG, "getWearStepSensorData  entries:" + entries);
            Log.i(TAG, "getWearStepSensorData SYNCED steps up to " + JoH.dateTimeText(last_send_success) + " count = " + logs.size());
            return entries;
        } else
            Log.i(TAG, "getWearStepSensorData SYNCED steps up to " + JoH.dateTimeText(last_send_success) + " count = 0");
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) PebbleMovement(com.eveningoutpost.dexdrip.Models.PebbleMovement) Date(java.util.Date) DataMap(com.google.android.gms.wearable.DataMap)

Example 5 with PebbleMovement

use of com.eveningoutpost.dexdrip.Models.PebbleMovement in project xDrip by NightscoutFoundation.

the class ListenerService method restartMeasurement.

private void restartMeasurement() {
    PebbleMovement last = PebbleMovement.last();
    boolean sameDay = last != null ? ListenerService.isSameDay(System.currentTimeMillis(), last.timestamp) : false;
    if (!sameDay) {
        initCounters();
        Log.d(TAG, "restartMeasurement Sensor isSameDay=false initCounters mSteps = " + mSteps + " mCounterSteps = " + mCounterSteps + " mPreviousCounterSteps = " + mPreviousCounterSteps + " last_movement_timestamp = " + JoH.dateTimeText(last_movement_timestamp));
        stopMeasurement();
        startMeasurement();
    } else {
        Log.d(TAG, "restartMeasurement Sensor isSameDay=true PersistentStore mSteps = " + mSteps + " mCounterSteps = " + mCounterSteps + " mPreviousCounterSteps = " + mPreviousCounterSteps + " last_movement_timestamp = " + JoH.dateTimeText(last_movement_timestamp));
    }
}
Also used : PebbleMovement(com.eveningoutpost.dexdrip.Models.PebbleMovement)

Aggregations

PebbleMovement (com.eveningoutpost.dexdrip.Models.PebbleMovement)10 DataMap (com.google.android.gms.wearable.DataMap)4 HeartRate (com.eveningoutpost.dexdrip.Models.HeartRate)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2