Rename BgReading.filtered to BgReading.isFiltered and add to NS.
Avoids collision with 'filtered' value in NS data.
This commit is contained in:
parent
6d437b4afa
commit
73e8a0c876
11 changed files with 21 additions and 22 deletions
|
@ -39,7 +39,7 @@ public class BgReading implements DataPointWithLabelInterface {
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public double noise = -999; // xDrip sends -999 to indicate lack of a noise reading (due to missed readings or calibration)
|
public double noise = -999; // xDrip sends -999 to indicate lack of a noise reading (due to missed readings or calibration)
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public boolean filtered;
|
public boolean isFiltered;
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public String sourcePlugin;
|
public String sourcePlugin;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public class BgReading implements DataPointWithLabelInterface {
|
||||||
", value=" + value +
|
", value=" + value +
|
||||||
", direction=" + direction +
|
", direction=" + direction +
|
||||||
", raw=" + raw +
|
", raw=" + raw +
|
||||||
", filtered=" + filtered +
|
", filtered=" + isFiltered +
|
||||||
", sourcePlugin=" + sourcePlugin +
|
", sourcePlugin=" + sourcePlugin +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ public class BgReading implements DataPointWithLabelInterface {
|
||||||
_id = other._id;
|
_id = other._id;
|
||||||
noise = other.noise;
|
noise = other.noise;
|
||||||
sourcePlugin = other.sourcePlugin;
|
sourcePlugin = other.sourcePlugin;
|
||||||
filtered = other.filtered;
|
isFiltered = other.isFiltered;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------ DataPointWithLabelInterface ------------------
|
// ------------------ DataPointWithLabelInterface ------------------
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
|
|
||||||
// soft migration without changing DB version
|
// soft migration without changing DB version
|
||||||
createRowIfNotExists(getDaoBgReadings(), DatabaseHelper.DATABASE_BGREADINGS,
|
createRowIfNotExists(getDaoBgReadings(), DatabaseHelper.DATABASE_BGREADINGS,
|
||||||
"filtered", "integer");
|
"isFiltered", "integer");
|
||||||
createRowIfNotExists(getDaoBgReadings(), DatabaseHelper.DATABASE_BGREADINGS,
|
createRowIfNotExists(getDaoBgReadings(), DatabaseHelper.DATABASE_BGREADINGS,
|
||||||
"sourcePlugin", "text");
|
"sourcePlugin", "text");
|
||||||
createRowIfNotExists(getDaoBgReadings(), DatabaseHelper.DATABASE_BGREADINGS,
|
createRowIfNotExists(getDaoBgReadings(), DatabaseHelper.DATABASE_BGREADINGS,
|
||||||
|
|
|
@ -192,8 +192,8 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
||||||
MainApp.getConstraintChecker().isSMBModeEnabled(smbAllowed);
|
MainApp.getConstraintChecker().isSMBModeEnabled(smbAllowed);
|
||||||
inputConstraints.copyReasons(smbAllowed);
|
inputConstraints.copyReasons(smbAllowed);
|
||||||
|
|
||||||
Constraint<Boolean> bgFiltered = new Constraint<>(bgReading.filtered);
|
Constraint<Boolean> bgFiltered = new Constraint<>(bgReading.isFiltered);
|
||||||
if (!bgReading.filtered) {
|
if (!bgReading.isFiltered) {
|
||||||
bgFiltered.set(false, MainApp.gs(R.string.smbalwaysdisabled), this);
|
bgFiltered.set(false, MainApp.gs(R.string.smbalwaysdisabled), this);
|
||||||
}
|
}
|
||||||
inputConstraints.copyReasons(bgFiltered);
|
inputConstraints.copyReasons(bgFiltered);
|
||||||
|
@ -207,7 +207,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
||||||
lastAutosensResult.ratio, //autosensDataRatio
|
lastAutosensResult.ratio, //autosensDataRatio
|
||||||
isTempTarget,
|
isTempTarget,
|
||||||
smbAllowed.value(),
|
smbAllowed.value(),
|
||||||
bgReading.filtered
|
bgReading.isFiltered
|
||||||
);
|
);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
|
|
|
@ -2,8 +2,6 @@ package info.nightscout.androidaps.plugins.Source;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -11,7 +9,6 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
|
@ -70,7 +67,7 @@ public class SourceDexcomG5Plugin extends PluginBase implements BgSourceInterfac
|
||||||
bgReading.direction = json.getString("m_trend");
|
bgReading.direction = json.getString("m_trend");
|
||||||
bgReading.date = json.getLong("m_time") * 1000L;
|
bgReading.date = json.getLong("m_time") * 1000L;
|
||||||
bgReading.raw = 0;
|
bgReading.raw = 0;
|
||||||
bgReading.filtered = true;
|
bgReading.isFiltered = true;
|
||||||
bgReading.sourcePlugin = getName();
|
bgReading.sourcePlugin = getName();
|
||||||
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName());
|
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName());
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class SourceGlimpPlugin extends PluginBase implements BgSourceInterface {
|
||||||
bgReading.direction = bundle.getString("myTrend");
|
bgReading.direction = bundle.getString("myTrend");
|
||||||
bgReading.date = bundle.getLong("myTimestamp");
|
bgReading.date = bundle.getLong("myTimestamp");
|
||||||
bgReading.raw = 0;
|
bgReading.raw = 0;
|
||||||
bgReading.filtered = false;
|
bgReading.isFiltered = false;
|
||||||
bgReading.sourcePlugin = getName();
|
bgReading.sourcePlugin = getName();
|
||||||
|
|
||||||
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName());
|
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName());
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class SourceMM640gPlugin extends PluginBase implements BgSourceInterface
|
||||||
bgReading.direction = json_object.getString("direction");
|
bgReading.direction = json_object.getString("direction");
|
||||||
bgReading.date = json_object.getLong("date");
|
bgReading.date = json_object.getLong("date");
|
||||||
bgReading.raw = json_object.getDouble("sgv");
|
bgReading.raw = json_object.getDouble("sgv");
|
||||||
bgReading.filtered = true;
|
bgReading.isFiltered = true;
|
||||||
bgReading.sourcePlugin = getName();
|
bgReading.sourcePlugin = getName();
|
||||||
|
|
||||||
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName());
|
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName());
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac
|
||||||
JSONObject sgvJson = jsonArray.getJSONObject(i);
|
JSONObject sgvJson = jsonArray.getJSONObject(i);
|
||||||
BgReading bgReading = new BgReading(new NSSgv(sgvJson));
|
BgReading bgReading = new BgReading(new NSSgv(sgvJson));
|
||||||
String sourceDescription = JsonHelper.safeGetString(sgvJson, "device");
|
String sourceDescription = JsonHelper.safeGetString(sgvJson, "device");
|
||||||
bgReading.filtered = sourceDescription != null
|
bgReading.isFiltered = sourceDescription != null
|
||||||
&& (sourceDescription.contains("G5 Native") || sourceDescription.contains("AndroidAPS-DexcomG5"));
|
&& (sourceDescription.contains("G5 Native") || sourceDescription.contains("AndroidAPS-DexcomG5"));
|
||||||
bgReading.sourcePlugin = getName();
|
bgReading.sourcePlugin = getName();
|
||||||
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName());
|
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName());
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class SourcePoctechPlugin extends PluginBase implements BgSourceInterface
|
||||||
bgReading.direction = json.getString("direction");
|
bgReading.direction = json.getString("direction");
|
||||||
bgReading.date = json.getLong("date");
|
bgReading.date = json.getLong("date");
|
||||||
bgReading.raw = json.getDouble("raw");
|
bgReading.raw = json.getDouble("raw");
|
||||||
bgReading.filtered = false;
|
bgReading.isFiltered = false;
|
||||||
bgReading.sourcePlugin = getName();
|
bgReading.sourcePlugin = getName();
|
||||||
if (JsonHelper.safeGetString(json, "utils", Constants.MGDL).equals("mmol/L"))
|
if (JsonHelper.safeGetString(json, "utils", Constants.MGDL).equals("mmol/L"))
|
||||||
bgReading.value = bgReading.value * Constants.MMOLL_TO_MGDL;
|
bgReading.value = bgReading.value * Constants.MMOLL_TO_MGDL;
|
||||||
|
|
|
@ -52,12 +52,12 @@ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface {
|
||||||
bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW);
|
bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW);
|
||||||
bgReading.noise = bundle.getDouble(Intents.EXTRA_NOISE, -999);
|
bgReading.noise = bundle.getDouble(Intents.EXTRA_NOISE, -999);
|
||||||
String sourceDescription = bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION, "");
|
String sourceDescription = bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION, "");
|
||||||
bgReading.filtered = sourceDescription.equals("G5 Native");
|
bgReading.isFiltered = sourceDescription.equals("G5 Native");
|
||||||
if (MainApp.engineeringMode && !bgReading.filtered && bgReading.noise >= 0 && bgReading.noise <= 4) {
|
if (MainApp.engineeringMode && !bgReading.isFiltered && bgReading.noise >= 0 && bgReading.noise <= 4) {
|
||||||
// TODO syncing noice with NS is neither implemented nor tested
|
// TODO syncing noice with NS is neither implemented nor tested
|
||||||
// * NSUpload.uploadBg
|
// * NSUpload.uploadBg
|
||||||
log.debug("Setting filtered=true, since noise is provided and passed check: " + bgReading.noise);
|
log.debug("Setting filtered=true, since noise is provided and passed check: " + bgReading.noise);
|
||||||
bgReading.filtered = true;
|
bgReading.isFiltered = true;
|
||||||
}
|
}
|
||||||
bgReading.sourcePlugin = getName();
|
bgReading.sourcePlugin = getName();
|
||||||
|
|
||||||
|
|
|
@ -469,6 +469,8 @@ public class NSUpload {
|
||||||
data.put("sgv", reading.value);
|
data.put("sgv", reading.value);
|
||||||
data.put("direction", reading.direction);
|
data.put("direction", reading.direction);
|
||||||
data.put("type", "sgv");
|
data.put("type", "sgv");
|
||||||
|
data.put("isFiltered", reading.isFiltered);
|
||||||
|
data.put("sourcePlugin", reading.sourcePlugin);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class SourceXdripPluginTest {
|
||||||
public void bgWithUnknownSourceIsMarkedUnfiltered() {
|
public void bgWithUnknownSourceIsMarkedUnfiltered() {
|
||||||
Bundle bundle = createBroadcastBundle();
|
Bundle bundle = createBroadcastBundle();
|
||||||
BgReading bgReadings = plugin.processNewData(bundle).get(0);
|
BgReading bgReadings = plugin.processNewData(bundle).get(0);
|
||||||
assertFalse(bgReadings.filtered);
|
assertFalse(bgReadings.isFiltered);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -60,7 +60,7 @@ public class SourceXdripPluginTest {
|
||||||
bundle.putString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION, "G5 Native");
|
bundle.putString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION, "G5 Native");
|
||||||
|
|
||||||
BgReading bgReadings = plugin.processNewData(bundle).get(0);
|
BgReading bgReadings = plugin.processNewData(bundle).get(0);
|
||||||
assertTrue(bgReadings.filtered);
|
assertTrue(bgReadings.isFiltered);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -71,7 +71,7 @@ public class SourceXdripPluginTest {
|
||||||
bundle.putString(Intents.EXTRA_NOISE, "1.0");
|
bundle.putString(Intents.EXTRA_NOISE, "1.0");
|
||||||
|
|
||||||
BgReading bgReadings = plugin.processNewData(bundle).get(0);
|
BgReading bgReadings = plugin.processNewData(bundle).get(0);
|
||||||
assertTrue(bgReadings.filtered);
|
assertTrue(bgReadings.isFiltered);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -82,7 +82,7 @@ public class SourceXdripPluginTest {
|
||||||
bundle.putString(Intents.EXTRA_NOISE, "80.0");
|
bundle.putString(Intents.EXTRA_NOISE, "80.0");
|
||||||
|
|
||||||
BgReading bgReadings = plugin.processNewData(bundle).get(0);
|
BgReading bgReadings = plugin.processNewData(bundle).get(0);
|
||||||
assertTrue(bgReadings.filtered);
|
assertTrue(bgReadings.isFiltered);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
Loading…
Reference in a new issue