Merge remote-tracking branch 'origin/dev' into rs
This commit is contained in:
commit
b3db476533
|
@ -80,12 +80,13 @@ interface AppComponent : AndroidInjector<MainApp> {
|
||||||
fun injectObjective1(objective1: Objective1)
|
fun injectObjective1(objective1: Objective1)
|
||||||
fun injectObjective2(objective2: Objective2)
|
fun injectObjective2(objective2: Objective2)
|
||||||
fun injectObjective3(objective3: Objective3)
|
fun injectObjective3(objective3: Objective3)
|
||||||
fun injectObjective3(objective4: Objective4)
|
fun injectObjective4(objective4: Objective4)
|
||||||
fun injectObjective5(objective5: Objective5)
|
fun injectObjective5(objective5: Objective5)
|
||||||
fun injectObjective6(objective6: Objective6)
|
fun injectObjective6(objective6: Objective6)
|
||||||
fun injectObjective6(objective7: Objective7)
|
fun injectObjective7(objective7: Objective7)
|
||||||
fun injectObjective6(objective8: Objective8)
|
fun injectObjective8(objective8: Objective8)
|
||||||
fun injectObjective6(objective9: Objective9)
|
fun injectObjective9(objective9: Objective9)
|
||||||
|
fun injectObjective10(objective10: Objective10)
|
||||||
|
|
||||||
fun injectAutomationEvent(automationEvent: AutomationEvent)
|
fun injectAutomationEvent(automationEvent: AutomationEvent)
|
||||||
|
|
||||||
|
|
|
@ -161,6 +161,7 @@ open class AppModule {
|
||||||
@ContributesAndroidInjector fun objective7Injector(): Objective7
|
@ContributesAndroidInjector fun objective7Injector(): Objective7
|
||||||
@ContributesAndroidInjector fun objective8Injector(): Objective8
|
@ContributesAndroidInjector fun objective8Injector(): Objective8
|
||||||
@ContributesAndroidInjector fun objective9Injector(): Objective9
|
@ContributesAndroidInjector fun objective9Injector(): Objective9
|
||||||
|
@ContributesAndroidInjector fun objective10Injector(): Objective10
|
||||||
|
|
||||||
@ContributesAndroidInjector fun automationEventInjector(): AutomationEvent
|
@ContributesAndroidInjector fun automationEventInjector(): AutomationEvent
|
||||||
|
|
||||||
|
|
|
@ -76,4 +76,9 @@ interface ConstraintsInterface {
|
||||||
fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> {
|
fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> {
|
||||||
return maxIob
|
return maxIob
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmDefault
|
||||||
|
fun isAutomationEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
|
return value
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -54,6 +54,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
fun getMaxIOBAllowed(): Constraint<Double> =
|
fun getMaxIOBAllowed(): Constraint<Double> =
|
||||||
applyMaxIOBConstraints(Constraint(Constants.REALLYHIGHIOB))
|
applyMaxIOBConstraints(Constraint(Constants.REALLYHIGHIOB))
|
||||||
|
|
||||||
|
fun isAutomationEnabled(): Constraint<Boolean> =
|
||||||
|
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(ConstraintsInterface::class.java)
|
||||||
for (p in constraintsPlugins) {
|
for (p in constraintsPlugins) {
|
||||||
|
@ -193,4 +196,14 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
|
||||||
}
|
}
|
||||||
return maxIob
|
return maxIob
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun isAutomationEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
|
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java)
|
||||||
|
for (p in constraintsPlugins) {
|
||||||
|
val constraint = p as ConstraintsInterface
|
||||||
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
|
||||||
|
constraint.isAutomationEnabled(value)
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -161,7 +161,7 @@ class ObjectivesFragment : DaggerFragment() {
|
||||||
holder.accomplished.visibility = View.GONE
|
holder.accomplished.visibility = View.GONE
|
||||||
holder.unFinish.visibility = View.GONE
|
holder.unFinish.visibility = View.GONE
|
||||||
holder.unStart.visibility = View.GONE
|
holder.unStart.visibility = View.GONE
|
||||||
if (position == 0 || objectivesPlugin.objectives[position - 1].isAccomplished)
|
if (position == 0 || objectivesPlugin.allPriorAccomplished(position))
|
||||||
holder.start.visibility = View.VISIBLE
|
holder.start.visibility = View.VISIBLE
|
||||||
else
|
else
|
||||||
holder.start.visibility = View.GONE
|
holder.start.visibility = View.GONE
|
||||||
|
|
|
@ -50,6 +50,7 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
const val AUTOSENS_OBJECTIVE = 7
|
const val AUTOSENS_OBJECTIVE = 7
|
||||||
const val AMA_OBJECTIVE = 8
|
const val AMA_OBJECTIVE = 8
|
||||||
const val SMB_OBJECTIVE = 9
|
const val SMB_OBJECTIVE = 9
|
||||||
|
const val AUTO_OBJECTIVE = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
public override fun onStart() {
|
public override fun onStart() {
|
||||||
|
@ -94,6 +95,7 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
objectives.add(Objective7(injector))
|
objectives.add(Objective7(injector))
|
||||||
objectives.add(Objective8(injector))
|
objectives.add(Objective8(injector))
|
||||||
objectives.add(Objective9(injector))
|
objectives.add(Objective9(injector))
|
||||||
|
objectives.add(Objective10(injector))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reset() {
|
fun reset() {
|
||||||
|
@ -133,6 +135,8 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
sp.putLong("Objectives_" + "ama" + "_accomplished", 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" + "_accomplished", DateUtil.now())
|
||||||
setupObjectives()
|
setupObjectives()
|
||||||
OKDialog.show(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.codeaccepted))
|
OKDialog.show(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.codeaccepted))
|
||||||
} else {
|
} else {
|
||||||
|
@ -140,6 +144,14 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun allPriorAccomplished(position: Int) : Boolean {
|
||||||
|
var accomplished = true
|
||||||
|
for (i in 0 until position) {
|
||||||
|
accomplished = accomplished && objectives[i].isAccomplished
|
||||||
|
}
|
||||||
|
return accomplished
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constraints interface
|
* Constraints interface
|
||||||
*/
|
*/
|
||||||
|
@ -178,4 +190,10 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
maxIob.set(aapsLogger, 0.0, String.format(resourceHelper.gs(R.string.objectivenotfinished), MAXIOB_ZERO_CL_OBJECTIVE + 1), this)
|
maxIob.set(aapsLogger, 0.0, String.format(resourceHelper.gs(R.string.objectivenotfinished), MAXIOB_ZERO_CL_OBJECTIVE + 1), this)
|
||||||
return maxIob
|
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)
|
||||||
|
return value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package info.nightscout.androidaps.plugins.constraints.objectives.objectives;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.utils.T;
|
||||||
|
|
||||||
|
public class Objective10 extends Objective {
|
||||||
|
|
||||||
|
public Objective10(HasAndroidInjector injector) {
|
||||||
|
super(injector, "auto", R.string.objectives_auto_objective, R.string.objectives_auto_gate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setupTasks(List<Task> tasks) {
|
||||||
|
tasks.add(new MinimumDurationTask(T.days(28).msecs()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -184,9 +184,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun updateGui() {
|
fun updateGui() {
|
||||||
actions_profileswitch?.visibility =
|
actions_profileswitch?.visibility = (activePlugin.activeProfileInterface.profile != null).toVisibility()
|
||||||
if (activePlugin.activeProfileInterface.profile != null) View.VISIBLE
|
|
||||||
else View.GONE
|
|
||||||
|
|
||||||
val profile = profileFunction.getProfile()
|
val profile = profileFunction.getProfile()
|
||||||
val pump = activePlugin.activePump
|
val pump = activePlugin.activePump
|
||||||
|
|
|
@ -18,6 +18,7 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
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.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.general.automation.actions.*
|
import info.nightscout.androidaps.plugins.general.automation.actions.*
|
||||||
import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationDataChanged
|
import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationDataChanged
|
||||||
import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationUpdateGui
|
import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationUpdateGui
|
||||||
|
@ -50,6 +51,7 @@ class AutomationPlugin @Inject constructor(
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
private val loopPlugin: LoopPlugin,
|
private val loopPlugin: LoopPlugin,
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
|
private val constraintChecker: ConstraintChecker,
|
||||||
aapsLogger: AAPSLogger
|
aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
|
@ -181,6 +183,11 @@ class AutomationPlugin @Inject constructor(
|
||||||
aapsLogger.debug(LTag.AUTOMATION, "Loop deactivated")
|
aapsLogger.debug(LTag.AUTOMATION, "Loop deactivated")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
val enabled = constraintChecker.isAutomationEnabled()
|
||||||
|
if (!enabled.value()) {
|
||||||
|
executionLog.add(enabled.getMostLimitedReasons(aapsLogger))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
aapsLogger.debug(LTag.AUTOMATION, "processActions")
|
aapsLogger.debug(LTag.AUTOMATION, "processActions")
|
||||||
for (event in automationEvents) {
|
for (event in automationEvents) {
|
||||||
|
|
|
@ -32,7 +32,9 @@
|
||||||
<string name="objectives_autosens_gate">1 week successful daytime looping with regular carb entry</string>
|
<string name="objectives_autosens_gate">1 week successful daytime looping with regular carb entry</string>
|
||||||
<string name="objectives_ama_objective">Enabling additional features for daytime use, such as advanced meal assist</string>
|
<string name="objectives_ama_objective">Enabling additional features for daytime use, such as advanced meal assist</string>
|
||||||
<string name="objectives_smb_objective">Enabling additional features for daytime use, such as SMB</string>
|
<string name="objectives_smb_objective">Enabling additional features for daytime use, such as SMB</string>
|
||||||
|
<string name="objectives_auto_objective">Enabling automation</string>
|
||||||
<string name="objectives_smb_gate">You must read the wiki and rise maxIOB to get SMBs working fine! A good start is maxIOB=average mealbolus + 3 x max daily basal</string>
|
<string name="objectives_smb_gate">You must read the wiki and rise maxIOB to get SMBs working fine! A good start is maxIOB=average mealbolus + 3 x max daily basal</string>
|
||||||
|
<string name="objectives_auto_gate">Read the wiki how automation works. Setup your first simple rules. Instead of action let AAPS display only notification. When you are sure automation is triggered at the right time replace notification by real action.</string>
|
||||||
<string name="objectives_bgavailableinns">BG available in NS</string>
|
<string name="objectives_bgavailableinns">BG available in NS</string>
|
||||||
<string name="objectives_pumpstatusavailableinns">Pump status available in NS</string>
|
<string name="objectives_pumpstatusavailableinns">Pump status available in NS</string>
|
||||||
<string name="objectives_manualenacts">Manual enacts</string>
|
<string name="objectives_manualenacts">Manual enacts</string>
|
||||||
|
|
Loading…
Reference in a new issue