From 11687eaf0233a061e051f377876b017774214445 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Fri, 21 Jan 2022 23:31:23 +0100 Subject: [PATCH] prevent 049 pod fault --- .../omnipod/dash/OmnipodDashPumpPlugin.kt | 22 +++++++++++++------ omnipod-dash/src/main/res/values/strings.xml | 2 ++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt index b7e724a68e..bc747c02f9 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt @@ -546,12 +546,6 @@ class OmnipodDashPumpPlugin @Inject constructor( try { bolusDeliveryInProgress = true aapsLogger.info(LTag.PUMP, "Delivering treatment: $detailedBolusInfo $bolusCanceled") - val beepsConfigurationKey = if (detailedBolusInfo.bolusType == DetailedBolusInfo.BolusType.SMB) - R.string.key_omnipod_common_smb_beeps_enabled - else - R.string.key_omnipod_common_bolus_beeps_enabled - val bolusBeeps = sp.getBoolean(beepsConfigurationKey, false) - R.string.key_omnipod_common_smb_beeps_enabled if (detailedBolusInfo.carbs > 0 || detailedBolusInfo.insulin == 0.0 ) { @@ -568,10 +562,24 @@ class OmnipodDashPumpPlugin @Inject constructor( .success(false) .enacted(false) .bolusDelivered(0.0) - .comment("Not enough insulin in the reservoir") + .comment(rh.gs(R.string.omnipod_dash_not_enough_insulin)) } + if (podStateManager.deliveryStatus == DeliveryStatus.BOLUS_AND_BASAL_ACTIVE || + podStateManager.deliveryStatus == DeliveryStatus.BOLUS_AND_TEMP_BASAL_ACTIVE) { + return PumpEnactResult(injector) + .success(false) + .enacted(false) + .bolusDelivered(0.0) + .comment(rh.gs(R.string.omnipod_dash_bolus_already_in_progress)) + } + var deliveredBolusAmount = 0.0 + val beepsConfigurationKey = if (detailedBolusInfo.bolusType == DetailedBolusInfo.BolusType.SMB) + R.string.key_omnipod_common_smb_beeps_enabled + else + R.string.key_omnipod_common_bolus_beeps_enabled + val bolusBeeps = sp.getBoolean(beepsConfigurationKey, false) aapsLogger.info( LTag.PUMP, "deliverTreatment: requestedBolusAmount=$requestedBolusAmount" diff --git a/omnipod-dash/src/main/res/values/strings.xml b/omnipod-dash/src/main/res/values/strings.xml index e016b351b6..9a13bac3c0 100644 --- a/omnipod-dash/src/main/res/values/strings.xml +++ b/omnipod-dash/src/main/res/values/strings.xml @@ -49,4 +49,6 @@ Delivering %1$.2f U Insulin delivery is suspended Lost connection to pod + Another bolus is being delivered + Not enough insulin left in the reservoir