IobTotal -> interfaces

This commit is contained in:
Milos Kozak 2022-11-10 14:54:51 +01:00
parent 28d6a73c2f
commit d0a240b417
33 changed files with 231 additions and 201 deletions

View file

@ -34,6 +34,7 @@ import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
import info.nightscout.androidaps.utils.wizard.BolusWizard import info.nightscout.androidaps.utils.wizard.BolusWizard
import info.nightscout.core.fabric.FabricPrivacy import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.iob.round
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper import info.nightscout.database.impl.ValueWrapper
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.aps.openAPSAMA
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.getPassedDurationToTimeInMinutes import info.nightscout.androidaps.extensions.getPassedDurationToTimeInMinutes
import info.nightscout.androidaps.extensions.plannedRemainingMinutes import info.nightscout.androidaps.extensions.plannedRemainingMinutes
@ -17,6 +16,7 @@ import info.nightscout.androidaps.plugins.aps.loop.ScriptReader
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.aps.SMBDefaults import info.nightscout.interfaces.aps.SMBDefaults
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.iob.MealData import info.nightscout.interfaces.iob.MealData
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.aps.openAPSSMB
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.getPassedDurationToTimeInMinutes import info.nightscout.androidaps.extensions.getPassedDurationToTimeInMinutes
import info.nightscout.androidaps.extensions.plannedRemainingMinutes import info.nightscout.androidaps.extensions.plannedRemainingMinutes
@ -18,6 +17,7 @@ import info.nightscout.androidaps.plugins.aps.loop.ScriptReader
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.aps.SMBDefaults import info.nightscout.interfaces.aps.SMBDefaults
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.iob.MealData import info.nightscout.interfaces.iob.MealData
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.aps.openAPSSMBDynamicISF
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.getPassedDurationToTimeInMinutes import info.nightscout.androidaps.extensions.getPassedDurationToTimeInMinutes
import info.nightscout.androidaps.extensions.plannedRemainingMinutes import info.nightscout.androidaps.extensions.plannedRemainingMinutes
@ -20,6 +19,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.aps.SMBDefaults import info.nightscout.interfaces.aps.SMBDefaults
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.iob.MealData import info.nightscout.interfaces.iob.MealData
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger

View file

@ -18,6 +18,7 @@ import info.nightscout.androidaps.receivers.Intents
import info.nightscout.androidaps.receivers.ReceiverStatusStore import info.nightscout.androidaps.receivers.ReceiverStatusStore
import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.core.fabric.FabricPrivacy import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.iob.round
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription

View file

@ -18,6 +18,7 @@ import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.core.fabric.FabricPrivacy import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.iob.round
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.NotificationHolder import info.nightscout.interfaces.NotificationHolder
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase

View file

@ -31,6 +31,7 @@ import info.nightscout.androidaps.utils.wizard.BolusWizard
import info.nightscout.androidaps.utils.wizard.QuickWizard import info.nightscout.androidaps.utils.wizard.QuickWizard
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
import info.nightscout.core.fabric.FabricPrivacy import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.iob.round
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.entities.TemporaryBasal import info.nightscout.database.entities.TemporaryBasal

View file

@ -4,7 +4,6 @@ import androidx.collection.LongSparseArray
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged
import info.nightscout.androidaps.events.EventNewBG import info.nightscout.androidaps.events.EventNewBG
import info.nightscout.androidaps.events.EventNewHistoryData import info.nightscout.androidaps.events.EventNewHistoryData
@ -21,6 +20,11 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData
import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.workflow.CalculationWorkflow import info.nightscout.androidaps.workflow.CalculationWorkflow
import info.nightscout.core.fabric.FabricPrivacy import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.iob.combine
import info.nightscout.core.iob.copy
import info.nightscout.core.iob.determineBasalJson
import info.nightscout.core.iob.plus
import info.nightscout.core.iob.round
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.ExtendedBolus import info.nightscout.database.entities.ExtendedBolus
import info.nightscout.database.entities.TemporaryBasal import info.nightscout.database.entities.TemporaryBasal
@ -28,6 +32,7 @@ import info.nightscout.database.entities.interfaces.end
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper import info.nightscout.database.impl.ValueWrapper
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.iob.MealData import info.nightscout.interfaces.iob.MealData
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription

View file

@ -20,6 +20,7 @@ import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.core.iob.round
import info.nightscout.database.entities.BolusCalculatorResult import info.nightscout.database.entities.BolusCalculatorResult
import info.nightscout.database.entities.OfflineEvent import info.nightscout.database.entities.OfflineEvent
import info.nightscout.database.entities.TemporaryTarget import info.nightscout.database.entities.TemporaryTarget

