Replace BgSourceInterface.advancedFilteringSupported.

Replaced by 'filtered' property on BgReading.
This commit is contained in:
Johannes Mockenhaupt 2018-06-22 18:11:57 +02:00
parent 98c933af57
commit 6abad56b1f
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
21 changed files with 124 additions and 200 deletions

View file

@ -12,6 +12,8 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Objects;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
@ -60,56 +62,58 @@ public class DataService extends IntentService {
public DataService() { public DataService() {
super("DataService"); super("DataService");
registerBus(); MainApp.subscribe(this);
} }
@Override @Override
protected void onHandleIntent(final Intent intent) { protected void onHandleIntent(final Intent intent) {
if (intent == null)
return;
if (Config.logFunctionCalls) if (Config.logFunctionCalls)
log.debug("onHandleIntent " + BundleLogger.log(intent.getExtras())); log.debug("onHandleIntent " + BundleLogger.log(intent.getExtras()));
if (ConfigBuilderPlugin.getPlugin().getActiveBgSource() == null) { if (ConfigBuilderPlugin.getActiveBgSource() == null) {
xDripEnabled = true; xDripEnabled = true;
nsClientEnabled = false; nsClientEnabled = false;
mm640gEnabled = false; mm640gEnabled = false;
glimpEnabled = false; glimpEnabled = false;
dexcomG5Enabled = false; dexcomG5Enabled = false;
poctechEnabled = false; poctechEnabled = false;
} else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceXdripPlugin.class)) { } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceXdripPlugin.class)) {
xDripEnabled = true; xDripEnabled = true;
nsClientEnabled = false; nsClientEnabled = false;
mm640gEnabled = false; mm640gEnabled = false;
glimpEnabled = false; glimpEnabled = false;
dexcomG5Enabled = false; dexcomG5Enabled = false;
poctechEnabled = false; poctechEnabled = false;
} else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceNSClientPlugin.class)) { } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceNSClientPlugin.class)) {
xDripEnabled = false; xDripEnabled = false;
nsClientEnabled = true; nsClientEnabled = true;
mm640gEnabled = false; mm640gEnabled = false;
glimpEnabled = false; glimpEnabled = false;
dexcomG5Enabled = false; dexcomG5Enabled = false;
poctechEnabled = false; poctechEnabled = false;
} else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceMM640gPlugin.class)) { } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceMM640gPlugin.class)) {
xDripEnabled = false; xDripEnabled = false;
nsClientEnabled = false; nsClientEnabled = false;
mm640gEnabled = true; mm640gEnabled = true;
glimpEnabled = false; glimpEnabled = false;
dexcomG5Enabled = false; dexcomG5Enabled = false;
poctechEnabled = false; poctechEnabled = false;
} else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceGlimpPlugin.class)) { } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceGlimpPlugin.class)) {
xDripEnabled = false; xDripEnabled = false;
nsClientEnabled = false; nsClientEnabled = false;
mm640gEnabled = false; mm640gEnabled = false;
glimpEnabled = true; glimpEnabled = true;
dexcomG5Enabled = false; dexcomG5Enabled = false;
poctechEnabled = false; poctechEnabled = false;
} else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceDexcomG5Plugin.class)) { } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceDexcomG5Plugin.class)) {
xDripEnabled = false; xDripEnabled = false;
nsClientEnabled = false; nsClientEnabled = false;
mm640gEnabled = false; mm640gEnabled = false;
glimpEnabled = false; glimpEnabled = false;
dexcomG5Enabled = true; dexcomG5Enabled = true;
poctechEnabled = false; poctechEnabled = false;
} else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourcePoctechPlugin.class)) { } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourcePoctechPlugin.class)) {
xDripEnabled = false; xDripEnabled = false;
nsClientEnabled = false; nsClientEnabled = false;
mm640gEnabled = false; mm640gEnabled = false;
@ -126,55 +130,53 @@ public class DataService extends IntentService {
acceptNSData = acceptNSData || bundles.getBoolean("islocal"); acceptNSData = acceptNSData || bundles.getBoolean("islocal");
} }
final String action = intent.getAction();
if (intent != null) { if (Intents.ACTION_NEW_BG_ESTIMATE.equals(action)) {
final String action = intent.getAction(); if (xDripEnabled) {
if (Intents.ACTION_NEW_BG_ESTIMATE.equals(action)) { handleNewDataFromXDrip(intent);
if (xDripEnabled) {
handleNewDataFromXDrip(intent);
}
} else if (Intents.NS_EMULATOR.equals(action)) {
if (mm640gEnabled) {
handleNewDataFromMM640g(intent);
}
} else if (Intents.GLIMP_BG.equals(action)) {
if (glimpEnabled) {
handleNewDataFromGlimp(intent);
}
} else if (Intents.DEXCOMG5_BG.equals(action)) {
if (dexcomG5Enabled) {
handleNewDataFromDexcomG5(intent);
}
} else if (Intents.POCTECH_BG.equals(action)) {
if (poctechEnabled) {
handleNewDataFromPoctech(intent);
}
} else if (Intents.ACTION_NEW_SGV.equals(action)) {
if (nsClientEnabled || SP.getBoolean(R.string.key_ns_autobackfill, true))
handleNewDataFromNSClient(intent);
// Objectives 0
ObjectivesPlugin.bgIsAvailableInNS = true;
ObjectivesPlugin.saveProgress();
} else if (isNSProfile && Intents.ACTION_NEW_PROFILE.equals(action) || Intents.ACTION_NEW_DEVICESTATUS.equals(action)) {
// always handle Profile if NSProfile is enabled without looking at nsUploadOnly
handleNewDataFromNSClient(intent);
} else if (acceptNSData &&
(Intents.ACTION_NEW_TREATMENT.equals(action) ||
Intents.ACTION_CHANGED_TREATMENT.equals(action) ||
Intents.ACTION_REMOVED_TREATMENT.equals(action) ||
Intents.ACTION_NEW_STATUS.equals(action) ||
Intents.ACTION_NEW_DEVICESTATUS.equals(action) ||
Intents.ACTION_NEW_FOOD.equals(action) ||
Intents.ACTION_CHANGED_FOOD.equals(action) ||
Intents.ACTION_REMOVED_FOOD.equals(action) ||
Intents.ACTION_NEW_CAL.equals(action) ||
Intents.ACTION_NEW_MBG.equals(action))
) {
handleNewDataFromNSClient(intent);
} else if (Telephony.Sms.Intents.SMS_RECEIVED_ACTION.equals(action)) {
handleNewSMS(intent);
} }
} else if (Intents.NS_EMULATOR.equals(action)) {
if (mm640gEnabled) {
handleNewDataFromMM640g(intent);
}
} else if (Intents.GLIMP_BG.equals(action)) {
if (glimpEnabled) {
handleNewDataFromGlimp(intent);
}
} else if (Intents.DEXCOMG5_BG.equals(action)) {
if (dexcomG5Enabled) {
handleNewDataFromDexcomG5(intent);
}
} else if (Intents.POCTECH_BG.equals(action)) {
if (poctechEnabled) {
handleNewDataFromPoctech(intent);
}
} else if (Intents.ACTION_NEW_SGV.equals(action)) {
if (nsClientEnabled || SP.getBoolean(R.string.key_ns_autobackfill, true))
handleNewDataFromNSClient(intent);
// Objectives 0
ObjectivesPlugin.bgIsAvailableInNS = true;
ObjectivesPlugin.saveProgress();
} else if (isNSProfile && Intents.ACTION_NEW_PROFILE.equals(action) || Intents.ACTION_NEW_DEVICESTATUS.equals(action)) {
// always handle Profile if NSProfile is enabled without looking at nsUploadOnly
handleNewDataFromNSClient(intent);
} else if (acceptNSData &&
(Intents.ACTION_NEW_TREATMENT.equals(action) ||
Intents.ACTION_CHANGED_TREATMENT.equals(action) ||
Intents.ACTION_REMOVED_TREATMENT.equals(action) ||
Intents.ACTION_NEW_STATUS.equals(action) ||
Intents.ACTION_NEW_DEVICESTATUS.equals(action) ||
Intents.ACTION_NEW_FOOD.equals(action) ||
Intents.ACTION_CHANGED_FOOD.equals(action) ||
Intents.ACTION_REMOVED_FOOD.equals(action) ||
Intents.ACTION_NEW_CAL.equals(action) ||
Intents.ACTION_NEW_MBG.equals(action))
) {
handleNewDataFromNSClient(intent);
} else if (Telephony.Sms.Intents.SMS_RECEIVED_ACTION.equals(action)) {
handleNewSMS(intent);
} }
if (Config.logFunctionCalls) if (Config.logFunctionCalls)
log.debug("onHandleIntent exit " + intent); log.debug("onHandleIntent exit " + intent);
DataReceiver.completeWakefulIntent(intent); DataReceiver.completeWakefulIntent(intent);
@ -195,16 +197,7 @@ public class DataService extends IntentService {
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
MainApp.bus().unregister(this); MainApp.unsubscribe(this);
}
private void registerBus() {
try {
MainApp.bus().unregister(this);
} catch (RuntimeException x) {
// Ignore
}
MainApp.bus().register(this);
} }
private void handleNewDataFromXDrip(Intent intent) { private void handleNewDataFromXDrip(Intent intent) {
@ -217,8 +210,9 @@ public class DataService extends IntentService {
bgReading.direction = bundle.getString(Intents.EXTRA_BG_SLOPE_NAME); bgReading.direction = bundle.getString(Intents.EXTRA_BG_SLOPE_NAME);
bgReading.date = bundle.getLong(Intents.EXTRA_TIMESTAMP); bgReading.date = bundle.getLong(Intents.EXTRA_TIMESTAMP);
bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW); bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW);
String source = bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION, "no Source specified"); bgReading.sourcePlugin = SourceXdripPlugin.getPlugin().pluginDescription.getUserfriendlyName();
SourceXdripPlugin.getPlugin().setSource(source); bgReading.filtered = Objects.equals(bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION), "G5 Native");
MainApp.getDbHelper().createIfNotExists(bgReading, "XDRIP"); MainApp.getDbHelper().createIfNotExists(bgReading, "XDRIP");
} }
@ -232,6 +226,8 @@ public class DataService extends IntentService {
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.sourcePlugin = SourceGlimpPlugin.getPlugin().pluginDescription.getUserfriendlyName();
MainApp.getDbHelper().createIfNotExists(bgReading, "GLIMP"); MainApp.getDbHelper().createIfNotExists(bgReading, "GLIMP");
} }
@ -256,6 +252,8 @@ public class DataService extends IntentService {
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.sourcePlugin = SourceDexcomG5Plugin.getPlugin().pluginDescription.getUserfriendlyName();
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "DexcomG5"); boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "DexcomG5");
if (isNew && SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) { if (isNew && SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
NSUpload.uploadBg(bgReading); NSUpload.uploadBg(bgReading);
@ -264,9 +262,8 @@ public class DataService extends IntentService {
NSUpload.sendToXdrip(bgReading); NSUpload.sendToXdrip(bgReading);
} }
} }
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); log.error("Unhandled exception", e);
} }
} }
@ -329,6 +326,8 @@ public class DataService extends IntentService {
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.sourcePlugin = SourceMM640gPlugin.getPlugin().pluginDescription.getUserfriendlyName();
MainApp.getDbHelper().createIfNotExists(bgReading, "MM640g"); MainApp.getDbHelper().createIfNotExists(bgReading, "MM640g");
break; break;
@ -545,7 +544,7 @@ public class DataService extends IntentService {
MainApp.getDbHelper().deleteProfileSwitchById(_id); MainApp.getDbHelper().deleteProfileSwitchById(_id);
} }
private void handleTreatmentFromNS(JSONObject json, Intent intent) throws JSONException { private void handleTreatmentFromNS(JSONObject json, Intent intent) {
// new DB model // new DB model
int mode = Intents.ACTION_NEW_TREATMENT.equals(intent.getAction()) ? EventNsTreatment.ADD : EventNsTreatment.UPDATE; int mode = Intents.ACTION_NEW_TREATMENT.equals(intent.getAction()) ? EventNsTreatment.ADD : EventNsTreatment.UPDATE;
double insulin = JsonHelper.safeGetDouble(json, "insulin"); double insulin = JsonHelper.safeGetDouble(json, "insulin");

View file

@ -42,10 +42,6 @@ public class ConstraintChecker implements ConstraintsInterface {
return isSMBModeEnabled(new Constraint<>(true)); return isSMBModeEnabled(new Constraint<>(true));
} }
public Constraint<Boolean> isAdvancedFilteringEnabled() {
return isAdvancedFilteringEnabled(new Constraint<>(true));
}
public Constraint<Double> getMaxBasalAllowed(Profile profile) { public Constraint<Double> getMaxBasalAllowed(Profile profile) {
return applyBasalConstraints(new Constraint<>(Constants.REALLYHIGHBASALRATE), profile); return applyBasalConstraints(new Constraint<>(Constants.REALLYHIGHBASALRATE), profile);
} }
@ -69,7 +65,7 @@ public class ConstraintChecker implements ConstraintsInterface {
@Override @Override
public Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> value) { public Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> value) {
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) { for (PluginBase p : constraintsPlugins) {
ConstraintsInterface constraint = (ConstraintsInterface) p; ConstraintsInterface constraint = (ConstraintsInterface) p;
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
@ -81,7 +77,7 @@ public class ConstraintChecker implements ConstraintsInterface {
@Override @Override
public Constraint<Boolean> isClosedLoopAllowed(Constraint<Boolean> value) { public Constraint<Boolean> isClosedLoopAllowed(Constraint<Boolean> value) {
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) { for (PluginBase p : constraintsPlugins) {
ConstraintsInterface constraint = (ConstraintsInterface) p; ConstraintsInterface constraint = (ConstraintsInterface) p;
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
@ -126,17 +122,6 @@ public class ConstraintChecker implements ConstraintsInterface {
return value; return value;
} }
@Override
public Constraint<Boolean> isAdvancedFilteringEnabled(Constraint<Boolean> value) {
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) {
ConstraintsInterface constraint = (ConstraintsInterface) p;
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
constraint.isAdvancedFilteringEnabled(value);
}
return value;
}
@Override @Override
public Constraint<Double> applyBasalConstraints(Constraint<Double> absoluteRate, Profile profile) { public Constraint<Double> applyBasalConstraints(Constraint<Double> absoluteRate, Profile profile) {
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);

View file

@ -3,6 +3,4 @@ package info.nightscout.androidaps.interfaces;
/** /**
* Created by mike on 20.06.2016. * Created by mike on 20.06.2016.
*/ */
public interface BgSourceInterface { public interface BgSourceInterface {}
boolean advancedFilteringSupported();
}

View file

@ -27,10 +27,6 @@ public interface ConstraintsInterface {
return value; return value;
} }
default Constraint<Boolean> isAdvancedFilteringEnabled(Constraint<Boolean> value) {
return value;
}
default Constraint<Double> applyBasalConstraints(Constraint<Double> absoluteRate, Profile profile) { default Constraint<Double> applyBasalConstraints(Constraint<Double> absoluteRate, Profile profile) {
return absoluteRate; return absoluteRate;
} }

View file

@ -1,5 +1,7 @@
package info.nightscout.androidaps.interfaces; package info.nightscout.androidaps.interfaces;
import info.nightscout.androidaps.MainApp;
public class PluginDescription { public class PluginDescription {
PluginType mainType = PluginType.GENERAL; PluginType mainType = PluginType.GENERAL;
String fragmentClass = null; String fragmentClass = null;
@ -87,4 +89,8 @@ public class PluginDescription {
public PluginType getType() { public PluginType getType() {
return mainType; return mainType;
} }
public String getUserfriendlyName() {
return MainApp.gs(pluginName);
}
} }

View file

@ -65,12 +65,11 @@ public class ConfigBuilderPlugin extends PluginBase {
return configBuilderPlugin; return configBuilderPlugin;
} }
private BgSourceInterface activeBgSource; private static BgSourceInterface activeBgSource;
private static PumpInterface activePump; private static PumpInterface activePump;
private static ProfileInterface activeProfile; private static ProfileInterface activeProfile;
private static TreatmentsInterface activeTreatments; private static TreatmentsInterface activeTreatments;
private static APSInterface activeAPS; private static APSInterface activeAPS;
private static LoopPlugin activeLoop;
private static InsulinInterface activeInsulin; private static InsulinInterface activeInsulin;
private static SensitivityInterface activeSensitivity; private static SensitivityInterface activeSensitivity;
@ -249,7 +248,7 @@ public class ConfigBuilderPlugin extends PluginBase {
return commandQueue; return commandQueue;
} }
public BgSourceInterface getActiveBgSource() { public static BgSourceInterface getActiveBgSource() {
return activeBgSource; return activeBgSource;
} }
@ -329,9 +328,6 @@ public class ConfigBuilderPlugin extends PluginBase {
} }
this.setFragmentVisiblities(((PluginBase) activePump).getName(), pluginsInCategory, PluginType.PUMP); this.setFragmentVisiblities(((PluginBase) activePump).getName(), pluginsInCategory, PluginType.PUMP);
// PluginType.LOOP
activeLoop = this.determineActivePlugin(PluginType.LOOP);
// PluginType.TREATMENT // PluginType.TREATMENT
activeTreatments = this.determineActivePlugin(PluginType.TREATMENT); activeTreatments = this.determineActivePlugin(PluginType.TREATMENT);
} }

View file

@ -92,17 +92,6 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
return value; return value;
} }
@Override
public Constraint<Boolean> isAdvancedFilteringEnabled(Constraint<Boolean> value) {
BgSourceInterface bgSource = MainApp.getConfigBuilder().getActiveBgSource();
if (bgSource != null) {
if (!bgSource.advancedFilteringSupported())
value.set(false, MainApp.gs(R.string.smbalwaysdisabled), this);
}
return value;
}
@Override @Override
public Constraint<Double> applyBasalConstraints(Constraint<Double> absoluteRate, Profile profile) { public Constraint<Double> applyBasalConstraints(Constraint<Double> absoluteRate, Profile profile) {

View file

@ -14,6 +14,8 @@ import info.nightscout.androidaps.data.GlucoseStatus;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.MealData;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.interfaces.APSInterface; import info.nightscout.androidaps.interfaces.APSInterface;
@ -104,6 +106,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
} }
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(); GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
BgReading bgReading = DatabaseHelper.actualBg();
Profile profile = MainApp.getConfigBuilder().getProfile(); Profile profile = MainApp.getConfigBuilder().getProfile();
PumpInterface pump = ConfigBuilderPlugin.getActivePump(); PumpInterface pump = ConfigBuilderPlugin.getActivePump();
@ -121,7 +124,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
return; return;
} }
if (glucoseStatus == null) { if (glucoseStatus == null || bgReading == null) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata))); MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
if (Config.logAPSResult) if (Config.logAPSResult)
log.debug(MainApp.gs(R.string.openapsma_noglucosedata)); log.debug(MainApp.gs(R.string.openapsma_noglucosedata));
@ -189,10 +192,6 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
MainApp.getConstraintChecker().isSMBModeEnabled(smbAllowed); MainApp.getConstraintChecker().isSMBModeEnabled(smbAllowed);
inputConstraints.copyReasons(smbAllowed); inputConstraints.copyReasons(smbAllowed);
Constraint<Boolean> advancedFiltering = new Constraint<>(!tempBasalFallback);
MainApp.getConstraintChecker().isAdvancedFilteringEnabled(advancedFiltering);
inputConstraints.copyReasons(advancedFiltering);
Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart); Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart);
Profiler.log(log, "SMB data gathering", start); Profiler.log(log, "SMB data gathering", start);
@ -202,7 +201,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
lastAutosensResult.ratio, //autosensDataRatio lastAutosensResult.ratio, //autosensDataRatio
isTempTarget, isTempTarget,
smbAllowed.value(), smbAllowed.value(),
advancedFiltering.value() bgReading.filtered
); );
} catch (JSONException e) { } catch (JSONException e) {
log.error(e.getMessage()); log.error(e.getMessage());

View file

@ -33,8 +33,4 @@ public class SourceDexcomG5Plugin extends PluginBase implements BgSourceInterfac
); );
} }
@Override
public boolean advancedFilteringSupported() {
return true;
}
} }

