disable the suspend Button

This commit is contained in:
Andrei Vereha 2021-11-24 21:43:36 +01:00
parent e903c9c055
commit 1247fded3b
7 changed files with 10 additions and 66 deletions

View file

@ -1092,8 +1092,6 @@ class OmnipodDashPumpPlugin @Inject constructor(
return when (customCommand) { return when (customCommand) {
is CommandSilenceAlerts -> is CommandSilenceAlerts ->
silenceAlerts() silenceAlerts()
is CommandSuspendDelivery ->
suspendDelivery()
is CommandResumeDelivery -> is CommandResumeDelivery ->
resumeDelivery() resumeDelivery()
is CommandDeactivatePod -> is CommandDeactivatePod ->
@ -1131,17 +1129,6 @@ class OmnipodDashPumpPlugin @Inject constructor(
private fun disableSuspendAlerts(): PumpEnactResult { private fun disableSuspendAlerts(): PumpEnactResult {
val alerts = listOf( val alerts = listOf(
AlertConfiguration(
AlertType.SUSPEND_IN_PROGRESS,
enabled = false,
durationInMinutes = 0,
autoOff = false,
AlertTrigger.TimerTrigger(
0
),
BeepType.XXX,
BeepRepetitionType.XXX4
),
AlertConfiguration( AlertConfiguration(
AlertType.SUSPEND_ENDED, AlertType.SUSPEND_ENDED,
enabled = false, enabled = false,
@ -1151,7 +1138,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
0 0
), ),
BeepType.FOUR_TIMES_BIP_BEEP, BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.EVERY_MINUTE BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
), ),
) )
val ret = executeProgrammingCommand( val ret = executeProgrammingCommand(
@ -1164,29 +1151,6 @@ class OmnipodDashPumpPlugin @Inject constructor(
return ret return ret
} }
private fun suspendDelivery(): PumpEnactResult {
return executeProgrammingCommand(
historyEntry = history.createRecord(OmnipodCommandType.SUSPEND_DELIVERY),
command = omnipodManager.suspendDelivery(hasBasalBeepEnabled())
.filter { podEvent -> podEvent.isCommandSent() }
.map {
pumpSyncTempBasal(
0.0,
PodConstants.MAX_POD_LIFETIME.toMinutes(),
PumpSync.TemporaryBasalType.PUMP_SUSPEND
)
}
.ignoreElements(),
pre = observeDeliveryActive(),
).doFinally {
notifyOnUnconfirmed(
Notification.PUMP_ERROR,
"Unconfirmed suspendDelivery command. Please refresh pod status",
R.raw.boluserror
)
}.toPumpEnactResult()
}
private fun observeDeliveryActive(): Completable = Completable.defer { private fun observeDeliveryActive(): Completable = Completable.defer {
if (podStateManager.deliveryStatus != DeliveryStatus.SUSPENDED) if (podStateManager.deliveryStatus != DeliveryStatus.SUSPENDED)
Completable.complete() Completable.complete()
@ -1289,7 +1253,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
expiryAlertDelay.toMinutes().toShort() expiryAlertDelay.toMinutes().toShort()
), ),
BeepType.FOUR_TIMES_BIP_BEEP, BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.EVERY_MINUTE BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
) )
) )
return executeProgrammingCommand( return executeProgrammingCommand(

View file

@ -437,7 +437,7 @@ class OmnipodDashManagerImpl @Inject constructor(
userExpiryAlertDelay.toMinutes().toShort() userExpiryAlertDelay.toMinutes().toShort()
), ),
BeepType.FOUR_TIMES_BIP_BEEP, BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.EVERY_MINUTE BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
) )
) )
} }

View file

