From 09cc8c01b645ecfe89d27314fffcd0b9b05b0996 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 19 Apr 2018 13:31:34 +0200 Subject: [PATCH] use min5min impact actually used for SMB --- .../java/info/nightscout/androidaps/data/MealData.java | 1 + .../plugins/IobCobCalculator/AutosensData.java | 2 ++ .../plugins/IobCobCalculator/IobCobThread.java | 1 + .../plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java | 8 ++++++-- .../plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java | 9 ++++++--- .../androidaps/plugins/Source/SourceXdripPlugin.java | 2 +- .../androidaps/plugins/Treatments/TreatmentsPlugin.java | 1 + 7 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/data/MealData.java b/app/src/main/java/info/nightscout/androidaps/data/MealData.java index 054c76d602..8acf4285bf 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/MealData.java +++ b/app/src/main/java/info/nightscout/androidaps/data/MealData.java @@ -11,4 +11,5 @@ public class MealData { public double slopeFromMinDeviation = 999; public long lastBolusTime; public long lastCarbTime = 0L; + public double usedMinCarbsImpact = 0d; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java index b4013a7a3c..85dc6999a0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java @@ -65,6 +65,8 @@ public class AutosensData { public double autosensRatio = 1d; public double slopeFromMaxDeviation = 0; public double slopeFromMinDeviation = 999; + public double usedMinCarbsImpact = -0; + @Override public String 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 7789f8a5a6..60d315a070 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 @@ -222,6 +222,7 @@ public class IobCobThread extends Thread { // and add that to the running total carbsAbsorbed autosensData.cob = Math.max(previous.cob - autosensData.absorbed, 0d); autosensData.substractAbosorbedCarbs(); + autosensData.usedMinCarbsImpact = totalMinCarbsImpact; } autosensData.removeOldCarbs(bgTime); autosensData.cob += autosensData.carbsFromBolus; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java index 96e004d996..928987393d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java @@ -213,8 +213,12 @@ public class DetermineBasalAdapterAMAJS { mProfile.put("current_basal", basalrate); mProfile.put("temptargetSet", tempTargetSet); mProfile.put("autosens_adjust_targets", SP.getBoolean("openapsama_autosens_adjusttargets", true)); - //TODO: align with max-absorption model in AMA sensitivity - mProfile.put("min_5m_carbimpact", SP.getDouble("openapsama_min_5m_carbimpact", SMBDefaults.min_5m_carbimpact)); + //align with max-absorption model in AMA sensitivity + if(mealData.usedMinCarbsImpact >0){ + mProfile.put("min_5m_carbimpact", mealData.usedMinCarbsImpact); + } else { + mProfile.put("min_5m_carbimpact", SP.getDouble("openapsama_min_5m_carbimpact", SMBDefaults.min_5m_carbimpact)); + } if (units.equals(Constants.MMOL)) { mProfile.put("out_units", "mmol/L"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java index 89bf8431f4..b28ce599f7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java @@ -243,9 +243,12 @@ public class DetermineBasalAdapterSMBJS { mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target); mProfile.put("maxCOB", SMBDefaults.maxCOB); mProfile.put("skip_neutral_temps", SMBDefaults.skip_neutral_temps); - //TODO: align with max-absorption model in AMA sensitivity - mProfile.put("min_5m_carbimpact", SP.getDouble("openapsama_min_5m_carbimpact", SMBDefaults.min_5m_carbimpact)); - ; + //align with max-absorption model in AMA sensitivity + if(mealData.usedMinCarbsImpact >0){ + mProfile.put("min_5m_carbimpact", mealData.usedMinCarbsImpact); + } else { + mProfile.put("min_5m_carbimpact", SP.getDouble("openapsama_min_5m_carbimpact", SMBDefaults.min_5m_carbimpact)); + } mProfile.put("remainingCarbsCap", SMBDefaults.remainingCarbsCap); mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false)); mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java index 0d33f529b3..bfc1a184ff 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java @@ -29,6 +29,6 @@ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface { @Override public boolean advancedFilteringSupported() { - return false; + return true; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java index 2f5135c0cb..c3198f752a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java @@ -235,6 +235,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface result.mealCOB = autosensData.cob; result.slopeFromMinDeviation = autosensData.slopeFromMinDeviation; result.slopeFromMaxDeviation = autosensData.slopeFromMaxDeviation; + result.usedMinCarbsImpact = autosensData.usedMinCarbsImpact; } result.lastBolusTime = getLastBolusTime(); return result;