Merge branch 'dev' of github.com:MilosKozak/AndroidAPS into carbs-required

This commit is contained in:
Tim Gunn 2020-05-29 21:51:05 +12:00
commit 0dfdf6c68a
No known key found for this signature in database
GPG key ID: C9BC1E9D0D0AED8C
8 changed files with 15 additions and 11 deletions

View file

@ -814,9 +814,9 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
getAapsLogger().debug(LTag.AUTOSENS, "Starting calculation thread: " + from + " to " + dateUtil.dateAndTimeString(end)); getAapsLogger().debug(LTag.AUTOSENS, "Starting calculation thread: " + from + " to " + dateUtil.dateAndTimeString(end));
if (thread == null || thread.getState() == Thread.State.TERMINATED) { if (thread == null || thread.getState() == Thread.State.TERMINATED) {
if (sensitivityOref1Plugin.isEnabled()) if (sensitivityOref1Plugin.isEnabled())
thread = new IobCobOref1Thread(injector, this, from, end, bgDataReload, limitDataToOldestAvailable, cause); thread = new IobCobOref1Thread(injector, this, treatmentsPlugin, from, end, bgDataReload, limitDataToOldestAvailable, cause);
else else
thread = new IobCobThread(injector, this, from, end, bgDataReload, limitDataToOldestAvailable, cause); thread = new IobCobThread(injector, this, treatmentsPlugin, from, end, bgDataReload, limitDataToOldestAvailable, cause);
thread.start(); thread.start();
} }
} }

View file