View file

@ -28,8 +28,4 @@ public class SourceGlimpPlugin extends PluginBase implements BgSourceInterface {
); );
} }
@Override
public boolean advancedFilteringSupported() {
return false;
}
} }

View file

@ -27,8 +27,4 @@ public class SourceMM640gPlugin extends PluginBase implements BgSourceInterface
); );
} }
@Override
public boolean advancedFilteringSupported() {
return false;
}
} }

View file

@ -20,9 +20,6 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac
return plugin; return plugin;
} }
private long lastBGTimeStamp = 0;
private boolean isAdvancedFilteringEnabled = false;
private SourceNSClientPlugin() { private SourceNSClientPlugin() {
super(new PluginDescription() super(new PluginDescription()
.mainType(PluginType.BGSOURCE) .mainType(PluginType.BGSOURCE)
@ -34,18 +31,4 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac
); );
} }
@Override
public boolean advancedFilteringSupported() {
return isAdvancedFilteringEnabled;
}
public void detectSource(String source, long timeStamp) {
if (timeStamp > lastBGTimeStamp) {
if (source.contains("G5 Native") || source.contains("AndroidAPS-DexcomG5"))
isAdvancedFilteringEnabled = true;
else
isAdvancedFilteringEnabled = false;
lastBGTimeStamp = timeStamp;
}
}
} }

