ApsMode enum - discard usage of lowercase property
This commit is contained in:
parent
812499ea81
commit
5ea430ffc5
|
@ -430,7 +430,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
@Test
|
@Test
|
||||||
fun iobAMAShouldBeLimited() {
|
fun iobAMAShouldBeLimited() {
|
||||||
// No limit by default
|
// No limit by default
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
|
||||||
`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.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("teenage")
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("teenage")
|
||||||
openAPSAMAPlugin.setPluginEnabled(PluginType.APS, true)
|
openAPSAMAPlugin.setPluginEnabled(PluginType.APS, true)
|
||||||
|
@ -446,7 +446,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
@Test
|
@Test
|
||||||
fun iobSMBShouldBeLimited() {
|
fun iobSMBShouldBeLimited() {
|
||||||
// No limit by default
|
// No limit by default
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
|
||||||
`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(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("teenage")
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("teenage")
|
||||||
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
|
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
|
||||||
|
|
|
@ -71,7 +71,7 @@ class LoopPluginTest : TestBase() {
|
||||||
fun testPluginInterface() {
|
fun testPluginInterface() {
|
||||||
`when`(rh.gs(info.nightscout.core.ui.R.string.loop)).thenReturn("Loop")
|
`when`(rh.gs(info.nightscout.core.ui.R.string.loop)).thenReturn("Loop")
|
||||||
`when`(rh.gs(info.nightscout.plugins.aps.R.string.loop_shortname)).thenReturn("LOOP")
|
`when`(rh.gs(info.nightscout.plugins.aps.R.string.loop_shortname)).thenReturn("LOOP")
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
|
||||||
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)
|
||||||
|
|
|
@ -98,7 +98,7 @@ class SafetyPluginTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun disabledEngineeringModeShouldLimitClosedLoop() {
|
fun disabledEngineeringModeShouldLimitClosedLoop() {
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
|
||||||
`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)
|
||||||
|
@ -108,7 +108,7 @@ class SafetyPluginTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun setOpenLoopInPreferencesShouldLimitClosedLoop() {
|
fun setOpenLoopInPreferencesShouldLimitClosedLoop() {
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.OPEN.lowercase)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name)
|
||||||
var c = Constraint(true)
|
var c = Constraint(true)
|
||||||
c = safetyPlugin.isClosedLoopAllowed(c)
|
c = safetyPlugin.isClosedLoopAllowed(c)
|
||||||
Assertions.assertTrue(c.getReasons(aapsLogger).contains("Closed loop mode disabled in preferences"))
|
Assertions.assertTrue(c.getReasons(aapsLogger).contains("Closed loop mode disabled in preferences"))
|
||||||
|
@ -278,7 +278,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(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.LGS.lowercase)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.LGS.name)
|
||||||
`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(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("teenage")
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("teenage")
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.interfaces
|
package info.nightscout.interfaces
|
||||||
|
|
||||||
enum class ApsMode(val lowercase: String) {
|
enum class ApsMode() {
|
||||||
OPEN("open"),
|
OPEN,
|
||||||
CLOSED("closed"),
|
CLOSED,
|
||||||
LGS("lgs"),
|
LGS,
|
||||||
UNDEFINED("undefined");
|
UNDEFINED;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
|
|
@ -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(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase))
|
val apsMode = ApsMode.secureValueOf(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name))
|
||||||
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
|
||||||
|
|
|
@ -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(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)) == ApsMode.CLOSED
|
override fun isCompleted(): Boolean = ApsMode.secureValueOf(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)) == ApsMode.CLOSED
|
||||||
})
|
})
|
||||||
tasks.add(
|
tasks.add(
|
||||||
object : Task(this, R.string.maxiobset) {
|
object : Task(this, R.string.maxiobset) {
|
||||||
|
|
|
@ -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(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase))
|
val mode = ApsMode.secureValueOf(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name))
|
||||||
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(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase))
|
val apsMode = ApsMode.secureValueOf(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name))
|
||||||
if (apsMode == ApsMode.LGS) maxIob.setIfSmaller(aapsLogger, HardLimits.MAX_IOB_LGS, rh.gs(info.nightscout.core.ui.R.string.limiting_iob, HardLimits.MAX_IOB_LGS, rh.gs(info.nightscout.core.ui.R.string.lowglucosesuspend)), this)
|
if (apsMode == ApsMode.LGS) maxIob.setIfSmaller(aapsLogger, HardLimits.MAX_IOB_LGS, rh.gs(info.nightscout.core.ui.R.string.limiting_iob, HardLimits.MAX_IOB_LGS, rh.gs(info.nightscout.core.ui.R.string.lowglucosesuspend)), this)
|
||||||
return maxIob
|
return maxIob
|
||||||
}
|
}
|
||||||
|
|
|
@ -510,7 +510,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(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.LGS.lowercase)
|
sp.putString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.LGS.name)
|
||||||
rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.ui.R.string.lowglucosesuspend)))
|
rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.ui.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))
|
||||||
|
@ -525,7 +525,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(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.CLOSED.lowercase)
|
sp.putString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.CLOSED.name)
|
||||||
rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.ui.R.string.closedloop)))
|
rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.ui.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))
|
||||||
|
@ -1284,7 +1284,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getApsModeText(): String =
|
private fun getApsModeText(): String =
|
||||||
when (ApsMode.secureValueOf(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase))) {
|
when (ApsMode.secureValueOf(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name))) {
|
||||||
ApsMode.OPEN -> rh.gs(info.nightscout.core.ui.R.string.openloop)
|
ApsMode.OPEN -> rh.gs(info.nightscout.core.ui.R.string.openloop)
|
||||||
ApsMode.CLOSED -> rh.gs(info.nightscout.core.ui.R.string.closedloop)
|
ApsMode.CLOSED -> rh.gs(info.nightscout.core.ui.R.string.closedloop)
|
||||||
ApsMode.LGS -> rh.gs(info.nightscout.core.ui.R.string.lowglucosesuspend)
|
ApsMode.LGS -> rh.gs(info.nightscout.core.ui.R.string.lowglucosesuspend)
|
||||||
|
|
|
@ -343,7 +343,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(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
|
||||||
smsCommunicatorPlugin.messages = ArrayList()
|
smsCommunicatorPlugin.messages = ArrayList()
|
||||||
sms = Sms("1234", "LOOP STATUS")
|
sms = Sms("1234", "LOOP STATUS")
|
||||||
smsCommunicatorPlugin.processSms(sms)
|
smsCommunicatorPlugin.processSms(sms)
|
||||||
|
@ -352,7 +352,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
|
||||||
Assertions.assertEquals("Loop is enabled - $modeClosed", smsCommunicatorPlugin.messages[1].text)
|
Assertions.assertEquals("Loop is enabled - $modeClosed", smsCommunicatorPlugin.messages[1].text)
|
||||||
|
|
||||||
//LOOP STATUS : enabled - APS mode - Open
|
//LOOP STATUS : enabled - APS mode - Open
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.OPEN.lowercase)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name)
|
||||||
smsCommunicatorPlugin.messages = ArrayList()
|
smsCommunicatorPlugin.messages = ArrayList()
|
||||||
smsCommunicatorPlugin.processSms(sms)
|
smsCommunicatorPlugin.processSms(sms)
|
||||||
Assertions.assertFalse(sms.ignored)
|
Assertions.assertFalse(sms.ignored)
|
||||||
|
@ -360,7 +360,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
|
||||||
Assertions.assertEquals("Loop is enabled - $modeOpen", smsCommunicatorPlugin.messages[1].text)
|
Assertions.assertEquals("Loop is enabled - $modeOpen", smsCommunicatorPlugin.messages[1].text)
|
||||||
|
|
||||||
//LOOP STATUS : enabled - APS mode - LGS
|
//LOOP STATUS : enabled - APS mode - LGS
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.LGS.lowercase)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.LGS.name)
|
||||||
smsCommunicatorPlugin.messages = ArrayList()
|
smsCommunicatorPlugin.messages = ArrayList()
|
||||||
smsCommunicatorPlugin.processSms(sms)
|
smsCommunicatorPlugin.processSms(sms)
|
||||||
Assertions.assertFalse(sms.ignored)
|
Assertions.assertFalse(sms.ignored)
|
||||||
|
@ -368,7 +368,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
|
||||||
Assertions.assertEquals("Loop is enabled - $modeLgs", smsCommunicatorPlugin.messages[1].text)
|
Assertions.assertEquals("Loop is enabled - $modeLgs", smsCommunicatorPlugin.messages[1].text)
|
||||||
|
|
||||||
//LOOP STATUS : enabled - APS mode - unknown
|
//LOOP STATUS : enabled - APS mode - unknown
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn("some wrong value")
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn("some wrong value")
|
||||||
smsCommunicatorPlugin.messages = ArrayList()
|
smsCommunicatorPlugin.messages = ArrayList()
|
||||||
smsCommunicatorPlugin.processSms(sms)
|
smsCommunicatorPlugin.processSms(sms)
|
||||||
Assertions.assertFalse(sms.ignored)
|
Assertions.assertFalse(sms.ignored)
|
||||||
|
@ -520,7 +520,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(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
|
||||||
smsCommunicatorPlugin.messages = ArrayList()
|
smsCommunicatorPlugin.messages = ArrayList()
|
||||||
sms = Sms("1234", smsCommand)
|
sms = Sms("1234", smsCommand)
|
||||||
smsCommunicatorPlugin.processSms(sms)
|
smsCommunicatorPlugin.processSms(sms)
|
||||||
|
@ -535,7 +535,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(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.LGS.lowercase)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.LGS.name)
|
||||||
smsCommunicatorPlugin.messages = ArrayList()
|
smsCommunicatorPlugin.messages = ArrayList()
|
||||||
sms = Sms("1234", smsCommand)
|
sms = Sms("1234", smsCommand)
|
||||||
smsCommunicatorPlugin.processSms(sms)
|
smsCommunicatorPlugin.processSms(sms)
|
||||||
|
|
|
@ -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(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase))
|
val apsMode = ApsMode.secureValueOf(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name))
|
||||||
val pump = activePlugin.activePump
|
val pump = activePlugin.activePump
|
||||||
|
|
||||||
binding.overviewDisconnect15m.visibility = pumpDescription.tempDurationStep15mAllowed.toVisibility()
|
binding.overviewDisconnect15m.visibility = pumpDescription.tempDurationStep15mAllowed.toVisibility()
|
||||||
|
@ -211,27 +211,27 @@ class LoopDialog : DaggerDialogFragment() {
|
||||||
else -> {
|
else -> {
|
||||||
binding.overviewLoop.visibility = View.VISIBLE
|
binding.overviewLoop.visibility = View.VISIBLE
|
||||||
binding.overviewEnable.visibility = View.GONE
|
binding.overviewEnable.visibility = View.GONE
|
||||||
when {
|
when (apsMode) {
|
||||||
apsMode == ApsMode.CLOSED -> {
|
ApsMode.CLOSED -> {
|
||||||
binding.overviewCloseloop.visibility = View.GONE
|
binding.overviewCloseloop.visibility = View.GONE
|
||||||
binding.overviewLgsloop.visibility = View.VISIBLE
|
binding.overviewLgsloop.visibility = View.VISIBLE
|
||||||
binding.overviewOpenloop.visibility = View.VISIBLE
|
binding.overviewOpenloop.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
apsMode == ApsMode.LGS -> {
|
ApsMode.LGS -> {
|
||||||
binding.overviewCloseloop.visibility = closedLoopAllowed.value().toVisibility() //show Close loop button only if Close loop allowed
|
binding.overviewCloseloop.visibility = closedLoopAllowed.value().toVisibility() //show Close loop button only if Close loop allowed
|
||||||
binding.overviewLgsloop.visibility = View.GONE
|
binding.overviewLgsloop.visibility = View.GONE
|
||||||
binding.overviewOpenloop.visibility = View.VISIBLE
|
binding.overviewOpenloop.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
apsMode == ApsMode.OPEN -> {
|
ApsMode.OPEN -> {
|
||||||
binding.overviewCloseloop.visibility =
|
binding.overviewCloseloop.visibility =
|
||||||
closedLoopAllowed2.toVisibility() //show CloseLoop button only if Objective 6 is completed (closedLoopAllowed always false in open loop mode)
|
closedLoopAllowed2.toVisibility() //show CloseLoop button only if Objective 6 is completed (closedLoopAllowed always false in open loop mode)
|
||||||
binding.overviewLgsloop.visibility = lgsEnabled.value().toVisibility()
|
binding.overviewLgsloop.visibility = lgsEnabled.value().toVisibility()
|
||||||
binding.overviewOpenloop.visibility = View.GONE
|
binding.overviewOpenloop.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
binding.overviewCloseloop.visibility = View.GONE
|
binding.overviewCloseloop.visibility = View.GONE
|
||||||
binding.overviewLgsloop.visibility = View.GONE
|
binding.overviewLgsloop.visibility = View.GONE
|
||||||
binding.overviewOpenloop.visibility = View.GONE
|
binding.overviewOpenloop.visibility = View.GONE
|
||||||
|
@ -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(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.CLOSED.lowercase)
|
sp.putString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.CLOSED.name)
|
||||||
rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.ui.R.string.closedloop)))
|
rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.ui.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(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.LGS.lowercase)
|
sp.putString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.LGS.name)
|
||||||
rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.ui.R.string.lowglucosesuspend)))
|
rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.ui.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(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)
|
sp.putString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)
|
||||||
rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.ui.R.string.lowglucosesuspend)))
|
rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.ui.R.string.lowglucosesuspend)))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue