Automation: set precision level for comparsion to mgdl int values
This commit is contained in:
parent
26024dc7e1
commit
27355c18a2
3 changed files with 7 additions and 4 deletions
|
@ -13,6 +13,7 @@ import app.aaps.plugins.automation.elements.StaticLabel
|
|||
import dagger.android.HasAndroidInjector
|
||||
import org.json.JSONObject
|
||||
import java.util.Optional
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class TriggerBg(injector: HasAndroidInjector) : Trigger(injector) {
|
||||
|
||||
|
@ -54,7 +55,7 @@ class TriggerBg(injector: HasAndroidInjector) : Trigger(injector) {
|
|||
aapsLogger.debug(LTag.AUTOMATION, "NOT ready for execution: " + friendlyDescription())
|
||||
return false
|
||||
}
|
||||
if (comparator.value.check(glucoseStatus.glucose, profileUtil.convertToMgdl(bg.value, bg.units))) {
|
||||
if (comparator.value.check(glucoseStatus.glucose.roundToInt(), profileUtil.convertToMgdl(bg.value, bg.units).roundToInt())) {
|
||||
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import app.aaps.plugins.automation.elements.StaticLabel
|
|||
import dagger.android.HasAndroidInjector
|
||||
import org.json.JSONObject
|
||||
import java.util.Optional
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class TriggerProfilePercent(injector: HasAndroidInjector) : Trigger(injector) {
|
||||
|
||||
|
@ -54,13 +55,13 @@ class TriggerProfilePercent(injector: HasAndroidInjector) : Trigger(injector) {
|
|||
return false
|
||||
}
|
||||
if (profile is ProfileSealed.EPS) {
|
||||
if (comparator.value.check(profile.value.originalPercentage.toDouble(), pct.value)) {
|
||||
if (comparator.value.check(profile.value.originalPercentage, pct.value.roundToInt())) {
|
||||
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
|
||||
return true
|
||||
}
|
||||
}
|
||||
if (profile is ProfileSealed.Pure) {
|
||||
if (comparator.value.check(100.0, pct.value)) {
|
||||
if (comparator.value.check(100, pct.value.roundToInt())) {
|
||||
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import app.aaps.plugins.automation.elements.StaticLabel
|
|||
import dagger.android.HasAndroidInjector
|
||||
import org.json.JSONObject
|
||||
import java.util.Optional
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class TriggerTempTargetValue(injector: HasAndroidInjector) : Trigger(injector) {
|
||||
|
||||
|
@ -51,7 +52,7 @@ class TriggerTempTargetValue(injector: HasAndroidInjector) : Trigger(injector) {
|
|||
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
|
||||
return true
|
||||
}
|
||||
if (tt is ValueWrapper.Existing && comparator.value.check(tt.value.lowTarget, profileUtil.convertToMgdl(ttValue.value, ttValue.units))) {
|
||||
if (tt is ValueWrapper.Existing && comparator.value.check(tt.value.lowTarget.roundToInt(), profileUtil.convertToMgdl(ttValue.value, ttValue.units).roundToInt())) {
|
||||
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue