Fix progressBar
This commit is contained in:
parent
82fb85c9e0
commit
9412f88672
|
@ -51,9 +51,11 @@ class PrepareBasalDataWorker(
|
|||
var lastAbsoluteLineBasal = -1.0
|
||||
var lastBaseBasal = 0.0
|
||||
var lastTempBasal = 0.0
|
||||
var time = data.overviewData.fromTime
|
||||
while (time < data.overviewData.endTime) {
|
||||
val progress = (time - data.overviewData.endTime).toDouble() / (data.overviewData.endTime - data.overviewData.fromTime) * 100.0
|
||||
val endTime = data.overviewData.endTime
|
||||
val fromTime = data.overviewData.fromTime
|
||||
var time = fromTime
|
||||
while (time < endTime) {
|
||||
val progress = (time - endTime).toDouble() / (endTime - fromTime) * 100.0
|
||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_BASAL_DATA, progress.toInt(), null))
|
||||
val profile = profileFunction.getProfile(time)
|
||||
if (profile == null) {
|
||||
|
@ -103,10 +105,10 @@ class PrepareBasalDataWorker(
|
|||
}
|
||||
|
||||
// final points
|
||||
basalLineArray.add(ScaledDataPoint(data.overviewData.endTime, lastLineBasal, data.overviewData.basalScale))
|
||||
baseBasalArray.add(ScaledDataPoint(data.overviewData.endTime, lastBaseBasal, data.overviewData.basalScale))
|
||||
tempBasalArray.add(ScaledDataPoint(data.overviewData.endTime, lastTempBasal, data.overviewData.basalScale))
|
||||
absoluteBasalLineArray.add(ScaledDataPoint(data.overviewData.endTime, lastAbsoluteLineBasal, data.overviewData.basalScale))
|
||||
basalLineArray.add(ScaledDataPoint(endTime, lastLineBasal, data.overviewData.basalScale))
|
||||
baseBasalArray.add(ScaledDataPoint(endTime, lastBaseBasal, data.overviewData.basalScale))
|
||||
tempBasalArray.add(ScaledDataPoint(endTime, lastTempBasal, data.overviewData.basalScale))
|
||||
absoluteBasalLineArray.add(ScaledDataPoint(endTime, lastAbsoluteLineBasal, data.overviewData.basalScale))
|
||||
|
||||
// create series
|
||||
data.overviewData.baseBasalGraphSeries = LineGraphSeries(Array(baseBasalArray.size) { i -> baseBasalArray[i] }).also {
|
||||
|
|
|
@ -40,11 +40,13 @@ class PrepareBgDataWorker(
|
|||
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareBgData?
|
||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||
|
||||
val toTime = data.overviewData.toTime
|
||||
val fromTime = data.overviewData.fromTime
|
||||
data.overviewData.maxBgValue = Double.MIN_VALUE
|
||||
data.overviewData.bgReadingsArray = repository.compatGetBgReadingsDataFromTime(data.overviewData.fromTime, data.overviewData.toTime, false).blockingGet()
|
||||
val bgListArray: MutableList<DataPointWithLabelInterface> = ArrayList()
|
||||
for (bg in data.overviewData.bgReadingsArray) {
|
||||
if (bg.timestamp < data.overviewData.fromTime || bg.timestamp > data.overviewData.toTime) continue
|
||||
if (bg.timestamp < fromTime || bg.timestamp > toTime) continue
|
||||
if (bg.value > data.overviewData.maxBgValue) data.overviewData.maxBgValue = bg.value
|
||||
bgListArray.add(GlucoseValueDataPoint(bg, defaultValueHelper, profileFunction, rh))
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ class PrepareBucketedDataWorker(
|
|||
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareBucketedData?
|
||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||
|
||||
val toTime = data.overviewData.toTime
|
||||
val fromTime = data.overviewData.fromTime
|
||||
val bucketedData = data.iobCobCalculator.ads.getBucketedDataTableCopy() ?: return Result.success()
|
||||
if (bucketedData.isEmpty()) {
|
||||
aapsLogger.debug("No bucketed data.")
|
||||
|
@ -42,7 +44,7 @@ class PrepareBucketedDataWorker(
|
|||
}
|
||||
val bucketedListArray: MutableList<DataPointWithLabelInterface> = ArrayList()
|
||||
for (inMemoryGlucoseValue in bucketedData) {
|
||||
if (inMemoryGlucoseValue.timestamp < data.overviewData.fromTime || inMemoryGlucoseValue.timestamp > data.overviewData.toTime) continue
|
||||
if (inMemoryGlucoseValue.timestamp < fromTime || inMemoryGlucoseValue.timestamp > toTime) continue
|
||||
bucketedListArray.add(InMemoryGlucoseValueDataPoint(inMemoryGlucoseValue, defaultValueHelper , profileFunction, rh))
|
||||
}
|
||||
bucketedListArray.sortWith { o1: DataPointWithLabelInterface, o2: DataPointWithLabelInterface -> o1.x.compareTo(o2.x) }
|
||||
|
|
|
@ -117,13 +117,16 @@ class PrepareIobAutosensGraphDataWorker(
|
|||
override fun doWorkAndLog(): Result {
|
||||
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareIobAutosensData?
|
||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||
|
||||
val endTime = data.overviewData.endTime
|
||||
val fromTime = data.overviewData.fromTime
|
||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_IOB_AUTOSENS_DATA, 0, null))
|
||||
val iobArray: MutableList<ScaledDataPoint> = ArrayList()
|
||||
val absIobArray: MutableList<ScaledDataPoint> = ArrayList()
|
||||
data.overviewData.maxIobValueFound = Double.MIN_VALUE
|
||||
var lastIob = 0.0
|
||||
var absLastIob = 0.0
|
||||
var time = data.overviewData.fromTime
|
||||
var time = fromTime
|
||||
|
||||
val minFailOverActiveList: MutableList<DataPointWithLabelInterface> = ArrayList()
|
||||
val cobArray: MutableList<ScaledDataPoint> = ArrayList()
|
||||
|
@ -153,8 +156,8 @@ class PrepareIobAutosensGraphDataWorker(
|
|||
|
||||
val adsData = data.iobCobCalculator.ads.clone()
|
||||
|
||||
while (time <= data.overviewData.endTime) {
|
||||
val progress = (time - data.overviewData.endTime).toDouble() / (data.overviewData.endTime - data.overviewData.fromTime) * 100.0
|
||||
while (time <= endTime) {
|
||||
val progress = (time - endTime).toDouble() / (endTime - fromTime) * 100.0
|
||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_IOB_AUTOSENS_DATA, progress.toInt(), null))
|
||||
val profile = profileFunction.getProfile(time)
|
||||
if (profile == null) {
|
||||
|
|
|
@ -49,13 +49,14 @@ class PrepareTemporaryTargetDataWorker(
|
|||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TEMPORARY_TARGET_DATA, 0, null))
|
||||
val profile = profileFunction.getProfile() ?: return Result.success(workDataOf("Error" to "missing profile"))
|
||||
val units = profileFunction.getUnits()
|
||||
var toTime = data.overviewData.endTime
|
||||
var endTime = data.overviewData.endTime
|
||||
val fromTime = data.overviewData.fromTime
|
||||
val targetsSeriesArray: MutableList<DataPoint> = ArrayList()
|
||||
var lastTarget = -1.0
|
||||
loop.lastRun?.constraintsProcessed?.let { toTime = max(it.latestPredictionsTime, toTime) }
|
||||
var time = data.overviewData.fromTime
|
||||
while (time < toTime) {
|
||||
val progress = (time - data.overviewData.fromTime).toDouble() / (data.overviewData.toTime - data.overviewData.fromTime) * 100.0
|
||||
loop.lastRun?.constraintsProcessed?.let { endTime = max(it.latestPredictionsTime, endTime) }
|
||||
var time = fromTime
|
||||
while (time < endTime) {
|
||||
val progress = (time - fromTime).toDouble() / (endTime - fromTime) * 100.0
|
||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TEMPORARY_TARGET_DATA, progress.toInt(), null))
|
||||
val tt = repository.getTemporaryTargetActiveAt(time).blockingGet()
|
||||
val value: Double = if (tt is ValueWrapper.Existing) {
|
||||
|
@ -71,7 +72,7 @@ class PrepareTemporaryTargetDataWorker(
|
|||
time += 5 * 60 * 1000L
|
||||
}
|
||||
// final point
|
||||
targetsSeriesArray.add(DataPoint(toTime.toDouble(), lastTarget))
|
||||
targetsSeriesArray.add(DataPoint(endTime.toDouble(), lastTarget))
|
||||
// create series
|
||||
data.overviewData.temporaryTargetSeries = LineGraphSeries(Array(targetsSeriesArray.size) { i -> targetsSeriesArray[i] }).also {
|
||||
it.isDrawBackground = false
|
||||
|
|
|
@ -53,6 +53,8 @@ class PrepareTreatmentsDataWorker(
|
|||
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareTreatmentsData?
|
||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||
|
||||
val endTime = data.overviewData.endTime
|
||||
val fromTime = data.overviewData.fromTime
|
||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TREATMENTS_DATA, 0, null))
|
||||
data.overviewData.maxTreatmentsValue = 0.0
|
||||
data.overviewData.maxEpsValue = 0.0
|
||||
|
@ -60,14 +62,14 @@ class PrepareTreatmentsDataWorker(
|
|||
val filteredTherapyEvents: MutableList<DataPointWithLabelInterface> = ArrayList()
|
||||
val filteredEps: MutableList<DataPointWithLabelInterface> = ArrayList()
|
||||
|
||||
repository.getBolusesDataFromTimeToTime(data.overviewData.fromTime, data.overviewData.endTime, true).blockingGet()
|
||||
repository.getBolusesDataFromTimeToTime(fromTime, endTime, true).blockingGet()
|
||||
.map { BolusDataPoint(it, rh, activePlugin, defaultValueHelper) }
|
||||
.filter { it.data.type == Bolus.Type.NORMAL || it.data.type == Bolus.Type.SMB }
|
||||
.forEach {
|
||||
it.y = getNearestBg(data.overviewData, it.x.toLong())
|
||||
filteredTreatments.add(it)
|
||||
}
|
||||
repository.getCarbsDataFromTimeToTimeExpanded(data.overviewData.fromTime, data.overviewData.endTime, true).blockingGet()
|
||||
repository.getCarbsDataFromTimeToTimeExpanded(fromTime, endTime, true).blockingGet()
|
||||
.map { CarbsDataPoint(it, rh) }
|
||||
.forEach {
|
||||
it.y = getNearestBg(data.overviewData, it.x.toLong())
|
||||
|
@ -75,7 +77,7 @@ class PrepareTreatmentsDataWorker(
|
|||
}
|
||||
|
||||
// ProfileSwitch
|
||||
repository.getEffectiveProfileSwitchDataFromTimeToTime(data.overviewData.fromTime, data.overviewData.endTime, true).blockingGet()
|
||||
repository.getEffectiveProfileSwitchDataFromTimeToTime(fromTime, endTime, true).blockingGet()
|
||||
.map { EffectiveProfileSwitchDataPoint(it, rh, data.overviewData.epsScale) }
|
||||
.forEach {
|
||||
data.overviewData.maxEpsValue = maxOf(data.overviewData.maxEpsValue, it.data.originalPercentage.toDouble())
|
||||
|
@ -96,7 +98,7 @@ class PrepareTreatmentsDataWorker(
|
|||
|
||||
// Extended bolus
|
||||
if (!activePlugin.activePump.isFakingTempsByExtendedBoluses) {
|
||||
repository.getExtendedBolusDataFromTimeToTime(data.overviewData.fromTime, data.overviewData.endTime, true).blockingGet()
|
||||
repository.getExtendedBolusDataFromTimeToTime(fromTime, endTime, true).blockingGet()
|
||||
.map { ExtendedBolusDataPoint(it, rh) }
|
||||
.filter { it.duration != 0L }
|
||||
.forEach {
|
||||
|
@ -106,21 +108,19 @@ class PrepareTreatmentsDataWorker(
|
|||
}
|
||||
|
||||
// Careportal
|
||||
repository.compatGetTherapyEventDataFromToTime(data.overviewData.fromTime - T.hours(6).msecs(), data.overviewData.endTime).blockingGet()
|
||||
repository.compatGetTherapyEventDataFromToTime(fromTime - T.hours(6).msecs(), endTime).blockingGet()
|
||||
.map { TherapyEventDataPoint(it, rh, profileFunction, translator) }
|
||||
.filterTimeframe(data.overviewData.fromTime, data.overviewData.endTime)
|
||||
.filterTimeframe(fromTime, endTime)
|
||||
.forEach {
|
||||
if (it.y == 0.0) it.y = getNearestBg(data.overviewData, it.x.toLong())
|
||||
filteredTherapyEvents.add(it)
|
||||
}
|
||||
|
||||
// increase maxY if a treatment forces it's own height that's higher than a BG value
|
||||
filteredTreatments.map { it.y }
|
||||
.maxOrNull()
|
||||
filteredTreatments.maxOfOrNull { it.y }
|
||||
?.let(::addUpperChartMargin)
|
||||
?.let { data.overviewData.maxTreatmentsValue = maxOf(data.overviewData.maxTreatmentsValue, it) }
|
||||
filteredTherapyEvents.map { it.y }
|
||||
.maxOrNull()
|
||||
filteredTherapyEvents.maxOfOrNull { it.y }
|
||||
?.let(::addUpperChartMargin)
|
||||
?.let { data.overviewData.maxTherapyEventValue = maxOf(data.overviewData.maxTherapyEventValue, it) }
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import androidx.work.WorkerParameters
|
|||
import androidx.work.workDataOf
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.core.events.EventIobCalculationProgress
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||
import info.nightscout.core.utils.receivers.DataWorkerStorage
|
||||
import info.nightscout.core.utils.worker.LoggingWorker
|
||||
import info.nightscout.core.workflow.CalculationWorkflow
|
||||
|
@ -250,9 +249,7 @@ class IobCobOrefWorker @Inject internal constructor(
|
|||
if (bgTime < dateUtil.now()) autosensDataTable.put(bgTime, autosensData)
|
||||
aapsLogger.debug(
|
||||
LTag.AUTOSENS,
|
||||
"Running detectSensitivity from: " + dateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + dateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + ads.lastDataTime(
|
||||
dateUtil
|
||||
)
|
||||
"Running detectSensitivity from: " + dateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + dateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + ads.lastDataTime(dateUtil)
|
||||
)
|
||||
val sensitivity = activePlugin.activeSensitivity.detectSensitivity(ads, oldestTimeWithData, bgTime)
|
||||
aapsLogger.debug(LTag.AUTOSENS, "Sensitivity result: $sensitivity")
|
||||
|
|
Loading…
Reference in a new issue