ignore enforeNew for now

This commit is contained in:
Andrei Vereha 2021-06-05 20:14:28 +02:00
parent 3dc4781692
commit b440003de4
2 changed files with 21 additions and 26 deletions

View file

@ -272,7 +272,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
.filter { podEvent -> podEvent is PodEvent.CommandSent } .filter { podEvent -> podEvent is PodEvent.CommandSent }
.map { pumpSyncTempBasal(it, tbrType) } .map { pumpSyncTempBasal(it, tbrType) }
.ignoreElements(), .ignoreElements(),
pre = observeNoActiveTempBasal(enforceNew) pre = observeNoActiveTempBasal()
).toPumpEnactResult() ).toPumpEnactResult()
} }
@ -307,28 +307,19 @@ class OmnipodDashPumpPlugin @Inject constructor(
return ret return ret
} }
private fun observeNoActiveTempBasal(enforceNew: Boolean): Completable { private fun observeNoActiveTempBasal(): Completable {
return Completable.defer { return Completable.defer {
val expectedState = pumpSync.expectedPumpState() val expectedState = pumpSync.expectedPumpState()
when { if (expectedState.temporaryBasal == null) {
expectedState.temporaryBasal == null -> { aapsLogger.info(LTag.PUMP, "No temporary basal to cancel")
aapsLogger.info(LTag.PUMP, "No temporary basal to cancel") Completable.complete()
Completable.complete() } else {
} // enforceNew == true
!enforceNew -> aapsLogger.info(LTag.PUMP, "Canceling existing temp basal")
Completable.error( executeSimpleProgrammingCommand(
IllegalStateException( history.createRecord(OmnipodCommandType.CANCEL_TEMPORARY_BASAL),
"Temporary basal already active and enforeNew is not set." omnipodManager.stopTempBasal().ignoreElements()
) )
)
else -> {
// enforceNew == true
aapsLogger.info(LTag.PUMP, "Canceling existing temp basal")
executeSimpleProgrammingCommand(
history.createRecord(OmnipodCommandType.CANCEL_TEMPORARY_BASAL),
omnipodManager.stopTempBasal().ignoreElements()
)
}
} }
} }
} }

View file

@ -240,11 +240,15 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
if (sentRealtime < createdRealtime) { // command was not sent, clear it up if (sentRealtime < createdRealtime) { // command was not sent, clear it up
podState.activeCommand = null podState.activeCommand = null
source.onError(this.sendError source.onError(
?: java.lang.IllegalStateException("Could not send command and sendError is " + this.sendError
"missing") ) ?: java.lang.IllegalStateException(
} else if (createdRealtime >= lastStatusResponseReceived) "Could not send command and sendError is " +
// we did not receive a valid response yet "missing"
)
)
} else if (createdRealtime >= lastStatusResponseReceived)
// we did not receive a valid response yet
source.onComplete() source.onComplete()
else { else {
podState.activeCommand = null podState.activeCommand = null