beeps
This commit is contained in:
parent
d4a73abbf3
commit
a0b64a9062
|
@ -198,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()
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
else
|
||||
executeProgrammingCommand(
|
||||
historyEntry = history.createRecord(OmnipodCommandType.SUSPEND_DELIVERY),
|
||||
command = omnipodManager.suspendDelivery()
|
||||
command = omnipodManager.suspendDelivery(hasBasalBeepEnabled())
|
||||
.filter { podEvent -> podEvent.isCommandSent() }
|
||||
.map {
|
||||
pumpSyncTempBasal(
|
||||
|
@ -293,8 +293,12 @@ 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
|
||||
) {
|
||||
|
@ -451,9 +455,10 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
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().ignoreElements()
|
||||
command = omnipodManager.stopBolus(bolusBeeps).ignoreElements()
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -497,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 :: " +
|
||||
|
@ -586,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()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -611,6 +616,14 @@ 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
|
||||
|
@ -621,7 +634,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
|
||||
return executeProgrammingCommand(
|
||||
historyEntry = history.createRecord(OmnipodCommandType.CANCEL_TEMPORARY_BASAL),
|
||||
command = omnipodManager.stopTempBasal().ignoreElements(),
|
||||
command = omnipodManager.stopTempBasal(hasTempBasalBeepEnabled()).ignoreElements(),
|
||||
).toPumpEnactResult()
|
||||
}
|
||||
|
||||
|
@ -728,7 +741,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
private fun suspendDelivery(): PumpEnactResult {
|
||||
return executeProgrammingCommand(
|
||||
historyEntry = history.createRecord(OmnipodCommandType.SUSPEND_DELIVERY),
|
||||
command = omnipodManager.suspendDelivery()
|
||||
command = omnipodManager.suspendDelivery(hasBasalBeepEnabled())
|
||||
.filter { podEvent -> podEvent.isCommandSent() }
|
||||
.map {
|
||||
pumpSyncTempBasal(
|
||||
|
@ -754,7 +767,7 @@ 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
|
||||
}
|
||||
|
|
|
@ -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 = hasBasalBeepEnabled, 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,41 @@ 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 {
|
||||
when (deliveryType) {
|
||||
StopDeliveryCommand.DeliveryType.ALL, StopDeliveryCommand.DeliveryType.BASAL ->
|
||||
BeepType.FOUR_TIMES_BIP_BEEP
|
||||
StopDeliveryCommand.DeliveryType.TEMP_BASAL ->
|
||||
BeepType.LONG_SINGLE_BEEP
|
||||
StopDeliveryCommand.DeliveryType.BOLUS ->
|
||||
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 +507,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 +536,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())
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -561,9 +561,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))
|
||||
) {
|
||||
|
@ -592,7 +590,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