Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ class ObjectivesPlugin @Inject constructor(
}

override fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
// 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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Loading