View file

@ -8,6 +8,7 @@ import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.Profile import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.core.iob.round
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper import info.nightscout.database.impl.ValueWrapper

View file

@ -10,13 +10,8 @@ import com.jjoe64.graphview.series.BarGraphSeries
import com.jjoe64.graphview.series.LineGraphSeries import com.jjoe64.graphview.series.LineGraphSeries
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.androidaps.interfaces.IobCobCalculator import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.interfaces.aps.SMBDefaults
import info.nightscout.androidaps.plugins.general.overview.OverviewData import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.general.overview.OverviewMenus import info.nightscout.androidaps.plugins.general.overview.OverviewMenus
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
@ -27,11 +22,18 @@ import info.nightscout.androidaps.plugins.general.overview.graphExtensions.Scale
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.androidaps.receivers.DataWorkerStorage import info.nightscout.androidaps.receivers.DataWorkerStorage
import info.nightscout.shared.utils.DateUtil
import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.core.iob.combine
import info.nightscout.core.iob.copy
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.interfaces.aps.SMBDefaults
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import javax.inject.Inject import javax.inject.Inject
import kotlin.math.abs import kotlin.math.abs
import kotlin.math.max import kotlin.math.max
@ -51,9 +53,10 @@ class PrepareIobAutosensGraphDataWorker(
@Inject lateinit var repository: AppRepository @Inject lateinit var repository: AppRepository
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
var ctx: Context var ctx: Context
init { init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this) (context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
ctx = rh.getThemedCtx(context) ctx = rh.getThemedCtx(context)
} }
class PrepareIobAutosensData( class PrepareIobAutosensData(
@ -61,6 +64,37 @@ class PrepareIobAutosensGraphDataWorker(
val overviewData: OverviewData val overviewData: OverviewData
) )
class IobTotalDataPoint(time: Long) : IobTotal(time), DataPointWithLabelInterface {
constructor(i: IobTotal) : this(i.time) {
iob = i.iob
activity = i.activity
bolussnooze = i.bolussnooze
basaliob = i.basaliob
netbasalinsulin = i.netbasalinsulin
hightempinsulin = i.hightempinsulin
lastBolusTime = i.lastBolusTime
iobWithZeroTemp = i.iobWithZeroTemp?.copy()
netInsulin = i.netInsulin
extendedBolusInsulin = i.extendedBolusInsulin
}
private var color = 0
override fun getX(): Double = time.toDouble()
override fun getY(): Double = iob
override fun setY(y: Double) {}
override val label = ""
override val duration = 0L
override val shape = PointsWithLabelGraphSeries.Shape.IOB_PREDICTION
override val size = 0.5f
override fun color(context: Context?): Int = color
fun setColor(color: Int): IobTotalDataPoint {
this.color = color
return this
}
}
override fun doWork(): Result { override fun doWork(): Result {
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareIobAutosensData? val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareIobAutosensData?
?: return Result.failure(workDataOf("Error" to "missing input data")) ?: return Result.failure(workDataOf("Error" to "missing input data"))
@ -157,15 +191,15 @@ class PrepareIobAutosensGraphDataWorker(
// DEVIATIONS // DEVIATIONS
if (autosensData != null) { if (autosensData != null) {
var color = rh.gac( ctx, R.attr.deviationBlackColor) // "=" var color = rh.gac(ctx, R.attr.deviationBlackColor) // "="
if (autosensData.type == "" || autosensData.type == "non-meal") { if (autosensData.type == "" || autosensData.type == "non-meal") {
if (autosensData.pastSensitivity == "C") color = rh.gac( ctx, R.attr.deviationGreyColor) if (autosensData.pastSensitivity == "C") color = rh.gac(ctx, R.attr.deviationGreyColor)
if (autosensData.pastSensitivity == "+") color = rh.gac( ctx, R.attr.deviationGreenColor) if (autosensData.pastSensitivity == "+") color = rh.gac(ctx, R.attr.deviationGreenColor)
if (autosensData.pastSensitivity == "-") color = rh.gac( ctx, R.attr.deviationRedColor) if (autosensData.pastSensitivity == "-") color = rh.gac(ctx, R.attr.deviationRedColor)
} else if (autosensData.type == "uam") { } else if (autosensData.type == "uam") {
color = rh.gac( ctx, R.attr.uamColor) color = rh.gac(ctx, R.attr.uamColor)
} else if (autosensData.type == "csf") { } else if (autosensData.type == "csf") {
color = rh.gac( ctx, R.attr.deviationGreyColor) color = rh.gac(ctx, R.attr.deviationGreyColor)
} }
devArray.add(DeviationDataPoint(time.toDouble(), autosensData.deviation, color, data.overviewData.devScale)) devArray.add(DeviationDataPoint(time.toDouble(), autosensData.deviation, color, data.overviewData.devScale))
data.overviewData.maxDevValueFound = maxOf(data.overviewData.maxDevValueFound, abs(autosensData.deviation), abs(bgi)) data.overviewData.maxDevValueFound = maxOf(data.overviewData.maxDevValueFound, abs(autosensData.deviation), abs(bgi))
@ -191,14 +225,14 @@ class PrepareIobAutosensGraphDataWorker(
// IOB // IOB
data.overviewData.iobSeries = FixedLineGraphSeries(Array(iobArray.size) { i -> iobArray[i] }).also { data.overviewData.iobSeries = FixedLineGraphSeries(Array(iobArray.size) { i -> iobArray[i] }).also {
it.isDrawBackground = true it.isDrawBackground = true
it.backgroundColor = -0x7f000001 and rh.gac( ctx, R.attr.iobColor) //50% it.backgroundColor = -0x7f000001 and rh.gac(ctx, R.attr.iobColor) //50%
it.color = rh.gac( ctx, R.attr.iobColor) it.color = rh.gac(ctx, R.attr.iobColor)
it.thickness = 3 it.thickness = 3
} }
data.overviewData.absIobSeries = FixedLineGraphSeries(Array(absIobArray.size) { i -> absIobArray[i] }).also { data.overviewData.absIobSeries = FixedLineGraphSeries(Array(absIobArray.size) { i -> absIobArray[i] }).also {
it.isDrawBackground = true it.isDrawBackground = true
it.backgroundColor = -0x7f000001 and rh.gac( ctx, R.attr.iobColor) //50% it.backgroundColor = -0x7f000001 and rh.gac(ctx, R.attr.iobColor) //50%
it.color = rh.gac( ctx, R.attr.iobColor) it.color = rh.gac(ctx, R.attr.iobColor)
it.thickness = 3 it.thickness = 3
} }
@ -209,7 +243,7 @@ class PrepareIobAutosensGraphDataWorker(
val iobPrediction: MutableList<DataPointWithLabelInterface> = ArrayList() val iobPrediction: MutableList<DataPointWithLabelInterface> = ArrayList()
val iobPredictionArray = data.iobCobCalculator.calculateIobArrayForSMB(lastAutosensResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, isTempTarget) val iobPredictionArray = data.iobCobCalculator.calculateIobArrayForSMB(lastAutosensResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, isTempTarget)
for (i in iobPredictionArray) { for (i in iobPredictionArray) {
iobPrediction.add(i.setColor(rh.gac( ctx, R.attr.iobPredASColor))) iobPrediction.add(IobTotalDataPoint(i).setColor(rh.gac(ctx, R.attr.iobPredASColor)))
data.overviewData.maxIobValueFound = max(data.overviewData.maxIobValueFound, abs(i.iob)) data.overviewData.maxIobValueFound = max(data.overviewData.maxIobValueFound, abs(i.iob))
} }
data.overviewData.iobPredictions1Series = PointsWithLabelGraphSeries(Array(iobPrediction.size) { i -> iobPrediction[i] }) data.overviewData.iobPredictions1Series = PointsWithLabelGraphSeries(Array(iobPrediction.size) { i -> iobPrediction[i] })
@ -221,8 +255,8 @@ class PrepareIobAutosensGraphDataWorker(
// COB // COB
data.overviewData.cobSeries = FixedLineGraphSeries(Array(cobArray.size) { i -> cobArray[i] }).also { data.overviewData.cobSeries = FixedLineGraphSeries(Array(cobArray.size) { i -> cobArray[i] }).also {
it.isDrawBackground = true it.isDrawBackground = true
it.backgroundColor = -0x7f000001 and rh.gac( ctx, R.attr.cobColor) //50% it.backgroundColor = -0x7f000001 and rh.gac(ctx, R.attr.cobColor) //50%
it.color = rh.gac( ctx, R.attr.cobColor) it.color = rh.gac(ctx, R.attr.cobColor)
it.thickness = 3 it.thickness = 3
} }
data.overviewData.cobMinFailOverSeries = PointsWithLabelGraphSeries(Array(minFailOverActiveList.size) { i -> minFailOverActiveList[i] }) data.overviewData.cobMinFailOverSeries = PointsWithLabelGraphSeries(Array(minFailOverActiveList.size) { i -> minFailOverActiveList[i] })
@ -230,7 +264,7 @@ class PrepareIobAutosensGraphDataWorker(
// ACTIVITY // ACTIVITY
data.overviewData.activitySeries = FixedLineGraphSeries(Array(actArrayHist.size) { i -> actArrayHist[i] }).also { data.overviewData.activitySeries = FixedLineGraphSeries(Array(actArrayHist.size) { i -> actArrayHist[i] }).also {
it.isDrawBackground = false it.isDrawBackground = false
it.color = rh.gac( ctx, R.attr.activityColor) it.color = rh.gac(ctx, R.attr.activityColor)
it.thickness = 3 it.thickness = 3
} }
data.overviewData.activityPredictionSeries = FixedLineGraphSeries(Array(actArrayPrediction.size) { i -> actArrayPrediction[i] }).also { data.overviewData.activityPredictionSeries = FixedLineGraphSeries(Array(actArrayPrediction.size) { i -> actArrayPrediction[i] }).also {
@ -238,14 +272,14 @@ class PrepareIobAutosensGraphDataWorker(
paint.style = Paint.Style.STROKE paint.style = Paint.Style.STROKE
paint.strokeWidth = 3f paint.strokeWidth = 3f
paint.pathEffect = DashPathEffect(floatArrayOf(4f, 4f), 0f) paint.pathEffect = DashPathEffect(floatArrayOf(4f, 4f), 0f)
paint.color = rh.gac( ctx, R.attr.activityColor) paint.color = rh.gac(ctx, R.attr.activityColor)
}) })
} }
// BGI // BGI
data.overviewData.minusBgiSeries = FixedLineGraphSeries(Array(bgiArrayHist.size) { i -> bgiArrayHist[i] }).also { data.overviewData.minusBgiSeries = FixedLineGraphSeries(Array(bgiArrayHist.size) { i -> bgiArrayHist[i] }).also {
it.isDrawBackground = false it.isDrawBackground = false
it.color = rh.gac( ctx, R.attr.bgiColor) it.color = rh.gac(ctx, R.attr.bgiColor)
it.thickness = 3 it.thickness = 3
} }
data.overviewData.minusBgiHistSeries = FixedLineGraphSeries(Array(bgiArrayPrediction.size) { i -> bgiArrayPrediction[i] }).also { data.overviewData.minusBgiHistSeries = FixedLineGraphSeries(Array(bgiArrayPrediction.size) { i -> bgiArrayPrediction[i] }).also {
@ -253,7 +287,7 @@ class PrepareIobAutosensGraphDataWorker(
paint.style = Paint.Style.STROKE paint.style = Paint.Style.STROKE
paint.strokeWidth = 3f paint.strokeWidth = 3f
paint.pathEffect = DashPathEffect(floatArrayOf(4f, 4f), 0f) paint.pathEffect = DashPathEffect(floatArrayOf(4f, 4f), 0f)
paint.color = rh.gac( ctx, R.attr.bgiColor) paint.color = rh.gac(ctx, R.attr.bgiColor)
}) })
} }
@ -264,17 +298,17 @@ class PrepareIobAutosensGraphDataWorker(
// RATIO // RATIO
data.overviewData.ratioSeries = LineGraphSeries(Array(ratioArray.size) { i -> ratioArray[i] }).also { data.overviewData.ratioSeries = LineGraphSeries(Array(ratioArray.size) { i -> ratioArray[i] }).also {
it.color = rh.gac( ctx, R.attr.ratioColor) it.color = rh.gac(ctx, R.attr.ratioColor)
it.thickness = 3 it.thickness = 3
} }
// DEV SLOPE // DEV SLOPE
data.overviewData.dsMaxSeries = LineGraphSeries(Array(dsMaxArray.size) { i -> dsMaxArray[i] }).also { data.overviewData.dsMaxSeries = LineGraphSeries(Array(dsMaxArray.size) { i -> dsMaxArray[i] }).also {
it.color = rh.gac( ctx, R.attr.devSlopePosColor) it.color = rh.gac(ctx, R.attr.devSlopePosColor)
it.thickness = 3 it.thickness = 3
} }
data.overviewData.dsMinSeries = LineGraphSeries(Array(dsMinArray.size) { i -> dsMinArray[i] }).also { data.overviewData.dsMinSeries = LineGraphSeries(Array(dsMinArray.size) { i -> dsMinArray[i] }).also {
it.color = rh.gac( ctx, R.attr.devSlopeNegColor) it.color = rh.gac(ctx, R.attr.devSlopeNegColor)
it.thickness = 3 it.thickness = 3
} }
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_IOB_AUTOSENS_DATA, 100, null)) rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_IOB_AUTOSENS_DATA, 100, null))

View file

@ -4,7 +4,6 @@ import android.content.Context
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.CommandQueue import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Constraints import info.nightscout.androidaps.interfaces.Constraints
@ -16,6 +15,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStore
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus

View file

@ -1,9 +1,9 @@
package info.nightscout.automation.triggers package info.nightscout.automation.triggers
import com.google.common.base.Optional import com.google.common.base.Optional
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.automation.elements.Comparator import info.nightscout.automation.elements.Comparator
import info.nightscout.interfaces.iob.IobTotal
import org.json.JSONObject import org.json.JSONObject
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before

View file

@ -1,143 +0,0 @@
package info.nightscout.androidaps.data
import android.content.Context
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries
import info.nightscout.shared.utils.DateUtil
import info.nightscout.interfaces.utils.Round
import org.json.JSONException
import org.json.JSONObject
@Suppress("SpellCheckingInspection")
class IobTotal(val time: Long) : DataPointWithLabelInterface {
var iob = 0.0
var activity = 0.0
var bolussnooze = 0.0
var basaliob = 0.0
var netbasalinsulin = 0.0
var hightempinsulin = 0.0
// oref1
var lastBolusTime: Long = 0
var iobWithZeroTemp: IobTotal? = null
var netInsulin = 0.0 // for calculations from temp basals only
var extendedBolusInsulin = 0.0 // total insulin for extended bolus
fun copy(): IobTotal {
val i = IobTotal(time)
i.iob = iob
i.activity = activity
i.bolussnooze = bolussnooze
i.basaliob = basaliob
i.netbasalinsulin = netbasalinsulin
i.hightempinsulin = hightempinsulin
i.lastBolusTime = lastBolusTime
i.iobWithZeroTemp = iobWithZeroTemp?.copy()
i.netInsulin = netInsulin
i.extendedBolusInsulin = extendedBolusInsulin
return i
}
operator fun plus(other: IobTotal): IobTotal {
iob += other.iob
activity += other.activity
bolussnooze += other.bolussnooze
basaliob += other.basaliob
netbasalinsulin += other.netbasalinsulin
hightempinsulin += other.hightempinsulin
netInsulin += other.netInsulin
extendedBolusInsulin += other.extendedBolusInsulin
return this
}
fun round(): IobTotal {
iob = Round.roundTo(iob, 0.001)
activity = Round.roundTo(activity, 0.0001)
bolussnooze = Round.roundTo(bolussnooze, 0.0001)
basaliob = Round.roundTo(basaliob, 0.001)
netbasalinsulin = Round.roundTo(netbasalinsulin, 0.001)
hightempinsulin = Round.roundTo(hightempinsulin, 0.001)
netInsulin = Round.roundTo(netInsulin, 0.001)
extendedBolusInsulin = Round.roundTo(extendedBolusInsulin, 0.001)
return this
}
fun json(dateUtil: DateUtil): JSONObject {
val json = JSONObject()
try {
json.put("iob", iob)
json.put("basaliob", basaliob)
json.put("activity", activity)
json.put("time", dateUtil.toISOString(time))
} catch (ignored: JSONException) {
}
return json
}
fun determineBasalJson(dateUtil: DateUtil): JSONObject {
val json = JSONObject()
try {
json.put("iob", iob)
json.put("basaliob", basaliob)
json.put("bolussnooze", bolussnooze)
json.put("activity", activity)
json.put("lastBolusTime", lastBolusTime)
json.put("time", dateUtil.toISOString(time))
/*
This is requested by SMB determine_basal but by based on Scott's info
it's MDT specific safety check only
It's causing rounding issues in determine_basal
JSONObject lastTemp = new JSONObject();
lastTemp.put("date", lastTempDate);
lastTemp.put("rate", lastTempRate);
lastTemp.put("duration", lastTempDuration);
json.put("lastTemp", lastTemp);
*/
if (iobWithZeroTemp != null) {
val iwzt = iobWithZeroTemp!!.determineBasalJson(dateUtil)
json.put("iobWithZeroTemp", iwzt)
}
} catch (ignored: JSONException) {
}
return json
}
// DataPoint interface
private var color = 0
override fun getX(): Double = time.toDouble()
override fun getY(): Double = iob
override fun setY(y: Double) {}
override val label = ""
override val duration = 0L
override val shape = PointsWithLabelGraphSeries.Shape.IOB_PREDICTION
override val size = 0.5f
override fun color(context: Context?): Int {
return color
}
fun setColor(color: Int): IobTotal {
this.color = color
return this
}
companion object {
fun combine(bolusIOB: IobTotal, basalIob: IobTotal): IobTotal {
val result = IobTotal(bolusIOB.time)
result.iob = bolusIOB.iob + basalIob.basaliob
result.activity = bolusIOB.activity + basalIob.activity
result.bolussnooze = bolusIOB.bolussnooze
result.basaliob = bolusIOB.basaliob + basalIob.basaliob
result.netbasalinsulin = bolusIOB.netbasalinsulin + basalIob.netbasalinsulin
result.hightempinsulin = basalIob.hightempinsulin + bolusIOB.hightempinsulin
result.netInsulin = basalIob.netInsulin + bolusIOB.netInsulin
result.extendedBolusInsulin = basalIob.extendedBolusInsulin + bolusIOB.extendedBolusInsulin
result.lastBolusTime = bolusIOB.lastBolusTime
result.iobWithZeroTemp = basalIob.iobWithZeroTemp
return result
}
}
}

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps.extensions package info.nightscout.androidaps.extensions
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.interfaces.Insulin import info.nightscout.androidaps.interfaces.Insulin
import info.nightscout.androidaps.interfaces.Profile import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
@ -9,6 +8,7 @@ import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.ExtendedBolus import info.nightscout.database.entities.ExtendedBolus
import info.nightscout.database.entities.TemporaryBasal import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.database.entities.interfaces.end import info.nightscout.database.entities.interfaces.end
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import kotlin.math.ceil import kotlin.math.ceil

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps.extensions package info.nightscout.androidaps.extensions
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.interfaces.Insulin import info.nightscout.androidaps.interfaces.Insulin
import info.nightscout.androidaps.interfaces.Profile import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
@ -9,6 +8,7 @@ import info.nightscout.androidaps.utils.DecimalFormatter.to2Decimal
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.TemporaryBasal import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.database.entities.interfaces.end import info.nightscout.database.entities.interfaces.end
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import kotlin.math.ceil import kotlin.math.ceil

View file

@ -1,8 +1,8 @@
package info.nightscout.androidaps.interfaces package info.nightscout.androidaps.interfaces
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.plugins.aps.loop.APSResult import info.nightscout.androidaps.plugins.aps.loop.APSResult
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.iob.MealData import info.nightscout.interfaces.iob.MealData
interface DetermineBasalAdapterInterface { interface DetermineBasalAdapterInterface {

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps.interfaces package info.nightscout.androidaps.interfaces
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStore import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStore
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.BasalData import info.nightscout.androidaps.plugins.iob.iobCobCalculator.BasalData
@ -8,6 +7,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData
import info.nightscout.database.entities.ExtendedBolus import info.nightscout.database.entities.ExtendedBolus
import info.nightscout.database.entities.TemporaryBasal import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.iob.MealData import info.nightscout.interfaces.iob.MealData
import org.json.JSONArray import org.json.JSONArray

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.aps.loop
import android.text.Spanned import android.text.Spanned
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.convertedToPercent import info.nightscout.androidaps.extensions.convertedToPercent
import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ActivePlugin
@ -13,6 +12,7 @@ import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.utils.HtmlHelper.fromHtml import info.nightscout.interfaces.utils.HtmlHelper.fromHtml
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger

View file

@ -7,9 +7,6 @@ import androidx.annotation.DrawableRes
import com.jjoe64.graphview.series.BarGraphSeries import com.jjoe64.graphview.series.BarGraphSeries
import com.jjoe64.graphview.series.DataPoint import com.jjoe64.graphview.series.DataPoint
import com.jjoe64.graphview.series.LineGraphSeries import com.jjoe64.graphview.series.LineGraphSeries
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.androidaps.extensions.convertedToPercent import info.nightscout.androidaps.extensions.convertedToPercent
import info.nightscout.androidaps.extensions.isInProgress import info.nightscout.androidaps.extensions.isInProgress
import info.nightscout.androidaps.extensions.toStringFull import info.nightscout.androidaps.extensions.toStringFull
@ -27,9 +24,13 @@ import info.nightscout.androidaps.plugins.general.overview.graphExtensions.Scale
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData
import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.core.iob.round
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.entities.TemporaryTarget import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP

View file

@ -1,11 +1,11 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.androidaps.plugins.general.overview.graphExtensions
import android.content.Context import android.content.Context
import info.nightscout.interfaces.Constants
import info.nightscout.core.main.R
import info.nightscout.androidaps.data.InMemoryGlucoseValue
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.core.main.R
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.iob.InMemoryGlucoseValue
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
class InMemoryGlucoseValueDataPoint( class InMemoryGlucoseValueDataPoint(

View file

@ -3,11 +3,11 @@ package info.nightscout.androidaps.plugins.iob.iobCobCalculator
import androidx.collection.LongSparseArray import androidx.collection.LongSparseArray
import androidx.collection.size import androidx.collection.size
import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.InMemoryGlucoseValue
import info.nightscout.database.impl.AppRepository
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventBucketedDataCreated import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventBucketedDataCreated
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.iob.InMemoryGlucoseValue
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag

View file

@ -0,0 +1,103 @@
package info.nightscout.core.iob
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.utils.Round
import info.nightscout.shared.utils.DateUtil
import org.json.JSONException
import org.json.JSONObject
fun IobTotal.copy(): IobTotal {
val i = IobTotal(time)
i.iob = iob
i.activity = activity
i.bolussnooze = bolussnooze
i.basaliob = basaliob
i.netbasalinsulin = netbasalinsulin
i.hightempinsulin = hightempinsulin
i.lastBolusTime = lastBolusTime
i.iobWithZeroTemp = iobWithZeroTemp?.copy()
i.netInsulin = netInsulin
i.extendedBolusInsulin = extendedBolusInsulin
return i
}
operator fun IobTotal.plus(other: IobTotal): IobTotal {
iob += other.iob
activity += other.activity
bolussnooze += other.bolussnooze
basaliob += other.basaliob
netbasalinsulin += other.netbasalinsulin
hightempinsulin += other.hightempinsulin
netInsulin += other.netInsulin
extendedBolusInsulin += other.extendedBolusInsulin
return this
}
fun IobTotal.round(): IobTotal {
iob = Round.roundTo(iob, 0.001)
activity = Round.roundTo(activity, 0.0001)
bolussnooze = Round.roundTo(bolussnooze, 0.0001)
basaliob = Round.roundTo(basaliob, 0.001)
netbasalinsulin = Round.roundTo(netbasalinsulin, 0.001)
hightempinsulin = Round.roundTo(hightempinsulin, 0.001)
netInsulin = Round.roundTo(netInsulin, 0.001)
extendedBolusInsulin = Round.roundTo(extendedBolusInsulin, 0.001)
return this
}
fun IobTotal.json(dateUtil: DateUtil): JSONObject {
val json = JSONObject()
try {
json.put("iob", iob)
json.put("basaliob", basaliob)
json.put("activity", activity)
json.put("time", dateUtil.toISOString(time))
} catch (ignored: JSONException) {
}
return json
}
fun IobTotal.determineBasalJson(dateUtil: DateUtil): JSONObject {
val json = JSONObject()
try {
json.put("iob", iob)
json.put("basaliob", basaliob)
json.put("bolussnooze", bolussnooze)
json.put("activity", activity)
json.put("lastBolusTime", lastBolusTime)
json.put("time", dateUtil.toISOString(time))
/*
This is requested by SMB determine_basal but by based on Scott's info
it's MDT specific safety check only
It's causing rounding issues in determine_basal
JSONObject lastTemp = new JSONObject();
lastTemp.put("date", lastTempDate);
lastTemp.put("rate", lastTempRate);
lastTemp.put("duration", lastTempDuration);
json.put("lastTemp", lastTemp);
*/
if (iobWithZeroTemp != null) {
val iwzt = iobWithZeroTemp!!.determineBasalJson(dateUtil)
json.put("iobWithZeroTemp", iwzt)
}
} catch (ignored: JSONException) {
}
return json
}
fun IobTotal.Companion.combine(bolusIOB: IobTotal, basalIob: IobTotal): IobTotal {
val result = IobTotal(bolusIOB.time)
result.iob = bolusIOB.iob + basalIob.basaliob
result.activity = bolusIOB.activity + basalIob.activity
result.bolussnooze = bolusIOB.bolussnooze
result.basaliob = bolusIOB.basaliob + basalIob.basaliob
result.netbasalinsulin = bolusIOB.netbasalinsulin + basalIob.netbasalinsulin
result.hightempinsulin = basalIob.hightempinsulin + bolusIOB.hightempinsulin
result.netInsulin = basalIob.netInsulin + bolusIOB.netInsulin
result.extendedBolusInsulin = basalIob.extendedBolusInsulin + bolusIOB.extendedBolusInsulin
result.lastBolusTime = bolusIOB.lastBolusTime
result.iobWithZeroTemp = basalIob.iobWithZeroTemp
return result
}

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.data
import android.content.Context import android.content.Context
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.data package info.nightscout.interfaces.iob
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue

View file

@ -0,0 +1,19 @@
package info.nightscout.interfaces.iob
@Suppress("SpellCheckingInspection")
open class IobTotal(val time: Long) {
var iob = 0.0
var activity = 0.0
var bolussnooze = 0.0
var basaliob = 0.0
var netbasalinsulin = 0.0
var hightempinsulin = 0.0
// oref1
var lastBolusTime: Long = 0
var iobWithZeroTemp: IobTotal? = null
var netInsulin = 0.0 // for calculations from temp basals only
var extendedBolusInsulin = 0.0 // total insulin for extended bolus
companion object
}

View file

@ -1,14 +1,13 @@
package info.nightscout.plugins.general.autotune package info.nightscout.plugins.general.autotune
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.data.LocalInsulin import info.nightscout.androidaps.data.LocalInsulin
import info.nightscout.database.impl.AppRepository
import info.nightscout.androidaps.extensions.durationInMinutes import info.nightscout.androidaps.extensions.durationInMinutes
import info.nightscout.androidaps.extensions.iobCalc import info.nightscout.androidaps.extensions.iobCalc
import info.nightscout.androidaps.extensions.toJson import info.nightscout.androidaps.extensions.toJson
import info.nightscout.androidaps.extensions.toTemporaryBasal import info.nightscout.androidaps.extensions.toTemporaryBasal
import info.nightscout.androidaps.interfaces.Profile import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.core.iob.round
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.Carbs import info.nightscout.database.entities.Carbs
import info.nightscout.database.entities.ExtendedBolus import info.nightscout.database.entities.ExtendedBolus
@ -16,7 +15,9 @@ import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.entities.TemporaryBasal import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.database.entities.TherapyEvent import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.plugins.general.autotune.data.ATProfile import info.nightscout.plugins.general.autotune.data.ATProfile

View file

@ -30,6 +30,7 @@ import info.nightscout.androidaps.receivers.DataWorkerStorage
import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference import info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
import info.nightscout.core.fabric.FabricPrivacy import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.iob.round
import info.nightscout.database.entities.OfflineEvent import info.nightscout.database.entities.OfflineEvent
import info.nightscout.database.entities.TemporaryTarget import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Action

View file

@ -12,6 +12,7 @@ import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.core.fabric.FabricPrivacy import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.iob.round
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType

View file

@ -6,6 +6,7 @@ import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.Pump import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.androidaps.receivers.ReceiverStatusStore import info.nightscout.androidaps.receivers.ReceiverStatusStore
import info.nightscout.core.iob.json
import info.nightscout.database.entities.DeviceStatus import info.nightscout.database.entities.DeviceStatus
import info.nightscout.plugins.configBuilder.RunningConfiguration import info.nightscout.plugins.configBuilder.RunningConfiguration
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil

View file

@ -2,11 +2,9 @@ package info.nightscout.plugins.general.autotune
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.data.LocalInsulin import info.nightscout.androidaps.data.LocalInsulin
import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.data.PureProfile import info.nightscout.androidaps.data.PureProfile
import info.nightscout.database.impl.AppRepository
import info.nightscout.androidaps.extensions.shiftBlock import info.nightscout.androidaps.extensions.shiftBlock
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
@ -14,7 +12,9 @@ import info.nightscout.database.entities.Carbs
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.entities.data.Block import info.nightscout.database.entities.data.Block
import info.nightscout.database.entities.data.TargetBlock import info.nightscout.database.entities.data.TargetBlock
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.plugins.general.autotune.data.ATProfile import info.nightscout.plugins.general.autotune.data.ATProfile

View file

@ -5,7 +5,6 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.TestPumpPlugin import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.data.PumpEnactResultImpl import info.nightscout.androidaps.data.PumpEnactResultImpl
import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.CommandQueue import info.nightscout.androidaps.interfaces.CommandQueue
@ -26,6 +25,7 @@ import info.nightscout.database.impl.transactions.Transaction
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType

View file

@ -15,11 +15,6 @@ import androidx.lifecycle.Lifecycle
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.database.impl.transactions.InvalidateExtendedBolusTransaction
import info.nightscout.database.impl.transactions.InvalidateTemporaryBasalTransaction
import info.nightscout.androidaps.extensions.iobCalc import info.nightscout.androidaps.extensions.iobCalc
import info.nightscout.androidaps.extensions.toStringFull import info.nightscout.androidaps.extensions.toStringFull
import info.nightscout.androidaps.extensions.toTemporaryBasal import info.nightscout.androidaps.extensions.toTemporaryBasal
@ -36,6 +31,11 @@ import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.database.entities.interfaces.end import info.nightscout.database.entities.interfaces.end
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper
import info.nightscout.database.impl.transactions.InvalidateExtendedBolusTransaction
import info.nightscout.database.impl.transactions.InvalidateTemporaryBasalTransaction
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventTempBasalChange import info.nightscout.rx.events.EventTempBasalChange