@ -36,6 +36,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCa
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin; import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin; import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.DecimalFormatter;
import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.FabricPrivacy;
@ -62,7 +63,6 @@ public class IobCobOref1Thread extends Thread {
@Inject ResourceHelper resourceHelper; @Inject ResourceHelper resourceHelper;
@Inject ProfileFunction profileFunction; @Inject ProfileFunction profileFunction;
@Inject Context context; @Inject Context context;
@Inject ActivePluginProvider activePluginProvider;
@Inject SensitivityAAPSPlugin sensitivityAAPSPlugin; @Inject SensitivityAAPSPlugin sensitivityAAPSPlugin;
@Inject SensitivityWeightedAveragePlugin sensitivityWeightedAveragePlugin; @Inject SensitivityWeightedAveragePlugin sensitivityWeightedAveragePlugin;
@Inject BuildHelper buildHelper; @Inject BuildHelper buildHelper;
@ -72,6 +72,7 @@ public class IobCobOref1Thread extends Thread {
private final HasAndroidInjector injector; private final HasAndroidInjector injector;
private final IobCobCalculatorPlugin iobCobCalculatorPlugin; // cannot be injected : HistoryBrowser uses different instance private final IobCobCalculatorPlugin iobCobCalculatorPlugin; // cannot be injected : HistoryBrowser uses different instance
private final TreatmentsPlugin treatmentsPlugin; // cannot be injected : HistoryBrowser uses different instance
private boolean bgDataReload; private boolean bgDataReload;
private boolean limitDataToOldestAvailable; private boolean limitDataToOldestAvailable;
private String from; private String from;
@ -79,11 +80,12 @@ public class IobCobOref1Thread extends Thread {
private PowerManager.WakeLock mWakeLock; private PowerManager.WakeLock mWakeLock;
IobCobOref1Thread(HasAndroidInjector injector, IobCobCalculatorPlugin iobCobCalculatorPlugin, String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) { IobCobOref1Thread(HasAndroidInjector injector, IobCobCalculatorPlugin iobCobCalculatorPlugin, TreatmentsPlugin treatmentsPlugin, String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) {
super(); super();
injector.androidInjector().inject(this); injector.androidInjector().inject(this);
this.injector = injector; this.injector = injector;
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin; this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
this.treatmentsPlugin = treatmentsPlugin;
this.bgDataReload = bgDataReload; this.bgDataReload = bgDataReload;
this.limitDataToOldestAvailable = limitDataToOldestAvailable; this.limitDataToOldestAvailable = limitDataToOldestAvailable;
@ -242,7 +244,7 @@ public class IobCobOref1Thread extends Thread {
} }
} }
List<Treatment> recentCarbTreatments = activePluginProvider.getActiveTreatments().getCarbTreatments5MinBackFromHistory(bgTime); List<Treatment> recentCarbTreatments = treatmentsPlugin.getCarbTreatments5MinBackFromHistory(bgTime);
for (Treatment recentCarbTreatment : recentCarbTreatments) { for (Treatment recentCarbTreatment : recentCarbTreatments) {
autosensData.carbsFromBolus += recentCarbTreatment.carbs; autosensData.carbsFromBolus += recentCarbTreatment.carbs;
boolean isAAPSOrWeighted = sensitivityAAPSPlugin.isEnabled() || sensitivityWeightedAveragePlugin.isEnabled(); boolean isAAPSOrWeighted = sensitivityAAPSPlugin.isEnabled() || sensitivityWeightedAveragePlugin.isEnabled();
@ -365,7 +367,7 @@ public class IobCobOref1Thread extends Thread {
// add an extra negative deviation if a high temptarget is running and exercise mode is set // add an extra negative deviation if a high temptarget is running and exercise mode is set
// TODO AS-FIX // TODO AS-FIX
if (false && sp.getBoolean(R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity)) { if (false && sp.getBoolean(R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity)) {
TempTarget tempTarget = activePluginProvider.getActiveTreatments().getTempTargetFromHistory(bgTime); TempTarget tempTarget = treatmentsPlugin.getTempTargetFromHistory(bgTime);
if (tempTarget != null && tempTarget.target() >= 100) { if (tempTarget != null && tempTarget.target() >= 100) {
autosensData.extraDeviation.add(-(tempTarget.target() - 100) / 20); autosensData.extraDeviation.add(-(tempTarget.target() - 100) / 20);
} }

View file

@ -34,6 +34,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCa
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin; import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin; import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.DecimalFormatter;
import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.FabricPrivacy;
@ -59,7 +60,6 @@ public class IobCobThread extends Thread {
@Inject ResourceHelper resourceHelper; @Inject ResourceHelper resourceHelper;
@Inject ProfileFunction profileFunction; @Inject ProfileFunction profileFunction;
@Inject Context context; @Inject Context context;
@Inject ActivePluginProvider activePluginProvider;
@Inject SensitivityAAPSPlugin sensitivityAAPSPlugin; @Inject SensitivityAAPSPlugin sensitivityAAPSPlugin;
@Inject SensitivityWeightedAveragePlugin sensitivityWeightedAveragePlugin; @Inject SensitivityWeightedAveragePlugin sensitivityWeightedAveragePlugin;
@Inject BuildHelper buildHelper; @Inject BuildHelper buildHelper;
@ -69,6 +69,7 @@ public class IobCobThread extends Thread {
private final HasAndroidInjector injector; private final HasAndroidInjector injector;
private final IobCobCalculatorPlugin iobCobCalculatorPlugin; // cannot be injected : HistoryBrowser uses different instance private final IobCobCalculatorPlugin iobCobCalculatorPlugin; // cannot be injected : HistoryBrowser uses different instance
private final TreatmentsPlugin treatmentsPlugin; // cannot be injected : HistoryBrowser uses different instance
private boolean bgDataReload; private boolean bgDataReload;
private boolean limitDataToOldestAvailable; private boolean limitDataToOldestAvailable;
private String from; private String from;
@ -76,11 +77,12 @@ public class IobCobThread extends Thread {
private PowerManager.WakeLock mWakeLock; private PowerManager.WakeLock mWakeLock;
@Inject IobCobThread(HasAndroidInjector injector, IobCobCalculatorPlugin iobCobCalculatorPlugin, String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) { @Inject IobCobThread(HasAndroidInjector injector, IobCobCalculatorPlugin iobCobCalculatorPlugin, TreatmentsPlugin treatmentsPlugin, String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) {
super(); super();
injector.androidInjector().inject(this); injector.androidInjector().inject(this);
this.injector = injector; this.injector = injector;
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin; this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
this.treatmentsPlugin = treatmentsPlugin;
this.bgDataReload = bgDataReload; this.bgDataReload = bgDataReload;
this.limitDataToOldestAvailable = limitDataToOldestAvailable; this.limitDataToOldestAvailable = limitDataToOldestAvailable;
@ -239,7 +241,7 @@ public class IobCobThread extends Thread {
} }
} }
List<Treatment> recentCarbTreatments = activePluginProvider.getActiveTreatments().getCarbTreatments5MinBackFromHistory(bgTime); List<Treatment> recentCarbTreatments = treatmentsPlugin.getCarbTreatments5MinBackFromHistory(bgTime);
for (Treatment recentCarbTreatment : recentCarbTreatments) { for (Treatment recentCarbTreatment : recentCarbTreatments) {
autosensData.carbsFromBolus += recentCarbTreatment.carbs; autosensData.carbsFromBolus += recentCarbTreatment.carbs;
boolean isAAPSOrWeighted = sensitivityAAPSPlugin.isEnabled() || sensitivityWeightedAveragePlugin.isEnabled(); boolean isAAPSOrWeighted = sensitivityAAPSPlugin.isEnabled() || sensitivityWeightedAveragePlugin.isEnabled();

View file

@ -55,7 +55,7 @@ class RandomBgPlugin @Inject constructor(
} }
override fun advancedFilteringSupported(): Boolean { override fun advancedFilteringSupported(): Boolean {
return false return true
} }
override fun onStart() { override fun onStart() {
@ -69,7 +69,7 @@ class RandomBgPlugin @Inject constructor(
} }
override fun specialEnableCondition(): Boolean { override fun specialEnableCondition(): Boolean {
return isRunningTest() || virtualPumpPlugin.isEnabled(PluginType.PUMP) && buildHelper.isEngineeringMode() return true //isRunningTest() || virtualPumpPlugin.isEnabled(PluginType.PUMP) && buildHelper.isEngineeringMode()
} }
override fun handleNewData(intent: Intent) { override fun handleNewData(intent: Intent) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB