more debug to autosens

This commit is contained in:
Milos Kozak 2018-07-12 21:28:35 +03:00
parent d97e195ad1
commit 35e93ffafd
10 changed files with 34 additions and 32 deletions

View file

@ -14,7 +14,7 @@ public class AutosensResult {
//default values to show when autosens algorithm is not called //default values to show when autosens algorithm is not called
public double ratio = 1d; public double ratio = 1d;
public double carbsAbsorbed = 0d; public double carbsAbsorbed = 0d;
public String sensResult = "autosens deactivated"; public String sensResult = "autosens not available";
public String pastSensitivity = ""; public String pastSensitivity = "";
public String ratioLimit = ""; public String ratioLimit = "";

View file

@ -456,6 +456,13 @@ public class IobCobCalculatorPlugin extends PluginBase {
} }
} }
public String lastDataTime() {
if (autosensDataTable.size() > 0)
return DateUtil.dateAndTimeString(autosensDataTable.valueAt(autosensDataTable.size() - 1).time);
else
return "autosensDataTable empty";
}
public IobTotal[] calculateIobArrayInDia(Profile profile) { public IobTotal[] calculateIobArrayInDia(Profile profile) {
// predict IOB out to DIA plus 30m // predict IOB out to DIA plus 30m
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();

View file

@ -337,8 +337,11 @@ public class IobCobOref1Thread extends Thread {
if (bgTime < now()) if (bgTime < now())
autosensDataTable.put(bgTime, autosensData); autosensDataTable.put(bgTime, autosensData);
if (Config.logAutosensData) if (Config.logAutosensData)
log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime)); log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + IobCobCalculatorPlugin.getPlugin().lastDataTime());
autosensData.autosensRatio = iobCobCalculatorPlugin.detectSensitivity(oldestTimeWithData, bgTime).ratio; AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime);
if (Config.logAutosensData)
log.debug("Sensitivity result: " + sensitivity.toString());
autosensData.autosensRatio = sensitivity.ratio;
if (Config.logAutosensData) if (Config.logAutosensData)
log.debug(autosensData.toString()); log.debug(autosensData.toString());
} }

View file

@ -264,8 +264,8 @@ public class IobCobThread extends Thread {
if (bgTime < now()) if (bgTime < now())
autosensDataTable.put(bgTime, autosensData); autosensDataTable.put(bgTime, autosensData);
if (Config.logAutosensData) if (Config.logAutosensData)
log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime)); log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + IobCobCalculatorPlugin.getPlugin().lastDataTime());
AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivity(oldestTimeWithData, bgTime); AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime);
if (Config.logAutosensData) if (Config.logAutosensData)
log.debug("Sensitivity result: " + sensitivity.toString()); log.debug("Sensitivity result: " + sensitivity.toString());
autosensData.autosensRatio = sensitivity.ratio; autosensData.autosensRatio = sensitivity.ratio;

View file

@ -176,6 +176,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
lastAutosensResult = IobCobCalculatorPlugin.getPlugin().detectSensitivityWithLock(IobCobCalculatorPlugin.getPlugin().oldestDataAvailable(), System.currentTimeMillis()); lastAutosensResult = IobCobCalculatorPlugin.getPlugin().detectSensitivityWithLock(IobCobCalculatorPlugin.getPlugin().oldestDataAvailable(), System.currentTimeMillis());
} else { } else {
lastAutosensResult = new AutosensResult(); lastAutosensResult = new AutosensResult();
lastAutosensResult.sensResult = "autosens disabled";
} }
Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart); Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart);
Profiler.log(log, "AMA data gathering", start); Profiler.log(log, "AMA data gathering", start);

View file

@ -183,6 +183,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
lastAutosensResult = IobCobCalculatorPlugin.getPlugin().detectSensitivityWithLock(IobCobCalculatorPlugin.getPlugin().oldestDataAvailable(), System.currentTimeMillis()); lastAutosensResult = IobCobCalculatorPlugin.getPlugin().detectSensitivityWithLock(IobCobCalculatorPlugin.getPlugin().oldestDataAvailable(), System.currentTimeMillis());
} else { } else {
lastAutosensResult = new AutosensResult(); lastAutosensResult = new AutosensResult();
lastAutosensResult.sensResult = "autosens disabled";
} }
Constraint<Boolean> smbAllowed = new Constraint<>(!tempBasalFallback); Constraint<Boolean> smbAllowed = new Constraint<>(!tempBasalFallback);

View file

