fix bolus advisor for nsclient

This commit is contained in:
Milos Kozak 2021-01-20 21:03:45 +01:00
parent ad2f2e18b4
commit 8801c28176
2 changed files with 18 additions and 11 deletions

View file

@ -205,7 +205,7 @@ abstract class PluginsModule {
abstract fun bindLocalProfilePlugin(plugin: LocalProfilePlugin): PluginBase
@Binds
@APS
@AllConfigs
@IntoMap
@IntKey(250)
abstract fun bindAutomationPlugin(plugin: AutomationPlugin): PluginBase

View file

@ -5,6 +5,7 @@ import android.os.Handler
import android.os.HandlerThread
import android.os.SystemClock
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventBTChange
import info.nightscout.androidaps.events.EventChargingState
@ -53,6 +54,7 @@ class AutomationPlugin @Inject constructor(
private val rxBus: RxBusWrapper,
private val constraintChecker: ConstraintChecker,
aapsLogger: AAPSLogger,
private val config: Config,
private val locationServiceHelper: LocationServiceHelper,
private val dateUtil: DateUtil
) : PluginBase(PluginDescription()
@ -61,6 +63,9 @@ class AutomationPlugin @Inject constructor(
.pluginIcon(R.drawable.ic_automation)
.pluginName(R.string.automation)
.shortName(R.string.automation_short)
.showInList(config.APS)
.neverVisible(!config.APS)
.alwaysEnabled(!config.APS)
.preferencesId(R.xml.pref_automation)
.description(R.string.automation_description),
aapsLogger, resourceHelper, injector
@ -180,16 +185,18 @@ class AutomationPlugin @Inject constructor(
@Synchronized
private fun processActions() {
var userEventsEnabled = true
if (loopPlugin.isSuspended || !loopPlugin.isEnabled()) {
aapsLogger.debug(LTag.AUTOMATION, "Loop deactivated")
executionLog.add(resourceHelper.gs(R.string.smscommunicator_loopisdisabled))
userEventsEnabled = false
}
val enabled = constraintChecker.isAutomationEnabled()
if (!enabled.value()) {
executionLog.add(enabled.getMostLimitedReasons(aapsLogger))
userEventsEnabled = false
var userEventsEnabled = config.APS
if (config.APS) {
if (loopPlugin.isSuspended || !loopPlugin.isEnabled()) {
aapsLogger.debug(LTag.AUTOMATION, "Loop deactivated")
executionLog.add(resourceHelper.gs(R.string.smscommunicator_loopisdisabled))
userEventsEnabled = false
}
val enabled = constraintChecker.isAutomationEnabled()
if (!enabled.value()) {
executionLog.add(enabled.getMostLimitedReasons(aapsLogger))
userEventsEnabled = false
}
}
aapsLogger.debug(LTag.AUTOMATION, "processActions")