diff --git a/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSSMBDynamicISF/OpenAPSSMBDynamicISFPlugin.kt b/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSSMBDynamicISF/OpenAPSSMBDynamicISFPlugin.kt index fcf0a249ef..60b120c0c0 100644 --- a/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSSMBDynamicISF/OpenAPSSMBDynamicISFPlugin.kt +++ b/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSSMBDynamicISF/OpenAPSSMBDynamicISFPlugin.kt @@ -6,6 +6,7 @@ import app.aaps.core.interfaces.aps.DetermineBasalAdapter import app.aaps.core.interfaces.bgQualityCheck.BgQualityCheck import app.aaps.core.interfaces.constraints.Constraint import app.aaps.core.interfaces.constraints.ConstraintsChecker +import app.aaps.core.interfaces.constraints.Objectives import app.aaps.core.interfaces.iob.GlucoseStatusProvider import app.aaps.core.interfaces.iob.IobCobCalculator import app.aaps.core.interfaces.logging.AAPSLogger @@ -50,7 +51,8 @@ class OpenAPSSMBDynamicISFPlugin @Inject constructor( glucoseStatusProvider: GlucoseStatusProvider, bgQualityCheck: BgQualityCheck, tddCalculator: TddCalculator, - private val uiInteraction: UiInteraction + private val uiInteraction: UiInteraction, + private val objectives: Objectives ) : OpenAPSSMBPlugin( injector, aapsLogger, @@ -80,6 +82,9 @@ class OpenAPSSMBDynamicISFPlugin @Inject constructor( .setDefault(false) } + override fun specialEnableCondition(): Boolean = + objectives.isStarted(Objectives.DYN_ISF_OBJECTIVE) + // If there is no TDD data fallback to SMB as ISF calculation may be really off override fun provideDetermineBasalAdapter(): DetermineBasalAdapter = if (tdd1D == null || tdd7D == null || tddLast4H == null || tddLast8to4H == null || tddLast24H == null || !dynIsfEnabled.value()) { diff --git a/plugins/constraints/src/main/kotlin/app/aaps/plugins/constraints/di/PluginsConstraintsModule.kt b/plugins/constraints/src/main/kotlin/app/aaps/plugins/constraints/di/PluginsConstraintsModule.kt index 2893e33526..3b9078ac7f 100644 --- a/plugins/constraints/src/main/kotlin/app/aaps/plugins/constraints/di/PluginsConstraintsModule.kt +++ b/plugins/constraints/src/main/kotlin/app/aaps/plugins/constraints/di/PluginsConstraintsModule.kt @@ -2,11 +2,13 @@ package app.aaps.plugins.constraints.di import app.aaps.core.interfaces.bgQualityCheck.BgQualityCheck import app.aaps.core.interfaces.constraints.ConstraintsChecker +import app.aaps.core.interfaces.constraints.Objectives import app.aaps.core.interfaces.versionChecker.VersionCheckerUtils import dagger.Binds import dagger.Module import app.aaps.plugins.constraints.ConstraintsCheckerImpl import app.aaps.plugins.constraints.bgQualityCheck.BgQualityCheckPlugin +import app.aaps.plugins.constraints.objectives.ObjectivesPlugin import app.aaps.plugins.constraints.versionChecker.VersionCheckerUtilsImpl @Module( @@ -25,5 +27,6 @@ abstract class PluginsConstraintsModule { @Binds fun bindVersionCheckerUtils(versionCheckerUtils: VersionCheckerUtilsImpl): VersionCheckerUtils @Binds fun bindBgQualityCheck(bgQualityCheck: BgQualityCheckPlugin): BgQualityCheck @Binds fun bindsConstraintChecker(constraintsCheckerImpl: ConstraintsCheckerImpl): ConstraintsChecker + @Binds fun bindsObjectives(objectivesPlugin: ObjectivesPlugin): Objectives } } \ No newline at end of file diff --git a/plugins/constraints/src/main/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPlugin.kt b/plugins/constraints/src/main/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPlugin.kt index de159b20f2..2430e4bcdf 100644 --- a/plugins/constraints/src/main/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPlugin.kt +++ b/plugins/constraints/src/main/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPlugin.kt @@ -58,11 +58,9 @@ class ObjectivesPlugin @Inject constructor( var objectives: MutableList = ArrayList() - public override fun onStart() { - super.onStart() + init { setupObjectives() } - override fun specialEnableCondition(): Boolean = activePlugin.activePump.pumpDescription.isTempBasalCapable diff --git a/plugins/constraints/src/test/kotlin/app/aaps/plugins/constraints/ConstraintsCheckerImplTest.kt b/plugins/constraints/src/test/kotlin/app/aaps/plugins/constraints/ConstraintsCheckerImplTest.kt index 58bd58cb4c..7cd8932f79 100644 --- a/plugins/constraints/src/test/kotlin/app/aaps/plugins/constraints/ConstraintsCheckerImplTest.kt +++ b/plugins/constraints/src/test/kotlin/app/aaps/plugins/constraints/ConstraintsCheckerImplTest.kt @@ -138,6 +138,7 @@ class ConstraintsCheckerImplTest : TestBaseWithProfile() { insightDbHelper = InsightDbHelper(insightDatabaseDao) danaPump = DanaPump(aapsLogger, sp, dateUtil, instantiator, decimalFormatter) objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, rh, activePlugin, sp, config) + objectivesPlugin.onStart() comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, rh, profileFunction, sp, commandQueue, pumpSync, dateUtil, ruffyScripter, uiInteraction) danaRPlugin = DanaRPlugin( injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync, @@ -189,7 +190,8 @@ class ConstraintsCheckerImplTest : TestBaseWithProfile() { glucoseStatusProvider, bgQualityCheck, tddCalculator, - uiInteraction + uiInteraction, + objectivesPlugin ) openAPSAMAPlugin = OpenAPSAMAPlugin(