Merge branch 'dash' into avereha/basal

This commit is contained in:
Andrei Vereha 2021-06-06 21:28:23 +02:00
commit 697e646854

View file

@ -302,7 +302,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
.filter { podEvent -> podEvent is PodEvent.CommandSent }
.map { pumpSyncTempBasal(it, absoluteRate, durationInMinutes.toLong(), tbrType) }
.ignoreElements(),
pre = observeNoActiveTempBasal(enforceNew)
pre = observeNoActiveTempBasal()
).toPumpEnactResult()
}
@ -336,24 +336,13 @@ class OmnipodDashPumpPlugin @Inject constructor(
return ret
}
private fun observeNoActiveTempBasal(enforceNew: Boolean): Completable {
private fun observeNoActiveTempBasal(): Completable {
return Completable.defer {
when {
podStateManager.deliveryStatus !in
arrayOf(DeliveryStatus.TEMP_BASAL_ACTIVE, DeliveryStatus.BOLUS_AND_TEMP_BASAL_ACTIVE) -> {
// TODO: what happens if we try to cancel inexistent temp basal?
val expectedState = pumpSync.expectedPumpState()
if (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 -> {
} else {
// enforceNew == true
aapsLogger.info(LTag.PUMP, "Canceling existing temp basal")
executeSimpleProgrammingCommand(
@ -363,7 +352,6 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
}
}
}
private fun observeActiveTempBasal(): Completable {