com.eveningoutpost.dexdrip.UtilityModels.SensorSendQueue Java Examples

The following examples show how to use com.eveningoutpost.dexdrip.UtilityModels.SensorSendQueue. 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: Sensor.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static Sensor create(long started_at, String uuid) {//KS
    try {
        Sensor sensor = new Sensor();
        sensor.started_at = started_at;
        sensor.uuid = uuid;

        sensor.save();
        SensorSendQueue.addToQueue(sensor);
        Log.d("SENSOR MODEL:", sensor.toString());
        return sensor;
    }
    catch (Exception e)
    {
        Log.d("SENSOR create new error ", uuid);
        return null;
    }
}
 
Example #2
Source File: Sensor.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static void updateBatteryLevel(Sensor sensor, int sensorBatteryLevel, boolean from_sync) {
    if(sensorBatteryLevel < 120) {
        // This must be a wrong battery level. Some transmitter send those every couple of readings
        // even if the battery is ok.
        return;
    }
    int startBatteryLevel = sensor.latest_battery_level;
    if(sensor.latest_battery_level == 0) {
        sensor.latest_battery_level = sensorBatteryLevel;
    } else {
        sensor.latest_battery_level = Math.min(sensor.latest_battery_level, sensorBatteryLevel);
    }
    if(startBatteryLevel == sensor.latest_battery_level) {
        // no need to update anything if nothing has changed.
        return;
    }
    sensor.save();
    SensorSendQueue.addToQueue(sensor);
    //KS if ((!from_sync) && (Home.get_master())) { GcmActivity.sendSensorBattery(sensor.latest_battery_level); }
}
 
Example #3
Source File: Sensor.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
public static void updateBatteryLevel(Sensor sensor, int sensorBatteryLevel) {
    if(sensorBatteryLevel < 120) {
        // This must be a wrong battery level. Some transmitter send those every couple of readings
        // even if the battery is ok.
        return;
    }
    int startBatteryLevel = sensor.latest_battery_level;
    if(sensor.latest_battery_level == 0) {
        sensor.latest_battery_level = sensorBatteryLevel;
    } else {
        sensor.latest_battery_level = Math.min(sensor.latest_battery_level, sensorBatteryLevel);
    }
    if(startBatteryLevel == sensor.latest_battery_level) {
        // no need to update anything if nothing has changed.
        return;
    }
    sensor.save();
    SensorSendQueue.addToQueue(sensor);
}
 
Example #4
Source File: Sensor.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static void updateBatteryLevel(Sensor sensor, int sensorBatteryLevel, boolean from_sync) {
    if (sensorBatteryLevel < 120) {
        // This must be a wrong battery level. Some transmitter send those every couple of readings
        // even if the battery is ok.
        return;
    }
    int startBatteryLevel = sensor.latest_battery_level;
    //  if(sensor.latest_battery_level == 0) {
    // allow sensor battery level to go up and down
    sensor.latest_battery_level = sensorBatteryLevel;
    //  } else {
    //     sensor.latest_battery_level = Math.min(sensor.latest_battery_level, sensorBatteryLevel);
    // }
    if (startBatteryLevel == sensor.latest_battery_level) {
        // no need to update anything if nothing has changed.
        return;
    }
    sensor.save();
    SensorSendQueue.addToQueue(sensor);
    if ((!from_sync) && (Home.get_master())) {
        GcmActivity.sendSensorBattery(sensor.latest_battery_level);
    }
}
 
Example #5
Source File: Sensor.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static void updateBatteryLevel(Sensor sensor, int sensorBatteryLevel, boolean from_sync) {
    if (sensorBatteryLevel < 120) {
        // This must be a wrong battery level. Some transmitter send those every couple of readings
        // even if the battery is ok.
        return;
    }
    int startBatteryLevel = sensor.latest_battery_level;
    //  if(sensor.latest_battery_level == 0) {
    // allow sensor battery level to go up and down
    sensor.latest_battery_level = sensorBatteryLevel;
    //  } else {
    //     sensor.latest_battery_level = Math.min(sensor.latest_battery_level, sensorBatteryLevel);
    // }
    if (startBatteryLevel == sensor.latest_battery_level) {
        // no need to update anything if nothing has changed.
        return;
    }
    sensor.save();
    SensorSendQueue.addToQueue(sensor);
    if ((!from_sync) && (Home.get_master())) {
        GcmActivity.sendSensorBattery(sensor.latest_battery_level);
    }
}
 
Example #6
Source File: Sensor.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static Sensor create(long started_at, String uuid) {//KS
    try {
        Sensor sensor = new Sensor();
        sensor.started_at = started_at;
        sensor.uuid = uuid;

        sensor.save();
        SensorSendQueue.addToQueue(sensor);
        Log.d("SENSOR MODEL:", sensor.toString());
        return sensor;
    }
    catch (Exception e)
    {
        Log.d("SENSOR create new error ", uuid);
        return null;
    }
}
 
Example #7
Source File: Sensor.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static void updateBatteryLevel(Sensor sensor, int sensorBatteryLevel, boolean from_sync) {
    if(sensorBatteryLevel < 120) {
        // This must be a wrong battery level. Some transmitter send those every couple of readings
        // even if the battery is ok.
        return;
    }
    int startBatteryLevel = sensor.latest_battery_level;
    if(sensor.latest_battery_level == 0) {
        sensor.latest_battery_level = sensorBatteryLevel;
    } else {
        sensor.latest_battery_level = Math.min(sensor.latest_battery_level, sensorBatteryLevel);
    }
    if(startBatteryLevel == sensor.latest_battery_level) {
        // no need to update anything if nothing has changed.
        return;
    }
    sensor.save();
    SensorSendQueue.addToQueue(sensor);
    //KS if ((!from_sync) && (Home.get_master())) { GcmActivity.sendSensorBattery(sensor.latest_battery_level); }
}
 
