From 4201fe08a5844b8decc08d4fe76b06914ee62b66 Mon Sep 17 00:00:00 2001 From: Carlos Rafael Giani Date: Wed, 2 Nov 2022 22:57:42 +0100 Subject: [PATCH] combov2: Improve shortStatus output Signed-off-by: Carlos Rafael Giani --- .../plugins/pump/combov2/ComboV2Plugin.kt | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/pump/combov2/src/main/kotlin/info/nightscout/androidaps/plugins/pump/combov2/ComboV2Plugin.kt b/pump/combov2/src/main/kotlin/info/nightscout/androidaps/plugins/pump/combov2/ComboV2Plugin.kt index 74329b229a..b26803c5d8 100644 --- a/pump/combov2/src/main/kotlin/info/nightscout/androidaps/plugins/pump/combov2/ComboV2Plugin.kt +++ b/pump/combov2/src/main/kotlin/info/nightscout/androidaps/plugins/pump/combov2/ComboV2Plugin.kt @@ -1116,11 +1116,12 @@ class ComboV2Plugin @Inject constructor ( get() = _pumpDescription override fun shortStatus(veryShort: Boolean): String { - var ret = "" + var lines = mutableListOf() + if (lastConnectionTimestamp != 0L) { val agoMsec: Long = System.currentTimeMillis() - lastConnectionTimestamp 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) { @@ -1129,41 +1130,45 @@ class ComboV2Plugin @Inject constructor ( else -> 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 { 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()), String.format("%02d:%02d", localBolusTimestamp.hour, localBolusTimestamp.minute) - ) + "\n" + ) } val temporaryBasal = pumpSync.expectedPumpState().temporaryBasal temporaryBasal?.let { - ret += rh.gs( + lines += rh.gs( R.string.combov2_short_status_temp_basal, it.toStringFull(dateUtil) - ) + "\n" + ) } pumpStatus?.let { - ret += rh.gs( + lines += rh.gs( R.string.combov2_short_status_reservoir, it.availableUnitsInReservoir - ) + "\n" + ) val batteryStateDesc = when (it.batteryState) { 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.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, batteryStateDesc - ) + "\n" + ) } - return ret + val shortStatusString = lines.joinToString("\n") + + aapsLogger.debug(LTag.PUMP, "Produced short status: [$shortStatusString]") + + return shortStatusString } override val isFakingTempsByExtendedBoluses = false