Merge remote-tracking branch 'origin/dagger3' into rs

This commit is contained in:
Milos Kozak 2020-04-08 17:29:15 +02:00
commit 1696092844
6 changed files with 137 additions and 284 deletions

View file

@ -82,7 +82,6 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
@Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin @Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin
@Inject lateinit var safetyPlugin: SafetyPlugin @Inject lateinit var safetyPlugin: SafetyPlugin
@Inject lateinit var sensitivityAAPSPlugin: SensitivityAAPSPlugin @Inject lateinit var sensitivityAAPSPlugin: SensitivityAAPSPlugin
@Inject lateinit var sensitivityOref0Plugin: SensitivityOref1Plugin
@Inject lateinit var sensitivityOref1Plugin: SensitivityOref1Plugin @Inject lateinit var sensitivityOref1Plugin: SensitivityOref1Plugin
@Inject lateinit var sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin @Inject lateinit var sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin
@Inject lateinit var dexcomPlugin: DexcomPlugin @Inject lateinit var dexcomPlugin: DexcomPlugin
@ -164,7 +163,6 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
addPreferencesFromResourceIfEnabled(openAPSSMBPlugin, rootKey, Config.APS) addPreferencesFromResourceIfEnabled(openAPSSMBPlugin, rootKey, Config.APS)
addPreferencesFromResourceIfEnabled(sensitivityAAPSPlugin, rootKey) addPreferencesFromResourceIfEnabled(sensitivityAAPSPlugin, rootKey)
addPreferencesFromResourceIfEnabled(sensitivityWeightedAveragePlugin, rootKey) addPreferencesFromResourceIfEnabled(sensitivityWeightedAveragePlugin, rootKey)
addPreferencesFromResourceIfEnabled(sensitivityOref0Plugin, rootKey)
addPreferencesFromResourceIfEnabled(sensitivityOref1Plugin, rootKey) addPreferencesFromResourceIfEnabled(sensitivityOref1Plugin, rootKey)
addPreferencesFromResourceIfEnabled(danaRPlugin, rootKey, Config.PUMPDRIVERS) addPreferencesFromResourceIfEnabled(danaRPlugin, rootKey, Config.PUMPDRIVERS)
addPreferencesFromResourceIfEnabled(danaRKoreanPlugin, rootKey, Config.PUMPDRIVERS) addPreferencesFromResourceIfEnabled(danaRKoreanPlugin, rootKey, Config.PUMPDRIVERS)

View file

