Merge pull request #893 from 0pen-dash/avereha/fix-bolus

Avereha/fix bolus
This commit is contained in:
Milos Kozak 2021-11-09 23:43:41 +01:00 committed by GitHub
commit 43287f6dca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 37 deletions

View file

@ -461,16 +461,16 @@ class OmnipodDashPumpPlugin @Inject constructor(
R.string.key_omnipod_common_expiration_reminder_enabled
) ||
it.isChanged(
rh,
R.string.key_omnipod_common_expiration_reminder_hours_before_shutdown
rh,
R.string.key_omnipod_common_expiration_reminder_hours_before_shutdown
) ||
it.isChanged(
rh,
R.string.key_omnipod_common_low_reservoir_alert_enabled
rh,
R.string.key_omnipod_common_low_reservoir_alert_enabled
) ||
it.isChanged(
rh,
R.string.key_omnipod_common_low_reservoir_alert_units
rh,
R.string.key_omnipod_common_low_reservoir_alert_units
)
) {
commandQueue.customCommand(CommandUpdateAlertConfiguration(), null)
@ -625,15 +625,20 @@ class OmnipodDashPumpPlugin @Inject constructor(
)
}
}
}.toSingleDefault(
}.toSingle {
PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(deliveredBolusAmount)
}.onErrorReturnItem(
// success if canceled
PumpEnactResult(injector).success(bolusCanceled).enacted(false)
)
.onErrorReturnItem(
// success if canceled
PumpEnactResult(injector).success(bolusCanceled).enacted(false)
)
.blockingGet()
aapsLogger.info(LTag.PUMP, "deliverTreatment result: $ret")
aapsLogger.info(
LTag.PUMP,
"deliverTreatment result: $ret. " +
"deliveredBolusAmount=$deliveredBolusAmount. " +
"ret bolus=${ret.bolusDelivered}" +
"bolusCanceled=$bolusCanceled"
)
return ret
} finally {
bolusCanceled = false

View file

@ -56,44 +56,44 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
private fun groupForCommandType(type: OmnipodCommandType): PumpHistoryEntryGroup {
return when (type) {
OmnipodCommandType.INITIALIZE_POD ->
OmnipodCommandType.INITIALIZE_POD ->
PumpHistoryEntryGroup.Prime
OmnipodCommandType.INSERT_CANNULA ->
OmnipodCommandType.INSERT_CANNULA ->
PumpHistoryEntryGroup.Prime
OmnipodCommandType.DEACTIVATE_POD ->
OmnipodCommandType.DEACTIVATE_POD ->
PumpHistoryEntryGroup.Prime
OmnipodCommandType.DISCARD_POD ->
OmnipodCommandType.DISCARD_POD ->
PumpHistoryEntryGroup.Prime
OmnipodCommandType.CANCEL_TEMPORARY_BASAL ->
PumpHistoryEntryGroup.Basal
OmnipodCommandType.SET_BASAL_PROFILE ->
OmnipodCommandType.SET_BASAL_PROFILE ->
PumpHistoryEntryGroup.Basal
OmnipodCommandType.SET_TEMPORARY_BASAL ->
OmnipodCommandType.SET_TEMPORARY_BASAL ->
PumpHistoryEntryGroup.Basal
OmnipodCommandType.RESUME_DELIVERY ->
OmnipodCommandType.RESUME_DELIVERY ->
PumpHistoryEntryGroup.Basal
OmnipodCommandType.SUSPEND_DELIVERY ->
OmnipodCommandType.SUSPEND_DELIVERY ->
PumpHistoryEntryGroup.Basal
OmnipodCommandType.SET_BOLUS ->
OmnipodCommandType.SET_BOLUS ->
PumpHistoryEntryGroup.Bolus
OmnipodCommandType.CANCEL_BOLUS ->
OmnipodCommandType.CANCEL_BOLUS ->
PumpHistoryEntryGroup.Bolus
OmnipodCommandType.ACKNOWLEDGE_ALERTS ->
OmnipodCommandType.ACKNOWLEDGE_ALERTS ->
PumpHistoryEntryGroup.Alarm
OmnipodCommandType.CONFIGURE_ALERTS ->
OmnipodCommandType.CONFIGURE_ALERTS ->
PumpHistoryEntryGroup.Alarm
OmnipodCommandType.PLAY_TEST_BEEP ->
OmnipodCommandType.PLAY_TEST_BEEP ->
PumpHistoryEntryGroup.Alarm
OmnipodCommandType.GET_POD_STATUS ->
OmnipodCommandType.GET_POD_STATUS ->
PumpHistoryEntryGroup.Configuration
OmnipodCommandType.SET_TIME ->
OmnipodCommandType.SET_TIME ->
PumpHistoryEntryGroup.Configuration
OmnipodCommandType.READ_POD_PULSE_LOG ->
OmnipodCommandType.READ_POD_PULSE_LOG ->
PumpHistoryEntryGroup.Unknown
}
}
@ -225,13 +225,13 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
OmnipodCommandType.DISCARD_POD,
OmnipodCommandType.SUSPEND_DELIVERY,
OmnipodCommandType.RESUME_DELIVERY,
OmnipodCommandType.SET_BASAL_PROFILE -> {
OmnipodCommandType.SET_BASAL_PROFILE -> {
android.graphics.Color.CYAN
}
// User action
OmnipodCommandType.PLAY_TEST_BEEP,
OmnipodCommandType.ACKNOWLEDGE_ALERTS,
OmnipodCommandType.CANCEL_BOLUS -> {
OmnipodCommandType.CANCEL_BOLUS -> {
android.graphics.Color.GREEN
}
// Insulin treatment
@ -240,7 +240,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
android.graphics.Color.WHITE
}
else ->
else ->
// Other
android.graphics.Color.LTGRAY
}
@ -268,7 +268,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
}
}
OmnipodCommandType.SET_BOLUS -> {
OmnipodCommandType.SET_BOLUS -> {
val bolus = historyEntry.record as BolusRecord
bolus.let {
rh.gs(R.string.omnipod_common_history_bolus_value, it.amout)
@ -278,12 +278,12 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
OmnipodCommandType.SET_BASAL_PROFILE,
OmnipodCommandType.SET_TIME,
OmnipodCommandType.INSERT_CANNULA,
OmnipodCommandType.RESUME_DELIVERY -> {
OmnipodCommandType.RESUME_DELIVERY -> {
val basal = historyEntry.record as BasalValuesRecord
ProfileUtil.getBasalProfilesDisplayable(basal.segments.toTypedArray(), PumpType.OMNIPOD_DASH)
}
else ->
else ->
""
}
// Set some color
@ -306,12 +306,12 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
return when {
historyEntry.initialResult == InitialResult.FAILURE_SENDING ->
R.string.omnipod_dash_failed_to_send
historyEntry.initialResult == InitialResult.NOT_SENT ->
historyEntry.initialResult == InitialResult.NOT_SENT ->
R.string.omnipod_dash_command_not_sent
historyEntry.initialResult == InitialResult.SENT &&
historyEntry.resolvedResult == ResolvedResult.FAILURE ->
historyEntry.resolvedResult == ResolvedResult.FAILURE ->
R.string.omnipod_dash_command_not_received_by_the_pod
else ->
else ->
R.string.omnipod_dash_unknown
}
}