This commit is contained in:
Milos Kozak 2021-02-16 13:49:03 +01:00
commit 0a31d79e29
4 changed files with 25 additions and 85 deletions

View file

@ -22,7 +22,6 @@ import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin
import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.ToastUtils
@ -42,7 +41,6 @@ class LoopDialog : DaggerDialogFragment() {
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var loopPlugin: LoopPlugin @Inject lateinit var loopPlugin: LoopPlugin
@Inject lateinit var objectivesPlugin: ObjectivesPlugin
@Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var activePlugin: ActivePluginProvider
@Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var commandQueue: CommandQueueProvider @Inject lateinit var commandQueue: CommandQueueProvider
@ -107,7 +105,7 @@ class LoopDialog : DaggerDialogFragment() {
binding.cancel.setOnClickListener { dismiss() } binding.cancel.setOnClickListener { dismiss() }
refreshDialog = Runnable { refreshDialog = Runnable {
scheduleUpdateGUI("refreshDialog") scheduleUpdateGUI()
loopHandler.postDelayed(refreshDialog, 15 * 1000L) loopHandler.postDelayed(refreshDialog, 15 * 1000L)
} }
loopHandler.postDelayed(refreshDialog, 15 * 1000L) loopHandler.postDelayed(refreshDialog, 15 * 1000L)
@ -122,11 +120,11 @@ class LoopDialog : DaggerDialogFragment() {
var task: Runnable? = null var task: Runnable? = null
private fun scheduleUpdateGUI(from: String) { private fun scheduleUpdateGUI() {
class UpdateRunnable : Runnable { class UpdateRunnable : Runnable {
override fun run() { override fun run() {
updateGUI(from) updateGUI("refreshDialog")
task = null task = null
} }
} }
@ -140,8 +138,8 @@ class LoopDialog : DaggerDialogFragment() {
if (_binding == null) return if (_binding == null) return
aapsLogger.debug("UpdateGUI from $from") aapsLogger.debug("UpdateGUI from $from")
val pumpDescription: PumpDescription = activePlugin.activePump.pumpDescription val pumpDescription: PumpDescription = activePlugin.activePump.pumpDescription
val closedLoopAllowed = objectivesPlugin.isClosedLoopAllowed(Constraint(true)) val closedLoopAllowed = constraintChecker.isClosedLoopAllowed(Constraint(true))
val lgsEnabled = objectivesPlugin.isLgsAllowed(Constraint(true)) val lgsEnabled = constraintChecker.isLgsAllowed(Constraint(true))
val apsMode = sp.getString(R.string.key_aps_mode, "open") val apsMode = sp.getString(R.string.key_aps_mode, "open")
if (profileFunction.isProfileValid("LoopDialogUpdateGUI")) { if (profileFunction.isProfileValid("LoopDialogUpdateGUI")) {
if (loopPlugin.isEnabled(PluginType.LOOP)) { if (loopPlugin.isEnabled(PluginType.LOOP)) {

View file

@ -165,7 +165,7 @@ class ObjectivesPlugin @Inject constructor(
return value return value
} }
fun isLgsAllowed(value: Constraint<Boolean>): Constraint<Boolean> { override fun isLgsAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[MAXBASAL_OBJECTIVE].isStarted) if (!objectives[MAXBASAL_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), MAXBASAL_OBJECTIVE + 1), this) value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), MAXBASAL_OBJECTIVE + 1), this)
return value return value

View file

@ -46,9 +46,9 @@ public class Constants {
public static final int defaultEatingSoonTTDuration = 45; // min public static final int defaultEatingSoonTTDuration = 45; // min
public static final double defaultEatingSoonTTmgdl = 90d; public static final double defaultEatingSoonTTmgdl = 90d;
public static final double defaultEatingSoonTTmmol = 5d; public static final double defaultEatingSoonTTmmol = 5d;
public static final int defaultHypoTTDuration = 30; // min public static final int defaultHypoTTDuration = 60; // min
public static final double defaultHypoTTmgdl = 120d; public static final double defaultHypoTTmgdl = 160d;
public static final double defaultHypoTTmmol = 6.5d; public static final double defaultHypoTTmmol = 8d;
public static final double MIN_TT_MGDL = 72d; public static final double MIN_TT_MGDL = 72d;
public static final double MAX_TT_MGDL = 180d; public static final double MAX_TT_MGDL = 180d;

View file

@ -7,78 +7,20 @@ import info.nightscout.androidaps.data.Profile
*/ */
interface ConstraintsInterface { interface ConstraintsInterface {
@JvmDefault @JvmDefault fun isLoopInvocationAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isLoopInvocationAllowed(value: Constraint<Boolean>): Constraint<Boolean> { @JvmDefault fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
return value @JvmDefault fun isLgsAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
} @JvmDefault fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
@JvmDefault fun isAMAModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
@JvmDefault @JvmDefault fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> { @JvmDefault fun isUAMEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
return value @JvmDefault fun isAdvancedFilteringEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
} @JvmDefault fun isSuperBolusEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
@JvmDefault fun applyBasalConstraints(absoluteRate: Constraint<Double>, profile: Profile): Constraint<Double> = absoluteRate
@JvmDefault @JvmDefault fun applyBasalPercentConstraints(percentRate: Constraint<Int>, profile: Profile): Constraint<Int> = percentRate
fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> { @JvmDefault fun applyBolusConstraints(insulin: Constraint<Double>): Constraint<Double> = insulin
return value @JvmDefault fun applyExtendedBolusConstraints(insulin: Constraint<Double>): Constraint<Double> = insulin
} @JvmDefault fun applyCarbsConstraints(carbs: Constraint<Int>): Constraint<Int> = carbs
@JvmDefault fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> = maxIob
@JvmDefault @JvmDefault fun isAutomationEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isAMAModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
return value
}
@JvmDefault
fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
return value
}
@JvmDefault
fun isUAMEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
return value
}
@JvmDefault
fun isAdvancedFilteringEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
return value
}
@JvmDefault
fun isSuperBolusEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
return value
}
@JvmDefault
fun applyBasalConstraints(absoluteRate: Constraint<Double>, profile: Profile): Constraint<Double> {
return absoluteRate
}
@JvmDefault
fun applyBasalPercentConstraints(percentRate: Constraint<Int>, profile: Profile): Constraint<Int> {
return percentRate
}
@JvmDefault
fun applyBolusConstraints(insulin: Constraint<Double>): Constraint<Double> {
return insulin
}
@JvmDefault
fun applyExtendedBolusConstraints(insulin: Constraint<Double>): Constraint<Double> {
return insulin
}
@JvmDefault
fun applyCarbsConstraints(carbs: Constraint<Int>): Constraint<Int> {
return carbs
}
@JvmDefault
fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> {
return maxIob
}
@JvmDefault
fun isAutomationEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
return value
}
} }