From 35e93ffafd00379ba8bd0f7357de0a6b1acac9ea Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 12 Jul 2018 21:28:35 +0300 Subject: [PATCH] more debug to autosens --- .../plugins/IobCobCalculator/AutosensResult.java | 2 +- .../IobCobCalculator/IobCobCalculatorPlugin.java | 7 +++++++ .../IobCobCalculator/IobCobOref1Thread.java | 7 +++++-- .../plugins/IobCobCalculator/IobCobThread.java | 4 ++-- .../plugins/OpenAPSAMA/OpenAPSAMAPlugin.java | 1 + .../plugins/OpenAPSSMB/OpenAPSSMBPlugin.java | 1 + .../Sensitivity/SensitivityAAPSPlugin.java | 9 +++------ .../Sensitivity/SensitivityOref0Plugin.java | 10 +++------- .../Sensitivity/SensitivityOref1Plugin.java | 10 +++------- .../SensitivityWeightedAveragePlugin.java | 15 ++++++++------- 10 files changed, 34 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensResult.java index 6602038fb4..fbd5b0a0d1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensResult.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensResult.java @@ -14,7 +14,7 @@ public class AutosensResult { //default values to show when autosens algorithm is not called public double ratio = 1d; public double carbsAbsorbed = 0d; - public String sensResult = "autosens deactivated"; + public String sensResult = "autosens not available"; public String pastSensitivity = ""; public String ratioLimit = ""; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java index 3f2cac2c1b..a34ae6a308 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java @@ -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) { // predict IOB out to DIA plus 30m long time = System.currentTimeMillis(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobOref1Thread.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobOref1Thread.java index 725cfab741..a4374541a5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobOref1Thread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobOref1Thread.java @@ -337,8 +337,11 @@ public class IobCobOref1Thread extends Thread { if (bgTime < now()) autosensDataTable.put(bgTime, autosensData); if (Config.logAutosensData) - log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime)); - autosensData.autosensRatio = iobCobCalculatorPlugin.detectSensitivity(oldestTimeWithData, bgTime).ratio; + log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + IobCobCalculatorPlugin.getPlugin().lastDataTime()); + AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime); + if (Config.logAutosensData) + log.debug("Sensitivity result: " + sensitivity.toString()); + autosensData.autosensRatio = sensitivity.ratio; if (Config.logAutosensData) log.debug(autosensData.toString()); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java index 2ba476996f..de4a70224c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java @@ -264,8 +264,8 @@ public class IobCobThread extends Thread { if (bgTime < now()) autosensDataTable.put(bgTime, autosensData); if (Config.logAutosensData) - log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime)); - AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivity(oldestTimeWithData, bgTime); + log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + IobCobCalculatorPlugin.getPlugin().lastDataTime()); + AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime); if (Config.logAutosensData) log.debug("Sensitivity result: " + sensitivity.toString()); autosensData.autosensRatio = sensitivity.ratio; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java index b6e07bb004..937489bc8f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java @@ -176,6 +176,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { lastAutosensResult = IobCobCalculatorPlugin.getPlugin().detectSensitivityWithLock(IobCobCalculatorPlugin.getPlugin().oldestDataAvailable(), System.currentTimeMillis()); } else { lastAutosensResult = new AutosensResult(); + lastAutosensResult.sensResult = "autosens disabled"; } Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart); Profiler.log(log, "AMA data gathering", start); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java index f28a6eff8e..3227be526e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java @@ -183,6 +183,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { lastAutosensResult = IobCobCalculatorPlugin.getPlugin().detectSensitivityWithLock(IobCobCalculatorPlugin.getPlugin().oldestDataAvailable(), System.currentTimeMillis()); } else { lastAutosensResult = new AutosensResult(); + lastAutosensResult.sensResult = "autosens disabled"; } Constraint smbAllowed = new Constraint<>(!tempBasalFallback); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityAAPSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityAAPSPlugin.java index fdf85c064e..4fbde5f9f8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityAAPSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityAAPSPlugin.java @@ -15,16 +15,13 @@ 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.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; 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.AutosensResult; 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. @@ -70,13 +67,13 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { } 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(); } AutosensData current = IobCobCalculatorPlugin.getPlugin().getAutosensData(toTime); // this is running inside lock already 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(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref0Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref0Plugin.java index a97297f551..d9c7b97d04 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref0Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref0Plugin.java @@ -15,16 +15,12 @@ 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.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; 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.AutosensResult; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; -import info.nightscout.utils.Round; -import info.nightscout.utils.SP; -import info.nightscout.utils.SafeParse; +import info.nightscout.utils.DateUtil; /** * Created by mike on 24.06.2017. @@ -66,13 +62,13 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin { } 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(); } AutosensData current = IobCobCalculatorPlugin.getPlugin().getAutosensData(toTime); // this is running inside lock already 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(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref1Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref1Plugin.java index ae01c2158d..42f02b12de 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref1Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref1Plugin.java @@ -15,16 +15,12 @@ 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.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; 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.AutosensResult; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; -import info.nightscout.utils.Round; -import info.nightscout.utils.SP; -import info.nightscout.utils.SafeParse; +import info.nightscout.utils.DateUtil; /** * Created by mike on 19.06.2018. @@ -65,14 +61,14 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { } 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(); } // the current AutosensData current = IobCobCalculatorPlugin.getPlugin().getAutosensData(toTime); // this is running inside lock already 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(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityWeightedAveragePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityWeightedAveragePlugin.java index ed185e88f9..b4dd5ab250 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityWeightedAveragePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityWeightedAveragePlugin.java @@ -13,16 +13,13 @@ 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.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; 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.AutosensResult; 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. @@ -61,15 +58,14 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours); if (autosensDataTable == null || autosensDataTable.size() < 4) { - if (Config.logAutosensData) - log.debug("No autosens data available"); + log.debug("No autosens data available. lastDataTime=" + IobCobCalculatorPlugin.getPlugin().lastDataTime()); return new AutosensResult(); } AutosensData current = IobCobCalculatorPlugin.getPlugin().getAutosensData(toTime); // this is running inside lock already if (current == null) { 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(); } @@ -134,7 +130,12 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin } if (data.size() == 0) { + if (Config.logAutosensData) + log.debug("Data size: " + data.size() + " fromTime: " + DateUtil.dateAndTimeString(fromTime) + " toTime: " + DateUtil.dateAndTimeString(toTime)); return new AutosensResult(); + } else { + if (Config.logAutosensData) + log.debug("Data size: " + data.size() + " fromTime: " + DateUtil.dateAndTimeString(fromTime) + " toTime: " + DateUtil.dateAndTimeString(toTime)); } double weightedsum = 0;