Merge pull request #398 from Tornado-Tim/fix-LGS-constraint

Fix Low Glucose Constraint
This commit is contained in:
Milos Kozak 2021-03-07 18:20:22 +01:00 committed by GitHub
commit 9345276f94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,6 +18,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
fun isClosedLoopAllowed(): Constraint<Boolean> =
isClosedLoopAllowed(Constraint(true))
fun isLgsAllowed(): Constraint<Boolean> =
isLgsAllowed(Constraint(true))
fun isAutosensModeEnabled(): Constraint<Boolean> =
isAutosensModeEnabled(Constraint(true))
@ -77,6 +80,16 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
return value
}
override fun isLgsAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
for (p in constraintsPlugins) {
val constraint = p as ConstraintsInterface
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
constraint.isLgsAllowed(value)
}
return value
}
override fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
for (p in constraintsPlugins) {