From 8d0d8d3866768e5a150d966a2ca621c88772bb04 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 16 Sep 2022 22:08:36 +0200 Subject: [PATCH] show disabled closed reasons --- .../nightscout/androidaps/plugins/aps/loop/LoopFragment.kt | 3 ++- .../nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt | 5 +++-- .../main/java/info/nightscout/androidaps/interfaces/Loop.kt | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopFragment.kt index 49345faff8..400080344a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopFragment.kt @@ -130,13 +130,14 @@ class LoopFragment : DaggerFragment(), MenuProvider { binding.smbsetbypump.text = it.smbSetByPump?.let { smbSetByPump -> HtmlHelper.fromHtml(smbSetByPump.toHtml()) } ?: "" - val constraints = + var constraints = it.constraintsProcessed?.let { constraintsProcessed -> val allConstraints = Constraint(0.0) constraintsProcessed.rateConstraint?.let { rateConstraint -> allConstraints.copyReasons(rateConstraint) } constraintsProcessed.smbConstraint?.let { smbConstraint -> allConstraints.copyReasons(smbConstraint) } allConstraints.getMostLimitedReasons(aapsLogger) } ?: "" + constraints += loop.closedLoopEnabled?.getReasons(aapsLogger) ?: "" binding.constraints.text = constraints binding.swipeRefresh.isRefreshing = false } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt index 4303cb179f..dee30eeec1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt @@ -105,6 +105,7 @@ class LoopPlugin @Inject constructor( private var carbsSuggestionsSuspendedUntil: Long = 0 private var prevCarbsreq = 0 override var lastRun: LastRun? = null + override var closedLoopEnabled: Constraint? = null override fun onStart() { createNotificationChannel() @@ -294,8 +295,8 @@ class LoopPlugin @Inject constructor( rxBus.send(EventLoopSetLastRunGui(rh.gs(R.string.pumpsuspended))) return } - val closedLoopEnabled = constraintChecker.isClosedLoopAllowed() - if (closedLoopEnabled.value()) { + closedLoopEnabled = constraintChecker.isClosedLoopAllowed() + if (closedLoopEnabled?.value() == true) { if (allowNotification) { if (resultAfterConstraints.isCarbsRequired && resultAfterConstraints.carbsReq >= sp.getInt( diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/Loop.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/Loop.kt index fdf44f4661..284cb71ae7 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/Loop.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/Loop.kt @@ -22,6 +22,7 @@ interface Loop { } var lastRun: LastRun? + var closedLoopEnabled: Constraint? val isSuspended: Boolean val isLGS: Boolean val isSuperBolus: Boolean