Preference switches for Autosens
This commit is contained in:
parent
1822f2a6c0
commit
50b7e619fc
|
@ -36,14 +36,13 @@ public class Constants {
|
||||||
public static final int BOLUSSNOOZE_DIA_ADVISOR = 2;
|
public static final int BOLUSSNOOZE_DIA_ADVISOR = 2;
|
||||||
public static final double AUTOSENS_MAX = 1.2d;
|
public static final double AUTOSENS_MAX = 1.2d;
|
||||||
public static final double AUTOSENS_MIN = 0.7d;
|
public static final double AUTOSENS_MIN = 0.7d;
|
||||||
public static final boolean AUTOSENS_ADJUST_TARGETS = false;
|
|
||||||
public static final double MIN_5M_CARBIMPACT = 3d;
|
public static final double MIN_5M_CARBIMPACT = 3d;
|
||||||
|
|
||||||
// Circadian Percentage Profile
|
// Circadian Percentage Profile
|
||||||
public static final int CPP_MIN_PERCENTAGE = 50;
|
public static final int CPP_MIN_PERCENTAGE = 50;
|
||||||
public static final int CPP_MAX_PERCENTAGE = 200;
|
public static final int CPP_MAX_PERCENTAGE = 200;
|
||||||
|
|
||||||
|
// Defaults for settings
|
||||||
public static final String MAX_BG_DEFAULT_MGDL = "180";
|
public static final String MAX_BG_DEFAULT_MGDL = "180";
|
||||||
public static final String MAX_BG_DEFAULT_MMOL = "10";
|
public static final String MAX_BG_DEFAULT_MMOL = "10";
|
||||||
public static final String MIN_BG_DEFAULT_MGDL = "100";
|
public static final String MIN_BG_DEFAULT_MGDL = "100";
|
||||||
|
|
|
@ -7,11 +7,13 @@ import org.json.JSONObject;
|
||||||
* Created by mike on 06.01.2017.
|
* Created by mike on 06.01.2017.
|
||||||
*/
|
*/
|
||||||
public class AutosensResult {
|
public class AutosensResult {
|
||||||
public double ratio;
|
|
||||||
public double carbsAbsorbed;
|
//default values to show when autosens algorithm is not called
|
||||||
public String sensResult;
|
public double ratio = 1d;
|
||||||
public String pastSensitivity;
|
public double carbsAbsorbed = 0d;
|
||||||
public String ratioLimit;
|
public String sensResult = "autosens deactivated";
|
||||||
|
public String pastSensitivity = "";
|
||||||
|
public String ratioLimit = "";
|
||||||
|
|
||||||
public JSONObject json() {
|
public JSONObject json() {
|
||||||
JSONObject ret = new JSONObject();
|
JSONObject ret = new JSONObject();
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.OpenAPSAMA;
|
package info.nightscout.androidaps.plugins.OpenAPSAMA;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
import com.eclipsesource.v8.JavaVoidCallback;
|
import com.eclipsesource.v8.JavaVoidCallback;
|
||||||
import com.eclipsesource.v8.V8;
|
import com.eclipsesource.v8.V8;
|
||||||
import com.eclipsesource.v8.V8Array;
|
import com.eclipsesource.v8.V8Array;
|
||||||
|
@ -214,6 +217,8 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
double min_5m_carbimpact) {
|
double min_5m_carbimpact) {
|
||||||
|
|
||||||
String units = profile.getUnits();
|
String units = profile.getUnits();
|
||||||
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
|
boolean autosensAdustTargets = preferences.getBoolean("openapsama_autosens_adjusttargets", false);
|
||||||
|
|
||||||
mProfile = new V8Object(mV8rt);
|
mProfile = new V8Object(mV8rt);
|
||||||
mProfile.add("max_iob", maxIob);
|
mProfile.add("max_iob", maxIob);
|
||||||
|
@ -232,7 +237,7 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
mProfile.add("skip_neutral_temps", true);
|
mProfile.add("skip_neutral_temps", true);
|
||||||
mProfile.add("current_basal", pump.getBaseBasalRate());
|
mProfile.add("current_basal", pump.getBaseBasalRate());
|
||||||
mProfile.add("temptargetSet", tempTargetSet);
|
mProfile.add("temptargetSet", tempTargetSet);
|
||||||
mProfile.add("autosens_adjust_targets", Constants.AUTOSENS_ADJUST_TARGETS);
|
mProfile.add("autosens_adjust_targets", autosensAdustTargets);
|
||||||
mProfile.add("min_5m_carbimpact", min_5m_carbimpact);
|
mProfile.add("min_5m_carbimpact", min_5m_carbimpact);
|
||||||
mV8rt.add(PARAM_profile, mProfile);
|
mV8rt.add(PARAM_profile, mProfile);
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,12 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
long oldestDataAvailable = MainApp.getConfigBuilder().getActiveTempBasals().oldestDataAvaialable();
|
long oldestDataAvailable = MainApp.getConfigBuilder().getActiveTempBasals().oldestDataAvaialable();
|
||||||
List<BgReading> bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(Math.max(oldestDataAvailable, (long) (new Date().getTime() - 60 * 60 * 1000L * (24 + profile.getDia()))), false);
|
List<BgReading> bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(Math.max(oldestDataAvailable, (long) (new Date().getTime() - 60 * 60 * 1000L * (24 + profile.getDia()))), false);
|
||||||
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString() + " (" + bgReadings.size() + " records)");
|
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString() + " (" + bgReadings.size() + " records)");
|
||||||
lastAutosensResult = Autosens.detectSensitivityandCarbAbsorption(bgReadings, new Date().getTime());
|
|
||||||
|
if(MainApp.getConfigBuilder().isAMAModeEnabled()){
|
||||||
|
lastAutosensResult = Autosens.detectSensitivityandCarbAbsorption(bgReadings, new Date().getTime());
|
||||||
|
} else {
|
||||||
|
lastAutosensResult = new AutosensResult();
|
||||||
|
}
|
||||||
|
|
||||||
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobArray, glucoseStatus, mealData,
|
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobArray, glucoseStatus, mealData,
|
||||||
lastAutosensResult.ratio, //autosensDataRatio
|
lastAutosensResult.ratio, //autosensDataRatio
|
||||||
|
|
|
@ -428,4 +428,5 @@
|
||||||
<string name="danar_stats_tbb2">Total Base Basal ²</string>
|
<string name="danar_stats_tbb2">Total Base Basal ²</string>
|
||||||
<string name="initializing">Initializing ...</string>
|
<string name="initializing">Initializing ...</string>
|
||||||
<string name="careportal_temptarget">Temporary Target</string>
|
<string name="careportal_temptarget">Temporary Target</string>
|
||||||
|
<string name="openapsama_autosens_adjusttargets">Allow autosens to adjust targets</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -9,6 +9,13 @@
|
||||||
android:key="openapsama_useautosens"
|
android:key="openapsama_useautosens"
|
||||||
android:title="@string/openapsama_useautosens" />
|
android:title="@string/openapsama_useautosens" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="openapsama_autosens_adjusttargets"
|
||||||
|
android:dependency="openapsama_useautosens"
|
||||||
|
android:title="@string/openapsama_autosens_adjusttargets"/>
|
||||||
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
Reference in a new issue