@ -47,7 +47,6 @@ import info.nightscout.androidaps.plugins.pump.mdi.MDIPlugin
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
import info.nightscout.androidaps.plugins.source.* import info.nightscout.androidaps.plugins.source.*
@ -97,90 +96,84 @@ abstract class PluginsModule {
@AllConfigs @AllConfigs
@IntoMap @IntoMap
@IntKey(60) @IntKey(60)
abstract fun bindSensitivityOref0Plugin(plugin: SensitivityOref0Plugin): PluginBase
@Binds
@AllConfigs
@IntoMap
@IntKey(70)
abstract fun bindSensitivityAAPSPlugin(plugin: SensitivityAAPSPlugin): PluginBase abstract fun bindSensitivityAAPSPlugin(plugin: SensitivityAAPSPlugin): PluginBase
@Binds @Binds
@AllConfigs @AllConfigs
@IntoMap @IntoMap
@IntKey(80) @IntKey(70)
abstract fun bindSensitivityWeightedAveragePlugin(plugin: SensitivityWeightedAveragePlugin): PluginBase abstract fun bindSensitivityWeightedAveragePlugin(plugin: SensitivityWeightedAveragePlugin): PluginBase
@Binds @Binds
@AllConfigs @AllConfigs
@IntoMap @IntoMap
@IntKey(90) @IntKey(80)
abstract fun bindSensitivityOref1Plugin(plugin: SensitivityOref1Plugin): PluginBase abstract fun bindSensitivityOref1Plugin(plugin: SensitivityOref1Plugin): PluginBase
@Binds @Binds
@PumpDriver @PumpDriver
@IntoMap @IntoMap
@IntKey(100) @IntKey(90)
abstract fun bindDanaRPlugin(plugin: DanaRPlugin): PluginBase abstract fun bindDanaRPlugin(plugin: DanaRPlugin): PluginBase
@Binds @Binds
@PumpDriver @PumpDriver
@IntoMap @IntoMap
@IntKey(110) @IntKey(100)
abstract fun bindDanaRKoreanPlugin(plugin: DanaRKoreanPlugin): PluginBase abstract fun bindDanaRKoreanPlugin(plugin: DanaRKoreanPlugin): PluginBase
@Binds @Binds
@PumpDriver @PumpDriver
@IntoMap @IntoMap
@IntKey(120) @IntKey(110)
abstract fun bindDanaRv2Plugin(plugin: DanaRv2Plugin): PluginBase abstract fun bindDanaRv2Plugin(plugin: DanaRv2Plugin): PluginBase
@Binds @Binds
@PumpDriver @PumpDriver
@IntoMap @IntoMap
@IntKey(130) @IntKey(120)
abstract fun bindDanaRSPlugin(plugin: DanaRSPlugin): PluginBase abstract fun bindDanaRSPlugin(plugin: DanaRSPlugin): PluginBase
@Binds @Binds
@PumpDriver @PumpDriver
@IntoMap @IntoMap
@IntKey(140) @IntKey(130)
abstract fun bindLocalInsightPlugin(plugin: LocalInsightPlugin): PluginBase abstract fun bindLocalInsightPlugin(plugin: LocalInsightPlugin): PluginBase
@Binds @Binds
@PumpDriver @PumpDriver
@IntoMap @IntoMap
@IntKey(150) @IntKey(140)
abstract fun bindComboPlugin(plugin: ComboPlugin): PluginBase abstract fun bindComboPlugin(plugin: ComboPlugin): PluginBase
@Binds @Binds
@PumpDriver @PumpDriver
@IntoMap @IntoMap
@IntKey(160) @IntKey(150)
abstract fun bindMedtronicPumpPlugin(plugin: MedtronicPumpPlugin): PluginBase abstract fun bindMedtronicPumpPlugin(plugin: MedtronicPumpPlugin): PluginBase
@Binds @Binds
@NotNSClient @NotNSClient
@IntoMap @IntoMap
@IntKey(170) @IntKey(160)
abstract fun bindMDIPlugin(plugin: MDIPlugin): PluginBase abstract fun bindMDIPlugin(plugin: MDIPlugin): PluginBase
@Binds @Binds
@AllConfigs @AllConfigs
@IntoMap @IntoMap
@IntKey(180) @IntKey(170)
abstract fun bindVirtualPumpPlugin(plugin: VirtualPumpPlugin): PluginBase abstract fun bindVirtualPumpPlugin(plugin: VirtualPumpPlugin): PluginBase
@Binds @Binds
@NotNSClient @NotNSClient
@IntoMap @IntoMap
@IntKey(190) @IntKey(180)
abstract fun bindCareportalPlugin(plugin: CareportalPlugin): PluginBase abstract fun bindCareportalPlugin(plugin: CareportalPlugin): PluginBase
@Binds @Binds
@APS @APS
@IntoMap @IntoMap
@IntKey(200) @IntKey(190)
abstract fun bindLoopPlugin(plugin: LoopPlugin): PluginBase abstract fun bindLoopPlugin(plugin: LoopPlugin): PluginBase
@Binds @Binds

View file

@ -130,14 +130,12 @@ public class Objective2 extends Objective {
); );
tasks.add(new ExamTask(R.string.sensitivity_label, R.string.sensitivity_which,"sensitivity") tasks.add(new ExamTask(R.string.sensitivity_label, R.string.sensitivity_which,"sensitivity")
.option(new Option(R.string.sensitivityweightedaverage, true)) .option(new Option(R.string.sensitivityweightedaverage, true))
.option(new Option(R.string.sensitivityoref0, false))
.option(new Option(R.string.sensitivityoref1, false)) .option(new Option(R.string.sensitivityoref1, false))
.option(new Option(R.string.sensitivityaaps, true)) .option(new Option(R.string.sensitivityaaps, true))
.hint(new Hint(R.string.sensitivity_hint1)) .hint(new Hint(R.string.sensitivity_hint1))
); );
tasks.add(new ExamTask(R.string.sensitivity_label, R.string.sensitivityuam_which,"sensitivityuam") tasks.add(new ExamTask(R.string.sensitivity_label, R.string.sensitivityuam_which,"sensitivityuam")
.option(new Option(R.string.sensitivityweightedaverage, false)) .option(new Option(R.string.sensitivityweightedaverage, false))
.option(new Option(R.string.sensitivityoref0, false))
.option(new Option(R.string.sensitivityoref1, true)) .option(new Option(R.string.sensitivityoref1, true))
.option(new Option(R.string.sensitivityaaps, false)) .option(new Option(R.string.sensitivityaaps, false))
.hint(new Hint(R.string.sensitivity_hint1)) .hint(new Hint(R.string.sensitivity_hint1))

View file

@ -1,182 +0,0 @@
package info.nightscout.androidaps.plugins.sensitivity;
import androidx.annotation.NonNull;
import androidx.collection.LongSparseArray;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
/**
* Created by mike on 24.06.2017.
*/
@Singleton
public class SensitivityOref0Plugin extends AbstractSensitivityPlugin {
private ProfileFunction profileFunction;
@Inject
public SensitivityOref0Plugin(
HasAndroidInjector injector,
AAPSLogger aapsLogger,
ResourceHelper resourceHelper,
SP sp,
ProfileFunction profileFunction
) {
super(new PluginDescription()
.mainType(PluginType.SENSITIVITY)
.pluginName(R.string.sensitivityoref0)
.shortName(R.string.sensitivity_shortname)
.preferencesId(R.xml.pref_absorption_oref0)
.description(R.string.description_sensitivity_oref0)
.setDefault(),
injector, aapsLogger, resourceHelper, sp
);
this.profileFunction = profileFunction;
}
@NonNull @Override
public AutosensResult detectSensitivity(IobCobCalculatorPlugin iobCobCalculatorPlugin, long fromTime, long toTime) {
LongSparseArray<AutosensData> autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable();
int hoursForDetection = 24;
Profile profile = profileFunction.getProfile();
if (profile == null) {
getAapsLogger().error("No profile");
return new AutosensResult();
}
if (autosensDataTable == null || autosensDataTable.size() < 4) {
getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult();
}
AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already
if (current == null) {
getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult();
}
List<CareportalEvent> siteChanges = MainApp.getDbHelper().getCareportalEventsFromTime(fromTime, CareportalEvent.SITECHANGE, true);
List<ProfileSwitch> profileSwitches = MainApp.getDbHelper().getProfileSwitchEventsFromTime(fromTime, true);
List<Double> deviationsArray = new ArrayList<>();
String pastSensitivity = "";
int index = 0;
while (index < autosensDataTable.size()) {
AutosensData autosensData = autosensDataTable.valueAt(index);
if (autosensData.time < fromTime) {
index++;
continue;
}
if (autosensData.time > toTime) {
index++;
continue;
}
// reset deviations after site change
if (CareportalEvent.isEvent5minBack(siteChanges, autosensData.time)) {
deviationsArray.clear();
pastSensitivity += "(SITECHANGE)";
}
// reset deviations after profile switch
if (ProfileSwitch.isEvent5minBack(getAapsLogger(), profileSwitches, autosensData.time, true)) {
deviationsArray.clear();
pastSensitivity += "(PROFILESWITCH)";
}
double deviation = autosensData.deviation;
//set positive deviations to zero if bg < 80
if (autosensData.bg < 80 && deviation > 0)
deviation = 0;
if (autosensData.validDeviation)
if (autosensData.time > toTime - hoursForDetection * 60 * 60 * 1000L)
deviationsArray.add(deviation);
if (deviationsArray.size() > hoursForDetection * 60 / 5)
deviationsArray.remove(0);
pastSensitivity += autosensData.pastSensitivity;
int secondsFromMidnight = Profile.secondsFromMidnight(autosensData.time);
if (secondsFromMidnight % 3600 < 2.5 * 60 || secondsFromMidnight % 3600 > 57.5 * 60) {
pastSensitivity += "(" + Math.round(secondsFromMidnight / 3600d) + ")";
}
index++;
}
Double[] deviations = new Double[deviationsArray.size()];
deviations = deviationsArray.toArray(deviations);
double sens = profile.getIsfMgdl();
double ratio;
String ratioLimit = "";
String sensResult;
getAapsLogger().debug(LTag.AUTOSENS, "Records: " + index + " " + pastSensitivity);
Arrays.sort(deviations);
for (double i = 0.9; i > 0.1; i = i - 0.02) {
if (IobCobCalculatorPlugin.percentile(deviations, (i + 0.02)) >= 0 && IobCobCalculatorPlugin.percentile(deviations, i) < 0) {
getAapsLogger().debug(LTag.AUTOSENS, Math.round(100 * i) + "% of non-meal deviations negative (target 45%-50%)");
}
}
double pSensitive = IobCobCalculatorPlugin.percentile(deviations, 0.50);
double pResistant = IobCobCalculatorPlugin.percentile(deviations, 0.45);
double basalOff = 0;
if (pSensitive < 0) { // sensitive
basalOff = pSensitive * (60 / 5.0) / sens;
sensResult = "Excess insulin sensitivity detected";
} else if (pResistant > 0) { // resistant
basalOff = pResistant * (60 / 5.0) / sens;
sensResult = "Excess insulin resistance detected";
} else {
sensResult = "Sensitivity normal";
}
getAapsLogger().debug(LTag.AUTOSENS, sensResult);
ratio = 1 + (basalOff / profile.getMaxDailyBasal());
AutosensResult output = fillResult(ratio, current.cob, pastSensitivity, ratioLimit,
sensResult, deviationsArray.size());
getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: "
+ DateUtil.dateAndTimeString(toTime) +
" ratio: " + output.ratio
+ " mealCOB: " + current.cob);
return output;
}
}

View file

@ -27,6 +27,7 @@ import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP; import info.nightscout.androidaps.utils.sharedPreferences.SP;
/** /**
* Created by mike on 19.06.2018. * Created by mike on 19.06.2018.
*/ */
@ -49,7 +50,8 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
.shortName(R.string.sensitivity_shortname) .shortName(R.string.sensitivity_shortname)
.enableByDefault(true) .enableByDefault(true)
.preferencesId(R.xml.pref_absorption_oref1) .preferencesId(R.xml.pref_absorption_oref1)
.description(R.string.description_sensitivity_oref1), .description(R.string.description_sensitivity_oref1)
.setDefault(),
injector, aapsLogger, resourceHelper, sp injector, aapsLogger, resourceHelper, sp
); );
this.profileFunction = profileFunction; this.profileFunction = profileFunction;
@ -83,8 +85,18 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
List<CareportalEvent> siteChanges = MainApp.getDbHelper().getCareportalEventsFromTime(fromTime, CareportalEvent.SITECHANGE, true); List<CareportalEvent> siteChanges = MainApp.getDbHelper().getCareportalEventsFromTime(fromTime, CareportalEvent.SITECHANGE, true);
List<ProfileSwitch> profileSwitches = MainApp.getDbHelper().getProfileSwitchEventsFromTime(fromTime, true); List<ProfileSwitch> profileSwitches = MainApp.getDbHelper().getProfileSwitchEventsFromTime(fromTime, true);
List<Double> deviationsArray = new ArrayList<>(); //[0] = 8 hour
String pastSensitivity = ""; //[1] = 24 hour
//Deviationshour has DeviationsArray
List<ArrayList> deviationsHour = Arrays.asList(new ArrayList(),new ArrayList());
List<String> pastSensitivityArray = Arrays.asList("","");
List<String> sensResultArray = Arrays.asList("","");
List<Double> ratioArray = Arrays.asList(0d,0d);
List<Double> deviationCategory = Arrays.asList(96d,288d);
List<String> ratioLimitArray = Arrays.asList("","");
List<Double> hoursDetection = Arrays.asList(8d,24d);
int index = 0; int index = 0;
while (index < autosensDataTable.size()) { while (index < autosensDataTable.size()) {
AutosensData autosensData = autosensDataTable.valueAt(index); AutosensData autosensData = autosensDataTable.valueAt(index);
@ -98,98 +110,133 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
index++; index++;
continue; continue;
} }
int hoursegment = 0;
//hoursegment = 0 = 8 hour
//hoursegment = 1 = 24 hour
while (hoursegment < deviationsHour.size()){
ArrayList deviationsArray = deviationsHour.get(hoursegment);
String pastSensitivity = pastSensitivityArray.get(hoursegment);
// reset deviations after site change // reset deviations after site change
if (CareportalEvent.isEvent5minBack(siteChanges, autosensData.time)) { if (CareportalEvent.isEvent5minBack(siteChanges, autosensData.time)) {
deviationsArray.clear(); deviationsArray.clear();
pastSensitivity += "(SITECHANGE)"; pastSensitivity += "(SITECHANGE)";
} }
// reset deviations after profile switch // reset deviations after profile switch
if (ProfileSwitch.isEvent5minBack(getAapsLogger(), profileSwitches, autosensData.time, true)) { if (ProfileSwitch.isEvent5minBack(getAapsLogger(),profileSwitches, autosensData.time, true)) {
deviationsArray.clear(); deviationsArray.clear();
pastSensitivity += "(PROFILESWITCH)"; pastSensitivity += "(PROFILESWITCH)";
} }
double deviation = autosensData.deviation; double deviation = autosensData.deviation;
//set positive deviations to zero if bg < 80 //set positive deviations to zero if bg < 80
if (autosensData.bg < 80 && deviation > 0) if (autosensData.bg < 80 && deviation > 0)
deviation = 0; deviation = 0;
if (autosensData.validDeviation) if (autosensData.validDeviation)
deviationsArray.add(deviation); if (autosensData.time > toTime - hoursDetection.get(hoursegment) * 60 * 60 * 1000L)
deviationsArray.add(deviation);
for (int i = 0; i < autosensData.extraDeviation.size(); i++)
deviationsArray.add(autosensData.extraDeviation.get(i));
if (deviationsArray.size() > 96)
deviationsArray.remove(0);
pastSensitivity += autosensData.pastSensitivity; for (int i = 0; i < autosensData.extraDeviation.size(); i++)
int secondsFromMidnight = Profile.secondsFromMidnight(autosensData.time); deviationsArray.add(autosensData.extraDeviation.get(i));
if (secondsFromMidnight % 3600 < 2.5 * 60 || secondsFromMidnight % 3600 > 57.5 * 60) {
pastSensitivity += "(" + Math.round(secondsFromMidnight / 3600d) + ")"; if (deviationsArray.size() > deviationCategory.get(hoursegment)){
} deviationsArray.remove(0);
index++; }
pastSensitivity += autosensData.pastSensitivity;
int secondsFromMidnight = Profile.secondsFromMidnight(autosensData.time);
if (secondsFromMidnight % 3600 < 2.5 * 60 || secondsFromMidnight % 3600 > 57.5 * 60) {
pastSensitivity += "(" + Math.round(secondsFromMidnight / 3600d) + ")";
}
//Update the data back to the parent
deviationsHour.set(hoursegment,deviationsArray);
pastSensitivityArray.set(hoursegment,pastSensitivity);
hoursegment++;
}
index++;
} }
// when we have less than 8h worth of deviation data, add up to 90m of zero deviations // when we have less than 8h/24 worth of deviation data, add up to 90m of zero deviations
// this dampens any large sensitivity changes detected based on too little data, without ignoring them completely // this dampens any large sensitivity changes detected based on too little data, without ignoring them completely
getAapsLogger().debug(LTag.AUTOSENS, "Using most recent " + deviationsArray.size() + " deviations");
if (deviationsArray.size() < 96) { for (int i = 0; i < deviationsHour.size(); i++) {
int pad = (int) Math.round((1 - (double) deviationsArray.size() / 96) * 18); ArrayList deviations = deviationsHour.get(i);
getAapsLogger().debug(LTag.AUTOSENS, "Adding " + pad + " more zero deviations"); getAapsLogger().debug(LTag.AUTOSENS,"Using most recent " + deviations.size() + " deviations");
for (int d = 0; d < pad; d++) { if (deviations.size() < deviationCategory.get(i)) {
//process.stderr.write("."); int pad = (int) Math.round((1 - (double) deviations.size() / deviationCategory.get(i)) * 18);
deviationsArray.add(0d); getAapsLogger().debug(LTag.AUTOSENS,"Adding " + pad + " more zero deviations");
for (int d = 0; d < pad; d++) { ;
deviations.add(0d);
}
} }
//Update the data back to the parent
deviationsHour.set(i,deviations);
} }
Double[] deviations = new Double[deviationsArray.size()]; int hourused = 0;
deviations = deviationsArray.toArray(deviations); while (hourused < deviationsHour.size()){
ArrayList deviationsArray = deviationsHour.get(hourused);
double sens = profile.getIsfMgdl(); String pastSensitivity = pastSensitivityArray.get(hourused);
String sensResult = "(8 hours) ";
double ratio = 1; String senstime = sensResult;
String ratioLimit = ""; if (hourused == 1){
String sensResult = ""; senstime = "(24 hours) ";
sensResult = senstime;
getAapsLogger().debug(LTag.AUTOSENS, "Records: " + index + " " + pastSensitivity);
Arrays.sort(deviations);
/* Not used in calculation
for (double i = 0.9; i > 0.1; i = i - 0.01) {
if (IobCobCalculatorPlugin.percentile(deviations, (i + 0.01)) >= 0 && IobCobCalculatorPlugin.percentile(deviations, i) < 0) {
if (L.isEnabled(L.AUTOSENS))
log.debug(Math.round(100 * i) + "% of non-meal deviations negative (>50% = sensitivity)");
} }
if (IobCobCalculatorPlugin.percentile(deviations, (i + 0.01)) > 0 && IobCobCalculatorPlugin.percentile(deviations, i) <= 0) { String ratioLimit = "";
if (L.isEnabled(L.AUTOSENS))
log.debug(Math.round(100 * i) + "% of non-meal deviations positive (>50% = resistance)"); Double[] deviations = new Double[deviationsArray.size()];
deviations = (Double[]) deviationsArray.toArray(deviations);
double sens = profile.getIsfMgdl();
getAapsLogger().debug(LTag.AUTOSENS,"Records: " + index + " " + pastSensitivity);
Arrays.sort(deviations);
double pSensitive = IobCobCalculatorPlugin.percentile(deviations, 0.50);
double pResistant = IobCobCalculatorPlugin.percentile(deviations, 0.50);
double basalOff = 0;
if (pSensitive < 0) { // sensitive
basalOff = pSensitive * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
sensResult+= "Excess insulin sensitivity detected";
} else if (pResistant > 0) { // resistant
basalOff = pResistant * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
sensResult+= "Excess insulin resistance detected";
} else {
sensResult+= "Sensitivity normal";
} }
}
*/
double pSensitive = IobCobCalculatorPlugin.percentile(deviations, 0.50);
double pResistant = IobCobCalculatorPlugin.percentile(deviations, 0.50);
double basalOff = 0; getAapsLogger().debug(LTag.AUTOSENS,sensResult);
if (pSensitive < 0) { // sensitive double ratio = 1 + (basalOff / profile.getMaxDailyBasal());
basalOff = pSensitive * (60 / 5.0) / sens;
sensResult = "Excess insulin sensitivity detected"; //Update the data back to the parent
} else if (pResistant > 0) { // resistant sensResultArray.set(hourused,sensResult);
basalOff = pResistant * (60 / 5.0) / sens; ratioArray.set(hourused,ratio);
sensResult = "Excess insulin resistance detected"; ratioLimitArray.set(hourused,ratioLimit);
} else { hourused++;
sensResult = "Sensitivity normal";
} }
getAapsLogger().debug(LTag.AUTOSENS, sensResult); int key = 1;
String comparison = " 8 h ratio " +ratioArray.get(0)+" vs 24h ratio "+ratioArray.get(1);
ratio = 1 + (basalOff / profile.getMaxDailyBasal()); //use 24 hour ratio by default
//if the 8 hour ratio is less than the 24 hour ratio, the 8 hour ratio is used
AutosensResult output = fillResult(ratio, current.cob, pastSensitivity, ratioLimit, if(ratioArray.get(0) < ratioArray.get(1)){
sensResult, deviationsArray.size()); key = 0;
}
String message = hoursDetection.get(key)+" of sensitivity used";
AutosensResult output = fillResult(ratioArray.get(key), current.cob, pastSensitivityArray.get(key), ratioLimitArray.get(key),
sensResultArray.get(key)+comparison, deviationsHour.get(key).size());
getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: " getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: "
+ DateUtil.dateAndTimeString(toTime) + + DateUtil.dateAndTimeString(toTime) +

View file

@ -66,8 +66,7 @@
<string name="description_pump_mdi">Pump integration for people who do multiple daily injections for their diabetes therapy</string> <string name="description_pump_mdi">Pump integration for people who do multiple daily injections for their diabetes therapy</string>
<string name="description_pump_virtual">Pump integration for pumps which don\'t have any driver yet (Open Loop)</string> <string name="description_pump_virtual">Pump integration for pumps which don\'t have any driver yet (Open Loop)</string>
<string name="description_sensitivity_aaps">Sensitivity is calculated the same way like Oref0, but you can specify timeframe to the past. Minimal carb absorption is calculated from max carb absorption time from preferences.</string> <string name="description_sensitivity_aaps">Sensitivity is calculated the same way like Oref0, but you can specify timeframe to the past. Minimal carb absorption is calculated from max carb absorption time from preferences.</string>
<string name="description_sensitivity_oref0">Sensitivity is calculated from 24h data in the past and carbs (if not absorbed) are cut after time specified in preferences.</string> <string name="description_sensitivity_oref1">Sensitivity is calculated from 8h or 24h data in the past (using either which is more sensitive). Carbs (if not absorbed) are cut after time specified in preferences. Plugin also calculates UAM.</string>
<string name="description_sensitivity_oref1">Sensitivity is calculated from 8h data in the past and carbs (if not absorbed) are cut after time specified in preferences. Plugin also calculates UAM.</string>
<string name="description_sensitivity_weighted_average">Sensitivity is calculated as a weighted average from deviations. Newer deviations have higher weight. Minimal carb absorption is calculated from max carb absorption time from preferences. This algorithm is the fastest in following sensitivity changes.</string> <string name="description_sensitivity_weighted_average">Sensitivity is calculated as a weighted average from deviations. Newer deviations have higher weight. Minimal carb absorption is calculated from max carb absorption time from preferences. This algorithm is the fastest in following sensitivity changes.</string>
<string name="description_source_eversense">Receive BG values from the patched Eversense app.</string> <string name="description_source_eversense">Receive BG values from the patched Eversense app.</string>
<string name="description_source_glimp">Receive BG values from Glimp.</string> <string name="description_source_glimp">Receive BG values from Glimp.</string>