Example #8
Source File: Sensor.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static Sensor create(double started_at) {
    Sensor sensor = new Sensor();
    sensor.started_at = started_at;
    sensor.uuid = UUID.randomUUID().toString();
    sensor.save();
    SensorSendQueue.addToQueue(sensor);
    Log.w("SENSOR MODEL:", sensor.toString());
    return sensor;
}
 
Example #9
Source File: Sensor.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static Sensor create(long started_at) {
    Sensor sensor = new Sensor();
    sensor.started_at = started_at;
    sensor.uuid = UUID.randomUUID().toString();

    sensor.save();
    SensorSendQueue.addToQueue(sensor);
    Log.d("SENSOR MODEL:", sensor.toString());
    return sensor;
}
 
Example #10
Source File: Sensor.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public static void stopSensor() {
    Sensor sensor = currentSensor();
    if(sensor == null) {
        return;
    }
    sensor.stopped_at = new Date().getTime();
    Log.i("SENSOR", "Sensor stopped at " + sensor.stopped_at);
    sensor.save();
    SensorSendQueue.addToQueue(sensor);
    
}
 
Example #11
Source File: Sensor.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public static Sensor create(long started_at, String uuid) {
    Sensor sensor = new Sensor();
    sensor.started_at = started_at;
    sensor.uuid = uuid;

    sensor.save();
    SensorSendQueue.addToQueue(sensor);
    Log.d("SENSOR MODEL:", sensor.toString());
    return sensor;
}
 
Example #12
Source File: Sensor.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public synchronized static void stopSensor() {
    final Sensor sensor = currentSensor();
    if (sensor == null) {
        return;
    }
    sensor.stopped_at = JoH.tsl();
    UserError.Log.ueh("SENSOR", "Sensor stopped at " + JoH.dateTimeText(sensor.stopped_at));
    sensor.save();
    if (currentSensor() != null) {
        UserError.Log.wtf(TAG, "Failed to update sensor stop in database");
    }
    SensorSendQueue.addToQueue(sensor);
    JoH.clearCache();

}
 
Example #13
Source File: Sensor.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static Sensor create(long started_at, String uuid) {//KS
    Sensor sensor = new Sensor();
    sensor.started_at = started_at;
    sensor.uuid = uuid;

    sensor.save();
    SensorSendQueue.addToQueue(sensor);
    Log.d("SENSOR MODEL:", sensor.toString());
    return sensor;
}
 
Example #14
Source File: Sensor.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static Sensor create(long started_at) {
    Sensor sensor = new Sensor();
    sensor.started_at = started_at;
    sensor.uuid = UUID.randomUUID().toString();

    sensor.save();
    SensorSendQueue.addToQueue(sensor);
    Log.d("SENSOR MODEL:", sensor.toString());
    return sensor;
}
 
Example #15
Source File: Sensor.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static void stopSensor() {
    Sensor sensor = currentSensor();
    if(sensor == null) {
        return;
    }
    sensor.stopped_at = new Date().getTime();
    Log.i("SENSOR", "Sensor stopped at " + sensor.stopped_at);
    sensor.save();
    SensorSendQueue.addToQueue(sensor);

}
 
Example #16
Source File: Sensor.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static Sensor create(long started_at) {
    Sensor sensor = new Sensor();
    sensor.started_at = started_at;
    sensor.uuid = UUID.randomUUID().toString();

    sensor.save();
    SensorSendQueue.addToQueue(sensor);
    Log.d("SENSOR MODEL:", sensor.toString());
    return sensor;
}
 
Example #17
Source File: Sensor.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public synchronized static void stopSensor() {
    final Sensor sensor = currentSensor();
    if (sensor == null) {
        return;
    }
    sensor.stopped_at = JoH.tsl();
    UserError.Log.ueh("SENSOR", "Sensor stopped at " + JoH.dateTimeText(sensor.stopped_at));
    sensor.save();
    if (currentSensor() != null) {
        UserError.Log.wtf(TAG, "Failed to update sensor stop in database");
    }
    SensorSendQueue.addToQueue(sensor);
    JoH.clearCache();

}
 
Example #18
Source File: Sensor.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static Sensor create(long started_at, String uuid) {//KS
    Sensor sensor = new Sensor();
    sensor.started_at = started_at;
    sensor.uuid = uuid;

    sensor.save();
    SensorSendQueue.addToQueue(sensor);
    Log.d("SENSOR MODEL:", sensor.toString());
    return sensor;
}
 
Example #19
Source File: Sensor.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static Sensor create(long started_at) {
    Sensor sensor = new Sensor();
    sensor.started_at = started_at;
    sensor.uuid = UUID.randomUUID().toString();

    sensor.save();
    SensorSendQueue.addToQueue(sensor);
    Log.d("SENSOR MODEL:", sensor.toString());
    return sensor;
}
 
Example #20
Source File: Sensor.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static void stopSensor() {
    Sensor sensor = currentSensor();
    if(sensor == null) {
        return;
    }
    sensor.stopped_at = new Date().getTime();
    Log.i("SENSOR", "Sensor stopped at " + sensor.stopped_at);
    sensor.save();
    SensorSendQueue.addToQueue(sensor);

}