combov2: Improve shortStatus output

Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
This commit is contained in:
Carlos Rafael Giani 2022-11-02 22:57:42 +01:00
parent 7d9925db47
commit 4201fe08a5

View file

@ -1116,11 +1116,12 @@ class ComboV2Plugin @Inject constructor (
get() = _pumpDescription get() = _pumpDescription
override fun shortStatus(veryShort: Boolean): String { override fun shortStatus(veryShort: Boolean): String {
var ret = "" var lines = mutableListOf<String>()
if (lastConnectionTimestamp != 0L) { if (lastConnectionTimestamp != 0L) {
val agoMsec: Long = System.currentTimeMillis() - lastConnectionTimestamp val agoMsec: Long = System.currentTimeMillis() - lastConnectionTimestamp
val agoMin = (agoMsec / 60.0 / 1000.0).toInt() val agoMin = (agoMsec / 60.0 / 1000.0).toInt()
ret += rh.gs(R.string.combov2_short_status_last_connection, agoMin) + "\n" lines += rh.gs(R.string.combov2_short_status_last_connection, agoMin)
} }
val alertCodeString = when (val alert = lastComboAlert) { val alertCodeString = when (val alert = lastComboAlert) {
@ -1129,41 +1130,45 @@ class ComboV2Plugin @Inject constructor (
else -> null else -> null
} }
if (alertCodeString != null) if (alertCodeString != null)
ret += rh.gs(R.string.combov2_short_status_alert, alertCodeString) + "\n" lines += rh.gs(R.string.combov2_short_status_alert, alertCodeString)
lastBolusUIFlow.value?.let { lastBolusUIFlow.value?.let {
val localBolusTimestamp = it.timestamp.toLocalDateTime(TimeZone.currentSystemDefault()) val localBolusTimestamp = it.timestamp.toLocalDateTime(TimeZone.currentSystemDefault())
ret += rh.gs( lines += rh.gs(
R.string.combov2_short_status_last_bolus, DecimalFormatter.to2Decimal(it.bolusAmount.cctlBolusToIU()), R.string.combov2_short_status_last_bolus, DecimalFormatter.to2Decimal(it.bolusAmount.cctlBolusToIU()),
String.format("%02d:%02d", localBolusTimestamp.hour, localBolusTimestamp.minute) String.format("%02d:%02d", localBolusTimestamp.hour, localBolusTimestamp.minute)
) + "\n" )
} }
val temporaryBasal = pumpSync.expectedPumpState().temporaryBasal val temporaryBasal = pumpSync.expectedPumpState().temporaryBasal
temporaryBasal?.let { temporaryBasal?.let {
ret += rh.gs( lines += rh.gs(
R.string.combov2_short_status_temp_basal, R.string.combov2_short_status_temp_basal,
it.toStringFull(dateUtil) it.toStringFull(dateUtil)
) + "\n" )
} }
pumpStatus?.let { pumpStatus?.let {
ret += rh.gs( lines += rh.gs(
R.string.combov2_short_status_reservoir, R.string.combov2_short_status_reservoir,
it.availableUnitsInReservoir it.availableUnitsInReservoir
) + "\n" )
val batteryStateDesc = when (it.batteryState) { val batteryStateDesc = when (it.batteryState) {
BatteryState.NO_BATTERY -> rh.gs(R.string.combov2_short_status_battery_state_empty) BatteryState.NO_BATTERY -> rh.gs(R.string.combov2_short_status_battery_state_empty)
BatteryState.LOW_BATTERY -> rh.gs(R.string.combov2_short_status_battery_state_low) BatteryState.LOW_BATTERY -> rh.gs(R.string.combov2_short_status_battery_state_low)
BatteryState.FULL_BATTERY -> rh.gs(R.string.combov2_short_status_battery_state_full) BatteryState.FULL_BATTERY -> rh.gs(R.string.combov2_short_status_battery_state_full)
} }
ret += rh.gs( lines += rh.gs(
R.string.combov2_short_status_battery_state, R.string.combov2_short_status_battery_state,
batteryStateDesc batteryStateDesc
) + "\n" )
} }
return ret val shortStatusString = lines.joinToString("\n")
aapsLogger.debug(LTag.PUMP, "Produced short status: [$shortStatusString]")
return shortStatusString
} }
override val isFakingTempsByExtendedBoluses = false override val isFakingTempsByExtendedBoluses = false