combov2: Check if pump is suspended before setting TBR and delivering bolus

This avoids a misleading error state caused by an IllegalStateException
that gets thrown by the Pump.setTbr() and Pump.deliverBolus() when these
get called while the pump is suspended. Instead, first check for this
suspended state, and if the pump is indeed suspended, immediately exit
with the pump enact result set to not have succeeded nor have been enacted.

Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
This commit is contained in:
Carlos Rafael Giani 2023-01-28 20:43:29 +01:00
parent 26433a872e
commit d505c1a90b

View file

@ -935,6 +935,16 @@ class ComboV2Plugin @Inject constructor (
val pumpEnactResult = PumpEnactResult(injector)
pumpEnactResult.success = false
if (isSuspended()) {
aapsLogger.info(LTag.PUMP, "Cannot deliver bolus since the pump is suspended")
pumpEnactResult.apply {
success = false
enacted = false
comment = rh.gs(R.string.combov2_cannot_deliver_pump_suspended)
}
return pumpEnactResult
}
// Set up initial bolus progress along with details that are invariant.
// FIXME: EventOverviewBolusProgress is a singleton purely for
// historical reasons and could be updated to be a regular
@ -1148,6 +1158,16 @@ class ComboV2Plugin @Inject constructor (
force100Percent: Boolean,
pumpEnactResult: PumpEnactResult
) {
if (isSuspended()) {
aapsLogger.info(LTag.PUMP, "Cannot set TBR since the pump is suspended")
pumpEnactResult.apply {
success = false
enacted = false
comment = rh.gs(R.string.combov2_pump_is_suspended)
}
return
}
runBlocking {
try {
executeCommand {