View file

@ -31,9 +31,4 @@ public class SourcePoctechPlugin extends PluginBase implements BgSourceInterface
); );
} }
@Override
public boolean advancedFilteringSupported() {
return false;
}
} }

View file

@ -13,8 +13,6 @@ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface {
private static SourceXdripPlugin plugin = null; private static SourceXdripPlugin plugin = null;
boolean advancedFiltering;
public static SourceXdripPlugin getPlugin() { public static SourceXdripPlugin getPlugin() {
if (plugin == null) if (plugin == null)
plugin = new SourceXdripPlugin(); plugin = new SourceXdripPlugin();
@ -29,13 +27,4 @@ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface {
.description(R.string.description_source_xdrip) .description(R.string.description_source_xdrip)
); );
} }
@Override
public boolean advancedFilteringSupported() {
return advancedFiltering;
}
public void setSource(String source) {
this.advancedFiltering = source.contains("G5 Native");
}
} }

View file

@ -111,15 +111,15 @@ public class ConstraintsCheckerTest {
Assert.assertEquals(Boolean.FALSE, c.value()); Assert.assertEquals(Boolean.FALSE, c.value());
} }
@Test // @Test
public void isAdvancedFilteringEnabledTest() throws Exception { // public void isAdvancedFilteringEnabledTest() throws Exception {
when(MainApp.getConfigBuilder().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin()); // when(MainApp.getConfigBuilder().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin());
//
Constraint<Boolean> c = constraintChecker.isAdvancedFilteringEnabled(); // Constraint<Boolean> c = constraintChecker.isAdvancedFilteringEnabled();
Assert.assertEquals(true, c.getReasonList().size() == 1); // Safety // Assert.assertEquals(true, c.getReasonList().size() == 1); // Safety
Assert.assertEquals(true, c.getMostLimitedReasonList().size() == 1); // Safety // Assert.assertEquals(true, c.getMostLimitedReasonList().size() == 1); // Safety
Assert.assertEquals(Boolean.FALSE, c.value()); // Assert.assertEquals(Boolean.FALSE, c.value());
} // }
@Test @Test
public void isSMBModeEnabledTest() throws Exception { public void isSMBModeEnabledTest() throws Exception {

View file

@ -89,15 +89,16 @@ public class SafetyPluginTest {
Assert.assertEquals(Boolean.FALSE, c.value()); Assert.assertEquals(Boolean.FALSE, c.value());
} }
@Test // TODO
public void bgsourceShouldPreventSMBAlways() throws Exception { // @Test
when(MainApp.getConfigBuilder().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin()); // public void bgsourceShouldPreventSMBAlways() throws Exception {
// when(MainApp.getConfigBuilder().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin());
Constraint<Boolean> c = new Constraint<>(true); //
c = safetyPlugin.isAdvancedFilteringEnabled(c); // Constraint<Boolean> c = new Constraint<>(true);
Assert.assertEquals("Safety: SMB always and after carbs disabled because active BG source doesn\\'t support advanced filtering", c.getReasons()); // c = safetyPlugin.isAdvancedFilteringEnabled(c);
Assert.assertEquals(Boolean.FALSE, c.value()); // Assert.assertEquals("Safety: SMB always and after carbs disabled because active BG source doesn\\'t support advanced filtering", c.getReasons());
} // Assert.assertEquals(Boolean.FALSE, c.value());
// }
@Test @Test
public void basalRateShouldBeLimited() throws Exception { public void basalRateShouldBeLimited() throws Exception {

View file

@ -15,8 +15,8 @@ public class SourceDexcomG5PluginTest {
Assert.assertNotEquals(null, SourceDexcomG5Plugin.getPlugin()); Assert.assertNotEquals(null, SourceDexcomG5Plugin.getPlugin());
} }
@Test // @Test
public void advancedFilteringSupported() { // public void advancedFilteringSupported() {
Assert.assertEquals(true, SourceDexcomG5Plugin.getPlugin().advancedFilteringSupported()); // Assert.assertEquals(true, SourceDexcomG5Plugin.getPlugin().advancedFilteringSupported());
} // }
} }

