fix calculation progress
This commit is contained in:
parent
8fb5c5a984
commit
cc4feb610c
4 changed files with 14 additions and 11 deletions
|
@ -31,31 +31,31 @@ class CompatDBHelper @Inject constructor(
|
|||
*
|
||||
*/
|
||||
var newestGlucoseValue: GlucoseValue? = null
|
||||
it.filterIsInstance<GlucoseValue>().lastOrNull()?.let { gv ->
|
||||
it.filterIsInstance<GlucoseValue>().maxByOrNull { gv -> gv.timestamp }?.let { gv ->
|
||||
aapsLogger.debug(LTag.DATABASE, "Firing EventNewBg $gv")
|
||||
rxBus.send(EventNewBG(gv))
|
||||
newestGlucoseValue = gv
|
||||
}
|
||||
it.filterIsInstance<GlucoseValue>().map { gv -> gv.timestamp }.minOrNull()?.let { timestamp ->
|
||||
aapsLogger.debug(LTag.DATABASE, "Firing EventNewHistoryData $newestGlucoseValue")
|
||||
it.filterIsInstance<GlucoseValue>().minOfOrNull { gv -> gv.timestamp }?.let { timestamp ->
|
||||
aapsLogger.debug(LTag.DATABASE, "Firing EventNewHistoryData $timestamp $newestGlucoseValue")
|
||||
rxBus.send(EventNewHistoryData(timestamp, true, newestGlucoseValue))
|
||||
}
|
||||
it.filterIsInstance<Carbs>().map { t -> t.timestamp }.minOrNull()?.let { timestamp ->
|
||||
it.filterIsInstance<Carbs>().minOfOrNull { t -> t.timestamp }?.let { timestamp ->
|
||||
aapsLogger.debug(LTag.DATABASE, "Firing EventTreatmentChange $timestamp")
|
||||
rxBus.send(EventTreatmentChange())
|
||||
rxBus.send(EventNewHistoryData(timestamp, false))
|
||||
}
|
||||
it.filterIsInstance<Bolus>().map { t -> t.timestamp }.minOrNull()?.let { timestamp ->
|
||||
it.filterIsInstance<Bolus>().minOfOrNull { t -> t.timestamp }?.let { timestamp ->
|
||||
aapsLogger.debug(LTag.DATABASE, "Firing EventTreatmentChange $timestamp")
|
||||
rxBus.send(EventTreatmentChange())
|
||||
rxBus.send(EventNewHistoryData(timestamp, false))
|
||||
}
|
||||
it.filterIsInstance<TemporaryBasal>().map { t -> t.timestamp }.minOrNull()?.let { timestamp ->
|
||||
it.filterIsInstance<TemporaryBasal>().minOfOrNull { t -> t.timestamp }?.let { timestamp ->
|
||||
aapsLogger.debug(LTag.DATABASE, "Firing EventTempBasalChange $timestamp")
|
||||
rxBus.send(EventTempBasalChange())
|
||||
rxBus.send(EventNewHistoryData(timestamp, false))
|
||||
}
|
||||
it.filterIsInstance<ExtendedBolus>().map { t -> t.timestamp }.minOrNull()?.let { timestamp ->
|
||||
it.filterIsInstance<ExtendedBolus>().minOfOrNull { t -> t.timestamp }?.let { timestamp ->
|
||||
aapsLogger.debug(LTag.DATABASE, "Firing EventExtendedBolusChange $timestamp")
|
||||
rxBus.send(EventExtendedBolusChange())
|
||||
rxBus.send(EventNewHistoryData(timestamp, false))
|
||||
|
|
|
@ -369,7 +369,7 @@ class IobCobCalculatorPlugin @Inject constructor(
|
|||
@Synchronized
|
||||
private fun scheduleHistoryDataChange(event: EventNewHistoryData) {
|
||||
// if there is nothing scheduled or asking reload deeper to the past
|
||||
if (scheduledEvent == null || event.oldDataTimestamp < (scheduledEvent?.oldDataTimestamp) ?: 0L) {
|
||||
if (scheduledEvent == null || event.oldDataTimestamp < (scheduledEvent?.oldDataTimestamp ?: 0L)) {
|
||||
// cancel waiting task to prevent sending multiple posts
|
||||
scheduledHistoryPost?.cancel(false)
|
||||
// prepare task for execution in 1 sec
|
||||
|
|
|
@ -60,12 +60,13 @@ class CalculationWorkflow @Inject constructor(
|
|||
private val overviewData: OverviewData
|
||||
get() = (iobCobCalculator as IobCobCalculatorPlugin).overviewData
|
||||
|
||||
enum class ProgressData(val pass: Int, val percentOfTotal: Int) {
|
||||
enum class ProgressData(private val pass: Int, val percentOfTotal: Int) {
|
||||
PREPARE_BASAL_DATA(0, 5),
|
||||
PREPARE_TEMPORARY_TARGET_DATA(1, 5),
|
||||
PREPARE_TREATMENTS_DATA(2, 5),
|
||||
IOB_COB_OREF(3, 75),
|
||||
PREPARE_IOB_AUTOSENS_DATA(4, 10);
|
||||
IOB_COB_OREF(3, 74),
|
||||
PREPARE_IOB_AUTOSENS_DATA(4, 10),
|
||||
DRAW(5, 1);
|
||||
|
||||
fun finalPercent(progress: Int): Int {
|
||||
var total = 0
|
||||
|
|
|
@ -7,6 +7,7 @@ import dagger.android.HasAndroidInjector
|
|||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewGraph
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
|
||||
import javax.inject.Inject
|
||||
|
||||
class UpdateGraphWorker(
|
||||
|
@ -26,6 +27,7 @@ class UpdateGraphWorker(
|
|||
overviewPlugin.overviewBus.send(EventUpdateOverviewGraph("UpdateGraphWorker"))
|
||||
else
|
||||
rxBus.send(EventUpdateOverviewGraph("UpdateGraphWorker"))
|
||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.DRAW, 100, null))
|
||||
return Result.success()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue