fix reloading data

This commit is contained in:
Milos Kozak 2023-09-20 17:28:49 +02:00
parent 355361ed6d
commit a38622f848
4 changed files with 6 additions and 6 deletions

View file

@ -121,12 +121,12 @@ class CalculationWorkflowImpl @Inject constructor(
}
override fun stopCalculation(job: String, from: String) {
aapsLogger.debug(LTag.AUTOSENS, "Stopping calculation thread: $from")
aapsLogger.debug(LTag.WORKER, "Stopping calculation thread: $from")
WorkManager.getInstance(context).cancelUniqueWork(job)
val workStatus = WorkManager.getInstance(context).getWorkInfosForUniqueWork(job).get()
while (workStatus.size >= 1 && workStatus[0].state == WorkInfo.State.RUNNING)
SystemClock.sleep(100)
aapsLogger.debug(LTag.AUTOSENS, "Calculation thread stopped: $from")
aapsLogger.debug(LTag.WORKER, "Calculation thread stopped: $from")
}
override fun runCalculation(
@ -138,7 +138,7 @@ class CalculationWorkflowImpl @Inject constructor(
bgDataReload: Boolean,
cause: Event?
) {
aapsLogger.debug(LTag.AUTOSENS, "Starting calculation worker: $reason to ${dateUtil.dateAndTimeAndSecondsString(end)}")
aapsLogger.debug(LTag.WORKER, "Starting calculation worker: $reason to ${dateUtil.dateAndTimeAndSecondsString(end)}")
WorkManager.getInstance(context)
.beginUniqueWork(

View file

@ -58,7 +58,7 @@ class CompatDBHelper @Inject constructor(
*/
var newestGlucoseValue: GlucoseValue? = null
it.filterIsInstance<GlucoseValue>().maxByOrNull { gv -> gv.timestamp }?.let { gv ->
aapsLogger.debug(LTag.DATABASE, "Firing EventNewBg $gv")
aapsLogger.debug(LTag.DATABASE, "Firing EventNewBG $gv")
rxBus.send(EventNewBG(gv.timestamp))
newestGlucoseValue = gv
}

View file

@ -390,7 +390,7 @@ class IobCobCalculatorPlugin @Inject constructor(
// prepare task for execution in 1 sec
scheduledEvent?.let {
// set reload bg data if was not set
if (!event.reloadBgData) event.reloadBgData = it.reloadBgData
event.reloadBgData = event.reloadBgData || it.reloadBgData
}
scheduledEvent = event
scheduledHistoryPost = historyWorker.schedule(

View file

@ -29,7 +29,7 @@ class InvokeLoopWorker(
This method is triggered once autosens calculation has completed, so the LoopPlugin
has current data to work with. However, autosens calculation can be triggered by multiple
sources and currently only a new BG should trigger a loop run. Hence we return early if
the event causing the calculation is not EventNewBg.
the event causing the calculation is not EventNewBG.
<p>
*/
override suspend fun doWorkAndLog(): Result {