ConstriantsInterface rename
This commit is contained in:
parent
8ecc02c994
commit
176fc4bb47
17 changed files with 71 additions and 58 deletions
|
@ -55,7 +55,7 @@ open class OpenAPSSMBPlugin @Inject constructor(
|
||||||
.description(R.string.description_smb)
|
.description(R.string.description_smb)
|
||||||
.setDefault(),
|
.setDefault(),
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
), APS, ConstraintsInterface {
|
), APS, Constraints {
|
||||||
|
|
||||||
// last values
|
// last values
|
||||||
override var lastAPSRun: Long = 0
|
override var lastAPSRun: Long = 0
|
||||||
|
|
|
@ -33,7 +33,7 @@ class DstHelperPlugin @Inject constructor(
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.pluginName(R.string.dst_plugin_name),
|
.pluginName(R.string.dst_plugin_name),
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
), ConstraintsInterface {
|
), Constraints {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val DISABLE_TIME_FRAME_HOURS = -3
|
private const val DISABLE_TIME_FRAME_HOURS = -3
|
||||||
|
|
|
@ -41,7 +41,7 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
.shortName(R.string.objectives_shortname)
|
.shortName(R.string.objectives_shortname)
|
||||||
.description(R.string.description_objectives),
|
.description(R.string.description_objectives),
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
), ConstraintsInterface {
|
), Constraints {
|
||||||
|
|
||||||
var objectives: MutableList<Objective> = ArrayList()
|
var objectives: MutableList<Objective> = ArrayList()
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import android.os.Build
|
||||||
import com.scottyab.rootbeer.RootBeer
|
import com.scottyab.rootbeer.RootBeer
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface
|
import info.nightscout.androidaps.interfaces.Constraints
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
@ -27,7 +27,7 @@ class PhoneCheckerPlugin @Inject constructor(
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.pluginName(R.string.phonechecker),
|
.pluginName(R.string.phonechecker),
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
), ConstraintsInterface {
|
), Constraints {
|
||||||
|
|
||||||
var phoneRooted: Boolean = false
|
var phoneRooted: Boolean = false
|
||||||
var devMode: Boolean = false
|
var devMode: Boolean = false
|
||||||
|
|
|
@ -49,7 +49,7 @@ class SafetyPlugin @Inject constructor(
|
||||||
.pluginName(R.string.safety)
|
.pluginName(R.string.safety)
|
||||||
.preferencesId(R.xml.pref_safety),
|
.preferencesId(R.xml.pref_safety),
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
), ConstraintsInterface {
|
), Constraints {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constraints interface
|
* Constraints interface
|
||||||
|
|
|
@ -5,7 +5,7 @@ import android.content.pm.PackageManager
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface
|
import info.nightscout.androidaps.interfaces.Constraints
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
@ -46,7 +46,7 @@ class SignatureVerifierPlugin @Inject constructor(
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.pluginName(R.string.signature_verifier),
|
.pluginName(R.string.signature_verifier),
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
), ConstraintsInterface {
|
), Constraints {
|
||||||
|
|
||||||
private val REVOKED_CERTS_URL = "https://raw.githubusercontent.com/nightscout/AndroidAPS/master/app/src/main/assets/revoked_certs.txt"
|
private val REVOKED_CERTS_URL = "https://raw.githubusercontent.com/nightscout/AndroidAPS/master/app/src/main/assets/revoked_certs.txt"
|
||||||
private val UPDATE_INTERVAL = TimeUnit.DAYS.toMillis(1)
|
private val UPDATE_INTERVAL = TimeUnit.DAYS.toMillis(1)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface
|
import info.nightscout.androidaps.interfaces.Constraints
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
@ -33,7 +33,7 @@ open class StorageConstraintPlugin @Inject constructor(
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.pluginName(R.string.storage),
|
.pluginName(R.string.storage),
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
), ConstraintsInterface {
|
), Constraints {
|
||||||
|
|
||||||
override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
val diskFree = availableInternalMemorySize()
|
val diskFree = availableInternalMemorySize()
|
||||||
|
|
|
@ -4,7 +4,7 @@ import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.BuildConfig
|
import info.nightscout.androidaps.BuildConfig
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface
|
import info.nightscout.androidaps.interfaces.Constraints
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
@ -35,7 +35,7 @@ class VersionCheckerPlugin @Inject constructor(
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.pluginName(R.string.versionChecker),
|
.pluginName(R.string.versionChecker),
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
), ConstraintsInterface {
|
), Constraints {
|
||||||
|
|
||||||
enum class GracePeriod(val warning: Long, val old: Long, val veryOld: Long) {
|
enum class GracePeriod(val warning: Long, val old: Long, val veryOld: Long) {
|
||||||
RELEASE(30, 60, 90),
|
RELEASE(30, 60, 90),
|
||||||
|
|
|
@ -156,7 +156,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
constraintsPluginsList.add(danaRSPlugin)
|
constraintsPluginsList.add(danaRSPlugin)
|
||||||
constraintsPluginsList.add(insightPlugin)
|
constraintsPluginsList.add(insightPlugin)
|
||||||
constraintsPluginsList.add(openAPSSMBPlugin)
|
constraintsPluginsList.add(openAPSSMBPlugin)
|
||||||
`when`(activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)).thenReturn(constraintsPluginsList)
|
`when`(activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)).thenReturn(constraintsPluginsList)
|
||||||
objectivesPlugin.onStart()
|
objectivesPlugin.onStart()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.Constraints;
|
||||||
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
|
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
@ -72,7 +72,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ComboPlugin extends PumpPluginBase implements PumpInterface, ConstraintsInterface {
|
public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constraints {
|
||||||
static final String COMBO_TBRS_SET = "combo_tbrs_set";
|
static final String COMBO_TBRS_SET = "combo_tbrs_set";
|
||||||
static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered";
|
static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered";
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,17 @@ package info.nightscout.androidaps.interfaces
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 15.06.2016.
|
* Constraints interface
|
||||||
|
*
|
||||||
|
* Every function has a param from previous chained call
|
||||||
|
* Function can limit the value even more and add another reason of restriction
|
||||||
|
*
|
||||||
|
* see [info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker]
|
||||||
|
* which iterates over all registered plugins with [Constraints] implemented
|
||||||
|
*
|
||||||
|
* @return updated parameter
|
||||||
*/
|
*/
|
||||||
interface ConstraintsInterface {
|
interface Constraints {
|
||||||
|
|
||||||
@JvmDefault fun isLoopInvocationAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
|
@JvmDefault fun isLoopInvocationAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
|
||||||
@JvmDefault fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
|
@JvmDefault fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
|
|
@ -1,5 +1,10 @@
|
||||||
package info.nightscout.androidaps.interfaces
|
package info.nightscout.androidaps.interfaces
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main plugin type
|
||||||
|
*
|
||||||
|
* set by [info.nightscout.androidaps.interfaces.PluginDescription.mainType]
|
||||||
|
*/
|
||||||
enum class PluginType {
|
enum class PluginType {
|
||||||
GENERAL, TREATMENT, SENSITIVITY, PROFILE, APS, PUMP, CONSTRAINTS, LOOP, BGSOURCE, INSULIN
|
GENERAL, TREATMENT, SENSITIVITY, PROFILE, APS, PUMP, CONSTRAINTS, LOOP, BGSOURCE, INSULIN
|
||||||
}
|
}
|
|
@ -4,13 +4,13 @@ import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface
|
import info.nightscout.androidaps.interfaces.Constraints
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlugin) : ConstraintsInterface {
|
class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlugin) : Constraints {
|
||||||
|
|
||||||
fun isLoopInvocationAllowed(): Constraint<Boolean> =
|
fun isLoopInvocationAllowed(): Constraint<Boolean> =
|
||||||
isLoopInvocationAllowed(Constraint(true))
|
isLoopInvocationAllowed(Constraint(true))
|
||||||
|
@ -61,9 +61,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
isAutomationEnabled(Constraint(true))
|
isAutomationEnabled(Constraint(true))
|
||||||
|
|
||||||
override fun isLoopInvocationAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isLoopInvocationAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constraint = p as ConstraintsInterface
|
val constraint = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constraint.isLoopInvocationAllowed(value)
|
constraint.isLoopInvocationAllowed(value)
|
||||||
}
|
}
|
||||||
|
@ -71,9 +71,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constraint = p as ConstraintsInterface
|
val constraint = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constraint.isClosedLoopAllowed(value)
|
constraint.isClosedLoopAllowed(value)
|
||||||
}
|
}
|
||||||
|
@ -81,9 +81,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isLgsAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isLgsAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constraint = p as ConstraintsInterface
|
val constraint = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constraint.isLgsAllowed(value)
|
constraint.isLgsAllowed(value)
|
||||||
}
|
}
|
||||||
|
@ -91,9 +91,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constraint = p as ConstraintsInterface
|
val constraint = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constraint.isAutosensModeEnabled(value)
|
constraint.isAutosensModeEnabled(value)
|
||||||
}
|
}
|
||||||
|
@ -101,9 +101,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isAMAModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isAMAModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constrain = p as ConstraintsInterface
|
val constrain = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constrain.isAMAModeEnabled(value)
|
constrain.isAMAModeEnabled(value)
|
||||||
}
|
}
|
||||||
|
@ -111,9 +111,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constraint = p as ConstraintsInterface
|
val constraint = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constraint.isSMBModeEnabled(value)
|
constraint.isSMBModeEnabled(value)
|
||||||
}
|
}
|
||||||
|
@ -121,9 +121,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isUAMEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isUAMEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constraint = p as ConstraintsInterface
|
val constraint = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constraint.isUAMEnabled(value)
|
constraint.isUAMEnabled(value)
|
||||||
}
|
}
|
||||||
|
@ -131,9 +131,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isAdvancedFilteringEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isAdvancedFilteringEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constraint = p as ConstraintsInterface
|
val constraint = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constraint.isAdvancedFilteringEnabled(value)
|
constraint.isAdvancedFilteringEnabled(value)
|
||||||
}
|
}
|
||||||
|
@ -141,9 +141,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isSuperBolusEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isSuperBolusEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constraint = p as ConstraintsInterface
|
val constraint = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constraint.isSuperBolusEnabled(value)
|
constraint.isSuperBolusEnabled(value)
|
||||||
}
|
}
|
||||||
|
@ -151,9 +151,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun applyBasalConstraints(absoluteRate: Constraint<Double>, profile: Profile): Constraint<Double> {
|
override fun applyBasalConstraints(absoluteRate: Constraint<Double>, profile: Profile): Constraint<Double> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constraint = p as ConstraintsInterface
|
val constraint = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constraint.applyBasalConstraints(absoluteRate, profile)
|
constraint.applyBasalConstraints(absoluteRate, profile)
|
||||||
}
|
}
|
||||||
|
@ -161,9 +161,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun applyBasalPercentConstraints(percentRate: Constraint<Int>, profile: Profile): Constraint<Int> {
|
override fun applyBasalPercentConstraints(percentRate: Constraint<Int>, profile: Profile): Constraint<Int> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constrain = p as ConstraintsInterface
|
val constrain = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constrain.applyBasalPercentConstraints(percentRate, profile)
|
constrain.applyBasalPercentConstraints(percentRate, profile)
|
||||||
}
|
}
|
||||||
|
@ -171,9 +171,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun applyBolusConstraints(insulin: Constraint<Double>): Constraint<Double> {
|
override fun applyBolusConstraints(insulin: Constraint<Double>): Constraint<Double> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constrain = p as ConstraintsInterface
|
val constrain = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constrain.applyBolusConstraints(insulin)
|
constrain.applyBolusConstraints(insulin)
|
||||||
}
|
}
|
||||||
|
@ -181,9 +181,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun applyExtendedBolusConstraints(insulin: Constraint<Double>): Constraint<Double> {
|
override fun applyExtendedBolusConstraints(insulin: Constraint<Double>): Constraint<Double> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constrain = p as ConstraintsInterface
|
val constrain = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constrain.applyExtendedBolusConstraints(insulin)
|
constrain.applyExtendedBolusConstraints(insulin)
|
||||||
}
|
}
|
||||||
|
@ -191,9 +191,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun applyCarbsConstraints(carbs: Constraint<Int>): Constraint<Int> {
|
override fun applyCarbsConstraints(carbs: Constraint<Int>): Constraint<Int> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constrain = p as ConstraintsInterface
|
val constrain = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constrain.applyCarbsConstraints(carbs)
|
constrain.applyCarbsConstraints(carbs)
|
||||||
}
|
}
|
||||||
|
@ -201,9 +201,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> {
|
override fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constrain = p as ConstraintsInterface
|
val constrain = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constrain.applyMaxIOBConstraints(maxIob)
|
constrain.applyMaxIOBConstraints(maxIob)
|
||||||
}
|
}
|
||||||
|
@ -211,9 +211,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isAutomationEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isAutomationEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
val constraint = p as ConstraintsInterface
|
val constraint = p as Constraints
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
constraint.isAutomationEnabled(value)
|
constraint.isAutomationEnabled(value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import info.nightscout.androidaps.extensions.PumpStateExtensionKt;
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin;
|
import info.nightscout.androidaps.interfaces.ActivePlugin;
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.Constraints;
|
||||||
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
@ -46,7 +46,7 @@ import io.reactivex.disposables.CompositeDisposable;
|
||||||
* Created by mike on 28.01.2018.
|
* Created by mike on 28.01.2018.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class AbstractDanaRPlugin extends PumpPluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface {
|
public abstract class AbstractDanaRPlugin extends PumpPluginBase implements PumpInterface, DanaRInterface, Constraints {
|
||||||
protected AbstractDanaRExecutionService sExecutionService;
|
protected AbstractDanaRExecutionService sExecutionService;
|
||||||
|
|
||||||
protected CompositeDisposable disposable = new CompositeDisposable();
|
protected CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
|
@ -71,7 +71,7 @@ class DanaRSPlugin @Inject constructor(
|
||||||
.preferencesId(R.xml.pref_danars)
|
.preferencesId(R.xml.pref_danars)
|
||||||
.description(R.string.description_pump_dana_rs),
|
.description(R.string.description_pump_dana_rs),
|
||||||
injector, aapsLogger, resourceHelper, commandQueue
|
injector, aapsLogger, resourceHelper, commandQueue
|
||||||
), PumpInterface, DanaRInterface, ConstraintsInterface {
|
), PumpInterface, DanaRInterface, Constraints {
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
private var danaRSService: DanaRSService? = null
|
private var danaRSService: DanaRSService? = null
|
||||||
|
|
|
@ -46,7 +46,7 @@ import info.nightscout.androidaps.insight.R;
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||||
import info.nightscout.androidaps.interfaces.Config;
|
import info.nightscout.androidaps.interfaces.Config;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.Constraints;
|
||||||
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
|
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
@ -138,7 +138,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, ConstraintsInterface, InsightConnectionService.StateCallback {
|
public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, Constraints, InsightConnectionService.StateCallback {
|
||||||
|
|
||||||
private final AAPSLogger aapsLogger;
|
private final AAPSLogger aapsLogger;
|
||||||
private final RxBusWrapper rxBus;
|
private final RxBusWrapper rxBus;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import info.nightscout.androidaps.events.EventCustomActionsChanged;
|
||||||
import info.nightscout.androidaps.extensions.PumpStateExtensionKt;
|
import info.nightscout.androidaps.extensions.PumpStateExtensionKt;
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin;
|
import info.nightscout.androidaps.interfaces.ActivePlugin;
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.Constraints;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
@ -50,7 +50,7 @@ import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
// When using this class, make sure that your first step is to create mConnection (see MedtronicPumpPlugin)
|
// When using this class, make sure that your first step is to create mConnection (see MedtronicPumpPlugin)
|
||||||
|
|
||||||
public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpInterface, ConstraintsInterface {
|
public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpInterface, Constraints {
|
||||||
private final CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
protected HasAndroidInjector injector;
|
protected HasAndroidInjector injector;
|
||||||
|
|
Loading…
Reference in a new issue