Java Code Examples for com.eveningoutpost.dexdrip.Models.BgReading#latestForSensorAsc()

The following examples show how to use com.eveningoutpost.dexdrip.Models.BgReading#latestForSensorAsc() . 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: PersistentHigh.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static boolean dataQualityCheck(final long since, final double highMarkMgDl) {

        final Sensor sensor = Sensor.currentSensor();
        if (sensor == null) {
            Log.e(TAG, "Cannot raise persistent high alert as no active sensor!");
            return false;
        }
        if (since < sensor.started_at) {
            Log.e(TAG, "Cannot raise persistent high alert as high time pre-dates sensor start");
            return false;
        }
        final long duration = msSince(since);
        if (duration > Constants.DAY_IN_MS || duration < 0) {
            Log.e(TAG, "Cannot raise persistent high alert as duration doesn't make sense: " + JoH.niceTimeScalar(duration));
            return false;
        }

        final List<BgReading> readings = BgReading.latestForSensorAsc(2000, since, JoH.tsl(), Home.get_follower());
        if (readings == null) {
            Log.e(TAG, "Cannot raise persistent high alert as there are no readings for this sensor!");
            return false;
        }

        final int numberOfReadings = readings.size();

        if (numberOfReadings == 0) {
            Log.e(TAG, "Cannot raise persistent high alert as there are 0 readings for this sensor!");
            return false;
        }

        final long frequency = duration / numberOfReadings;
        //Log.d(TAG, "Frequency Calculated as: " + frequency);
        if (frequency > MINUTE_IN_MS * 15) {
            Log.e(TAG, "Cannot raise persistent high alert as readings frequency is: " + niceTimeScalar(frequency));
            return false;
        }

        for (final BgReading bgr : readings) {
            if (bgr.getDg_mgdl() < highMarkMgDl) {
                Log.e(TAG, "High not persistent as reading at: " + JoH.dateTimeText(bgr.timestamp) + " does not exceed " + JoH.qs(highMarkMgDl) + " mgdl / high mark");
                return false;
            }
        }

        return true;

    }
 
Example 2
Source File: PersistentHigh.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static boolean dataQualityCheck(final long since, final double highMarkMgDl) {

        final Sensor sensor = Sensor.currentSensor();
        if (sensor == null) {
            Log.e(TAG, "Cannot raise persistent high alert as no active sensor!");
            return false;
        }
        if (since < sensor.started_at) {
            Log.e(TAG, "Cannot raise persistent high alert as high time pre-dates sensor start");
            return false;
        }
        final long duration = msSince(since);
        if (duration > Constants.DAY_IN_MS || duration < 0) {
            Log.e(TAG, "Cannot raise persistent high alert as duration doesn't make sense: " + JoH.niceTimeScalar(duration));
            return false;
        }

        final List<BgReading> readings = BgReading.latestForSensorAsc(2000, since, JoH.tsl(), Home.get_follower());
        if (readings == null) {
            Log.e(TAG, "Cannot raise persistent high alert as there are no readings for this sensor!");
            return false;
        }

        final int numberOfReadings = readings.size();

        if (numberOfReadings == 0) {
            Log.e(TAG, "Cannot raise persistent high alert as there are 0 readings for this sensor!");
            return false;
        }

        final long frequency = duration / numberOfReadings;
        //Log.d(TAG, "Frequency Calculated as: " + frequency);
        if (frequency > MINUTE_IN_MS * 15) {
            Log.e(TAG, "Cannot raise persistent high alert as readings frequency is: " + niceTimeScalar(frequency));
            return false;
        }

        for (final BgReading bgr : readings) {
            if (bgr.getDg_mgdl() < highMarkMgDl) {
                Log.e(TAG, "High not persistent as reading at: " + JoH.dateTimeText(bgr.timestamp) + " does not exceed " + JoH.qs(highMarkMgDl) + " mgdl / high mark");
                return false;
            }
        }

        return true;

    }
 
Example 3
Source File: PersistentHigh.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static boolean dataQualityCheck(final long since, final double highMarkMgDl) {

        final Sensor sensor = Sensor.currentSensor();
        if (sensor == null) {
            Log.e(TAG, "Cannot raise persistent high alert as no active sensor!");
            return false;
        }
        if (since < sensor.started_at) {
            Log.e(TAG, "Cannot raise persistent high alert as high time pre-dates sensor start");
            return false;
        }
        final long duration = msSince(since);
        if (duration > Constants.DAY_IN_MS || duration < 0) {
            Log.e(TAG, "Cannot raise persistent high alert as duration doesn't make sense: " + JoH.niceTimeScalar(duration));
            return false;
        }

        final List<BgReading> readings = BgReading.latestForSensorAsc(2000, since, JoH.tsl(), Home.get_follower());
        if (readings == null) {
            Log.e(TAG, "Cannot raise persistent high alert as there are no readings for this sensor!");
            return false;
        }

        final int numberOfReadings = readings.size();

        if (numberOfReadings == 0) {
            Log.e(TAG, "Cannot raise persistent high alert as there are 0 readings for this sensor!");
            return false;
        }

        final long frequency = duration / numberOfReadings;
        //Log.d(TAG, "Frequency Calculated as: " + frequency);
        if (frequency > MINUTE_IN_MS * 15) {
            Log.e(TAG, "Cannot raise persistent high alert as readings frequency is: " + niceTimeScalar(frequency));
            return false;
        }

        for (final BgReading bgr : readings) {
            if (bgr.getDg_mgdl() < highMarkMgDl) {
                Log.e(TAG, "High not persistent as reading at: " + JoH.dateTimeText(bgr.timestamp) + " does not exceed " + JoH.qs(highMarkMgDl) + " mgdl / high mark");
                return false;
            }
        }

        return true;

    }
 
Example 4
Source File: PersistentHigh.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static boolean dataQualityCheck(final long since, final double highMarkMgDl) {

        final Sensor sensor = Sensor.currentSensor();
        if (sensor == null) {
            Log.e(TAG, "Cannot raise persistent high alert as no active sensor!");
            return false;
        }
        if (since < sensor.started_at) {
            Log.e(TAG, "Cannot raise persistent high alert as high time pre-dates sensor start");
            return false;
        }
        final long duration = msSince(since);
        if (duration > Constants.DAY_IN_MS || duration < 0) {
            Log.e(TAG, "Cannot raise persistent high alert as duration doesn't make sense: " + JoH.niceTimeScalar(duration));
            return false;
        }

        final List<BgReading> readings = BgReading.latestForSensorAsc(2000, since, JoH.tsl(), Home.get_follower());
        if (readings == null) {
            Log.e(TAG, "Cannot raise persistent high alert as there are no readings for this sensor!");
            return false;
        }

        final int numberOfReadings = readings.size();

        if (numberOfReadings == 0) {
            Log.e(TAG, "Cannot raise persistent high alert as there are 0 readings for this sensor!");
            return false;
        }

        final long frequency = duration / numberOfReadings;
        //Log.d(TAG, "Frequency Calculated as: " + frequency);
        if (frequency > MINUTE_IN_MS * 15) {
            Log.e(TAG, "Cannot raise persistent high alert as readings frequency is: " + niceTimeScalar(frequency));
            return false;
        }

        for (final BgReading bgr : readings) {
            if (bgr.getDg_mgdl() < highMarkMgDl) {
                Log.e(TAG, "High not persistent as reading at: " + JoH.dateTimeText(bgr.timestamp) + " does not exceed " + JoH.qs(highMarkMgDl) + " mgdl / high mark");
                return false;
            }
        }

        return true;

    }