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 abstract fun bindLocalProfilePlugin(plugin: LocalProfilePlugin): PluginBase
@Binds @Binds
@APS @AllConfigs
@IntoMap @IntoMap
@IntKey(250) @IntKey(250)
abstract fun bindAutomationPlugin(plugin: AutomationPlugin): PluginBase abstract fun bindAutomationPlugin(plugin: AutomationPlugin): PluginBase

View file

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