Java Code Examples for com.eveningoutpost.dexdrip.Models.Sensor#create()

The following examples show how to use com.eveningoutpost.dexdrip.Models.Sensor#create() . 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: LibreReceiver.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private static void saveSensorStartTime(Bundle sensor, String serial) {
    if (sensor != null && sensor.containsKey("sensorStartTime")) {
        long sensorStartTime = sensor.getLong("sensorStartTime");

        Sensor last = Sensor.currentSensor();
        if(last!=null) {
            if (!last.uuid.equals(serial)) {
                Sensor.stopSensor();
                last = null;
            }
        }

        if(last==null) {
            Sensor.create(sensorStartTime,serial);
        }
    }
}
 
Example 2
Source File: LibreReceiver.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static void saveSensorStartTime(Bundle sensor, String serial) {
    if (sensor != null && sensor.containsKey("sensorStartTime")) {
        long sensorStartTime = sensor.getLong("sensorStartTime");

        Sensor last = Sensor.currentSensor();
        if(last!=null) {
            if (!last.uuid.equals(serial)) {
                Sensor.stopSensor();
                last = null;
            }
        }

        if(last==null) {
            Sensor.create(sensorStartTime,serial);
        }
    }
}
 
Example 3
Source File: XDripViewer.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
private static void verifyViewerNightscoutModeSensor(String device) {
    if(sensor_exists != null) {
        // We already have a cached sensor, no need to continue.
        return;
    }
    sensor_exists = Sensor.last();
    if(sensor_exists != null) {
        // We already have a sensor, no need to continue.
        return;
    }
    
    if(device == null) {
        return;
    }
    if(!device.equals("dexcom")) {
        return;
    }
    // No sensor exists, uploader is dexcom, let's create one.
    Log.e(TAG, "verifyViewerNightscoutModeSensor creating nightscout sensor");
    Sensor.create(new Date().getTime(), NIGHTSCOUT_SENSOR_UUID);
    isNightScoutMode = new Boolean(true);
}
 
Example 4
Source File: StartNewSensor.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static void startSensorForTime(long startTime) {
    Sensor.create(startTime);
    UserError.Log.ueh("NEW SENSOR", "Sensor started at " + JoH.dateTimeText(startTime));

    JoH.static_toast_long(gs(R.string.new_sensor_started));

    startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_SYNC_SENSOR, TAG);

    LibreAlarmReceiver.clearSensorStats();
    // TODO this is just a timer and could be confusing - consider removing this notification
   // JoH.scheduleNotification(xdrip.getAppContext(), "Sensor should be ready", xdrip.getAppContext().getString(R.string.please_enter_two_calibrations_to_get_started), 60 * 130, Home.SENSOR_READY_ID);

    // reverse libre hacky workaround
    Treatments.SensorStart((DexCollectionType.hasLibre() ? startTime + (3600000) : startTime));

    CollectionServiceStarter.restartCollectionServiceBackground();

    Ob1G5StateMachine.startSensor(startTime);
    JoH.clearCache();
    Home.staticRefreshBGCharts();

}
 
Example 5
Source File: StartNewSensor.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static void startSensorForTime(long startTime) {
    Sensor.create(startTime);
    UserError.Log.ueh("NEW SENSOR", "Sensor started at " + JoH.dateTimeText(startTime));

    JoH.static_toast_long(gs(R.string.new_sensor_started));

    startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_SYNC_SENSOR, TAG);

    LibreAlarmReceiver.clearSensorStats();
    // TODO this is just a timer and could be confusing - consider removing this notification
   // JoH.scheduleNotification(xdrip.getAppContext(), "Sensor should be ready", xdrip.getAppContext().getString(R.string.please_enter_two_calibrations_to_get_started), 60 * 130, Home.SENSOR_READY_ID);

    // reverse libre hacky workaround
    Treatments.SensorStart((DexCollectionType.hasLibre() ? startTime + (3600000) : startTime));

    CollectionServiceStarter.restartCollectionServiceBackground();

    Ob1G5StateMachine.startSensor(startTime);
    JoH.clearCache();
    Home.staticRefreshBGCharts();

}
 
Example 6
Source File: LibreReceiver.java    From xDrip with GNU General Public License v3.0 3 votes vote down vote up
private static void processValues(Libre2RawValue currentValue, List<Libre2RawValue> smoothingValues, Context context) {
    if (Sensor.currentSensor() == null) {
        Sensor.create(currentValue.timestamp, currentValue.serial);

    }

    double value = calculateWeightedAverage(smoothingValues, currentValue.timestamp);

    BgReading.bgReadingInsertLibre2(value, currentValue.timestamp,currentValue.glucose);
}
 
Example 7
Source File: LibreReceiver.java    From xDrip-plus with GNU General Public License v3.0 3 votes vote down vote up
private static void processValues(Libre2RawValue currentValue, List<Libre2RawValue> smoothingValues, Context context) {
    if (Sensor.currentSensor() == null) {
        Sensor.create(currentValue.timestamp, currentValue.serial);

    }

    double value = calculateWeightedAverage(smoothingValues, currentValue.timestamp);

    BgReading.bgReadingInsertLibre2(value, currentValue.timestamp,currentValue.glucose);
}