fix Objective4

This commit is contained in:
Milos Kozak 2023-10-25 09:58:38 +02:00
parent a909f8653a
commit 23c12077c6
7 changed files with 10 additions and 10 deletions

View file

@ -155,5 +155,6 @@
<string name="key_virtual_pump_upload_status" translatable="false">virtualpump_uploadstatus</string> <string name="key_virtual_pump_upload_status" translatable="false">virtualpump_uploadstatus</string>
<string name="key_use_autosens" translatable="false">openapsama_useautosens</string> <string name="key_use_autosens" translatable="false">openapsama_useautosens</string>
<string name="key_used_autosens_on_main_phone" translatable="false">used_autosens_on_main_phone</string> <string name="key_used_autosens_on_main_phone" translatable="false">used_autosens_on_main_phone</string>
<string name="key_openapsma_max_basal" translatable="false">openapsma_max_basal</string>
</resources> </resources>

View file

@ -247,7 +247,7 @@ class OpenAPSAMAPlugin @Inject constructor(
override fun applyBasalConstraints(absoluteRate: Constraint<Double>, profile: Profile): Constraint<Double> { override fun applyBasalConstraints(absoluteRate: Constraint<Double>, profile: Profile): Constraint<Double> {
if (isEnabled()) { if (isEnabled()) {
var maxBasal = sp.getDouble(R.string.key_openapsma_max_basal, 1.0) var maxBasal = sp.getDouble(app.aaps.core.utils.R.string.key_openapsma_max_basal, 1.0)
if (maxBasal < profile.getMaxDailyBasal()) { if (maxBasal < profile.getMaxDailyBasal()) {
maxBasal = profile.getMaxDailyBasal() maxBasal = profile.getMaxDailyBasal()
absoluteRate.addReason(rh.gs(R.string.increasing_max_basal), this) absoluteRate.addReason(rh.gs(R.string.increasing_max_basal), this)

View file

@ -313,7 +313,7 @@ open class OpenAPSSMBPlugin @Inject constructor(
override fun applyBasalConstraints(absoluteRate: Constraint<Double>, profile: Profile): Constraint<Double> { override fun applyBasalConstraints(absoluteRate: Constraint<Double>, profile: Profile): Constraint<Double> {
if (isEnabled()) { if (isEnabled()) {
var maxBasal = sp.getDouble(R.string.key_openapsma_max_basal, 1.0) var maxBasal = sp.getDouble(app.aaps.core.utils.R.string.key_openapsma_max_basal, 1.0)
if (maxBasal < profile.getMaxDailyBasal()) { if (maxBasal < profile.getMaxDailyBasal()) {
maxBasal = profile.getMaxDailyBasal() maxBasal = profile.getMaxDailyBasal()
absoluteRate.addReason(rh.gs(R.string.increasing_max_basal), this) absoluteRate.addReason(rh.gs(R.string.increasing_max_basal), this)

View file

@ -22,7 +22,6 @@
<string name="key_lgs_threshold" translatable="false">lgsThreshold</string> <string name="key_lgs_threshold" translatable="false">lgsThreshold</string>
<string name="key_DynISFAdjust" translatable="false">DynISFAdjust</string> <string name="key_DynISFAdjust" translatable="false">DynISFAdjust</string>
<string name="key_adjust_sensitivity" translatable="false">dynisf_adjust_sensitivity</string> <string name="key_adjust_sensitivity" translatable="false">dynisf_adjust_sensitivity</string>
<string name="key_openapsma_max_basal" translatable="false">openapsma_max_basal</string>
<string name="dynisf_adjust_sensitivity">Adjust sensitivity and BG</string> <string name="dynisf_adjust_sensitivity">Adjust sensitivity and BG</string>
<string name="DynISFAdjust_title" formatted="false">DynamicISF Adjustment Factor %</string> <string name="DynISFAdjust_title" formatted="false">DynamicISF Adjustment Factor %</string>

View file

@ -21,9 +21,9 @@ class Objective4(injector: HasAndroidInjector) : Objective(injector, "maxbasal",
object : Task(this, R.string.objectives_maxbasal_gate) { object : Task(this, R.string.objectives_maxbasal_gate) {
override fun isCompleted(): Boolean { override fun isCompleted(): Boolean {
val profile = profileFunction.getProfile() ?: return false val profile = profileFunction.getProfile() ?: return false
val maxBasalSet = (activePlugin.activeAPS as PluginConstraints).applyBasalConstraints(ConstraintObject(Double.MAX_VALUE, aapsLogger), profile) val maxBasalSet = sp.getDouble(app.aaps.core.utils.R.string.key_openapsma_max_basal, 0.0)
val maxDailyBasal = profile.getMaxDailyBasal() val maxDailyBasal = profile.getMaxDailyBasal()
return maxBasalSet.value() > 2.8 * maxDailyBasal return maxBasalSet > 2.8 * maxDailyBasal
} }
}.learned(Learned(R.string.objectives_maxbasal_learned)) }.learned(Learned(R.string.objectives_maxbasal_learned))
) )

View file

@ -316,7 +316,7 @@ class ConstraintsCheckerImplTest : TestBaseWithProfile() {
// insightPlugin.setStatusResult(result); // insightPlugin.setStatusResult(result);
// No limit by default // No limit by default
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0)
`when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")
@ -343,7 +343,7 @@ class ConstraintsCheckerImplTest : TestBaseWithProfile() {
// insightPlugin.setStatusResult(result); // insightPlugin.setStatusResult(result);
// No limit by default // No limit by default
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0)
`when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")

View file

@ -138,7 +138,7 @@ class SafetyPluginTest : TestBaseWithProfile() {
@Test @Test
fun basalRateShouldBeLimited() { fun basalRateShouldBeLimited() {
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0)
`when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")
@ -167,7 +167,7 @@ class SafetyPluginTest : TestBaseWithProfile() {
@Test @Test
fun percentBasalRateShouldBeLimited() { fun percentBasalRateShouldBeLimited() {
// No limit by default // No limit by default
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0)
`when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")
@ -190,7 +190,7 @@ Safety: Limiting max basal rate to 500.00 U/h because of pump limit
@Test @Test
fun percentBasalShouldBeLimitedBySMB() { fun percentBasalShouldBeLimitedBySMB() {
// No limit by default // No limit by default
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0)
`when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")