log red state

This commit is contained in:
Milos Kozak 2021-11-06 19:21:28 +01:00
parent 8ccef29dff
commit f9d24a0153
3 changed files with 17 additions and 3 deletions

View file

@ -4,6 +4,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventBucketedDataCreated
import info.nightscout.androidaps.utils.FabricPrivacy
@ -58,6 +59,7 @@ class BgQualityCheckPlugin @Inject constructor(
}
var state: State = State.UNKNOWN
var message: String = ""
// Return false if BG values are doubled
@Suppress("ReplaceGetOrSet")
@ -73,14 +75,20 @@ class BgQualityCheckPlugin @Inject constructor(
if (i < readings.size - 2)
if (abs(readings[i].timestamp - readings[i + 1].timestamp) <= 1000) {
state = State.DOUBLED
aapsLogger.debug(LTag.CORE, "BG similar. Turning on red state.\n${readings[i]}\n${readings[i+1]}")
message = rh.gs(R.string.bg_too_close, readings[i].toString(), readings[i+1].toString())
return
}
if (iobCobCalculator.ads.lastUsed5minCalculation == true)
if (iobCobCalculator.ads.lastUsed5minCalculation == true) {
state = State.FIVE_MIN_DATA
else if (iobCobCalculator.ads.lastUsed5minCalculation == false)
message = "Data is clean"
} else if (iobCobCalculator.ads.lastUsed5minCalculation == false) {
state = State.RECALCULATED
else
message = rh.gs(R.string.recalculated_data_used)
} else {
state = State.UNKNOWN
message = ""
}
}
fun icon(): Int =

View file

@ -668,6 +668,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
if (qualityIcon != 0) {
binding.infoLayout.bgQuality.visibility = View.VISIBLE
binding.infoLayout.bgQuality.setImageResource(qualityIcon)
binding.infoLayout.bgQuality.setOnClickListener {
context?.let { context -> OKDialog.show(context, rh.gs(R.string.data_status), bgQualityCheckPlugin.message) }
}
} else {
binding.infoLayout.bgQuality.visibility = View.GONE
}

View file

@ -1130,5 +1130,8 @@
<string name="view">View</string>
<string name="errors">Errors</string>
<string name="ns_sync_slow">Slow down uploads</string>
<string name="data_status">BG data status</string>
<string name="recalculated_data_used">Recalculated data used</string>
<string name="bg_too_close">BG too close:\n%1$s\n%2$s</string>
</resources>