add checkPodKaput

This commit is contained in:
Andrei Vereha 2021-06-06 18:41:17 +02:00
parent aa719e0b9f
commit b55dacd12c
3 changed files with 14 additions and 12 deletions

View file

@ -132,8 +132,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
history.updateFromState(podStateManager),
podStateManager.updateActiveCommand()
.map { handleCommandConfirmation(it) }
.map { checkPodKaput() }
.ignoreElement(),
checkPodKaput()
)
).blockingGet()
if (throwable != null) {
@ -143,12 +143,11 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
}
private fun checkPodKaput() {
if (podStateManager.isPodKaput) {
val tbr = pumpSync.expectedPumpState().temporaryBasal
if (tbr?.rate == 0.0) {
return
}
private fun checkPodKaput(): Completable = Completable.defer {
val tbr = pumpSync.expectedPumpState().temporaryBasal
if (podStateManager.isPodKaput &&
(tbr == null || tbr.rate != 0.0)
) {
pumpSync.syncTemporaryBasalWithPumpId(
timestamp = System.currentTimeMillis(),
rate = 0.0,
@ -160,6 +159,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
pumpSerial = serialNumber()
)
}
Completable.complete()
}
override fun setNewBasalProfile(profile: Profile): PumpEnactResult {

View file

@ -140,7 +140,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
override val activeAlerts: EnumSet<AlertType>?
get() = podState.activeAlerts
override val alarmType: AlarmType?
override val alarmType: AlarmType?
get() = podState.alarmType
override var tempBasal: OmnipodDashPodStateManager.TempBasal?

View file

@ -296,10 +296,12 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
}
*/
podStateManager.alarmType?.let {
errors.add(resourceHelper.gs(
R.string.omnipod_common_pod_status_pod_fault_description,
it.value,
it.toString())
errors.add(
resourceHelper.gs(
R.string.omnipod_common_pod_status_pod_fault_description,
it.value,
it.toString()
)
)
}