add lowercase values in ApsMode Enum

This commit is contained in:
piotrek 2022-11-30 17:17:23 +01:00
parent 1c82a65871
commit 3a0305c4d2
10 changed files with 32 additions and 32 deletions

View file

@ -267,13 +267,13 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
// 2x Safety & Objectives // 2x Safety & Objectives
@Test @Test
fun isClosedLoopAllowedTest() { fun isClosedLoopAllowedTest() {
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name) `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
objectivesPlugin.objectives[Objectives.MAXIOB_ZERO_CL_OBJECTIVE].startedOn = 0 objectivesPlugin.objectives[Objectives.MAXIOB_ZERO_CL_OBJECTIVE].startedOn = 0
var c: Constraint<Boolean> = constraintChecker.isClosedLoopAllowed() var c: Constraint<Boolean> = constraintChecker.isClosedLoopAllowed()
aapsLogger.debug("Reason list: " + c.reasonList.toString()) aapsLogger.debug("Reason list: " + c.reasonList.toString())
// Assert.assertTrue(c.reasonList[0].toString().contains("Closed loop is disabled")) // Safety & Objectives // Assert.assertTrue(c.reasonList[0].toString().contains("Closed loop is disabled")) // Safety & Objectives
Assert.assertEquals(false, c.value()) Assert.assertEquals(false, c.value())
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name) `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.OPEN.lowercase)
c = constraintChecker.isClosedLoopAllowed() c = constraintChecker.isClosedLoopAllowed()
Assert.assertTrue(c.reasonList[0].contains("Closed loop mode disabled in preferences")) // Safety & Objectives Assert.assertTrue(c.reasonList[0].contains("Closed loop mode disabled in preferences")) // Safety & Objectives
// Assert.assertEquals(3, c.reasonList.size) // 2x Safety & Objectives // Assert.assertEquals(3, c.reasonList.size) // 2x Safety & Objectives
@ -316,7 +316,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true) openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
objectivesPlugin.objectives[Objectives.SMB_OBJECTIVE].startedOn = 0 objectivesPlugin.objectives[Objectives.SMB_OBJECTIVE].startedOn = 0
`when`(sp.getBoolean(R.string.key_use_smb, false)).thenReturn(false) `when`(sp.getBoolean(R.string.key_use_smb, false)).thenReturn(false)
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name) `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.OPEN.lowercase)
// `when`(constraintChecker.isClosedLoopAllowed()).thenReturn(Constraint(true)) // `when`(constraintChecker.isClosedLoopAllowed()).thenReturn(Constraint(true))
val c = constraintChecker.isSMBModeEnabled() val c = constraintChecker.isSMBModeEnabled()
Assert.assertEquals(true, c.reasonList.size == 3) // 2x Safety & Objectives Assert.assertEquals(true, c.reasonList.size == 3) // 2x Safety & Objectives
@ -423,7 +423,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
@Test @Test
fun iobAMAShouldBeLimited() { fun iobAMAShouldBeLimited() {
// No limit by default // No limit by default
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name) `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
`when`(sp.getDouble(R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5) `when`(sp.getDouble(R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5)
`when`(sp.getString(R.string.key_age, "")).thenReturn("teenage") `when`(sp.getString(R.string.key_age, "")).thenReturn("teenage")
openAPSAMAPlugin.setPluginEnabled(PluginType.APS, true) openAPSAMAPlugin.setPluginEnabled(PluginType.APS, true)
@ -439,7 +439,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
@Test @Test
fun iobSMBShouldBeLimited() { fun iobSMBShouldBeLimited() {
// No limit by default // No limit by default
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name) `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
`when`(sp.getDouble(R.string.key_openapssmb_max_iob, 3.0)).thenReturn(3.0) `when`(sp.getDouble(R.string.key_openapssmb_max_iob, 3.0)).thenReturn(3.0)
`when`(sp.getString(R.string.key_age, "")).thenReturn("teenage") `when`(sp.getString(R.string.key_age, "")).thenReturn("teenage")
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true) openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)

View file

@ -72,7 +72,7 @@ class LoopPluginTest : TestBase() {
fun testPluginInterface() { fun testPluginInterface() {
`when`(rh.gs(R.string.loop)).thenReturn("Loop") `when`(rh.gs(R.string.loop)).thenReturn("Loop")
`when`(rh.gs(R.string.loop_shortname)).thenReturn("LOOP") `when`(rh.gs(R.string.loop_shortname)).thenReturn("LOOP")
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name) `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
val pumpDescription = PumpDescription() val pumpDescription = PumpDescription()
`when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription) `when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription)
Assert.assertEquals(LoopFragment::class.java.name, loopPlugin.pluginDescription.fragmentClass) Assert.assertEquals(LoopFragment::class.java.name, loopPlugin.pluginDescription.fragmentClass)

View file

@ -96,7 +96,7 @@ class SafetyPluginTest : TestBaseWithProfile() {
@Test @Test
fun disabledEngineeringModeShouldLimitClosedLoop() { fun disabledEngineeringModeShouldLimitClosedLoop() {
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name) `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
`when`(config.isEngineeringModeOrRelease()).thenReturn(false) `when`(config.isEngineeringModeOrRelease()).thenReturn(false)
var c = Constraint(true) var c = Constraint(true)
c = safetyPlugin.isClosedLoopAllowed(c) c = safetyPlugin.isClosedLoopAllowed(c)
@ -106,7 +106,7 @@ class SafetyPluginTest : TestBaseWithProfile() {
@Test @Test
fun setOpenLoopInPreferencesShouldLimitClosedLoop() { fun setOpenLoopInPreferencesShouldLimitClosedLoop() {
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name) `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.OPEN.lowercase)
var c = Constraint(true) var c = Constraint(true)
c = safetyPlugin.isClosedLoopAllowed(c) c = safetyPlugin.isClosedLoopAllowed(c)
Assert.assertTrue(c.getReasons(aapsLogger).contains("Closed loop mode disabled in preferences")) Assert.assertTrue(c.getReasons(aapsLogger).contains("Closed loop mode disabled in preferences"))
@ -276,7 +276,7 @@ Safety: Limiting max basal rate to 500.00 U/h because of pump limit
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true) openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
//`when`(openAPSSMBPlugin.isEnabled()).thenReturn(true) //`when`(openAPSSMBPlugin.isEnabled()).thenReturn(true)
//`when`(openAPSAMAPlugin.isEnabled()).thenReturn(false) //`when`(openAPSAMAPlugin.isEnabled()).thenReturn(false)
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.LGS.name) `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.LGS.lowercase)
`when`(sp.getDouble(info.nightscout.plugins.aps.R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5) `when`(sp.getDouble(info.nightscout.plugins.aps.R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5)
`when`(sp.getDouble(info.nightscout.plugins.aps.R.string.key_openapssmb_max_iob, 3.0)).thenReturn(3.0) `when`(sp.getDouble(info.nightscout.plugins.aps.R.string.key_openapssmb_max_iob, 3.0)).thenReturn(3.0)
`when`(sp.getString(R.string.key_age, "")).thenReturn("teenage") `when`(sp.getString(R.string.key_age, "")).thenReturn("teenage")

View file

@ -1,16 +1,16 @@
package info.nightscout.interfaces package info.nightscout.interfaces
enum class ApsMode { enum class ApsMode(val lowercase: String) {
OPEN, OPEN("open"),
CLOSED, CLOSED("closed"),
LGS, LGS("lgs"),
UNDEFINED; UNDEFINED("undefined");
companion object { companion object {
fun secureValueOf(stringValue: String): ApsMode { fun secureValueOf(stringValue: String): ApsMode {
return try { return try {
valueOf(stringValue) valueOf(stringValue.uppercase())
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
UNDEFINED UNDEFINED
} }

View file

@ -183,7 +183,7 @@ class LoopPlugin @Inject constructor(
get() { get() {
val closedLoopEnabled = constraintChecker.isClosedLoopAllowed() val closedLoopEnabled = constraintChecker.isClosedLoopAllowed()
val maxIobAllowed = constraintChecker.getMaxIOBAllowed().value() val maxIobAllowed = constraintChecker.getMaxIOBAllowed().value()
val apsMode = ApsMode.secureValueOf(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)) val apsMode = ApsMode.secureValueOf(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase))
val pump = activePlugin.activePump val pump = activePlugin.activePump
var isLGS = false var isLGS = false
if (!isSuspended && !pump.isSuspended()) if (closedLoopEnabled.value()) if (maxIobAllowed == HardLimits.MAX_IOB_LGS || apsMode == ApsMode.LGS) isLGS = true if (!isSuspended && !pump.isSuspended()) if (closedLoopEnabled.value()) if (maxIobAllowed == HardLimits.MAX_IOB_LGS || apsMode == ApsMode.LGS) isLGS = true

View file

@ -16,7 +16,7 @@ class Objective6(injector: HasAndroidInjector) : Objective(injector, "maxiob", R
tasks.add(MinimumDurationTask(this, T.days(1).msecs())) tasks.add(MinimumDurationTask(this, T.days(1).msecs()))
tasks.add( tasks.add(
object : Task(this, R.string.closedmodeenabled) { object : Task(this, R.string.closedmodeenabled) {
override fun isCompleted(): Boolean = ApsMode.secureValueOf(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)) == ApsMode.CLOSED override fun isCompleted(): Boolean = ApsMode.secureValueOf(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)) == ApsMode.CLOSED
}) })
tasks.add( tasks.add(
object : Task(this, R.string.maxiobset) { object : Task(this, R.string.maxiobset) {

View file

@ -67,7 +67,7 @@ class SafetyPlugin @Inject constructor(
} }
override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> { override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
val mode = ApsMode.secureValueOf(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)) val mode = ApsMode.secureValueOf(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase))
if (mode == ApsMode.OPEN) value.set(aapsLogger, false, rh.gs(R.string.closedmodedisabledinpreferences), this) if (mode == ApsMode.OPEN) value.set(aapsLogger, false, rh.gs(R.string.closedmodedisabledinpreferences), this)
if (!config.isEngineeringModeOrRelease()) { if (!config.isEngineeringModeOrRelease()) {
if (value.value()) { if (value.value()) {
@ -160,7 +160,7 @@ class SafetyPlugin @Inject constructor(
} }
override fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> { override fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> {
val apsMode = ApsMode.secureValueOf(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)) val apsMode = ApsMode.secureValueOf(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase))
if (apsMode == ApsMode.LGS) maxIob.setIfSmaller(aapsLogger, HardLimits.MAX_IOB_LGS, rh.gs(R.string.limiting_iob, HardLimits.MAX_IOB_LGS, rh.gs(R.string.lowglucosesuspend)), this) if (apsMode == ApsMode.LGS) maxIob.setIfSmaller(aapsLogger, HardLimits.MAX_IOB_LGS, rh.gs(R.string.limiting_iob, HardLimits.MAX_IOB_LGS, rh.gs(R.string.lowglucosesuspend)), this)
return maxIob return maxIob
} }

View file

@ -514,7 +514,7 @@ class SmsCommunicatorPlugin @Inject constructor(
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(pumpCommand = false) { messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(pumpCommand = false) {
override fun run() { override fun run() {
uel.log(Action.LGS_LOOP_MODE, Sources.SMS) uel.log(Action.LGS_LOOP_MODE, Sources.SMS)
sp.putString(R.string.key_aps_mode, ApsMode.LGS.name) sp.putString(R.string.key_aps_mode, ApsMode.LGS.lowercase)
rxBus.send(EventPreferenceChange(rh.gs(R.string.lowglucosesuspend))) rxBus.send(EventPreferenceChange(rh.gs(R.string.lowglucosesuspend)))
val replyText = rh.gs(R.string.smscommunicator_current_loop_mode, getApsModeText()) val replyText = rh.gs(R.string.smscommunicator_current_loop_mode, getApsModeText())
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
@ -529,7 +529,7 @@ class SmsCommunicatorPlugin @Inject constructor(
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(pumpCommand = false) { messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(pumpCommand = false) {
override fun run() { override fun run() {
uel.log(Action.CLOSED_LOOP_MODE, Sources.SMS) uel.log(Action.CLOSED_LOOP_MODE, Sources.SMS)
sp.putString(R.string.key_aps_mode, ApsMode.CLOSED.name) sp.putString(R.string.key_aps_mode, ApsMode.CLOSED.lowercase)
rxBus.send(EventPreferenceChange(rh.gs(R.string.closedloop))) rxBus.send(EventPreferenceChange(rh.gs(R.string.closedloop)))
val replyText = rh.gs(R.string.smscommunicator_current_loop_mode, getApsModeText()) val replyText = rh.gs(R.string.smscommunicator_current_loop_mode, getApsModeText())
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
@ -1288,7 +1288,7 @@ class SmsCommunicatorPlugin @Inject constructor(
} }
private fun getApsModeText(): String = private fun getApsModeText(): String =
when (ApsMode.secureValueOf(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name))) { when (ApsMode.secureValueOf(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase))) {
ApsMode.OPEN -> rh.gs(R.string.openloop) ApsMode.OPEN -> rh.gs(R.string.openloop)
ApsMode.CLOSED -> rh.gs(R.string.closedloop) ApsMode.CLOSED -> rh.gs(R.string.closedloop)
ApsMode.LGS -> rh.gs(R.string.lowglucosesuspend) ApsMode.LGS -> rh.gs(R.string.lowglucosesuspend)

View file

@ -344,7 +344,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
//LOOP STATUS : enabled - APS mode - Closed //LOOP STATUS : enabled - APS mode - Closed
`when`(loop.enabled).thenReturn(true) `when`(loop.enabled).thenReturn(true)
`when`(loop.isSuspended).thenReturn(false) `when`(loop.isSuspended).thenReturn(false)
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name) `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "LOOP STATUS") sms = Sms("1234", "LOOP STATUS")
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -353,7 +353,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("Loop is enabled - $modeClosed", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Loop is enabled - $modeClosed", smsCommunicatorPlugin.messages[1].text)
//LOOP STATUS : enabled - APS mode - Open //LOOP STATUS : enabled - APS mode - Open
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name) `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.OPEN.lowercase)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
Assert.assertFalse(sms.ignored) Assert.assertFalse(sms.ignored)
@ -361,7 +361,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("Loop is enabled - $modeOpen", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Loop is enabled - $modeOpen", smsCommunicatorPlugin.messages[1].text)
//LOOP STATUS : enabled - APS mode - LGS //LOOP STATUS : enabled - APS mode - LGS
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.LGS.name) `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.LGS.lowercase)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
Assert.assertFalse(sms.ignored) Assert.assertFalse(sms.ignored)
@ -369,7 +369,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("Loop is enabled - $modeLgs", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Loop is enabled - $modeLgs", smsCommunicatorPlugin.messages[1].text)
//LOOP STATUS : enabled - APS mode - unknown //LOOP STATUS : enabled - APS mode - unknown
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn("some wrong value") `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn("some wrong value")
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
Assert.assertFalse(sms.ignored) Assert.assertFalse(sms.ignored)
@ -521,7 +521,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
var smsCommand = "LOOP CLOSED" var smsCommand = "LOOP CLOSED"
val replyClosed = "In order to switch Loop mode to Closed loop reply with code " val replyClosed = "In order to switch Loop mode to Closed loop reply with code "
`when`(loop.enabled).thenReturn(true) `when`(loop.enabled).thenReturn(true)
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name) `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", smsCommand) sms = Sms("1234", smsCommand)
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -536,7 +536,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
//LOOP LGS //LOOP LGS
smsCommand = "LOOP LGS" smsCommand = "LOOP LGS"
val replyLgs = "In order to switch Loop mode to LGS (Low Glucose Suspend) reply with code " val replyLgs = "In order to switch Loop mode to LGS (Low Glucose Suspend) reply with code "
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.LGS.name) `when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.LGS.lowercase)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", smsCommand) sms = Sms("1234", smsCommand)
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)

View file

@ -162,7 +162,7 @@ class LoopDialog : DaggerDialogFragment() {
val closedLoopAllowed = constraintChecker.isClosedLoopAllowed(Constraint(true)) val closedLoopAllowed = constraintChecker.isClosedLoopAllowed(Constraint(true))
val closedLoopAllowed2 = activePlugin.activeObjectives?.isAccomplished(Objectives.MAXIOB_OBJECTIVE) ?: false val closedLoopAllowed2 = activePlugin.activeObjectives?.isAccomplished(Objectives.MAXIOB_OBJECTIVE) ?: false
val lgsEnabled = constraintChecker.isLgsAllowed(Constraint(true)) val lgsEnabled = constraintChecker.isLgsAllowed(Constraint(true))
val apsMode = ApsMode.secureValueOf(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.name)) val apsMode = ApsMode.secureValueOf(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase))
val pump = activePlugin.activePump val pump = activePlugin.activePump
binding.overviewDisconnect15m.visibility = pumpDescription.tempDurationStep15mAllowed.toVisibility() binding.overviewDisconnect15m.visibility = pumpDescription.tempDurationStep15mAllowed.toVisibility()
@ -283,21 +283,21 @@ class LoopDialog : DaggerDialogFragment() {
when (v.id) { when (v.id) {
R.id.overview_closeloop -> { R.id.overview_closeloop -> {
uel.log(UserEntry.Action.CLOSED_LOOP_MODE, UserEntry.Sources.LoopDialog) uel.log(UserEntry.Action.CLOSED_LOOP_MODE, UserEntry.Sources.LoopDialog)
sp.putString(R.string.key_aps_mode, ApsMode.CLOSED.name) sp.putString(R.string.key_aps_mode, ApsMode.CLOSED.lowercase)
rxBus.send(EventPreferenceChange(rh.gs(R.string.closedloop))) rxBus.send(EventPreferenceChange(rh.gs(R.string.closedloop)))
return true return true
} }
R.id.overview_lgsloop -> { R.id.overview_lgsloop -> {
uel.log(UserEntry.Action.LGS_LOOP_MODE, UserEntry.Sources.LoopDialog) uel.log(UserEntry.Action.LGS_LOOP_MODE, UserEntry.Sources.LoopDialog)
sp.putString(R.string.key_aps_mode, ApsMode.LGS.name) sp.putString(R.string.key_aps_mode, ApsMode.LGS.lowercase)
rxBus.send(EventPreferenceChange(rh.gs(R.string.lowglucosesuspend))) rxBus.send(EventPreferenceChange(rh.gs(R.string.lowglucosesuspend)))
return true return true
} }
R.id.overview_openloop -> { R.id.overview_openloop -> {
uel.log(UserEntry.Action.OPEN_LOOP_MODE, UserEntry.Sources.LoopDialog) uel.log(UserEntry.Action.OPEN_LOOP_MODE, UserEntry.Sources.LoopDialog)
sp.putString(R.string.key_aps_mode, ApsMode.OPEN.name) sp.putString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)
rxBus.send(EventPreferenceChange(rh.gs(R.string.lowglucosesuspend))) rxBus.send(EventPreferenceChange(rh.gs(R.string.lowglucosesuspend)))
return true return true
} }