From b440003de4ea754c904cd67b4cc5357b5094a320 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Sat, 5 Jun 2021 20:14:28 +0200 Subject: [PATCH] ignore enforeNew for now --- .../omnipod/dash/OmnipodDashPumpPlugin.kt | 33 +++++++------------ .../state/OmnipodDashPodStateManagerImpl.kt | 14 +++++--- 2 files changed, 21 insertions(+), 26 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 62d9d3748d..5c60486659 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 @@ -272,7 +272,7 @@ class OmnipodDashPumpPlugin @Inject constructor( .filter { podEvent -> podEvent is PodEvent.CommandSent } .map { pumpSyncTempBasal(it, tbrType) } .ignoreElements(), - pre = observeNoActiveTempBasal(enforceNew) + pre = observeNoActiveTempBasal() ).toPumpEnactResult() } @@ -307,28 +307,19 @@ class OmnipodDashPumpPlugin @Inject constructor( return ret } - private fun observeNoActiveTempBasal(enforceNew: Boolean): Completable { + private fun observeNoActiveTempBasal(): Completable { return Completable.defer { val expectedState = pumpSync.expectedPumpState() - when { - expectedState.temporaryBasal == null -> { - aapsLogger.info(LTag.PUMP, "No temporary basal to cancel") - Completable.complete() - } - !enforceNew -> - Completable.error( - IllegalStateException( - "Temporary basal already active and enforeNew is not set." - ) - ) - else -> { - // enforceNew == true - aapsLogger.info(LTag.PUMP, "Canceling existing temp basal") - executeSimpleProgrammingCommand( - history.createRecord(OmnipodCommandType.CANCEL_TEMPORARY_BASAL), - omnipodManager.stopTempBasal().ignoreElements() - ) - } + if (expectedState.temporaryBasal == null) { + aapsLogger.info(LTag.PUMP, "No temporary basal to cancel") + Completable.complete() + } else { + // enforceNew == true + aapsLogger.info(LTag.PUMP, "Canceling existing temp basal") + executeSimpleProgrammingCommand( + history.createRecord(OmnipodCommandType.CANCEL_TEMPORARY_BASAL), + omnipodManager.stopTempBasal().ignoreElements() + ) } } } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt index b84cf5eb13..9724f7f819 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt @@ -240,11 +240,15 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( if (sentRealtime < createdRealtime) { // command was not sent, clear it up podState.activeCommand = null - source.onError(this.sendError - ?: java.lang.IllegalStateException("Could not send command and sendError is " + - "missing") ) - } else if (createdRealtime >= lastStatusResponseReceived) - // we did not receive a valid response yet + source.onError( + this.sendError + ?: java.lang.IllegalStateException( + "Could not send command and sendError is " + + "missing" + ) + ) + } else if (createdRealtime >= lastStatusResponseReceived) + // we did not receive a valid response yet source.onComplete() else { podState.activeCommand = null