allow UAM only if oref1 sensitivity plugin is selected

This commit is contained in:
Milos Kozak 2018-10-13 18:07:01 +02:00
parent 94233d28e1
commit c1bbaab8e1
6 changed files with 41 additions and 1 deletions

View file

@ -42,6 +42,10 @@ public class ConstraintChecker implements ConstraintsInterface {
return isSMBModeEnabled(new Constraint<>(true));
}
public Constraint<Boolean> isUAMEnabled() {
return isUAMEnabled(new Constraint<>(true));
}
public Constraint<Boolean> isAdvancedFilteringEnabled() {
return isAdvancedFilteringEnabled(new Constraint<>(true));
}
@ -130,6 +134,18 @@ public class ConstraintChecker implements ConstraintsInterface {
return value;
}
@Override
public Constraint<Boolean> isUAMEnabled(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.isUAMEnabled(value);
}
return value;
}
@Override
public Constraint<Boolean> isAdvancedFilteringEnabled(Constraint<Boolean> value) {
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);

View file

@ -27,6 +27,10 @@ public interface ConstraintsInterface {
return value;
}
default Constraint<Boolean> isUAMEnabled(Constraint<Boolean> value) {
return value;
}
default Constraint<Boolean> isAdvancedFilteringEnabled(Constraint<Boolean> value) {
return value;
}

View file

@ -18,6 +18,7 @@ import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityOref1Plugin;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.HardLimits;
import info.nightscout.utils.Round;
@ -94,6 +95,17 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
return value;
}
@Override
public Constraint<Boolean> isUAMEnabled(Constraint<Boolean> value) {
boolean enabled = SP.getBoolean(R.string.key_use_uam, false);
if (!enabled)
value.set(false, MainApp.gs(R.string.uamdisabledinpreferences), this);
boolean oref1Enabled = SensitivityOref1Plugin.getPlugin().isEnabled(PluginType.SENSITIVITY);
if (!oref1Enabled)
value.set(false, MainApp.gs(R.string.uamdisabledoref1notselected), this);
return value;
}
@Override
public Constraint<Boolean> isAdvancedFilteringEnabled(Constraint<Boolean> value) {
BgSourceInterface bgSource = ConfigBuilderPlugin.getPlugin().getActiveBgSource();

View file

@ -211,6 +211,7 @@ public class DetermineBasalAdapterSMBJS {
double autosensDataRatio,
boolean tempTargetSet,
boolean microBolusAllowed,
boolean uamAllowed,
boolean advancedFiltering
) throws JSONException {
@ -247,7 +248,7 @@ public class DetermineBasalAdapterSMBJS {
// mProfile.put("min_5m_carbimpact", SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact));
//}
mProfile.put("remainingCarbsCap", SMBDefaults.remainingCarbsCap);
mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false));
mProfile.put("enableUAM", uamAllowed);
mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable);
mProfile.put("enableSMB_with_COB", SP.getBoolean(R.string.key_enableSMB_with_COB, false));
mProfile.put("enableSMB_with_temptarget", SP.getBoolean(R.string.key_enableSMB_with_temptarget, false));

View file

@ -198,6 +198,10 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
MainApp.getConstraintChecker().isAdvancedFilteringEnabled(advancedFiltering);
inputConstraints.copyReasons(advancedFiltering);
Constraint<Boolean> uam = new Constraint<>(true);
MainApp.getConstraintChecker().isUAMEnabled(uam);
inputConstraints.copyReasons(uam);
if (L.isEnabled(L.APS))
Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart);
if (L.isEnabled(L.APS))
@ -209,6 +213,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
lastAutosensResult.ratio, //autosensDataRatio
isTempTarget,
smbAllowed.value(),
uam.value(),
advancedFiltering.value()
);
} catch (JSONException e) {

View file

@ -1007,6 +1007,8 @@
<string name="closedmodedisabledinpreferences">Closed loop mode disabled in preferences</string>
<string name="autosensdisabledinpreferences">Autosens disabled in preferences</string>
<string name="smbdisabledinpreferences">SMB disabled in preferences</string>
<string name="uamdisabledinpreferences">UAM disabled in preferences</string>
<string name="uamdisabledoref1notselected">UAM disabled because it rely on Oref1 sensitivity plugin</string>
<string name="limitingbasalratio">Limiting max basal rate to %1$.2f U/h because of %2$s</string>
<string name="pumplimit">pump limit</string>
<string name="key_openapsma_max_basal" translatable="false">openapsma_max_basal</string>