View file

@ -15,8 +15,8 @@ public class SourceGlimpPluginTest {
Assert.assertNotEquals(null, SourceGlimpPlugin.getPlugin()); Assert.assertNotEquals(null, SourceGlimpPlugin.getPlugin());
} }
@Test // @Test
public void advancedFilteringSupported() { // public void advancedFilteringSupported() {
Assert.assertEquals(false, SourceGlimpPlugin.getPlugin().advancedFilteringSupported()); // Assert.assertEquals(false, SourceGlimpPlugin.getPlugin().advancedFilteringSupported());
} // }
} }

View file

@ -15,8 +15,8 @@ public class SourceMM640gPluginTest {
Assert.assertNotEquals(null, SourceMM640gPlugin.getPlugin()); Assert.assertNotEquals(null, SourceMM640gPlugin.getPlugin());
} }
@Test // @Test
public void advancedFilteringSupported() { // public void advancedFilteringSupported() {
Assert.assertEquals(false, SourceMM640gPlugin.getPlugin().advancedFilteringSupported()); // Assert.assertEquals(false, SourceMM640gPlugin.getPlugin().advancedFilteringSupported());
} // }
} }

View file

@ -13,8 +13,8 @@ public class SourceNSClientPluginTest {
Assert.assertNotEquals(null, SourceNSClientPlugin.getPlugin()); Assert.assertNotEquals(null, SourceNSClientPlugin.getPlugin());
} }
@Test // @Test
public void advancedFilteringSupported() { // public void advancedFilteringSupported() {
Assert.assertEquals(false, SourceNSClientPlugin.getPlugin().advancedFilteringSupported()); // Assert.assertEquals(false, SourceNSClientPlugin.getPlugin().advancedFilteringSupported());
} // }
} }

View file

@ -15,8 +15,8 @@ public class SourceXdripPluginTest {
Assert.assertNotEquals(null, SourceXdripPlugin.getPlugin()); Assert.assertNotEquals(null, SourceXdripPlugin.getPlugin());
} }
@Test // @Test
public void advancedFilteringSupported() { // public void advancedFilteringSupported() {
Assert.assertEquals(false, SourceXdripPlugin.getPlugin().advancedFilteringSupported()); // Assert.assertEquals(false, SourceXdripPlugin.getPlugin().advancedFilteringSupported());
} // }
} }