commit
d299b03ca2
13 changed files with 266 additions and 109 deletions
|
@ -344,6 +344,22 @@ interface PumpSync {
|
|||
**/
|
||||
fun invalidateTemporaryBasal(id: Long): Boolean
|
||||
|
||||
/**
|
||||
* Invalidate of temporary basals that failed to start
|
||||
* Dash specific, replace by setting duration to zero ????
|
||||
*
|
||||
* If exists, isValid is set false
|
||||
* If db record doesn't exist data is ignored and false returned
|
||||
*
|
||||
*
|
||||
* @param pumpId pumpId of temporary basal
|
||||
* @param pumpType pump type like PumpType.ACCU_CHEK_COMBO
|
||||
* @param pumpSerial pump serial number
|
||||
* @return true if running record is found and invalidated
|
||||
**/
|
||||
|
||||
fun invalidateTemporaryBasalWithPumpId(pumpId: Long, pumpType: PumpType, pumpSerial: String): Boolean
|
||||
|
||||
/**
|
||||
* Invalidate of temporary basals that failed to start
|
||||
* MDT specific
|
||||
|
|
|
@ -330,6 +330,19 @@ class PumpSyncImplementation @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun invalidateTemporaryBasalWithPumpId(pumpId: Long, pumpType: PumpType, pumpSerial: String): Boolean {
|
||||
repository.runTransactionForResult(InvalidateTemporaryBasalTransactionWithPumpId(pumpId, pumpType.toDbPumpType(),
|
||||
pumpSerial))
|
||||
.doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating TemporaryBasal", it) }
|
||||
.blockingGet()
|
||||
.also { result ->
|
||||
result.invalidated.forEach {
|
||||
aapsLogger.debug(LTag.DATABASE, "Invalidated TemporaryBasal $it")
|
||||
}
|
||||
return result.invalidated.size > 0
|
||||
}
|
||||
}
|
||||
|
||||
override fun invalidateTemporaryBasalWithTempId(temporaryId: Long): Boolean {
|
||||
repository.runTransactionForResult(InvalidateTemporaryBasalWithTempIdTransaction(temporaryId))
|
||||
.doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating TemporaryBasal", it) }
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package info.nightscout.androidaps.database.transactions
|
||||
|
||||
import info.nightscout.androidaps.database.embedments.InterfaceIDs
|
||||
import info.nightscout.androidaps.database.entities.TemporaryBasal
|
||||
|
||||
class InvalidateTemporaryBasalTransactionWithPumpId(val pumpId: Long, val pumpType: InterfaceIDs.PumpType, val
|
||||
pumpSerial:
|
||||
String) :
|
||||
Transaction<InvalidateTemporaryBasalTransactionWithPumpId.TransactionResult>() {
|
||||
|
||||
override fun run(): TransactionResult {
|
||||
val result = TransactionResult()
|
||||
val temporaryBasal = database.temporaryBasalDao.findByPumpIds(pumpId, pumpType, pumpSerial)
|
||||
?: throw IllegalArgumentException("There is no such Temporary Basal with the specified temp ID.")
|
||||
temporaryBasal.isValid = false
|
||||
database.temporaryBasalDao.updateExistingEntry(temporaryBasal)
|
||||
result.invalidated.add(temporaryBasal)
|
||||
return result
|
||||
}
|
||||
|
||||
class TransactionResult {
|
||||
|
||||
val invalidated = mutableListOf<TemporaryBasal>()
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.*
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.OmnipodDashManager
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event.PodEvent
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.OmnipodDashBleManager
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ActivationProgress
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus
|
||||
|
@ -57,6 +57,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
private val pumpSync: PumpSync,
|
||||
private val rxBus: RxBusWrapper,
|
||||
private val aapsSchedulers: AapsSchedulers,
|
||||
private val bleManager: OmnipodDashBleManager,
|
||||
|
||||
// private val disposable: CompositeDisposable = CompositeDisposable(),
|
||||
// private val aapsSchedulers: AapsSchedulers,
|
||||
|
@ -69,6 +70,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
@Volatile var bolusCanceled = false
|
||||
|
||||
companion object {
|
||||
private const val BOLUS_RETRY_INTERVAL_MS = 2000.toLong()
|
||||
private const val BOLUS_RETRIES = 5 // numer of retries for cancel/get bolus status
|
||||
|
||||
private val pluginDescription = PluginDescription()
|
||||
.mainType(PluginType.PUMP)
|
||||
|
@ -97,6 +100,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
override fun isConnected(): Boolean {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -164,9 +168,9 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
)
|
||||
}
|
||||
podStateManager.lastBolus?.run {
|
||||
if (!complete) {
|
||||
if (!deliveryComplete) {
|
||||
val deliveredUnits = markComplete()
|
||||
complete = true
|
||||
deliveryComplete = true
|
||||
val bolusHistoryEntry = history.getById(historyId)
|
||||
val sync = pumpSync.syncBolusWithPumpId(
|
||||
timestamp = bolusHistoryEntry.createdAt,
|
||||
|
@ -185,7 +189,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
|
||||
override fun setNewBasalProfile(profile: Profile): PumpEnactResult {
|
||||
if (!podStateManager.isActivationCompleted) {
|
||||
return PumpEnactResult(injector).success(true).enacted(false)
|
||||
return PumpEnactResult(injector).success(true).enacted(true)
|
||||
}
|
||||
val basalProgram = mapProfileToBasalProgram(profile)
|
||||
return executeProgrammingCommand(
|
||||
|
@ -194,7 +198,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
activeCommandEntry = { historyId ->
|
||||
podStateManager.createActiveCommand(historyId, basalProgram = basalProgram)
|
||||
},
|
||||
command = omnipodManager.setBasalProgram(basalProgram).ignoreElements(),
|
||||
command = omnipodManager.setBasalProgram(basalProgram, hasBasalBeepEnabled()).ignoreElements(),
|
||||
post = failWhenUnconfirmed(),
|
||||
).toPumpEnactResult()
|
||||
}
|
||||
|
@ -214,11 +218,10 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
else
|
||||
executeProgrammingCommand(
|
||||
historyEntry = history.createRecord(OmnipodCommandType.SUSPEND_DELIVERY),
|
||||
command = omnipodManager.suspendDelivery()
|
||||
.filter { podEvent -> podEvent is PodEvent.CommandSent }
|
||||
command = omnipodManager.suspendDelivery(hasBasalBeepEnabled())
|
||||
.filter { podEvent -> podEvent.isCommandSent() }
|
||||
.map {
|
||||
pumpSyncTempBasal(
|
||||
it,
|
||||
0.0,
|
||||
PodConstants.MAX_POD_LIFETIME.standardMinutes,
|
||||
PumpSync.TemporaryBasalType.PUMP_SUSPEND
|
||||
|
@ -290,16 +293,20 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult {
|
||||
try {
|
||||
aapsLogger.info(LTag.PUMP, "Delivering treatment: $detailedBolusInfo")
|
||||
val bolusBeeps = sp.getBoolean(R.string.key_omnipod_common_bolus_beeps_enabled, false)
|
||||
|
||||
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
|
||||
) {
|
||||
// Accept only valid insulin requests
|
||||
return PumpEnactResult(injector)
|
||||
.success(false)
|
||||
.enacted(false)
|
||||
.bolusDelivered(0.0)
|
||||
.carbsDelivered(0.0)
|
||||
.comment("Invalid input")
|
||||
}
|
||||
val requestedBolusAmount = detailedBolusInfo.insulin
|
||||
|
@ -308,7 +315,6 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
.success(false)
|
||||
.enacted(false)
|
||||
.bolusDelivered(0.0)
|
||||
.carbsDelivered(0.0)
|
||||
.comment("Not enough insulin in the reservoir")
|
||||
}
|
||||
var deliveredBolusAmount = 0.0
|
||||
|
@ -336,10 +342,10 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
detailedBolusInfo.insulin,
|
||||
bolusBeeps,
|
||||
bolusBeeps
|
||||
).filter { podEvent -> podEvent is PodEvent.CommandSent }
|
||||
.map { pumpSyncBolusStart(it, requestedBolusAmount, detailedBolusInfo.bolusType) }
|
||||
).filter { podEvent -> podEvent.isCommandSent() }
|
||||
.map { pumpSyncBolusStart(requestedBolusAmount, detailedBolusInfo.bolusType) }
|
||||
.ignoreElements(),
|
||||
post = waitForBolusDeliveryToComplete(5, requestedBolusAmount, detailedBolusInfo.bolusType)
|
||||
post = waitForBolusDeliveryToComplete(BOLUS_RETRIES, requestedBolusAmount, detailedBolusInfo.bolusType)
|
||||
.map {
|
||||
deliveredBolusAmount = it
|
||||
aapsLogger.info(LTag.PUMP, "deliverTreatment: deliveredBolusAmount=$deliveredBolusAmount")
|
||||
|
@ -348,7 +354,10 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
).toSingleDefault(
|
||||
PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(deliveredBolusAmount)
|
||||
)
|
||||
.onErrorReturnItem(PumpEnactResult(injector).success(false).enacted(false))
|
||||
.onErrorReturnItem(
|
||||
// success if canceled
|
||||
PumpEnactResult(injector).success(bolusCanceled).enacted(false)
|
||||
)
|
||||
.blockingGet()
|
||||
aapsLogger.info(LTag.PUMP, "deliverTreatment result: $ret")
|
||||
return ret
|
||||
|
@ -365,12 +374,37 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateBolusProgressDialog(msg: String, percent: Int) {
|
||||
val progressUpdateEvent = EventOverviewBolusProgress
|
||||
val percent = percent
|
||||
progressUpdateEvent.status = msg
|
||||
progressUpdateEvent.percent = percent
|
||||
rxBus.send(progressUpdateEvent)
|
||||
}
|
||||
|
||||
private fun waitForBolusDeliveryToComplete(
|
||||
maxRetries: Int,
|
||||
requestedBolusAmount: Double,
|
||||
bolusType: DetailedBolusInfo.BolusType
|
||||
): Single<Double> = Single.defer {
|
||||
// wait for bolus delivery confirmation, if possible
|
||||
|
||||
if (bolusCanceled && podStateManager.activeCommand != null) {
|
||||
var errorGettingStatus: Throwable? = null
|
||||
for (tries in 1..maxRetries) {
|
||||
errorGettingStatus = getPodStatus().blockingGet()
|
||||
if (errorGettingStatus != null) {
|
||||
aapsLogger.debug(LTag.PUMP, "waitForBolusDeliveryToComplete errorGettingStatus=$errorGettingStatus")
|
||||
Thread.sleep(BOLUS_RETRY_INTERVAL_MS) // retry every 2 sec
|
||||
continue
|
||||
}
|
||||
}
|
||||
if (errorGettingStatus != null) {
|
||||
// requestedBolusAmount will be updated later, via pumpSync
|
||||
// This state is: cancellation requested and getPodStatus failed 5 times.
|
||||
return@defer Single.just(requestedBolusAmount)
|
||||
}
|
||||
}
|
||||
|
||||
val estimatedDeliveryTimeSeconds = estimateBolusDeliverySeconds(requestedBolusAmount)
|
||||
aapsLogger.info(LTag.PUMP, "estimatedDeliveryTimeSeconds: $estimatedDeliveryTimeSeconds")
|
||||
var waited = 0
|
||||
|
@ -380,57 +414,67 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
if (bolusType == DetailedBolusInfo.BolusType.SMB) {
|
||||
continue
|
||||
}
|
||||
val progressUpdateEvent = EventOverviewBolusProgress
|
||||
val percent = (100 * waited) / estimatedDeliveryTimeSeconds
|
||||
progressUpdateEvent.status = resourceHelper.gs(R.string.bolusdelivering, requestedBolusAmount)
|
||||
progressUpdateEvent.percent = percent.toInt()
|
||||
rxBus.send(progressUpdateEvent)
|
||||
val percent = waited.toFloat() / estimatedDeliveryTimeSeconds
|
||||
updateBolusProgressDialog(resourceHelper.gs(R.string.bolusdelivering, requestedBolusAmount), percent.toInt())
|
||||
}
|
||||
|
||||
for (tries in 1..maxRetries) {
|
||||
val errorGettingStatus = getPodStatus().blockingGet()
|
||||
val cmd = if (bolusCanceled)
|
||||
cancelBolus()
|
||||
else
|
||||
getPodStatus()
|
||||
|
||||
val errorGettingStatus = cmd.blockingGet()
|
||||
if (errorGettingStatus != null) {
|
||||
Thread.sleep(3000) // retry every 3 sec
|
||||
aapsLogger.debug(LTag.PUMP, "waitForBolusDeliveryToComplete errorGettingStatus=$errorGettingStatus")
|
||||
Thread.sleep(BOLUS_RETRY_INTERVAL_MS) // retry every 3 sec
|
||||
continue
|
||||
}
|
||||
if (podStateManager.deliveryStatus in
|
||||
arrayOf(
|
||||
DeliveryStatus.BOLUS_AND_TEMP_BASAL_ACTIVE,
|
||||
DeliveryStatus.BOLUS_AND_BASAL_ACTIVE
|
||||
) &&
|
||||
!bolusCanceled
|
||||
) {
|
||||
val bolusDeliveringActive = podStateManager.deliveryStatus?.bolusDeliveringActive() ?: false
|
||||
|
||||
if (bolusDeliveringActive) {
|
||||
// delivery not complete yet
|
||||
val remainingUnits = podStateManager.lastBolus!!.bolusUnitsRemaining
|
||||
val progressUpdateEvent = EventOverviewBolusProgress
|
||||
val percent = ((requestedBolusAmount - remainingUnits) / requestedBolusAmount) * 100
|
||||
progressUpdateEvent.status = "Remaining: $remainingUnits units"
|
||||
progressUpdateEvent.percent = percent.toInt()
|
||||
Thread.sleep(estimateBolusDeliverySeconds(remainingUnits) * 1000.toLong())
|
||||
updateBolusProgressDialog(
|
||||
resourceHelper.gs(R.string.bolusdelivering, requestedBolusAmount),
|
||||
percent.toInt()
|
||||
)
|
||||
|
||||
val sleepSeconds = if (bolusCanceled)
|
||||
BOLUS_RETRY_INTERVAL_MS
|
||||
else
|
||||
estimateBolusDeliverySeconds(remainingUnits)
|
||||
Thread.sleep(sleepSeconds * 1000.toLong())
|
||||
} else {
|
||||
// delivery is complete. If pod is Kaput, we are handling this in getPodStatus
|
||||
// TODO: race with cancel!!
|
||||
return@defer Single.just(podStateManager.lastBolus!!.deliveredUnits()!!)
|
||||
}
|
||||
}
|
||||
Single.just(requestedBolusAmount) // will be updated later!
|
||||
}
|
||||
|
||||
private fun cancelBolus(): Completable {
|
||||
val bolusBeeps = sp.getBoolean(R.string.key_omnipod_common_bolus_beeps_enabled, false)
|
||||
return executeProgrammingCommand(
|
||||
historyEntry = history.createRecord(commandType = OmnipodCommandType.CANCEL_BOLUS),
|
||||
command = omnipodManager.stopBolus(bolusBeeps).ignoreElements()
|
||||
)
|
||||
}
|
||||
|
||||
private fun estimateBolusDeliverySeconds(requestedBolusAmount: Double): Long {
|
||||
return ceil(requestedBolusAmount / 0.05).toLong() * 2 + 3
|
||||
}
|
||||
|
||||
private fun pumpSyncBolusStart(
|
||||
podEvent: PodEvent,
|
||||
requestedBolusAmount: Double,
|
||||
bolusType: DetailedBolusInfo.BolusType
|
||||
): Boolean {
|
||||
val activeCommand = podStateManager.activeCommand
|
||||
if (activeCommand == null || podEvent !is PodEvent.CommandSent) {
|
||||
if (activeCommand == null) {
|
||||
throw IllegalArgumentException(
|
||||
"No active command or illegal podEvent: " +
|
||||
"activeCommand=$activeCommand" +
|
||||
"podEvent=$podEvent"
|
||||
"activeCommand=$activeCommand"
|
||||
)
|
||||
}
|
||||
val historyEntry = history.getById(activeCommand.historyId)
|
||||
|
@ -449,18 +493,6 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
override fun stopBolusDelivering() {
|
||||
aapsLogger.info(LTag.PUMP, "stopBolusDelivering called")
|
||||
bolusCanceled = true
|
||||
for (tries in 1..10) {
|
||||
val ret = executeProgrammingCommand(
|
||||
historyEntry = history.createRecord(OmnipodCommandType.CANCEL_BOLUS),
|
||||
command = omnipodManager.stopBolus().ignoreElements()
|
||||
).subscribeOn(aapsSchedulers.io) // stopBolusDelivering is executed on the main thread
|
||||
.toPumpEnactResult()
|
||||
aapsLogger.info(LTag.PUMP, "stopBolusDelivering finished with result: $ret")
|
||||
if (ret.success) {
|
||||
return
|
||||
}
|
||||
Thread.sleep(500)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setTempBasalAbsolute(
|
||||
|
@ -470,7 +502,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
enforceNew: Boolean,
|
||||
tbrType: PumpSync.TemporaryBasalType
|
||||
): PumpEnactResult {
|
||||
val tempBasalBeeps = sp.getBoolean(R.string.key_omnipod_common_tbr_beeps_enabled, false)
|
||||
val tempBasalBeeps = hasTempBasalBeepEnabled()
|
||||
aapsLogger.info(
|
||||
LTag.PUMP,
|
||||
"setTempBasalAbsolute: duration=$durationInMinutes min, rate=$absoluteRate U/h :: " +
|
||||
|
@ -498,30 +530,31 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
durationInMinutes.toShort(),
|
||||
tempBasalBeeps
|
||||
)
|
||||
.filter { podEvent -> podEvent is PodEvent.CommandSent }
|
||||
.map { pumpSyncTempBasal(it, absoluteRate, durationInMinutes.toLong(), tbrType) }
|
||||
.filter { podEvent -> podEvent.isCommandSent() }
|
||||
.map { pumpSyncTempBasal(absoluteRate, durationInMinutes.toLong(), tbrType) }
|
||||
.ignoreElements(),
|
||||
).toPumpEnactResult()
|
||||
if (ret.success && ret.enacted) {
|
||||
ret.isPercent(false).absolute(absoluteRate).duration(durationInMinutes)
|
||||
}
|
||||
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute: result=$ret")
|
||||
return ret
|
||||
}
|
||||
|
||||
private fun pumpSyncTempBasal(
|
||||
podEvent: PodEvent,
|
||||
absoluteRate: Double,
|
||||
durationInMinutes: Long,
|
||||
tbrType: PumpSync.TemporaryBasalType
|
||||
): Boolean {
|
||||
val activeCommand = podStateManager.activeCommand
|
||||
if (activeCommand == null || podEvent !is PodEvent.CommandSent) {
|
||||
if (activeCommand == null) {
|
||||
throw IllegalArgumentException(
|
||||
"No active command or illegal podEvent: " +
|
||||
"activeCommand=$activeCommand" +
|
||||
"podEvent=$podEvent"
|
||||
"No active command: " +
|
||||
"activeCommand=$activeCommand"
|
||||
)
|
||||
}
|
||||
val historyEntry = history.getById(activeCommand.historyId)
|
||||
|
||||
aapsLogger.debug(LTag.PUMP, "pumpSyncTempBasal: absoluteRate=$absoluteRate, durationInMinutes=$durationInMinutes")
|
||||
val ret = pumpSync.syncTemporaryBasalWithPumpId(
|
||||
timestamp = historyEntry.createdAt,
|
||||
rate = absoluteRate,
|
||||
|
@ -558,7 +591,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
aapsLogger.info(LTag.PUMP, "Canceling existing temp basal")
|
||||
executeProgrammingCommand(
|
||||
historyEntry = history.createRecord(OmnipodCommandType.CANCEL_TEMPORARY_BASAL),
|
||||
command = omnipodManager.stopTempBasal().ignoreElements()
|
||||
command = omnipodManager.stopTempBasal(hasTempBasalBeepEnabled()).ignoreElements()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -583,20 +616,29 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
.comment("Omnipod Dash driver does not support extended boluses")
|
||||
}
|
||||
|
||||
private fun hasTempBasalBeepEnabled(): Boolean {
|
||||
return sp.getBoolean(R.string.key_omnipod_common_tbr_beeps_enabled, false)
|
||||
}
|
||||
|
||||
private fun hasBasalBeepEnabled(): Boolean {
|
||||
return sp.getBoolean(R.string.key_omnipod_common_basal_beeps_enabled, false)
|
||||
}
|
||||
|
||||
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
|
||||
if (!podStateManager.tempBasalActive &&
|
||||
pumpSync.expectedPumpState().temporaryBasal == null) {
|
||||
pumpSync.expectedPumpState().temporaryBasal == null
|
||||
) {
|
||||
// nothing to cancel
|
||||
return PumpEnactResult(injector).success(true).enacted(false)
|
||||
}
|
||||
|
||||
return executeProgrammingCommand(
|
||||
historyEntry = history.createRecord(OmnipodCommandType.CANCEL_TEMPORARY_BASAL),
|
||||
command = omnipodManager.stopTempBasal().ignoreElements(),
|
||||
command = omnipodManager.stopTempBasal(hasTempBasalBeepEnabled()).ignoreElements(),
|
||||
).toPumpEnactResult()
|
||||
}
|
||||
|
||||
fun Completable.toPumpEnactResult(): PumpEnactResult {
|
||||
private fun Completable.toPumpEnactResult(): PumpEnactResult {
|
||||
return this.toSingleDefault(PumpEnactResult(injector).success(true).enacted(true))
|
||||
.doOnError { throwable ->
|
||||
aapsLogger.error(LTag.PUMP, "toPumpEnactResult, error executing command: $throwable")
|
||||
|
@ -699,11 +741,10 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
private fun suspendDelivery(): PumpEnactResult {
|
||||
return executeProgrammingCommand(
|
||||
historyEntry = history.createRecord(OmnipodCommandType.SUSPEND_DELIVERY),
|
||||
command = omnipodManager.suspendDelivery()
|
||||
.filter { podEvent -> podEvent is PodEvent.CommandSent }
|
||||
command = omnipodManager.suspendDelivery(hasBasalBeepEnabled())
|
||||
.filter { podEvent -> podEvent.isCommandSent() }
|
||||
.map {
|
||||
pumpSyncTempBasal(
|
||||
it,
|
||||
0.0,
|
||||
PodConstants.MAX_POD_LIFETIME.standardMinutes,
|
||||
PumpSync.TemporaryBasalType.PUMP_SUSPEND
|
||||
|
@ -726,16 +767,20 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
executeProgrammingCommand(
|
||||
pre = observeDeliverySuspended(),
|
||||
historyEntry = history.createRecord(OmnipodCommandType.RESUME_DELIVERY),
|
||||
command = omnipodManager.setBasalProgram(mapProfileToBasalProgram(it)).ignoreElements()
|
||||
command = omnipodManager.setBasalProgram(mapProfileToBasalProgram(it), hasBasalBeepEnabled()).ignoreElements()
|
||||
).toPumpEnactResult()
|
||||
} ?: PumpEnactResult(injector).success(false).enacted(false).comment("No profile active") // TODO i18n
|
||||
}
|
||||
|
||||
private fun deactivatePod(): PumpEnactResult {
|
||||
return executeProgrammingCommand(
|
||||
val ret = executeProgrammingCommand(
|
||||
historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD),
|
||||
command = omnipodManager.deactivatePod().ignoreElements()
|
||||
).toPumpEnactResult()
|
||||
if (podStateManager.activeCommand != null) {
|
||||
ret.success(false)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
private fun handleTimeChange(): PumpEnactResult {
|
||||
|
@ -783,11 +828,12 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
{ historyId -> podStateManager.createActiveCommand(historyId) },
|
||||
command: Completable,
|
||||
post: Completable = Completable.complete(),
|
||||
checkNoActiveCommand: Boolean = true
|
||||
): Completable {
|
||||
return Completable.concat(
|
||||
listOf(
|
||||
pre,
|
||||
podStateManager.observeNoActiveCommand().ignoreElements(),
|
||||
podStateManager.observeNoActiveCommand(checkNoActiveCommand).ignoreElements(),
|
||||
historyEntry
|
||||
.flatMap { activeCommandEntry(it) }
|
||||
.ignoreElement(),
|
||||
|
@ -847,7 +893,11 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
// This treatment was synced before sending the command
|
||||
if (!confirmation.success) {
|
||||
aapsLogger.info(LTag.PUMPCOMM, "temporary basal denied. PumpId: ${historyEntry.pumpId()}")
|
||||
pumpSync.invalidateTemporaryBasal(historyEntry.pumpId())
|
||||
pumpSync.invalidateTemporaryBasalWithPumpId(
|
||||
historyEntry.pumpId(),
|
||||
PumpType.OMNIPOD_DASH,
|
||||
serialNumber()
|
||||
)
|
||||
} else {
|
||||
podStateManager.tempBasal = command.tempBasal
|
||||
}
|
||||
|
@ -855,7 +905,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
|
||||
OmnipodCommandType.SUSPEND_DELIVERY -> {
|
||||
if (!confirmation.success) {
|
||||
pumpSync.invalidateTemporaryBasal(historyEntry.pumpId())
|
||||
pumpSync.invalidateTemporaryBasalWithPumpId(historyEntry.pumpId(), PumpType.OMNIPOD_DASH, serialNumber())
|
||||
} else {
|
||||
podStateManager.tempBasal = null
|
||||
}
|
||||
|
@ -916,7 +966,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
aapsLogger.warn(
|
||||
LTag.PUMP,
|
||||
"Will not sync confirmed command of type: $historyEntry and " +
|
||||
"succes: ${confirmation.success}"
|
||||
"success: ${confirmation.success}"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,19 +18,19 @@ interface OmnipodDashManager {
|
|||
|
||||
fun getStatus(type: ResponseType.StatusResponseType): Observable<PodEvent>
|
||||
|
||||
fun setBasalProgram(basalProgram: BasalProgram): Observable<PodEvent>
|
||||
fun setBasalProgram(basalProgram: BasalProgram, hasBasalBeepEnabled: Boolean): Observable<PodEvent>
|
||||
|
||||
fun suspendDelivery(): Observable<PodEvent>
|
||||
fun suspendDelivery(hasBasalBeepEnabled: Boolean): Observable<PodEvent>
|
||||
|
||||
fun setTime(): Observable<PodEvent>
|
||||
|
||||
fun setTempBasal(rate: Double, durationInMinutes: Short, tempBasalBeeps: Boolean): Observable<PodEvent>
|
||||
|
||||
fun stopTempBasal(): Observable<PodEvent>
|
||||
fun stopTempBasal(hasTempBasalBeepEnabled: Boolean): Observable<PodEvent>
|
||||
|
||||
fun bolus(units: Double, confirmationBeeps: Boolean, completionBeeps: Boolean): Observable<PodEvent>
|
||||
|
||||
fun stopBolus(): Observable<PodEvent>
|
||||
fun stopBolus(beep: Boolean): Observable<PodEvent>
|
||||
|
||||
fun playBeep(beepType: BeepType): Observable<PodEvent>
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ class OmnipodDashManagerImpl @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun observeSendProgramBasalCommand(basalProgram: BasalProgram): Observable<PodEvent> {
|
||||
private fun observeSendProgramBasalCommand(basalProgram: BasalProgram, hasBasalBeepEnabled: Boolean): Observable<PodEvent> {
|
||||
return Observable.defer {
|
||||
val currentTime = Date()
|
||||
logger.debug(LTag.PUMPCOMM, "Programming basal. currentTime={}, basalProgram={}", currentTime, basalProgram)
|
||||
|
@ -166,7 +166,7 @@ class OmnipodDashManagerImpl @Inject constructor(
|
|||
.setUniqueId(podStateManager.uniqueId!!.toInt())
|
||||
.setSequenceNumber(podStateManager.messageSequenceNumber)
|
||||
.setNonce(NONCE)
|
||||
.setProgramReminder(ProgramReminder(atStart = false, atEnd = false, atInterval = 0))
|
||||
.setProgramReminder(ProgramReminder(atStart = hasBasalBeepEnabled, atEnd = false, atInterval = 0))
|
||||
.setBasalProgram(basalProgram)
|
||||
.setCurrentTime(currentTime)
|
||||
.build(),
|
||||
|
@ -399,7 +399,7 @@ class OmnipodDashManagerImpl @Inject constructor(
|
|||
}
|
||||
if (podStateManager.activationProgress.isBefore(ActivationProgress.PROGRAMMED_BASAL)) {
|
||||
observables.add(
|
||||
observeSendProgramBasalCommand(basalProgram)
|
||||
observeSendProgramBasalCommand(basalProgram, false)
|
||||
.doOnComplete(ActivationProgressUpdater(ActivationProgress.PROGRAMMED_BASAL))
|
||||
)
|
||||
}
|
||||
|
@ -419,11 +419,11 @@ class OmnipodDashManagerImpl @Inject constructor(
|
|||
.subscribeOn(aapsSchedulers.io)
|
||||
}
|
||||
|
||||
override fun setBasalProgram(basalProgram: BasalProgram): Observable<PodEvent> {
|
||||
override fun setBasalProgram(basalProgram: BasalProgram, hasBasalBeepEnabled: Boolean): Observable<PodEvent> {
|
||||
return Observable.concat(
|
||||
observePodRunning,
|
||||
observeConnectToPod,
|
||||
observeSendProgramBasalCommand(basalProgram)
|
||||
observeSendProgramBasalCommand(basalProgram, hasBasalBeepEnabled)
|
||||
)
|
||||
// TODO these would be common for any observable returned in a public function in this class
|
||||
.doOnNext(PodEventInterceptor())
|
||||
|
@ -431,25 +431,34 @@ class OmnipodDashManagerImpl @Inject constructor(
|
|||
.subscribeOn(aapsSchedulers.io)
|
||||
}
|
||||
|
||||
private fun observeSendStopDeliveryCommand(deliveryType: StopDeliveryCommand.DeliveryType): Observable<PodEvent> {
|
||||
private fun observeSendStopDeliveryCommand(
|
||||
deliveryType: StopDeliveryCommand.DeliveryType,
|
||||
beepEnabled: Boolean
|
||||
): Observable<PodEvent> {
|
||||
return Observable.defer {
|
||||
val beepType = if (!beepEnabled)
|
||||
BeepType.SILENT
|
||||
else
|
||||
BeepType.LONG_SINGLE_BEEP
|
||||
|
||||
bleManager.sendCommand(
|
||||
StopDeliveryCommand.Builder()
|
||||
.setSequenceNumber(podStateManager.messageSequenceNumber)
|
||||
.setUniqueId(podStateManager.uniqueId!!.toInt())
|
||||
.setNonce(NONCE)
|
||||
.setDeliveryType(deliveryType)
|
||||
.setBeepType(beepType)
|
||||
.build(),
|
||||
DefaultStatusResponse::class
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun suspendDelivery(): Observable<PodEvent> {
|
||||
override fun suspendDelivery(hasBasalBeepEnabled: Boolean): Observable<PodEvent> {
|
||||
return Observable.concat(
|
||||
observePodRunning,
|
||||
observeConnectToPod,
|
||||
observeSendStopDeliveryCommand(StopDeliveryCommand.DeliveryType.ALL)
|
||||
observeSendStopDeliveryCommand(StopDeliveryCommand.DeliveryType.ALL, hasBasalBeepEnabled)
|
||||
)
|
||||
// TODO these would be common for any observable returned in a public function in this class
|
||||
.doOnNext(PodEventInterceptor())
|
||||
|
@ -491,11 +500,11 @@ class OmnipodDashManagerImpl @Inject constructor(
|
|||
.subscribeOn(aapsSchedulers.io)
|
||||
}
|
||||
|
||||
override fun stopTempBasal(): Observable<PodEvent> {
|
||||
override fun stopTempBasal(hasTempBasalBeepEnabled: Boolean): Observable<PodEvent> {
|
||||
return Observable.concat(
|
||||
observePodRunning,
|
||||
observeConnectToPod,
|
||||
observeSendStopDeliveryCommand(StopDeliveryCommand.DeliveryType.TEMP_BASAL)
|
||||
observeSendStopDeliveryCommand(StopDeliveryCommand.DeliveryType.TEMP_BASAL, hasTempBasalBeepEnabled)
|
||||
)
|
||||
// TODO these would be common for any observable returned in a public function in this class
|
||||
.doOnNext(PodEventInterceptor())
|
||||
|
@ -520,11 +529,11 @@ class OmnipodDashManagerImpl @Inject constructor(
|
|||
.subscribeOn(aapsSchedulers.io)
|
||||
}
|
||||
|
||||
override fun stopBolus(): Observable<PodEvent> {
|
||||
override fun stopBolus(beep: Boolean): Observable<PodEvent> {
|
||||
return Observable.concat(
|
||||
observePodRunning,
|
||||
observeConnectToPod,
|
||||
observeSendStopDeliveryCommand(StopDeliveryCommand.DeliveryType.BOLUS)
|
||||
observeSendStopDeliveryCommand(StopDeliveryCommand.DeliveryType.BOLUS, beep)
|
||||
)
|
||||
// TODO these would be common for any observable returned in a public function in this class
|
||||
.doOnNext(PodEventInterceptor())
|
||||
|
|
|
@ -44,6 +44,14 @@ class OmnipodDashBleManagerImpl @Inject constructor(
|
|||
val session = assertSessionEstablished()
|
||||
|
||||
emitter.onNext(PodEvent.CommandSending(cmd))
|
||||
/*
|
||||
if (Random.nextBoolean()) {
|
||||
// XXX use this to test "failed to confirm" commands
|
||||
emitter.onNext(PodEvent.CommandSendNotConfirmed(cmd))
|
||||
emitter.tryOnError(MessageIOException("XXX random failure to test unconfirmed commands"))
|
||||
return@create
|
||||
}
|
||||
*/
|
||||
when (session.sendCommand(cmd)) {
|
||||
is CommandSendErrorSending -> {
|
||||
emitter.tryOnError(CouldNotSendCommandException())
|
||||
|
@ -55,7 +63,12 @@ class OmnipodDashBleManagerImpl @Inject constructor(
|
|||
is CommandSendErrorConfirming ->
|
||||
emitter.onNext(PodEvent.CommandSendNotConfirmed(cmd))
|
||||
}
|
||||
|
||||
/*
|
||||
if (Random.nextBoolean()) {
|
||||
// XXX use this commands confirmed with success
|
||||
emitter.tryOnError(MessageIOException("XXX random failure to test unconfirmed commands"))
|
||||
return@create
|
||||
}*/
|
||||
when (val readResult = session.readAndAckResponse(responseType)) {
|
||||
is CommandReceiveSuccess ->
|
||||
emitter.onNext(PodEvent.ResponseReceived(cmd, readResult.result))
|
||||
|
@ -84,7 +97,7 @@ class OmnipodDashBleManagerImpl @Inject constructor(
|
|||
}
|
||||
|
||||
override fun getStatus(): ConnectionState {
|
||||
return connection?.let { getStatus() }
|
||||
return connection?.let { it.connectionState() }
|
||||
?: NotConnected
|
||||
}
|
||||
|
||||
|
|
|
@ -65,4 +65,8 @@ sealed class PodEvent {
|
|||
return "ResponseReceived(command=$command, response=$response)"
|
||||
}
|
||||
}
|
||||
|
||||
fun isCommandSent(): Boolean {
|
||||
return this is CommandSent || this is CommandSendNotConfirmed
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,4 +11,16 @@ enum class DeliveryStatus(override val value: Byte) : HasValue {
|
|||
BOLUS_AND_BASAL_ACTIVE(0x05.toByte()),
|
||||
BOLUS_AND_TEMP_BASAL_ACTIVE(0x06.toByte()),
|
||||
UNKNOWN(0xff.toByte());
|
||||
|
||||
fun bolusDeliveringActive(): Boolean {
|
||||
return value in arrayOf(BOLUS_AND_BASAL_ACTIVE.value, BOLUS_AND_TEMP_BASAL_ACTIVE.value)
|
||||
}
|
||||
|
||||
fun tempBasalActive(): Boolean {
|
||||
return value in arrayOf(BOLUS_AND_TEMP_BASAL_ACTIVE.value, TEMP_BASAL_ACTIVE.value)
|
||||
}
|
||||
|
||||
fun suspended(): Boolean {
|
||||
return value == SUSPENDED.value
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ interface OmnipodDashPodStateManager {
|
|||
requestedBolus: Double? = null
|
||||
): Single<ActiveCommand>
|
||||
fun updateActiveCommand(): Maybe<CommandConfirmed>
|
||||
fun observeNoActiveCommand(): Observable<PodEvent>
|
||||
fun observeNoActiveCommand(b: Boolean): Observable<PodEvent>
|
||||
fun getCommandConfirmationFromState(): CommandConfirmationFromState
|
||||
|
||||
fun createLastBolus(requestedUnits: Double, historyId: String, bolusType: DetailedBolusInfo.BolusType)
|
||||
|
@ -108,13 +108,13 @@ interface OmnipodDashPodStateManager {
|
|||
val startTime: Long,
|
||||
val requestedUnits: Double,
|
||||
var bolusUnitsRemaining: Double,
|
||||
var complete: Boolean,
|
||||
var deliveryComplete: Boolean,
|
||||
val historyId: String,
|
||||
val bolusType: DetailedBolusInfo.BolusType
|
||||
) {
|
||||
|
||||
fun deliveredUnits(): Double? {
|
||||
return if (complete) {
|
||||
return if (deliveryComplete) {
|
||||
requestedUnits - bolusUnitsRemaining
|
||||
} else {
|
||||
null
|
||||
|
@ -122,7 +122,7 @@ interface OmnipodDashPodStateManager {
|
|||
}
|
||||
|
||||
fun markComplete(): Double {
|
||||
this.complete = true
|
||||
this.deliveryComplete = true
|
||||
return requestedUnits - bolusUnitsRemaining
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
startTime = System.currentTimeMillis(),
|
||||
requestedUnits = requestedUnits,
|
||||
bolusUnitsRemaining = requestedUnits,
|
||||
complete = false, // cancelled, delivered 100% or pod failure
|
||||
deliveryComplete = false, // cancelled, delivered 100% or pod failure
|
||||
historyId = historyId,
|
||||
bolusType = bolusType
|
||||
)
|
||||
|
@ -219,7 +219,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
val lastBolus = podState.lastBolus
|
||||
|
||||
lastBolus?.run {
|
||||
this.complete = true
|
||||
this.deliveryComplete = true
|
||||
}
|
||||
?: logger.error(LTag.PUMP, "Trying to mark null bolus as complete")
|
||||
|
||||
|
@ -231,7 +231,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
val remainingUnits = bolusPulsesRemaining.toDouble() * 0.05
|
||||
this.bolusUnitsRemaining = remainingUnits
|
||||
if (remainingUnits == 0.0) {
|
||||
this.complete = true
|
||||
this.deliveryComplete = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -269,9 +269,9 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
override fun observeNoActiveCommand(): Observable<PodEvent> {
|
||||
override fun observeNoActiveCommand(check: Boolean): Observable<PodEvent> {
|
||||
return Observable.defer {
|
||||
if (activeCommand == null) {
|
||||
if (activeCommand == null || !check) {
|
||||
Observable.empty()
|
||||
} else {
|
||||
logger.warn(LTag.PUMP, "Active command already existing: $activeCommand")
|
||||
|
@ -427,6 +427,11 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
podState.uniqueId = response.uniqueIdReceivedInCommand
|
||||
|
||||
podState.lastUpdatedSystem = System.currentTimeMillis()
|
||||
// TODO: what is considered to be the pod activation time?
|
||||
// LTK negotiation ?
|
||||
// setUniqueId?
|
||||
// compute it from the number of "minutesOnPod"?
|
||||
podState.activationTime = System.currentTimeMillis()
|
||||
|
||||
store()
|
||||
rxBus.send(EventOmnipodDashPumpValuesChanged())
|
||||
|
|
|
@ -14,6 +14,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activati
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.databinding.OmnipodDashPodManagementBinding
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ActivationProgress
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.activation.DashPodActivationWizardActivity
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.deactivation.DashPodDeactivationWizardActivity
|
||||
|
@ -124,7 +125,8 @@ class DashPodManagementActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
binding.buttonActivatePod.isEnabled = podStateManager.activationProgress.isBefore(ActivationProgress.COMPLETED)
|
||||
binding.buttonDeactivatePod.isEnabled =
|
||||
podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED)
|
||||
podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED) ||
|
||||
podStateManager.podStatus == PodStatus.ALARM
|
||||
|
||||
if (podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED)) {
|
||||
if (commandQueue.isCustomCommandInQueue(CommandPlayTestBeep::class.java)) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.Comm
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandResumeDelivery
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandSilenceAlerts
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandSuspendDelivery
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.EventOmnipodDashPumpValuesChanged
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.OmnipodDashPumpPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
|
||||
|
@ -274,6 +275,13 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
|||
*/
|
||||
|
||||
// TODO
|
||||
if (podStateManager.activeCommand != null) {
|
||||
podInfoBinding.podExpiryDate.setTextColor(Color.RED)
|
||||
podInfoBinding.podExpiryDate.text = "Active command"
|
||||
} else {
|
||||
podInfoBinding.podExpiryDate.text = PLACEHOLDER
|
||||
podInfoBinding.podExpiryDate.setTextColor(Color.WHITE)
|
||||
}
|
||||
/*
|
||||
val expiresAt = podStateManager.expiresAt
|
||||
|
||||
|
@ -409,8 +417,9 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
|||
resourceHelper.gs(R.string.omnipod_common_pod_status_suspended)
|
||||
} else {
|
||||
resourceHelper.gs(R.string.omnipod_common_pod_status_running) +
|
||||
if (BuildConfig.DEBUG)
|
||||
podStateManager.deliveryStatus?.let { " " + podStateManager.deliveryStatus.toString() }
|
||||
// TODO Display deliveryStatus in a nice way
|
||||
else ""
|
||||
}
|
||||
// TODO
|
||||
/*
|
||||
|
@ -465,7 +474,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
|||
resourceHelper.gs(R.string.insulin_unit_shortname),
|
||||
readableDuration(Duration(it.startTime, System.currentTimeMillis()))
|
||||
)
|
||||
if (!it.complete) {
|
||||
if (!it.deliveryComplete) {
|
||||
textColor = Color.YELLOW
|
||||
}
|
||||
podInfoBinding.lastBolus.text = text
|
||||
|
@ -554,9 +563,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
|||
|
||||
private fun updateSuspendDeliveryButton() {
|
||||
// If the Pod is currently suspended, we show the Resume delivery button instead.
|
||||
// TODO: isSuspendDeliveryButtonEnabled doesn't work
|
||||
val isSuspendDeliveryButtonEnabled = true
|
||||
if (isSuspendDeliveryButtonEnabled &&
|
||||
if (isSuspendDeliveryButtonEnabled() &&
|
||||
podStateManager.isPodRunning &&
|
||||
(!podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(CommandSuspendDelivery::class.java))
|
||||
) {
|
||||
|
@ -585,7 +592,8 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
private fun isSuspendDeliveryButtonEnabled(): Boolean {
|
||||
return sp.getBoolean(R.string.omnipod_common_preferences_suspend_delivery_button_enabled, false)
|
||||
R.string.key_omnipod_common_basal_beeps_enabled
|
||||
return sp.getBoolean(R.string.key_omnipod_common_suspend_delivery_button_enabled, false)
|
||||
}
|
||||
|
||||
private fun displayErrorDialog(title: String, message: String, withSound: Boolean) {
|
||||
|
|
Loading…
Reference in a new issue