diff --git a/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSAutoISF/DetermineBasalAutoISF.kt b/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSAutoISF/DetermineBasalAutoISF.kt index e145fa15fb1c..6aa1e57c800e 100644 --- a/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSAutoISF/DetermineBasalAutoISF.kt +++ b/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSAutoISF/DetermineBasalAutoISF.kt @@ -389,13 +389,17 @@ class DetermineBasalAutoISF @Inject constructor( // min_bg of 90 -> threshold of 65, 100 -> 70 110 -> 75, and 130 -> 85 var threshold = min_bg - 0.5 * (min_bg - 40) - // if (profile.lgsThreshold != null) { - // val lgsThreshold = profile.lgsThreshold ?: error("lgsThreshold missing") - // if (lgsThreshold > threshold) { - // consoleError.add("Threshold set from ${convert_bg(threshold)} to ${convert_bg(lgsThreshold.toDouble())}; ") - // threshold = lgsThreshold.toDouble() - // } - // } + // Honour the user's Low Glucose Suspend threshold preference. Mainline ships this block + // commented out in the autoISF plugin (DetermineBasalSMB.kt keeps it active), so the + // lgsThreshold setting is silently inert whenever autoISF is the active APS. Re-enabled so + // the pref can raise the suspend floor above the target-derived default. + if (profile.lgsThreshold != null) { + val lgsThreshold = profile.lgsThreshold ?: error("lgsThreshold missing") + if (lgsThreshold > threshold) { + consoleError.add("Threshold set from ${convert_bg(threshold)} to ${convert_bg(lgsThreshold.toDouble())}; ") + threshold = lgsThreshold.toDouble() + } + } //console.error(reservoir_data); 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 fc45caa6787d..bb1df552148d 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 @@ -106,10 +106,10 @@ class ObjectivesPlugin @Inject constructor( } override fun isSMBModeEnabled(value: Constraint): Constraint { - // Check if initialized - if (objectives.isEmpty()) return value - if (!objectives[SMB_OBJECTIVE].isStarted) - value.set(false, rh.gs(R.string.objectivenotstarted, SMB_OBJECTIVE + 1), this) + // Objectives SMB gate removed for this build: the operator has run SMB on this loop before + // and does not need the progression re-walked after a device/build change. SMB is still + // gated by closed-loop (SafetyPlugin) and the use_smb preference, so this only drops the + // objective-progression requirement, not the real safety checks. return value } diff --git a/plugins/constraints/src/test/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPluginTest.kt b/plugins/constraints/src/test/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPluginTest.kt index 8cfd64312243..97786b8ebb93 100644 --- a/plugins/constraints/src/test/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPluginTest.kt +++ b/plugins/constraints/src/test/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPluginTest.kt @@ -98,10 +98,12 @@ class ObjectivesPluginTest : TestBaseWithProfile() { assertThat(c.value()).isFalse() } - @Test fun notStartedObjective10ShouldLimitSMBMode() { + @Test fun smbModeIsNotGatedByObjective() { + // The Objectives SMB gate was intentionally removed for this build (operator has run SMB + // before). An unstarted SMB objective must NOT disable SMB mode here; closed-loop and the + // use_smb preference remain the real gates elsewhere. objectivesPlugin.objectives[Objectives.SMB_OBJECTIVE].startedOn = 0 val c = objectivesPlugin.isSMBModeEnabled(ConstraintObject(true, aapsLogger)) - assertThat(c.getReasons()).contains("Objective 9 not started") - assertThat(c.value()).isFalse() + assertThat(c.value()).isTrue() } }