combov2: Use more specific PumpEnactResult comment after setTbr() finishes

Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
This commit is contained in:
Carlos Rafael Giani 2022-12-06 23:23:52 +01:00
parent ad381e3c26
commit 9fdc89ee72
2 changed files with 27 additions and 7 deletions

View file

@ -1091,17 +1091,34 @@ class ComboV2Plugin @Inject constructor (
return pumpEnactResult
}
private fun setTbrInternal(percentage: Int, durationInMinutes: Int, tbrType: ComboCtlTbr.Type, force100Percent: Boolean, pumpEnactResult: PumpEnactResult) {
private fun setTbrInternal(
percentage: Int,
durationInMinutes: Int,
tbrType: ComboCtlTbr.Type,
force100Percent: Boolean,
pumpEnactResult: PumpEnactResult
) {
runBlocking {
try {
executeCommand {
pump!!.setTbr(percentage, durationInMinutes, tbrType, force100Percent)
}
val setTbrOutcome = pump!!.setTbr(percentage, durationInMinutes, tbrType, force100Percent)
pumpEnactResult.apply {
success = true
enacted = true
comment = rh.gs(R.string.combov2_setting_tbr_succeeded)
val tbrComment = when (setTbrOutcome) {
ComboCtlPump.SetTbrOutcome.SET_NORMAL_TBR ->
rh.gs(R.string.combov2_setting_tbr_succeeded)
ComboCtlPump.SetTbrOutcome.SET_EMULATED_100_TBR ->
rh.gs(R.string.combov2_set_emulated_100_tbr)
ComboCtlPump.SetTbrOutcome.LETTING_EMULATED_100_TBR_FINISH ->
rh.gs(R.string.combov2_letting_emulated_100_tbr_finish)
ComboCtlPump.SetTbrOutcome.IGNORED_REDUNDANT_100_TBR ->
rh.gs(R.string.combov2_ignoring_redundant_100_tbr)
}
pumpEnactResult.apply {
success = true
enacted = true
comment = tbrComment
}
}
} catch (e: QuantityNotChangingException) {
aapsLogger.error(LTag.PUMP, "TBR percentage adjustment hit a limit: $e")

View file

@ -107,6 +107,9 @@ buttons at the same time to cancel pairing)\n
<string name="combov2_reservoir_low_warning">Pump reservoir level is low</string>
<string name="combov2_setting_tbr_succeeded">Setting TBR succeeded</string>
<string name="combov2_setting_tbr_failed">Setting TBR failed</string>
<string name="combov2_set_emulated_100_tbr">Set emulated 100% TBR</string>
<string name="combov2_letting_emulated_100_tbr_finish">Letting ongoing emulated 100% TBR finish</string>
<string name="combov2_ignoring_redundant_100_tbr">Ignoring redundant 100% TBR request</string>
<string name="combov2_hit_unexpected_tbr_limit">Unexpected limit encountered while adjusting TBR: target percentage was %1$d%%, hit a limit at %1$d%%</string>
<string name="combov2_cannot_set_absolute_tbr_if_basal_zero">Cannot set absolute TBR if base basal rate is zero</string>
<string name="combov2_pair_with_pump_summary">Pair AndroidAPS and Android with a currently unpaired Accu-Chek Combo pump</string>