@ -19,27 +19,16 @@ class SuspendDeliveryCommand private constructor(
override val encoded: ByteArray override val encoded: ByteArray
get() { get() {
val alerts = listOf( val alerts = listOf(
AlertConfiguration(
AlertType.SUSPEND_IN_PROGRESS,
enabled = true,
durationInMinutes = 10,
autoOff = false,
AlertTrigger.TimerTrigger(
1
),
BeepType.XXX,
BeepRepetitionType.XXX4
),
AlertConfiguration( AlertConfiguration(
AlertType.SUSPEND_ENDED, AlertType.SUSPEND_ENDED,
enabled = true, enabled = true,
durationInMinutes = 0, durationInMinutes = 0,
autoOff = false, autoOff = false,
AlertTrigger.TimerTrigger( AlertTrigger.TimerTrigger(
10 20
), ),
BeepType.FOUR_TIMES_BIP_BEEP, BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.EVERY_MINUTE BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
), ),
) )
val programAlerts = ProgramAlertsCommand.Builder() val programAlerts = ProgramAlertsCommand.Builder()

View file

@ -6,7 +6,7 @@ enum class BeepRepetitionType(
) { ) {
XXX(0x01.toByte()), // Used in lump of coal alert, LOW_RESERVOIR XXX(0x01.toByte()), // Used in lump of coal alert, LOW_RESERVOIR
EVERY_MINUTE(0x03.toByte()), // Used in USER_SET_EXPIRATION, suspend delivery EVERY_MINUTE_AND_EVERY_15_MIN(0x03.toByte()), // Used in USER_SET_EXPIRATION, suspend delivery
XXX3(0x05.toByte()), // published system expiration alert XXX3(0x05.toByte()), // published system expiration alert
XXX4(0x06.toByte()), // Used in imminent pod expiration alert, suspend in progress. No repeat? XXX4(0x06.toByte()), // Used in imminent pod expiration alert, suspend in progress. No repeat?
XXX5(0x08.toByte()); // Lump of coal alert XXX5(0x08.toByte()); // Lump of coal alert

View file

@ -442,7 +442,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
AlertType.SUSPEND_IN_PROGRESS -> AlertType.SUSPEND_IN_PROGRESS ->
R.string.omnipod_common_alert_delivery_suspended R.string.omnipod_common_alert_delivery_suspended
AlertType.SUSPEND_ENDED -> AlertType.SUSPEND_ENDED ->
R.string.omnipod_common_alert_delivery_suspended2 R.string.omnipod_common_alert_delivery_suspended
else -> else ->
R.string.omnipod_common_alert_unknown_alert R.string.omnipod_common_alert_unknown_alert
} }
@ -633,17 +633,9 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
private fun updateSuspendDeliveryButton() { private fun updateSuspendDeliveryButton() {
// If the Pod is currently suspended, we show the Resume delivery button instead. // If the Pod is currently suspended, we show the Resume delivery button instead.
if (isSuspendDeliveryButtonEnabled() && // disable the 'suspendDelivery' button.
podStateManager.isPodRunning &&
(!podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(CommandSuspendDelivery::class.java))
) {
buttonBinding.buttonSuspendDelivery.visibility = View.VISIBLE
buttonBinding.buttonSuspendDelivery.isEnabled =
podStateManager.isPodRunning && !podStateManager.isSuspended && isQueueEmpty()
} else {
buttonBinding.buttonSuspendDelivery.visibility = View.GONE buttonBinding.buttonSuspendDelivery.visibility = View.GONE
} }
}
private fun updateSetTimeButton() { private fun updateSetTimeButton() {
if (podStateManager.isActivationCompleted && !podStateManager.sameTimeZone) { if (podStateManager.isActivationCompleted && !podStateManager.sameTimeZone) {

View file

@ -48,5 +48,4 @@
<string name="omnipod_common_history_bolus_value">%1$.2f U</string> <string name="omnipod_common_history_bolus_value">%1$.2f U</string>
<string name="dash_bolusdelivering">Delivering %1$.2f U</string> <string name="dash_bolusdelivering">Delivering %1$.2f U</string>
<string name="omnipod_common_alert_delivery_suspended">Insulin delivery is suspended</string> <string name="omnipod_common_alert_delivery_suspended">Insulin delivery is suspended</string>
<string name="omnipod_common_alert_delivery_suspended2">Insulin delivery is suspended 2</string>
</resources> </resources>

View file

@ -85,7 +85,7 @@ class ProgramAlertsCommandTest {
false, false,
AlertTrigger.TimerTrigger(4079.toShort()), AlertTrigger.TimerTrigger(4079.toShort()),
BeepType.FOUR_TIMES_BIP_BEEP, BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.EVERY_MINUTE BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
) )
) )