Merge pull request #2647 from dv1/combov2-fixes-001

combov2: Set the bolusDelivered value when a bolus delivery is finished
This commit is contained in:
Milos Kozak 2023-08-04 10:29:53 +02:00 committed by GitHub
commit bf97c405d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1102,7 +1102,17 @@ class ComboV2Plugin @Inject constructor (
reportFinishedBolus(R.string.combov2_bolus_delivery_failed, pumpEnactResult, succeeded = false)
} finally {
// The delivery was enacted if even a partial amount was infused.
pumpEnactResult.enacted = acquiredPump.lastBolusFlow.value?.let { it.bolusAmount > 0 } ?: false
acquiredPump.lastBolusFlow.value?.also {
pumpEnactResult.enacted = (it.bolusAmount > 0)
pumpEnactResult.bolusDelivered = it.bolusAmount.cctlBolusToIU()
} ?: run {
pumpEnactResult.enacted = false
pumpEnactResult.bolusDelivered = 0.0
}
aapsLogger.debug(
LTag.PUMP,
"Pump enact result: success ${pumpEnactResult.success} enacted ${pumpEnactResult.enacted} bolusDelivered ${pumpEnactResult.bolusDelivered}"
)
bolusJob = null
bolusProgressJob.cancelAndJoin()
}