show bucketed data in dev mode
This commit is contained in:
parent
a6b67b2bb7
commit
639328bdc3
|
@ -295,7 +295,8 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
graphData.addInRangeArea(fromTime, toTime, lowLine, highLine)
|
||||
|
||||
// **** BG ****
|
||||
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, null)
|
||||
graphData.addBgReadings(fromTime, toTime, highLine, null)
|
||||
if (buildHelper.isDev()) graphData.addBucketedData(fromTime, toTime)
|
||||
|
||||
// add target line
|
||||
graphData.addTargetLine(fromTime, toTime, profile, null)
|
||||
|
|
|
@ -862,8 +862,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
|
||||
// **** BG ****
|
||||
if (predictionsAvailable && menuChartSettings[0][OverviewMenus.CharType.PRE.ordinal])
|
||||
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, apsResult?.predictions?.map { bg-> GlucoseValueDataPoint(bg, defaultValueHelper, profileFunction, resourceHelper) }?.toMutableList())
|
||||
else graphData.addBgReadings(fromTime, toTime, lowLine, highLine, null)
|
||||
graphData.addBgReadings(fromTime, toTime, highLine, apsResult?.predictions?.map { bg-> GlucoseValueDataPoint(bg, defaultValueHelper, profileFunction, resourceHelper) }?.toMutableList())
|
||||
else graphData.addBgReadings(fromTime, toTime, highLine, null)
|
||||
if (buildHelper.isDev()) graphData.addBucketedData(fromTime, toTime)
|
||||
|
||||
// Treatments
|
||||
graphData.addTreatments(fromTime, endTime)
|
||||
|
|
|
@ -61,10 +61,23 @@ class GraphData(
|
|||
units = profileFunction.getUnits()
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun addBgReadings(fromTime: Long, toTime: Long, lowLine: Double, highLine: Double, predictions: MutableList<GlucoseValueDataPoint>?) {
|
||||
fun addBucketedData(fromTime: Long, toTime: Long) {
|
||||
val bucketedData = iobCobCalculator.bucketedData ?: return
|
||||
if (bucketedData.isEmpty()) {
|
||||
aapsLogger.debug("No bucketed data.")
|
||||
return
|
||||
}
|
||||
val bucketedListArray: MutableList<DataPointWithLabelInterface> = ArrayList()
|
||||
for (inMemoryGlucoseValue in bucketedData) {
|
||||
if (inMemoryGlucoseValue.timestamp < fromTime || inMemoryGlucoseValue.timestamp > toTime) continue
|
||||
bucketedListArray.add(InMemoryGlucoseValueDataPoint(inMemoryGlucoseValue, qgiprofileFunction, resourceHelper))
|
||||
}
|
||||
addSeries(PointsWithLabelGraphSeries(Array(bucketedListArray.size) { i -> bucketedListArray[i] }))
|
||||
}
|
||||
|
||||
fun addBgReadings(fromTime: Long, toTime: Long, highLine: Double, predictions: MutableList<GlucoseValueDataPoint>?) {
|
||||
var maxBgValue = Double.MIN_VALUE
|
||||
bgReadingsArray = iobCobCalculator.bgReadings
|
||||
bgReadingsArray = repository.compatGetBgReadingsDataFromTime(fromTime, toTime, true).blockingGet()
|
||||
if (bgReadingsArray?.isEmpty() != false) {
|
||||
aapsLogger.debug("No BG data.")
|
||||
maxY = if (units == Constants.MGDL) 180.0 else 10.0
|
||||
|
|
|
@ -51,9 +51,9 @@ class GlucoseValueDataPoint @Inject constructor(
|
|||
get() {
|
||||
return when (data.sourceSensor) {
|
||||
GlucoseValue.SourceSensor.IOB_PREDICTION -> resourceHelper.gc(R.color.iob)
|
||||
GlucoseValue.SourceSensor.COB_PREDICTION -> resourceHelper.gc(R.color.cob)
|
||||
GlucoseValue.SourceSensor.aCOB_PREDICTION -> -0x7f000001 and resourceHelper.gc(R.color.cob)
|
||||
GlucoseValue.SourceSensor.UAM_PREDICTION -> resourceHelper.gc(R.color.uam)
|
||||
GlucoseValue.SourceSensor.COB_PREDICTION -> resourceHelper.gc(R.color.cob)
|
||||
GlucoseValue.SourceSensor.A_COB_PREDICTION -> -0x7f000001 and resourceHelper.gc(R.color.cob)
|
||||
GlucoseValue.SourceSensor.UAM_PREDICTION -> resourceHelper.gc(R.color.uam)
|
||||
GlucoseValue.SourceSensor.ZT_PREDICTION -> resourceHelper.gc(R.color.zt)
|
||||
else -> R.color.white
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class GlucoseValueDataPoint @Inject constructor(
|
|||
private val isPrediction: Boolean
|
||||
get() = data.sourceSensor == GlucoseValue.SourceSensor.IOB_PREDICTION ||
|
||||
data.sourceSensor == GlucoseValue.SourceSensor.COB_PREDICTION ||
|
||||
data.sourceSensor == GlucoseValue.SourceSensor.aCOB_PREDICTION ||
|
||||
data.sourceSensor == GlucoseValue.SourceSensor.A_COB_PREDICTION ||
|
||||
data.sourceSensor == GlucoseValue.SourceSensor.UAM_PREDICTION ||
|
||||
data.sourceSensor == GlucoseValue.SourceSensor.ZT_PREDICTION
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package info.nightscout.androidaps.plugins.general.overview.graphExtensions
|
||||
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.core.R
|
||||
import info.nightscout.androidaps.data.InMemoryGlucoseValue
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import javax.inject.Inject
|
||||
|
||||
class InMemoryGlucoseValueDataPoint @Inject constructor(
|
||||
val data: InMemoryGlucoseValue,
|
||||
private val profileFunction: ProfileFunction,
|
||||
private val resourceHelper: ResourceHelper
|
||||
) : DataPointWithLabelInterface {
|
||||
|
||||
fun valueToUnits(units: String): Double =
|
||||
if (units == Constants.MGDL) data.value else data.value * Constants.MGDL_TO_MMOLL
|
||||
|
||||
override fun getX(): Double = data.timestamp.toDouble()
|
||||
override fun getY(): Double = valueToUnits(profileFunction.getUnits())
|
||||
override fun setY(y: Double) {}
|
||||
override fun getLabel(): String? = null
|
||||
override fun getDuration(): Long = 0
|
||||
override fun getShape(): PointsWithLabelGraphSeries.Shape = PointsWithLabelGraphSeries.Shape.BUCKETED_BG
|
||||
override fun getSize(): Float = 0.3f
|
||||
override fun getColor(): Int = resourceHelper.gc(R.color.white)
|
||||
}
|
|
@ -1,9 +1,2 @@
|
|||
package info.nightscout.androidaps.plugins.iob.iobCobCalculator
|
||||
|
||||
import info.nightscout.androidaps.database.entities.GlucoseValue
|
||||
|
||||
class InMemoryGlucoseValue @JvmOverloads constructor(var timestamp: Long = 0L, var value: Double = 0.0, var interpolated: Boolean = false) {
|
||||
|
||||
constructor(gv: GlucoseValue) : this(gv.timestamp, gv.value)
|
||||
// var generated : value doesn't correspond to real value with timestamp close to real BG
|
||||
}
|
|
@ -5,6 +5,7 @@ import androidx.collection.LongSparseArray
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.data.InMemoryGlucoseValue
|
||||
import info.nightscout.androidaps.data.IobTotal
|
||||
import info.nightscout.androidaps.data.MealData
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
|
@ -77,8 +78,9 @@ open class IobCobCalculatorPlugin @Inject constructor(
|
|||
private var absIobTable = LongSparseArray<IobTotal>() // oldest at index 0, absolute insulin in the body
|
||||
private var autosensDataTable = LongSparseArray<AutosensData>() // oldest at index 0
|
||||
private var basalDataTable = LongSparseArray<BasalData>() // oldest at index 0
|
||||
@Volatile override var bgReadings: List<GlucoseValue> = listOf() // newest at index 0
|
||||
@Volatile var bucketedData: MutableList<InMemoryGlucoseValue>? = null
|
||||
override var bgReadings: List<GlucoseValue> = listOf() // newest at index 0
|
||||
|
||||
@Volatile override var bucketedData: MutableList<InMemoryGlucoseValue>? = null
|
||||
|
||||
// we need to make sure that bucketed_data will always have the same timestamp for correct use of cached values
|
||||
// once referenceTime != null all bucketed data should be (x * 5min) from referenceTime
|
||||
|
@ -780,7 +782,16 @@ open class IobCobCalculatorPlugin @Inject constructor(
|
|||
|
||||
override fun calculateIobFromBolus(): IobTotal = calculateIobFromBolusToTime(dateUtil.now())
|
||||
|
||||
override fun calculateIobFromBolusToTime(toTime: Long): IobTotal {
|
||||
/**
|
||||
* Calculate IobTotal from boluses and extended to provided timestamp.
|
||||
* NOTE: Only isValid == true boluses are included
|
||||
* NOTE: if faking by TBR by extended boluses is enabled, extended boluses are not included
|
||||
* and are calculated towards temporary basals
|
||||
*
|
||||
* @param toTime timestamp in milliseconds
|
||||
* @return calculated iob
|
||||
*/
|
||||
private fun calculateIobFromBolusToTime(toTime: Long): IobTotal {
|
||||
val total = IobTotal(toTime)
|
||||
val profile = profileFunction.getProfile() ?: return total
|
||||
val dia = profile.dia
|
||||
|
|
|
@ -63,8 +63,8 @@ class RandomBgPlugin @Inject constructor(
|
|||
|
||||
init {
|
||||
refreshLoop = Runnable {
|
||||
handleNewData()
|
||||
loopHandler.postDelayed(refreshLoop, T.mins(interval).msecs())
|
||||
handleNewData()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package info.nightscout.androidaps.data
|
||||
|
||||
import info.nightscout.androidaps.database.entities.GlucoseValue
|
||||
|
||||
class InMemoryGlucoseValue @JvmOverloads constructor(var timestamp: Long = 0L, var value: Double = 0.0, var interpolated: Boolean = false) {
|
||||
|
||||
constructor(gv: GlucoseValue) : this(gv.timestamp, gv.value)
|
||||
// var generated : value doesn't correspond to real value with timestamp close to real BG
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.androidaps.interfaces
|
||||
|
||||
import androidx.collection.LongSparseArray
|
||||
import info.nightscout.androidaps.data.InMemoryGlucoseValue
|
||||
import info.nightscout.androidaps.data.IobTotal
|
||||
import info.nightscout.androidaps.data.MealData
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
|
@ -17,6 +18,7 @@ interface IobCobCalculator {
|
|||
|
||||
val dataLock: Any
|
||||
var bgReadings: List<GlucoseValue>
|
||||
var bucketedData: MutableList<InMemoryGlucoseValue>?
|
||||
|
||||
val mealData: MealData
|
||||
fun getAutosensDataTable(): LongSparseArray<AutosensData>
|
||||
|
@ -33,6 +35,7 @@ interface IobCobCalculator {
|
|||
fun slowAbsorptionPercentage(timeInMinutes: Int): Double
|
||||
fun convertToJSONArray(iobArray: Array<IobTotal>): JSONArray
|
||||
|
||||
|
||||
/**
|
||||
* Return last valid (>39) GlucoseValue from database or null if db is empty
|
||||
*
|
||||
|
@ -66,17 +69,6 @@ interface IobCobCalculator {
|
|||
*/
|
||||
fun calculateIobFromBolus(): IobTotal
|
||||
|
||||
/**
|
||||
* Calculate IobTotal from boluses and extended to provided timestamp.
|
||||
* NOTE: Only isValid == true boluses are included
|
||||
* NOTE: if faking by TBR by extended boluses is enabled, extended boluses are not included
|
||||
* and are calculated towards temporary basals
|
||||
*
|
||||
* @param timestamp timestamp in milliseconds
|
||||
* @return calculated iob
|
||||
*/
|
||||
fun calculateIobFromBolusToTime(toTime: Long): IobTotal
|
||||
|
||||
/**
|
||||
* Get running temporary basal at time
|
||||
*
|
||||
|
|
|
@ -215,7 +215,7 @@ open class APSResult @Inject constructor(val injector: HasAndroidInjector) {
|
|||
noise = 0.0,
|
||||
value = iob.getInt(i).toDouble(),
|
||||
timestamp = startTime + i * 5 * 60 * 1000L,
|
||||
sourceSensor = GlucoseValue.SourceSensor.aCOB_PREDICTION,
|
||||
sourceSensor = GlucoseValue.SourceSensor.A_COB_PREDICTION,
|
||||
trendArrow = GlucoseValue.TrendArrow.NONE
|
||||
)
|
||||
array.add(gv)
|
||||
|
|
|
@ -70,7 +70,8 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
|||
GENERAL,
|
||||
GENERALWITHDURATION,
|
||||
COBFAILOVER,
|
||||
IOBPREDICTION
|
||||
IOBPREDICTION,
|
||||
BUCKETED_BG
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,7 +201,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
|||
mPaint.setStyle(Paint.Style.FILL);
|
||||
mPaint.setStrokeWidth(0);
|
||||
canvas.drawCircle(endX, endY, value.getSize() * scaledPxSize, mPaint);
|
||||
} else if (value.getShape() == Shape.BG || value.getShape() == Shape.IOBPREDICTION) {
|
||||
} else if (value.getShape() == Shape.BG || value.getShape() == Shape.IOBPREDICTION || value.getShape() == Shape.BUCKETED_BG) {
|
||||
mPaint.setColor(value.getColor());
|
||||
mPaint.setStyle(Paint.Style.FILL);
|
||||
mPaint.setStrokeWidth(0);
|
||||
|
|
|
@ -93,11 +93,11 @@ data class GlucoseValue(
|
|||
@SerializedName("Random") RANDOM("Random"),
|
||||
@SerializedName("Unknown") UNKNOWN("Unknown"),
|
||||
|
||||
@SerializedName("IOBPrediction") IOB_PREDICTION("IOBPrediction"),
|
||||
@SerializedName("aCOBPrediction") aCOB_PREDICTION("aCOBPrediction"),
|
||||
@SerializedName("COBPrediction") COB_PREDICTION("COBPrediction"),
|
||||
@SerializedName("UAMPrediction") UAM_PREDICTION("UAMPrediction"),
|
||||
@SerializedName("ZTPrediction") ZT_PREDICTION("ZTPrediction")
|
||||
IOB_PREDICTION("IOBPrediction"),
|
||||
A_COB_PREDICTION("aCOBPrediction"),
|
||||
COB_PREDICTION("COBPrediction"),
|
||||
UAM_PREDICTION("UAMPrediction"),
|
||||
ZT_PREDICTION("ZTPrediction"),
|
||||
;
|
||||
|
||||
companion object {
|
||||
|
|
Loading…
Reference in a new issue