finish removing Objective8
This commit is contained in:
parent
8184500467
commit
7f24933f4d
7 changed files with 13 additions and 55 deletions
|
@ -54,9 +54,8 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
const val MAXIOB_ZERO_CL_OBJECTIVE = 5
|
const val MAXIOB_ZERO_CL_OBJECTIVE = 5
|
||||||
@Suppress("unused") const val MAXIOB_OBJECTIVE = 6
|
@Suppress("unused") const val MAXIOB_OBJECTIVE = 6
|
||||||
const val AUTOSENS_OBJECTIVE = 7
|
const val AUTOSENS_OBJECTIVE = 7
|
||||||
const val AMA_OBJECTIVE = 8
|
const val SMB_OBJECTIVE = 8
|
||||||
const val SMB_OBJECTIVE = 9
|
const val AUTO_OBJECTIVE = 9
|
||||||
const val AUTO_OBJECTIVE = 10
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override fun onStart() {
|
public override fun onStart() {
|
||||||
|
@ -64,9 +63,8 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
setupObjectives()
|
setupObjectives()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun specialEnableCondition(): Boolean {
|
override fun specialEnableCondition(): Boolean =
|
||||||
return activePlugin.activePump.pumpDescription.isTempBasalCapable
|
activePlugin.activePump.pumpDescription.isTempBasalCapable
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupObjectives() {
|
private fun setupObjectives() {
|
||||||
objectives.clear()
|
objectives.clear()
|
||||||
|
@ -80,6 +78,7 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
objectives.add(Objective7(injector))
|
objectives.add(Objective7(injector))
|
||||||
objectives.add(Objective9(injector))
|
objectives.add(Objective9(injector))
|
||||||
objectives.add(Objective10(injector))
|
objectives.add(Objective10(injector))
|
||||||
|
// edit companion object if you remove/add Objective
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reset() {
|
fun reset() {
|
||||||
|
@ -115,8 +114,6 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
sp.putLong("Objectives_" + "maxiob" + "_accomplished", dateUtil.now())
|
sp.putLong("Objectives_" + "maxiob" + "_accomplished", dateUtil.now())
|
||||||
sp.putLong("Objectives_" + "autosens" + "_started", dateUtil.now())
|
sp.putLong("Objectives_" + "autosens" + "_started", dateUtil.now())
|
||||||
sp.putLong("Objectives_" + "autosens" + "_accomplished", 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" + "_started", dateUtil.now())
|
||||||
sp.putLong("Objectives_" + "smb" + "_accomplished", dateUtil.now())
|
sp.putLong("Objectives_" + "smb" + "_accomplished", dateUtil.now())
|
||||||
sp.putLong("Objectives_" + "auto" + "_started", 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> {
|
override fun isLoopInvocationAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
if (!objectives[FIRST_OBJECTIVE].isStarted)
|
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
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
override 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, resourceHelper.gs(R.string.objectivenotstarted, MAXBASAL_OBJECTIVE + 1), this)
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
if (!objectives[MAXIOB_ZERO_CL_OBJECTIVE].isStarted)
|
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
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
if (!objectives[AUTOSENS_OBJECTIVE].isStarted)
|
if (!objectives[AUTOSENS_OBJECTIVE].isStarted)
|
||||||
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), AUTOSENS_OBJECTIVE + 1), this)
|
value.set(aapsLogger, false, 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)
|
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
if (!objectives[SMB_OBJECTIVE].isStarted)
|
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
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> {
|
override fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> {
|
||||||
if (objectives[MAXIOB_ZERO_CL_OBJECTIVE].isStarted && !objectives[MAXIOB_ZERO_CL_OBJECTIVE].isAccomplished)
|
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
|
return maxIob
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isAutomationEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isAutomationEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
if (!objectives[AUTO_OBJECTIVE].isStarted)
|
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
|
return value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,16 +198,6 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
Assert.assertEquals(java.lang.Boolean.FALSE, c.value())
|
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
|
// Safety
|
||||||
@Test
|
@Test
|
||||||
fun isAdvancedFilteringEnabledTest() {
|
fun isAdvancedFilteringEnabledTest() {
|
||||||
|
|
|
@ -74,14 +74,6 @@ class ObjectivesPluginTest : TestBase() {
|
||||||
Assert.assertEquals(false, c.value())
|
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() {
|
@Test fun notStartedObjective10ShouldLimitSMBMode() {
|
||||||
objectivesPlugin.objectives[ObjectivesPlugin.SMB_OBJECTIVE].startedOn = 0
|
objectivesPlugin.objectives[ObjectivesPlugin.SMB_OBJECTIVE].startedOn = 0
|
||||||
var c = Constraint(true)
|
var c = Constraint(true)
|
||||||
|
|
|
@ -72,7 +72,6 @@ class AutomationEvent(private val injector: HasAndroidInjector) {
|
||||||
readOnly = d.optBoolean("readOnly", false)
|
readOnly = d.optBoolean("readOnly", false)
|
||||||
autoRemove = d.optBoolean("autoRemove", false)
|
autoRemove = d.optBoolean("autoRemove", false)
|
||||||
trigger = TriggerDummy(injector).instantiate(JSONObject(d.getString("trigger")))
|
trigger = TriggerDummy(injector).instantiate(JSONObject(d.getString("trigger")))
|
||||||
?: TriggerConnector(injector)
|
|
||||||
val array = d.getJSONArray("actions")
|
val array = d.getJSONArray("actions")
|
||||||
actions.clear()
|
actions.clear()
|
||||||
for (i in 0 until array.length()) {
|
for (i in 0 until array.length()) {
|
||||||
|
|
|
@ -95,7 +95,7 @@ class TriggerConnector(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
val array = d.getJSONArray("triggerList")
|
val array = d.getJSONArray("triggerList")
|
||||||
list.clear()
|
list.clear()
|
||||||
for (i in 0 until array.length()) {
|
for (i in 0 until array.length()) {
|
||||||
instantiate(JSONObject(array.getString(i)))?.let {
|
instantiate(JSONObject(array.getString(i))).let {
|
||||||
list.add(it)
|
list.add(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ interface Constraints {
|
||||||
fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
|
fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
|
||||||
fun isLgsAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
|
fun isLgsAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
|
||||||
fun isAutosensModeEnabled(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 isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
|
||||||
fun isUAMEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
|
fun isUAMEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
|
||||||
fun isAdvancedFilteringEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
|
fun isAdvancedFilteringEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
|
||||||
|
|
|
@ -24,9 +24,6 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
fun isAutosensModeEnabled(): Constraint<Boolean> =
|
fun isAutosensModeEnabled(): Constraint<Boolean> =
|
||||||
isAutosensModeEnabled(Constraint(true))
|
isAutosensModeEnabled(Constraint(true))
|
||||||
|
|
||||||
fun isAMAModeEnabled(): Constraint<Boolean> =
|
|
||||||
isAMAModeEnabled(Constraint(true))
|
|
||||||
|
|
||||||
fun isSMBModeEnabled(): Constraint<Boolean> =
|
fun isSMBModeEnabled(): Constraint<Boolean> =
|
||||||
isSMBModeEnabled(Constraint(true))
|
isSMBModeEnabled(Constraint(true))
|
||||||
|
|
||||||
|
@ -100,16 +97,6 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
return value
|
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> {
|
override fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
|
|
Loading…
Reference in a new issue