finish removing Objective8

This commit is contained in:
Milos Kozak 2021-09-21 15:16:19 +02:00 committed by Andrei Vereha
parent 8184500467
commit 7f24933f4d
7 changed files with 13 additions and 55 deletions

View file

@ -54,9 +54,8 @@ class ObjectivesPlugin @Inject constructor(
const val MAXIOB_ZERO_CL_OBJECTIVE = 5
@Suppress("unused") const val MAXIOB_OBJECTIVE = 6
const val AUTOSENS_OBJECTIVE = 7
const val AMA_OBJECTIVE = 8
const val SMB_OBJECTIVE = 9
const val AUTO_OBJECTIVE = 10
const val SMB_OBJECTIVE = 8
const val AUTO_OBJECTIVE = 9
}
public override fun onStart() {
@ -64,9 +63,8 @@ class ObjectivesPlugin @Inject constructor(
setupObjectives()
}
override fun specialEnableCondition(): Boolean {
return activePlugin.activePump.pumpDescription.isTempBasalCapable
}
override fun specialEnableCondition(): Boolean =
activePlugin.activePump.pumpDescription.isTempBasalCapable
private fun setupObjectives() {
objectives.clear()
@ -80,6 +78,7 @@ class ObjectivesPlugin @Inject constructor(
objectives.add(Objective7(injector))
objectives.add(Objective9(injector))
objectives.add(Objective10(injector))
// edit companion object if you remove/add Objective
}
fun reset() {
@ -115,8 +114,6 @@ class ObjectivesPlugin @Inject constructor(
sp.putLong("Objectives_" + "maxiob" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "autosens" + "_started", dateUtil.now())
sp.putLong("Objectives_" + "autosens" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "ama" + "_started", dateUtil.now())
sp.putLong("Objectives_" + "ama" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "smb" + "_started", dateUtil.now())
sp.putLong("Objectives_" + "smb" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "auto" + "_started", dateUtil.now())
@ -142,49 +139,43 @@ class ObjectivesPlugin @Inject constructor(
*/
override fun isLoopInvocationAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[FIRST_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), FIRST_OBJECTIVE + 1), this)
value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, FIRST_OBJECTIVE + 1), this)
return value
}
override fun isLgsAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[MAXBASAL_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), MAXBASAL_OBJECTIVE + 1), this)
value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, MAXBASAL_OBJECTIVE + 1), this)
return value
}
override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[MAXIOB_ZERO_CL_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), MAXIOB_ZERO_CL_OBJECTIVE + 1), this)
value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, MAXIOB_ZERO_CL_OBJECTIVE + 1), this)
return value
}
override fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[AUTOSENS_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), AUTOSENS_OBJECTIVE + 1), this)
return value
}
override fun isAMAModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[AMA_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), AMA_OBJECTIVE + 1), this)
value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, AUTOSENS_OBJECTIVE + 1), this)
return value
}
override fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[SMB_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), SMB_OBJECTIVE + 1), this)
value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, SMB_OBJECTIVE + 1), this)
return value
}
override fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> {
if (objectives[MAXIOB_ZERO_CL_OBJECTIVE].isStarted && !objectives[MAXIOB_ZERO_CL_OBJECTIVE].isAccomplished)
maxIob.set(aapsLogger, 0.0, String.format(resourceHelper.gs(R.string.objectivenotfinished), MAXIOB_ZERO_CL_OBJECTIVE + 1), this)
maxIob.set(aapsLogger, 0.0, resourceHelper.gs(R.string.objectivenotfinished, MAXIOB_ZERO_CL_OBJECTIVE + 1), this)
return maxIob
}
override fun isAutomationEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[AUTO_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), AUTO_OBJECTIVE + 1), this)
value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, AUTO_OBJECTIVE + 1), this)
return value
}
}

View file

@ -198,16 +198,6 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
Assert.assertEquals(java.lang.Boolean.FALSE, c.value())
}
// Objectives
@Test
fun isAMAModeEnabledTest() {
objectivesPlugin.objectives[ObjectivesPlugin.AMA_OBJECTIVE].startedOn = 0
val c = constraintChecker.isAMAModeEnabled()
Assert.assertEquals(true, c.reasonList.size == 1) // Objectives
Assert.assertEquals(true, c.mostLimitedReasonList.size == 1) // Objectives
Assert.assertEquals(java.lang.Boolean.FALSE, c.value())
}
// Safety
@Test
fun isAdvancedFilteringEnabledTest() {

View file

@ -74,14 +74,6 @@ class ObjectivesPluginTest : TestBase() {
Assert.assertEquals(false, c.value())
}
@Test fun notStartedObjective9ShouldLimitAMAMode() {
objectivesPlugin.objectives[ObjectivesPlugin.AMA_OBJECTIVE].startedOn = 0
var c = Constraint(true)
c = objectivesPlugin.isAMAModeEnabled(c)
Assert.assertEquals(true, c.getReasons(aapsLogger).contains("Objective 9 not started"))
Assert.assertEquals(false, c.value())
}
@Test fun notStartedObjective10ShouldLimitSMBMode() {
objectivesPlugin.objectives[ObjectivesPlugin.SMB_OBJECTIVE].startedOn = 0
var c = Constraint(true)

View file

@ -72,7 +72,6 @@ class AutomationEvent(private val injector: HasAndroidInjector) {
readOnly = d.optBoolean("readOnly", false)
autoRemove = d.optBoolean("autoRemove", false)
trigger = TriggerDummy(injector).instantiate(JSONObject(d.getString("trigger")))
?: TriggerConnector(injector)
val array = d.getJSONArray("actions")
actions.clear()
for (i in 0 until array.length()) {

View file

@ -95,7 +95,7 @@ class TriggerConnector(injector: HasAndroidInjector) : Trigger(injector) {
val array = d.getJSONArray("triggerList")
list.clear()
for (i in 0 until array.length()) {
instantiate(JSONObject(array.getString(i)))?.let {
instantiate(JSONObject(array.getString(i))).let {
list.add(it)
}
}

View file

@ -17,7 +17,6 @@ interface Constraints {
fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isLgsAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isAMAModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isUAMEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isAdvancedFilteringEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value

View file

@ -24,9 +24,6 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
fun isAutosensModeEnabled(): Constraint<Boolean> =
isAutosensModeEnabled(Constraint(true))
fun isAMAModeEnabled(): Constraint<Boolean> =
isAMAModeEnabled(Constraint(true))
fun isSMBModeEnabled(): Constraint<Boolean> =
isSMBModeEnabled(Constraint(true))
@ -100,16 +97,6 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
return value
}
override fun isAMAModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
for (p in constraintsPlugins) {
val constrain = p as Constraints
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
constrain.isAMAModeEnabled(value)
}
return value
}
override fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
for (p in constraintsPlugins) {