Merge pull request #2700 from jbr7rr/dash-expiration-warnings
Dash: Add option to disable pod expiration alert
This commit is contained in:
commit
d6e6a98642
11 changed files with 222 additions and 89 deletions
|
@ -8,7 +8,9 @@
|
|||
<string name="key_omnipod_common_suspend_delivery_button_enabled" translatable="false">AAPS.Omnipod.suspend_delivery_button_enabled</string>
|
||||
<string name="key_omnipod_common_time_change_event_enabled" translatable="false">AAPS.Omnipod.time_change_enabled</string>
|
||||
<string name="key_omnipod_common_expiration_reminder_enabled" translatable="false">AAPS.Omnipod.expiration_reminder_enabled</string>
|
||||
<string name="key_omnipod_common_expiration_reminder_hours_before_shutdown" translatable="false">AAPS.Omnipod.expiration_reminder_hours_before_shutdown</string>
|
||||
<string name="key_omnipod_common_expiration_reminder_hours_before_expiry" translatable="false">AAPS.Omnipod.expiration_reminder_hours_before_expiry</string>
|
||||
<string name="key_omnipod_common_expiration_alarm_enabled" translatable="false">AAPS.Omnipod.expiration_alarm_enabled</string>
|
||||
<string name="key_omnipod_common_expiration_alarm_hours_before_shutdown" translatable="false">AAPS.Omnipod.expiration_alarm_hours_before_shutdown</string>
|
||||
<string name="key_omnipod_common_low_reservoir_alert_enabled" translatable="false">AAPS.Omnipod.low_reservoir_alert_enabled</string>
|
||||
<string name="key_omnipod_common_low_reservoir_alert_units" translatable="false">AAPS.Omnipod.low_reservoir_alert_units</string>
|
||||
<string name="key_omnipod_common_automatically_silence_alerts_enabled" translatable="false">AAPS.Omnipod.automatically_acknowledge_alerts_enabled</string>
|
||||
|
@ -129,7 +131,11 @@
|
|||
<string name="omnipod_common_preferences_suspend_delivery_button_enabled">Show Suspend Delivery button in Omnipod tab</string>
|
||||
<string name="omnipod_common_preferences_time_change_enabled">DST/Time zone detection enabled</string>
|
||||
<string name="omnipod_common_preferences_expiration_reminder_enabled">Expiration reminder enabled</string>
|
||||
<string name="omnipod_common_preferences_expiration_reminder_hours_before_shutdown">Hours before shutdown</string>
|
||||
<string name="omnipod_common_preferences_expiration_reminder_enabled_summary">When enabled the pod will beep when the specified time is reached</string>
|
||||
<string name="omnipod_common_preferences_expiration_reminder_hours_before_expiry">Reminder at hours before expiry (72 Hours)</string>
|
||||
<string name="omnipod_common_preferences_expiration_alarm_enabled">Expiration alert enabled</string>
|
||||
<string name="omnipod_common_preferences_expiration_alarm_enabled_summary">When enabled the pod will beep when the specified time is reached and 1 hour before shutdown</string>
|
||||
<string name="omnipod_common_preferences_expiration_alarm_hours_before_shutdown">Alert at hours before shutdown (80 Hours)</string>
|
||||
<string name="omnipod_common_preferences_low_reservoir_alert_enabled">Low reservoir alert enabled</string>
|
||||
<string name="omnipod_common_preferences_low_reservoir_alert_units">Number of units</string>
|
||||
<string name="omnipod_common_preferences_automatically_silence_alerts">Automatically silence Pod alerts</string>
|
||||
|
|
|
@ -22,6 +22,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_IMMINENT_ALERT_HOURS_REMAINING
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.CommandConfirmed
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
|
||||
|
@ -84,6 +85,7 @@ import java.time.Duration
|
|||
import java.time.ZonedDateTime
|
||||
import java.util.Date
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import kotlin.concurrent.thread
|
||||
|
@ -480,7 +482,9 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
.subscribe(
|
||||
{
|
||||
if (it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_enabled)) ||
|
||||
it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_shutdown)) ||
|
||||
it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_expiry)) ||
|
||||
it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_enabled)) ||
|
||||
it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_hours_before_shutdown)) ||
|
||||
it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_low_reservoir_alert_enabled)) ||
|
||||
it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_low_reservoir_alert_units))
|
||||
) {
|
||||
|
@ -1102,16 +1106,22 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
return when (customCommand) {
|
||||
is CommandSilenceAlerts ->
|
||||
silenceAlerts()
|
||||
|
||||
is CommandResumeDelivery ->
|
||||
resumeDelivery()
|
||||
|
||||
is CommandDeactivatePod ->
|
||||
deactivatePod()
|
||||
|
||||
is CommandHandleTimeChange ->
|
||||
handleTimeChange()
|
||||
|
||||
is CommandUpdateAlertConfiguration ->
|
||||
updateAlertConfiguration()
|
||||
|
||||
is CommandPlayTestBeep ->
|
||||
playTestBeep()
|
||||
|
||||
is CommandDisableSuspendAlerts ->
|
||||
disableSuspendAlerts()
|
||||
|
||||
|
@ -1214,14 +1224,18 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
private fun updateAlertConfiguration(): PumpEnactResult {
|
||||
|
||||
val expirationReminderEnabled = sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_enabled, true)
|
||||
val expirationHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_shutdown, 7)
|
||||
val expirationReminderHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_expiry, 9)
|
||||
val expirationAlarmEnabled = sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_enabled, true)
|
||||
val expirationAlarmHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_hours_before_shutdown, 8)
|
||||
val lowReservoirAlertEnabled = sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_low_reservoir_alert_enabled, true)
|
||||
val lowReservoirAlertUnits = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_low_reservoir_alert_units, 10)
|
||||
|
||||
when {
|
||||
podStateManager.sameAlertSettings(
|
||||
expirationReminderEnabled,
|
||||
expirationHours,
|
||||
expirationReminderHours,
|
||||
expirationAlarmEnabled,
|
||||
expirationAlarmHours,
|
||||
lowReservoirAlertEnabled,
|
||||
lowReservoirAlertUnits
|
||||
) -> {
|
||||
|
@ -1236,12 +1250,28 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
val podLifeLeft = Duration.between(ZonedDateTime.now(), podStateManager.expiry)
|
||||
val expiryAlertDelay = podLifeLeft.minus(Duration.ofHours(expirationHours.toLong()))
|
||||
if (expiryAlertDelay.isNegative) {
|
||||
val expiryReminderDelay = podLifeLeft.minus(Duration.ofHours(expirationReminderHours.toLong()))
|
||||
if (expiryReminderDelay.isNegative) {
|
||||
aapsLogger.warn(
|
||||
LTag.PUMPBTCOMM,
|
||||
"updateAlertConfiguration negative " +
|
||||
"expiryAlertDuration=$expiryAlertDelay"
|
||||
"updateAlertConfiguration negative expiryAlertDuration=$expiryReminderDelay"
|
||||
)
|
||||
PumpEnactResult(injector).success(false).enacted(false)
|
||||
}
|
||||
// expiry Alarm Delay, add 8 hours (grace period)
|
||||
val expiryAlarmDelay = podLifeLeft.minus(Duration.ofHours(expirationAlarmHours.toLong())).plus(Duration.ofHours(8))
|
||||
if (expiryAlarmDelay.isNegative) {
|
||||
aapsLogger.warn(
|
||||
LTag.PUMPBTCOMM,
|
||||
"updateAlertConfiguration negative expiryAlarmDuration=$expiryAlarmDelay"
|
||||
)
|
||||
PumpEnactResult(injector).success(false).enacted(false)
|
||||
}
|
||||
val expiryImminentDelay = podLifeLeft.minus(Duration.ofHours(POD_EXPIRATION_IMMINENT_ALERT_HOURS_REMAINING)).plus(Duration.ofHours(8))
|
||||
if (expiryImminentDelay.isNegative) {
|
||||
aapsLogger.warn(
|
||||
LTag.PUMPBTCOMM,
|
||||
"updateAlertConfiguration negative expiryImminentDuration=$expiryImminentDelay"
|
||||
)
|
||||
PumpEnactResult(injector).success(false).enacted(false)
|
||||
}
|
||||
|
@ -1261,18 +1291,43 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
durationInMinutes = 0,
|
||||
autoOff = false,
|
||||
AlertTrigger.TimerTrigger(
|
||||
expiryAlertDelay.toMinutes().toShort()
|
||||
expiryReminderDelay.toMinutes().toShort()
|
||||
),
|
||||
BeepType.FOUR_TIMES_BIP_BEEP,
|
||||
BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
|
||||
),
|
||||
AlertConfiguration(
|
||||
AlertType.EXPIRATION,
|
||||
enabled = expirationAlarmEnabled,
|
||||
durationInMinutes = TimeUnit.HOURS.toMinutes((expirationAlarmHours - 1).toLong()).toShort(),
|
||||
autoOff = false,
|
||||
AlertTrigger.TimerTrigger(
|
||||
expiryAlarmDelay.toMinutes().toShort()
|
||||
),
|
||||
BeepType.FOUR_TIMES_BIP_BEEP,
|
||||
BeepRepetitionType.XXX3
|
||||
),
|
||||
AlertConfiguration(
|
||||
AlertType.EXPIRATION_IMMINENT,
|
||||
enabled = expirationAlarmEnabled,
|
||||
durationInMinutes = 0,
|
||||
autoOff = false,
|
||||
AlertTrigger.TimerTrigger(
|
||||
expiryImminentDelay.toMinutes().toShort()
|
||||
),
|
||||
BeepType.FOUR_TIMES_BIP_BEEP,
|
||||
BeepRepetitionType.XXX3
|
||||
)
|
||||
)
|
||||
|
||||
return executeProgrammingCommand(
|
||||
historyEntry = history.createRecord(OmnipodCommandType.CONFIGURE_ALERTS),
|
||||
command = omnipodManager.programAlerts(alerts).ignoreElements(),
|
||||
post = podStateManager.updateExpirationAlertSettings(
|
||||
expirationReminderEnabled,
|
||||
expirationHours
|
||||
expirationReminderHours,
|
||||
expirationAlarmEnabled,
|
||||
expirationAlarmHours
|
||||
).andThen(
|
||||
podStateManager.updateLowReservoirAlertSettings(
|
||||
lowReservoirAlertEnabled,
|
||||
|
@ -1537,10 +1592,13 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
return when (notificationType) {
|
||||
Notification.OMNIPOD_TBR_ALERTS ->
|
||||
sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_notification_uncertain_tbr_sound_enabled, true)
|
||||
|
||||
Notification.OMNIPOD_UNCERTAIN_SMB ->
|
||||
sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_notification_uncertain_smb_sound_enabled, true)
|
||||
|
||||
Notification.OMNIPOD_POD_SUSPENDED ->
|
||||
sp.getBoolean(R.string.key_omnipod_common_notification_delivery_suspended_sound_enabled, true)
|
||||
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ interface OmnipodDashManager {
|
|||
|
||||
fun activatePodPart1(lowReservoirAlertTrigger: AlertTrigger.ReservoirVolumeTrigger?): Observable<PodEvent>
|
||||
|
||||
fun activatePodPart2(basalProgram: BasalProgram, userConfiguredExpirationHours: Long?): Observable<PodEvent>
|
||||
fun activatePodPart2(basalProgram: BasalProgram, userConfiguredExpirationReminderHours: Long?, userConfiguredExpirationAlarmHours: Long?): Observable<PodEvent>
|
||||
|
||||
fun getStatus(type: ResponseType.StatusResponseType): Observable<PodEvent>
|
||||
|
||||
|
|
|
@ -23,11 +23,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepRepetitionType
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.MAX_POD_LIFETIME
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_HOURS
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_HOURS_DURATION
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_IMMINENT_ALERT_HOURS
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_HOURS_REMAINING_DEFAULT
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_IMMINENT_ALERT_HOURS_REMAINING
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_PULSE_BOLUS_UNITS
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder
|
||||
|
@ -368,19 +366,19 @@ class OmnipodDashManagerImpl @Inject constructor(
|
|||
return observables.reversed()
|
||||
}
|
||||
|
||||
override fun activatePodPart2(basalProgram: BasalProgram, userConfiguredExpirationHours: Long?):
|
||||
override fun activatePodPart2(basalProgram: BasalProgram, userConfiguredExpirationReminderHours: Long?, userConfiguredExpirationAlarmHours: Long?):
|
||||
Observable<PodEvent> {
|
||||
return Observable.concat(
|
||||
observePodReadyForActivationPart2,
|
||||
observeConnectToPod,
|
||||
observeActivationPart2Commands(basalProgram, userConfiguredExpirationHours)
|
||||
observeActivationPart2Commands(basalProgram, userConfiguredExpirationReminderHours, userConfiguredExpirationAlarmHours)
|
||||
).doOnComplete(ActivationProgressUpdater(ActivationProgress.COMPLETED))
|
||||
.interceptPodEvents()
|
||||
}
|
||||
|
||||
private fun observeActivationPart2Commands(basalProgram: BasalProgram, userConfiguredExpirationHours: Long?):
|
||||
private fun observeActivationPart2Commands(basalProgram: BasalProgram, userConfiguredExpirationReminderHours: Long?, userConfiguredExpirationAlarmHours: Long?):
|
||||
Observable<PodEvent> {
|
||||
val observables = createActivationPart2Observables(basalProgram, userConfiguredExpirationHours)
|
||||
val observables = createActivationPart2Observables(basalProgram, userConfiguredExpirationReminderHours, userConfiguredExpirationAlarmHours)
|
||||
|
||||
return if (observables.isEmpty()) {
|
||||
Observable.empty()
|
||||
|
@ -391,7 +389,8 @@ class OmnipodDashManagerImpl @Inject constructor(
|
|||
|
||||
private fun createActivationPart2Observables(
|
||||
basalProgram: BasalProgram,
|
||||
userConfiguredExpirationHours: Long?
|
||||
userConfiguredExpirationReminderHours: Long?,
|
||||
userConfiguredExpirationAlarmHours: Long?
|
||||
):
|
||||
List<Observable<PodEvent>> {
|
||||
val observables = ArrayList<Observable<PodEvent>>()
|
||||
|
@ -422,48 +421,60 @@ class OmnipodDashManagerImpl @Inject constructor(
|
|||
if (podStateManager.activationProgress.isBefore(ActivationProgress.UPDATED_EXPIRATION_ALERTS)) {
|
||||
val podLifeLeft = Duration.between(ZonedDateTime.now(), podStateManager.expiry)
|
||||
|
||||
val expirationAlarmEnabled = userConfiguredExpirationAlarmHours != null && userConfiguredExpirationAlarmHours > 0
|
||||
val expirationAlarmDelay = podLifeLeft.minus(
|
||||
Duration.ofHours(userConfiguredExpirationAlarmHours ?: POD_EXPIRATION_ALERT_HOURS_REMAINING_DEFAULT)
|
||||
).plus(Duration.ofHours(8)) // Add 8 hours for grace period
|
||||
|
||||
val expirationImminentDelay = podLifeLeft.minus(
|
||||
Duration.ofHours(POD_EXPIRATION_IMMINENT_ALERT_HOURS_REMAINING)
|
||||
).plus(Duration.ofHours(8)) // Add 8 hours for grace period
|
||||
|
||||
val alerts = mutableListOf(
|
||||
AlertConfiguration(
|
||||
AlertType.EXPIRATION,
|
||||
enabled = true,
|
||||
durationInMinutes = TimeUnit.HOURS.toMinutes(POD_EXPIRATION_ALERT_HOURS_DURATION).toShort(),
|
||||
enabled = expirationAlarmEnabled,
|
||||
durationInMinutes = (TimeUnit.HOURS.toMinutes(
|
||||
userConfiguredExpirationAlarmHours ?: POD_EXPIRATION_ALERT_HOURS_REMAINING_DEFAULT
|
||||
) - 60).toShort(),
|
||||
autoOff = false,
|
||||
AlertTrigger.TimerTrigger(
|
||||
TimeUnit.HOURS.toMinutes(POD_EXPIRATION_ALERT_HOURS).toShort()
|
||||
), // FIXME use activation time
|
||||
expirationAlarmDelay.toMinutes().toShort()
|
||||
),
|
||||
BeepType.FOUR_TIMES_BIP_BEEP,
|
||||
BeepRepetitionType.XXX3
|
||||
),
|
||||
AlertConfiguration(
|
||||
AlertType.EXPIRATION_IMMINENT,
|
||||
enabled = true,
|
||||
enabled = expirationAlarmEnabled,
|
||||
durationInMinutes = 0,
|
||||
autoOff = false,
|
||||
AlertTrigger.TimerTrigger(
|
||||
TimeUnit.HOURS.toMinutes(POD_EXPIRATION_IMMINENT_ALERT_HOURS).toShort()
|
||||
), // FIXME use activation time
|
||||
expirationImminentDelay.toMinutes().toShort()
|
||||
),
|
||||
BeepType.FOUR_TIMES_BIP_BEEP,
|
||||
BeepRepetitionType.XXX4
|
||||
)
|
||||
)
|
||||
val userExpiryAlertDelay = podLifeLeft.minus(
|
||||
Duration.ofHours(userConfiguredExpirationHours ?: MAX_POD_LIFETIME.toHours() + 1)
|
||||
val userExpiryReminderEnabled = userConfiguredExpirationReminderHours != null && userConfiguredExpirationReminderHours > 0
|
||||
val userExpiryReminderDelay = podLifeLeft.minus(
|
||||
Duration.ofHours(userConfiguredExpirationReminderHours ?: MAX_POD_LIFETIME.toHours() + 1)
|
||||
)
|
||||
if (userExpiryAlertDelay.isNegative) {
|
||||
if (userExpiryReminderDelay.isNegative) {
|
||||
logger.warn(
|
||||
LTag.PUMPBTCOMM,
|
||||
"createActivationPart2Observables negative " +
|
||||
"expiryAlertDuration=$userExpiryAlertDelay"
|
||||
"expiryAlertDuration=$userExpiryReminderDelay"
|
||||
)
|
||||
} else {
|
||||
alerts.add(
|
||||
AlertConfiguration(
|
||||
AlertType.USER_SET_EXPIRATION,
|
||||
enabled = true,
|
||||
enabled = userExpiryReminderEnabled,
|
||||
durationInMinutes = 0,
|
||||
autoOff = false,
|
||||
AlertTrigger.TimerTrigger(
|
||||
userExpiryAlertDelay.toMinutes().toShort()
|
||||
userExpiryReminderDelay.toMinutes().toShort()
|
||||
),
|
||||
BeepType.FOUR_TIMES_BIP_BEEP,
|
||||
BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
|
||||
|
|
|
@ -6,12 +6,11 @@ class PodConstants {
|
|||
companion object {
|
||||
val MAX_POD_LIFETIME: Duration = Duration.ofHours(80)
|
||||
|
||||
// Expiration alert time in minutes since activation and duration in minutes
|
||||
const val POD_EXPIRATION_ALERT_HOURS = 72L
|
||||
const val POD_EXPIRATION_ALERT_HOURS_DURATION = 7L
|
||||
// Expiration alert time in hours before lifetime end
|
||||
const val POD_EXPIRATION_ALERT_HOURS_REMAINING_DEFAULT = 7L
|
||||
|
||||
// Expiration eminent alert time in minutes since activation
|
||||
const val POD_EXPIRATION_IMMINENT_ALERT_HOURS = 79L
|
||||
// Imminent expiration alert time in hours before lifetime end
|
||||
const val POD_EXPIRATION_IMMINENT_ALERT_HOURS_REMAINING = 1L
|
||||
|
||||
// Bolus & Priming units
|
||||
const val POD_PULSE_BOLUS_UNITS = 0.05
|
||||
|
|
|
@ -112,8 +112,20 @@ interface OmnipodDashPodStateManager {
|
|||
- after getPodStatus was successful(we have an up-to-date podStatus)
|
||||
*/
|
||||
fun recoverActivationFromPodStatus(): String?
|
||||
fun sameAlertSettings(expirationReminderEnabled: Boolean, expirationHours: Int, lowReservoirAlertEnabled: Boolean, lowReservoirAlertUnits: Int): Boolean
|
||||
fun updateExpirationAlertSettings(expirationReminderEnabled: Boolean, expirationHours: Int): Completable
|
||||
fun sameAlertSettings(
|
||||
expirationReminderEnabled: Boolean,
|
||||
expirationReminderHours: Int,
|
||||
expirationAlarmEnabled: Boolean,
|
||||
expirationAlarmHours: Int,
|
||||
lowReservoirAlertEnabled: Boolean,
|
||||
lowReservoirAlertUnits: Int
|
||||
): Boolean
|
||||
fun updateExpirationAlertSettings(
|
||||
expirationReminderEnabled: Boolean,
|
||||
expirationReminderHours: Int,
|
||||
expirationAlarmEnabled: Boolean,
|
||||
expirationAlarmHours: Int
|
||||
): Completable
|
||||
fun updateLowReservoirAlertSettings(lowReservoirAlertEnabled: Boolean, lowReservoirAlertUnits: Int): Completable
|
||||
|
||||
data class ActiveCommand(
|
||||
|
|
|
@ -417,16 +417,22 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
val newActivationProgress = when (podState.podStatus) {
|
||||
PodStatus.FILLED ->
|
||||
ActivationProgress.NOT_STARTED
|
||||
|
||||
PodStatus.UID_SET ->
|
||||
ActivationProgress.SET_UNIQUE_ID
|
||||
|
||||
PodStatus.ENGAGING_CLUTCH_DRIVE, PodStatus.PRIMING ->
|
||||
return "Busy"
|
||||
|
||||
PodStatus.CLUTCH_DRIVE_ENGAGED ->
|
||||
ActivationProgress.PRIME_COMPLETED
|
||||
|
||||
PodStatus.BASAL_PROGRAM_SET ->
|
||||
ActivationProgress.PROGRAMMED_BASAL
|
||||
|
||||
PodStatus.RUNNING_ABOVE_MIN_VOLUME, PodStatus.RUNNING_BELOW_MIN_VOLUME ->
|
||||
ActivationProgress.CANNULA_INSERTED
|
||||
|
||||
else ->
|
||||
null
|
||||
}
|
||||
|
@ -482,20 +488,30 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
|
||||
override fun sameAlertSettings(
|
||||
expirationReminderEnabled: Boolean,
|
||||
expirationHours: Int,
|
||||
expirationReminderHours: Int,
|
||||
expirationAlarmEnabled: Boolean,
|
||||
expirationAlarmHours: Int,
|
||||
lowReservoirAlertEnabled: Boolean,
|
||||
lowReservoirAlertUnits: Int
|
||||
): Boolean {
|
||||
return podState.expirationReminderEnabled == expirationReminderEnabled &&
|
||||
podState.expirationHours == expirationHours &&
|
||||
podState.expirationReminderHours == expirationReminderHours &&
|
||||
podState.expirationAlarmEnabled == expirationAlarmEnabled &&
|
||||
podState.expirationAlarmHours == expirationAlarmHours &&
|
||||
podState.lowReservoirAlertEnabled == lowReservoirAlertEnabled &&
|
||||
podState.lowReservoirAlertUnits == lowReservoirAlertUnits
|
||||
}
|
||||
|
||||
override fun updateExpirationAlertSettings(expirationReminderEnabled: Boolean, expirationHours: Int):
|
||||
Completable = Completable.defer {
|
||||
override fun updateExpirationAlertSettings(
|
||||
expirationReminderEnabled: Boolean,
|
||||
expirationReminderHours: Int,
|
||||
expirationAlarmEnabled: Boolean,
|
||||
expirationAlarmHours: Int
|
||||
): Completable = Completable.defer {
|
||||
podState.expirationReminderEnabled = expirationReminderEnabled
|
||||
podState.expirationHours = expirationHours
|
||||
podState.expirationReminderHours = expirationReminderHours
|
||||
podState.expirationAlarmEnabled = expirationAlarmEnabled
|
||||
podState.expirationAlarmHours = expirationAlarmHours
|
||||
Completable.complete()
|
||||
}
|
||||
|
||||
|
@ -520,14 +536,17 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
createdRealtime <= podState.lastStatusResponseReceived &&
|
||||
sequence == podState.sequenceNumberOfLastProgrammingCommand ->
|
||||
CommandConfirmationSuccess
|
||||
|
||||
createdRealtime <= podState.lastStatusResponseReceived &&
|
||||
sequence != podState.sequenceNumberOfLastProgrammingCommand ->
|
||||
CommandConfirmationDenied
|
||||
// no response received after this point
|
||||
createdRealtime <= sentRealtime ->
|
||||
CommandSendingNotConfirmed
|
||||
|
||||
createdRealtime > sentRealtime ->
|
||||
CommandSendingFailure
|
||||
|
||||
else -> // this can't happen, see the previous two conditions
|
||||
NoActiveCommand
|
||||
}
|
||||
|
@ -745,7 +764,9 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
var secondPrimeBolusVolume: Short? = null,
|
||||
|
||||
var expirationReminderEnabled: Boolean? = null,
|
||||
var expirationHours: Int? = null,
|
||||
var expirationReminderHours: Int? = null,
|
||||
var expirationAlarmEnabled: Boolean? = null,
|
||||
var expirationAlarmHours: Int? = null,
|
||||
var lowReservoirAlertEnabled: Boolean? = null,
|
||||
var lowReservoirAlertUnits: Int? = null,
|
||||
|
||||
|
|
|
@ -67,16 +67,24 @@ class DashInsertCannulaViewModel @Inject constructor(
|
|||
basalProgram
|
||||
)
|
||||
val expirationReminderEnabled = sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_enabled, true)
|
||||
val expirationHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_shutdown, 9)
|
||||
val expirationReminderHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_expiry, 9)
|
||||
|
||||
val expirationHoursBeforeShutdown = if (expirationReminderEnabled)
|
||||
expirationHours.toLong()
|
||||
val expirationReminderHoursBeforeShutdown = if (expirationReminderEnabled)
|
||||
expirationReminderHours.toLong()
|
||||
else
|
||||
null
|
||||
|
||||
super.disposable += omnipodManager.activatePodPart2(basalProgram, expirationHoursBeforeShutdown)
|
||||
val expirationAlarmEnabled = sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_enabled, true)
|
||||
val expirationAlarmHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_hours_before_shutdown, 8)
|
||||
|
||||
val expirationAlarmHoursBeforeShutdown = if (expirationAlarmEnabled)
|
||||
expirationAlarmHours.toLong()
|
||||
else
|
||||
null
|
||||
|
||||
super.disposable += omnipodManager.activatePodPart2(basalProgram, expirationReminderHoursBeforeShutdown, expirationAlarmHoursBeforeShutdown)
|
||||
.ignoreElements()
|
||||
.andThen(podStateManager.updateExpirationAlertSettings(expirationReminderEnabled, expirationHours))
|
||||
.andThen(podStateManager.updateExpirationAlertSettings(expirationReminderEnabled, expirationReminderHours, expirationAlarmEnabled, expirationAlarmHours))
|
||||
.andThen(
|
||||
history.createRecord(
|
||||
OmnipodCommandType.INSERT_CANNULA,
|
||||
|
|
|
@ -37,17 +37,35 @@
|
|||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_omnipod_common_expiration_reminder_enabled"
|
||||
android:title="@string/omnipod_common_preferences_expiration_reminder_enabled" />
|
||||
android:title="@string/omnipod_common_preferences_expiration_reminder_enabled"
|
||||
android:summary="@string/omnipod_common_preferences_expiration_reminder_enabled_summary" />
|
||||
|
||||
<info.nightscout.core.validators.ValidatingEditTextPreference
|
||||
android:defaultValue="9"
|
||||
android:defaultValue="4"
|
||||
android:dependency="@string/key_omnipod_common_expiration_reminder_enabled"
|
||||
android:digits="0123456789"
|
||||
android:inputType="number"
|
||||
android:key="@string/key_omnipod_common_expiration_reminder_hours_before_shutdown"
|
||||
android:title="@string/omnipod_common_preferences_expiration_reminder_hours_before_shutdown"
|
||||
android:key="@string/key_omnipod_common_expiration_reminder_hours_before_expiry"
|
||||
android:title="@string/omnipod_common_preferences_expiration_reminder_hours_before_expiry"
|
||||
validate:maxNumber="24"
|
||||
validate:minNumber="2"
|
||||
validate:minNumber="1"
|
||||
validate:testType="numericRange" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_omnipod_common_expiration_alarm_enabled"
|
||||
android:title="@string/omnipod_common_preferences_expiration_alarm_enabled"
|
||||
android:summary="@string/omnipod_common_preferences_expiration_alarm_enabled_summary" />
|
||||
|
||||
<info.nightscout.core.validators.ValidatingEditTextPreference
|
||||
android:defaultValue="8"
|
||||
android:dependency="@string/key_omnipod_common_expiration_alarm_enabled"
|
||||
android:digits="0123456789"
|
||||
android:inputType="number"
|
||||
android:key="@string/key_omnipod_common_expiration_alarm_hours_before_shutdown"
|
||||
android:title="@string/omnipod_common_preferences_expiration_alarm_hours_before_shutdown"
|
||||
validate:maxNumber="8"
|
||||
validate:minNumber="1"
|
||||
validate:testType="numericRange" />
|
||||
|
||||
<SwitchPreference
|
||||
|
|
|
@ -14,7 +14,7 @@ public class OmnipodErosStorageKeys {
|
|||
public static final int PULSE_LOG_BUTTON_ENABLED = R.string.key_omnipod_eros_pulse_log_button_enabled;
|
||||
public static final int TIME_CHANGE_EVENT_ENABLED = info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_time_change_event_enabled;
|
||||
public static final int EXPIRATION_REMINDER_ENABLED = info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_enabled;
|
||||
public static final int EXPIRATION_REMINDER_HOURS_BEFORE_SHUTDOWN = info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_shutdown;
|
||||
public static final int EXPIRATION_REMINDER_HOURS_BEFORE_SHUTDOWN = info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_expiry;
|
||||
public static final int LOW_RESERVOIR_ALERT_ENABLED = info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_low_reservoir_alert_enabled;
|
||||
public static final int LOW_RESERVOIR_ALERT_UNITS = info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_low_reservoir_alert_units;
|
||||
public static final int NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED = R.string.key_omnipod_eros_notification_uncertain_tbr_sound_enabled;
|
||||
|
|
|
@ -76,8 +76,8 @@
|
|||
android:dependency="@string/key_omnipod_common_expiration_reminder_enabled"
|
||||
android:digits="0123456789"
|
||||
android:inputType="number"
|
||||
android:key="@string/key_omnipod_common_expiration_reminder_hours_before_shutdown"
|
||||
android:title="@string/omnipod_common_preferences_expiration_reminder_hours_before_shutdown"
|
||||
android:key="@string/key_omnipod_common_expiration_reminder_hours_before_expiry"
|
||||
android:title="@string/omnipod_common_preferences_expiration_reminder_hours_before_expiry"
|
||||
validate:maxNumber="24"
|
||||
validate:minNumber="2"
|
||||
validate:testType="numericRange" />
|
||||
|
|
Loading…
Reference in a new issue