AMA - Autosens cleanup
This commit is contained in:
parent
ae57241833
commit
ba09538f46
|
@ -14,7 +14,6 @@ import android.text.TextUtils;
|
|||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
|
||||
import info.nightscout.androidaps.plugins.Careportal.CareportalPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
||||
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefFreePeakPlugin;
|
||||
|
@ -22,6 +21,7 @@ import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
|||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||
|
@ -65,7 +65,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
|||
if (key.equals("short_tabtitles")) {
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
}
|
||||
if (key.equals("openapsama_useautosens") && SP.getBoolean("openapsama_useautosens", false)) {
|
||||
if (key.equals(MainApp.gs(R.string.key_openapsama_useautosens)) && SP.getBoolean(R.string.key_openapsama_useautosens, false)) {
|
||||
OKDialog.show(this, MainApp.sResources.getString(R.string.configbuilder_sensitivity), MainApp.sResources.getString(R.string.sensitivity_warning), null);
|
||||
}
|
||||
updatePrefSummary(myPreferenceFragment.getPreference(key));
|
||||
|
|
|
@ -342,25 +342,4 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
|||
return maxIob;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Constraint<Double> applyBasalConstraints(Constraint<Double> absoluteRate, Profile profile) {
|
||||
return absoluteRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Constraint<Integer> applyBasalPercentConstraints(Constraint<Integer> percentRate, Profile profile) {
|
||||
return percentRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Constraint<Double> applyBolusConstraints(Constraint<Double> insulin) {
|
||||
return insulin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Constraint<Integer> applyCarbsConstraints(Constraint<Integer> carbs) {
|
||||
return carbs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -115,14 +115,9 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
|||
|
||||
@Override
|
||||
public Constraint<Boolean> isAutosensModeEnabled(Constraint<Boolean> value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Constraint<Boolean> isAMAModeEnabled(Constraint<Boolean> value) {
|
||||
boolean enabled = SP.getBoolean("openapsama_useautosens", false);
|
||||
boolean enabled = SP.getBoolean(R.string.key_openapsama_useautosens, false);
|
||||
if (!enabled)
|
||||
value.set(false, MainApp.gs(R.string.amadisabledinpreferences), this);
|
||||
value.set(false, MainApp.gs(R.string.autosensdisabledinpreferences), this);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ public class DetermineBasalAdapterAMAJS {
|
|||
mMealData.put("boluses", mealData.boluses);
|
||||
mMealData.put("mealCOB", mealData.mealCOB);
|
||||
|
||||
if (MainApp.getConstraintChecker().isAMAModeEnabled().value()) {
|
||||
if (MainApp.getConstraintChecker().isAutosensModeEnabled().value()) {
|
||||
mAutosensData = new JSONObject();
|
||||
mAutosensData.put("ratio", autosensDataRatio);
|
||||
} else {
|
||||
|
|
|
@ -222,7 +222,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
|||
return;
|
||||
|
||||
startPart = new Date();
|
||||
if (MainApp.getConstraintChecker().isAMAModeEnabled().value()) {
|
||||
if (MainApp.getConstraintChecker().isAutosensModeEnabled().value()) {
|
||||
lastAutosensResult = IobCobCalculatorPlugin.getPlugin().detectSensitivityWithLock(IobCobCalculatorPlugin.oldestDataAvailable(), System.currentTimeMillis());
|
||||
} else {
|
||||
lastAutosensResult = new AutosensResult();
|
||||
|
|
|
@ -300,7 +300,7 @@ public class DetermineBasalAdapterSMBJS {
|
|||
mMealData.put("lastCarbTime", mealData.lastCarbTime);
|
||||
|
||||
|
||||
if (MainApp.getConstraintChecker().isAMAModeEnabled().value()) {
|
||||
if (MainApp.getConstraintChecker().isAutosensModeEnabled().value()) {
|
||||
mAutosensData = new JSONObject();
|
||||
mAutosensData.put("ratio", autosensDataRatio);
|
||||
} else {
|
||||
|
|
|
@ -224,7 +224,7 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface {
|
|||
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, HardLimits.maxBasal())) return;
|
||||
|
||||
startPart = new Date();
|
||||
if (MainApp.getConstraintChecker().isAMAModeEnabled().value()) {
|
||||
if (MainApp.getConstraintChecker().isAutosensModeEnabled().value()) {
|
||||
lastAutosensResult = IobCobCalculatorPlugin.getPlugin().detectSensitivityWithLock(IobCobCalculatorPlugin.oldestDataAvailable(), System.currentTimeMillis());
|
||||
} else {
|
||||
lastAutosensResult = new AutosensResult();
|
||||
|
|
|
@ -965,7 +965,7 @@
|
|||
<string name="pumpisnottempbasalcapable">Pump is not temp basal capable</string>
|
||||
<string name="novalidbasalrate">No valid basal rate read from pump</string>
|
||||
<string name="closedmodedisabledinpreferences">Closed loop mode disabled in preferences</string>
|
||||
<string name="amadisabledinpreferences">AMA disabled in preferences</string>
|
||||
<string name="autosensdisabledinpreferences">Autosens disabled in preferences</string>
|
||||
<string name="smbdisabledinpreferences">SMB disabled in preferences</string>
|
||||
<string name="limitingbasalratio">Limiting basal rate to %.2f U/h because of %s</string>
|
||||
<string name="pumplimit">pump limit</string>
|
||||
|
@ -988,5 +988,6 @@
|
|||
<string name="hardlimit">hard limit</string>
|
||||
<string name="key_treatmentssafety_maxcarbs">treatmentssafety_maxcarbs</string>
|
||||
<string name="unsafeusage">unsafe usage</string>
|
||||
<string name="key_openapsama_useautosens" translatable="false">openapsama_useautosens</string>
|
||||
</resources>
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
android:title="@string/openapsma_maxiob_title" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="openapsama_useautosens"
|
||||
android:key="@string/key_openapsama_useautosens"
|
||||
android:title="@string/openapsama_useautosens" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
|
|
|
@ -141,13 +141,15 @@ public class ConstraintsCheckerTest {
|
|||
Assert.assertEquals(Boolean.FALSE, c.value());
|
||||
}
|
||||
|
||||
// isAMAModeEnabled tests
|
||||
// isAutosensModeEnabled tests
|
||||
@Test
|
||||
public void notEnabledAMAInPreferencesDisablesAMA() throws Exception {
|
||||
when(SP.getBoolean("openapsama_useautosens", false)).thenReturn(false);
|
||||
public void notEnabledAutosensInPreferencesDisablesAutosens() throws Exception {
|
||||
objectivesPlugin.objectives.get(5).setStarted(new Date(0));
|
||||
when(SP.getBoolean(R.string.key_openapsama_useautosens, false)).thenReturn(false);
|
||||
|
||||
Constraint<Boolean> c = constraintChecker.isAMAModeEnabled();
|
||||
Assert.assertEquals(true, c.getReasons().contains("AMA disabled in preferences"));
|
||||
Constraint<Boolean> c = constraintChecker.isAutosensModeEnabled();
|
||||
Assert.assertEquals(true, c.getReasons().contains("Autosens disabled in preferences"));
|
||||
Assert.assertEquals(true, c.getReasons().contains("Objective 6 not started"));
|
||||
Assert.assertEquals(Boolean.FALSE, c.value());
|
||||
}
|
||||
|
||||
|
@ -377,7 +379,7 @@ public class ConstraintsCheckerTest {
|
|||
when(MainApp.gs(R.string.closedmodedisabledinpreferences)).thenReturn("Closed loop mode disabled in preferences");
|
||||
when(MainApp.gs(R.string.objectivenotstarted)).thenReturn("Objective %d not started");
|
||||
when(MainApp.gs(R.string.novalidbasalrate)).thenReturn("No valid basal rate read from pump");
|
||||
when(MainApp.gs(R.string.amadisabledinpreferences)).thenReturn("AMA disabled in preferences");
|
||||
when(MainApp.gs(R.string.autosensdisabledinpreferences)).thenReturn("Autosens disabled in preferences");
|
||||
when(MainApp.gs(R.string.smbdisabledinpreferences)).thenReturn("SMB disabled in preferences");
|
||||
when(MainApp.gs(R.string.limitingbasalratio)).thenReturn("Limiting basal rate to %.2f U/h because of %s");
|
||||
when(MainApp.gs(R.string.pumplimit)).thenReturn("pump limit");
|
||||
|
|
Loading…
Reference in a new issue