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