improve calculation workflow behavior
This commit is contained in:
parent
551af710b6
commit
6ebec7935d
|
@ -198,23 +198,23 @@ class CalculationWorkflowImpl @Inject constructor(
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
job == MAIN_CALCULATION,
|
runIf = job == MAIN_CALCULATION,
|
||||||
OneTimeWorkRequest.Builder(UpdateGraphWorker::class.java)
|
OneTimeWorkRequest.Builder(UpdateGraphWorker::class.java)
|
||||||
.setInputData(Data.Builder().putString(JOB, job).putInt(PASS, CalculationWorkflow.ProgressData.DRAW_IOB.pass).build())
|
.setInputData(Data.Builder().putString(JOB, job).putInt(PASS, CalculationWorkflow.ProgressData.DRAW_IOB.pass).build())
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
job == MAIN_CALCULATION,
|
runIf = job == MAIN_CALCULATION,
|
||||||
OneTimeWorkRequest.Builder(InvokeLoopWorker::class.java)
|
OneTimeWorkRequest.Builder(InvokeLoopWorker::class.java)
|
||||||
.setInputData(dataWorkerStorage.storeInputData(InvokeLoopWorker.InvokeLoopData(cause)))
|
.setInputData(dataWorkerStorage.storeInputData(InvokeLoopWorker.InvokeLoopData(cause)))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
job == MAIN_CALCULATION,
|
runIf = job == MAIN_CALCULATION,
|
||||||
OneTimeWorkRequest.Builder(UpdateWidgetWorker::class.java).build()
|
OneTimeWorkRequest.Builder(UpdateWidgetWorker::class.java).build()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
job == MAIN_CALCULATION,
|
runIf = job == MAIN_CALCULATION,
|
||||||
OneTimeWorkRequest.Builder(PreparePredictionsWorker::class.java)
|
OneTimeWorkRequest.Builder(PreparePredictionsWorker::class.java)
|
||||||
.setInputData(dataWorkerStorage.storeInputData(PreparePredictionsWorker.PreparePredictionsData(overviewData)))
|
.setInputData(dataWorkerStorage.storeInputData(PreparePredictionsWorker.PreparePredictionsData(overviewData)))
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -57,6 +57,7 @@ class PrepareBasalDataWorker(
|
||||||
val fromTime = data.overviewData.fromTime
|
val fromTime = data.overviewData.fromTime
|
||||||
var time = fromTime
|
var time = fromTime
|
||||||
while (time < endTime) {
|
while (time < endTime) {
|
||||||
|
if (isStopped) return Result.failure(workDataOf("Error" to "stopped"))
|
||||||
val progress = (time - fromTime).toDouble() / (endTime - fromTime) * 100.0
|
val progress = (time - fromTime).toDouble() / (endTime - fromTime) * 100.0
|
||||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_BASAL_DATA, progress.toInt(), null))
|
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_BASAL_DATA, progress.toInt(), null))
|
||||||
val profile = profileFunction.getProfile(time)
|
val profile = profileFunction.getProfile(time)
|
||||||
|
|
|
@ -158,6 +158,7 @@ class PrepareIobAutosensGraphDataWorker(
|
||||||
val adsData = data.iobCobCalculator.ads.clone()
|
val adsData = data.iobCobCalculator.ads.clone()
|
||||||
|
|
||||||
while (time <= endTime) {
|
while (time <= endTime) {
|
||||||
|
if (isStopped) return Result.failure(workDataOf("Error" to "stopped"))
|
||||||
val progress = (time - fromTime).toDouble() / (endTime - fromTime) * 100.0
|
val progress = (time - fromTime).toDouble() / (endTime - fromTime) * 100.0
|
||||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_IOB_AUTOSENS_DATA, progress.toInt(), null))
|
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_IOB_AUTOSENS_DATA, progress.toInt(), null))
|
||||||
val profile = profileFunction.getProfile(time)
|
val profile = profileFunction.getProfile(time)
|
||||||
|
|
|
@ -58,6 +58,7 @@ class PrepareTemporaryTargetDataWorker(
|
||||||
loop.lastRun?.constraintsProcessed?.let { endTime = max(it.latestPredictionsTime, endTime) }
|
loop.lastRun?.constraintsProcessed?.let { endTime = max(it.latestPredictionsTime, endTime) }
|
||||||
var time = fromTime
|
var time = fromTime
|
||||||
while (time < endTime) {
|
while (time < endTime) {
|
||||||
|
if (isStopped) return Result.failure(workDataOf("Error" to "stopped"))
|
||||||
val progress = (time - fromTime).toDouble() / (endTime - fromTime) * 100.0
|
val progress = (time - fromTime).toDouble() / (endTime - fromTime) * 100.0
|
||||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TEMPORARY_TARGET_DATA, progress.toInt(), null))
|
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TEMPORARY_TARGET_DATA, progress.toInt(), null))
|
||||||
val tt = repository.getTemporaryTargetActiveAt(time).blockingGet()
|
val tt = repository.getTemporaryTargetActiveAt(time).blockingGet()
|
||||||
|
|
Loading…
Reference in a new issue