Do not allow select DynISF without objective started

This commit is contained in:
Milos Kozak 2023-11-08 13:21:02 +01:00
parent 8070cac850
commit b5e00f9c1d
4 changed files with 13 additions and 5 deletions

View file

@ -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()) {

View file

@ -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
}
}

View file

@ -58,11 +58,9 @@ class ObjectivesPlugin @Inject constructor(
var objectives: MutableList<Objective> = ArrayList()
public override fun onStart() {
super.onStart()
init {
setupObjectives()
}
override fun specialEnableCondition(): Boolean =
activePlugin.activePump.pumpDescription.isTempBasalCapable

View file

@ -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(