@ -15,16 +15,13 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.SensitivityInterface;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.utils.Round; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse;
/** /**
* Created by mike on 24.06.2017. * Created by mike on 24.06.2017.
@ -70,13 +67,13 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
} }
if (autosensDataTable == null || autosensDataTable.size() < 4) { if (autosensDataTable == null || autosensDataTable.size() < 4) {
log.debug("No autosens data available"); log.debug("No autosens data available. lastDataTime=" + IobCobCalculatorPlugin.getPlugin().lastDataTime());
return new AutosensResult(); return new AutosensResult();
} }
AutosensData current = IobCobCalculatorPlugin.getPlugin().getAutosensData(toTime); // this is running inside lock already AutosensData current = IobCobCalculatorPlugin.getPlugin().getAutosensData(toTime); // this is running inside lock already
if (current == null) { if (current == null) {
log.debug("No autosens data available"); log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + IobCobCalculatorPlugin.getPlugin().lastDataTime());
return new AutosensResult(); return new AutosensResult();
} }

View file

@ -15,16 +15,12 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.SensitivityInterface;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.utils.Round; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse;
/** /**
* Created by mike on 24.06.2017. * Created by mike on 24.06.2017.
@ -66,13 +62,13 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin {
} }
if (autosensDataTable == null || autosensDataTable.size() < 4) { if (autosensDataTable == null || autosensDataTable.size() < 4) {
log.debug("No autosens data available"); log.debug("No autosens data available. lastDataTime=" + IobCobCalculatorPlugin.getPlugin().lastDataTime());
return new AutosensResult(); return new AutosensResult();
} }
AutosensData current = IobCobCalculatorPlugin.getPlugin().getAutosensData(toTime); // this is running inside lock already AutosensData current = IobCobCalculatorPlugin.getPlugin().getAutosensData(toTime); // this is running inside lock already
if (current == null) { if (current == null) {
log.debug("No autosens data available"); log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + IobCobCalculatorPlugin.getPlugin().lastDataTime());
return new AutosensResult(); return new AutosensResult();
} }

View file

@ -15,16 +15,12 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.SensitivityInterface;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.utils.Round; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse;
/** /**
* Created by mike on 19.06.2018. * Created by mike on 19.06.2018.
@ -65,14 +61,14 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
} }
if (autosensDataTable == null || autosensDataTable.size() < 4) { if (autosensDataTable == null || autosensDataTable.size() < 4) {
log.debug("No autosens data available"); log.debug("No autosens data available. lastDataTime=" + IobCobCalculatorPlugin.getPlugin().lastDataTime());
return new AutosensResult(); return new AutosensResult();
} }
// the current // the current
AutosensData current = IobCobCalculatorPlugin.getPlugin().getAutosensData(toTime); // this is running inside lock already AutosensData current = IobCobCalculatorPlugin.getPlugin().getAutosensData(toTime); // this is running inside lock already
if (current == null) { if (current == null) {
log.debug("No autosens data available"); log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + IobCobCalculatorPlugin.getPlugin().lastDataTime());
return new AutosensResult(); return new AutosensResult();
} }

View file

@ -13,16 +13,13 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.SensitivityInterface;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.utils.Round; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse;
/** /**
* Created by mike on 24.06.2017. * Created by mike on 24.06.2017.
@ -61,15 +58,14 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours); int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
if (autosensDataTable == null || autosensDataTable.size() < 4) { if (autosensDataTable == null || autosensDataTable.size() < 4) {
if (Config.logAutosensData) log.debug("No autosens data available. lastDataTime=" + IobCobCalculatorPlugin.getPlugin().lastDataTime());
log.debug("No autosens data available");
return new AutosensResult(); return new AutosensResult();
} }
AutosensData current = IobCobCalculatorPlugin.getPlugin().getAutosensData(toTime); // this is running inside lock already AutosensData current = IobCobCalculatorPlugin.getPlugin().getAutosensData(toTime); // this is running inside lock already
if (current == null) { if (current == null) {
if (Config.logAutosensData) if (Config.logAutosensData)
log.debug("No autosens data available"); log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + IobCobCalculatorPlugin.getPlugin().lastDataTime());
return new AutosensResult(); return new AutosensResult();
} }
@ -134,7 +130,12 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
} }
if (data.size() == 0) { if (data.size() == 0) {
if (Config.logAutosensData)
log.debug("Data size: " + data.size() + " fromTime: " + DateUtil.dateAndTimeString(fromTime) + " toTime: " + DateUtil.dateAndTimeString(toTime));
return new AutosensResult(); return new AutosensResult();
} else {
if (Config.logAutosensData)
log.debug("Data size: " + data.size() + " fromTime: " + DateUtil.dateAndTimeString(fromTime) + " toTime: " + DateUtil.dateAndTimeString(toTime));
} }
double weightedsum = 0; double weightedsum = 0;