From 735ff383d9e86c811a06aa30b92d66ee60938bab Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Wed, 27 Oct 2021 01:24:41 +0200 Subject: [PATCH 1/5] Add some color to History --- .../omnipod/dash/ui/DashPodHistoryActivity.kt | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt index fba505ffaa..263e8831a7 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt @@ -211,8 +211,40 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { } } + private fun getTextColor(commandType: OmnipodCommandType): Int { + val textColor = when (commandType) { + // Operational + OmnipodCommandType.INITIALIZE_POD, + OmnipodCommandType.CONFIGURE_ALERTS, + OmnipodCommandType.INSERT_CANNULA, + OmnipodCommandType.DEACTIVATE_POD, + OmnipodCommandType.DISCARD_POD, + OmnipodCommandType.SUSPEND_DELIVERY, + OmnipodCommandType.RESUME_DELIVERY, + OmnipodCommandType.SET_BASAL_PROFILE -> { + android.graphics.Color.CYAN + } + // User action + OmnipodCommandType.PLAY_TEST_BEEP, + OmnipodCommandType.ACKNOWLEDGE_ALERTS, + OmnipodCommandType.CANCEL_BOLUS -> { + android.graphics.Color.GREEN + } + // Insulin treatment + OmnipodCommandType.SET_BOLUS, + OmnipodCommandType.SET_TEMPORARY_BASAL -> { + android.graphics.Color.WHITE + } + else -> + // Other + android.graphics.Color.LTGRAY + } + return textColor + } + private fun setType(record: HistoryRecord, typeView: TextView) { typeView.text = resourceHelper.gs(record.commandType.resourceId) + typeView.setTextColor(getTextColor(record.commandType)) } private fun setValue(historyEntry: HistoryRecord, valueView: TextView) { @@ -245,6 +277,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { else -> "" } + valueView.setTextColor(getTextColor(historyEntry.commandType)) } override fun getItemCount(): Int { From f96727224df491fa978d264028a84939aeda7fbe Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Wed, 27 Oct 2021 22:46:38 +0200 Subject: [PATCH 2/5] Add some color to History, include success state --- .../omnipod/dash/ui/DashPodHistoryActivity.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt index 263e8831a7..15f7e57b81 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt @@ -211,8 +211,14 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { } } - private fun getTextColor(commandType: OmnipodCommandType): Int { - val textColor = when (commandType) { + private fun setTextViewColor(includeresult: Boolean, textview: TextView, record: HistoryRecord) { + if (includeresult && !record.isSuccess()) { + // Record says not success + textview.setTextColor(android.graphics.Color.YELLOW) + return + } + // On success set color + val textColor = when (record.commandType) { // Operational OmnipodCommandType.INITIALIZE_POD, OmnipodCommandType.CONFIGURE_ALERTS, @@ -239,12 +245,13 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { // Other android.graphics.Color.LTGRAY } - return textColor + textview.setTextColor(textColor) } private fun setType(record: HistoryRecord, typeView: TextView) { typeView.text = resourceHelper.gs(record.commandType.resourceId) - typeView.setTextColor(getTextColor(record.commandType)) + // Set some color, include result + setTextViewColor(includeresult=true, typeView, record) } private fun setValue(historyEntry: HistoryRecord, valueView: TextView) { @@ -277,7 +284,8 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { else -> "" } - valueView.setTextColor(getTextColor(historyEntry.commandType)) + // Set some color + setTextViewColor(includeresult=false, valueView, historyEntry) } override fun getItemCount(): Int { From b6451850057bff0fc7a85de05de1d496c91848af Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Wed, 27 Oct 2021 22:54:09 +0200 Subject: [PATCH 3/5] Refactoring name --- .../pump/omnipod/dash/ui/DashPodHistoryActivity.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt index 15f7e57b81..f0b5709ea5 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt @@ -211,8 +211,8 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { } } - private fun setTextViewColor(includeresult: Boolean, textview: TextView, record: HistoryRecord) { - if (includeresult && !record.isSuccess()) { + private fun setTextViewColor(check_result: Boolean, textview: TextView, record: HistoryRecord) { + if (check_result && !record.isSuccess()) { // Record says not success textview.setTextColor(android.graphics.Color.YELLOW) return @@ -251,7 +251,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { private fun setType(record: HistoryRecord, typeView: TextView) { typeView.text = resourceHelper.gs(record.commandType.resourceId) // Set some color, include result - setTextViewColor(includeresult=true, typeView, record) + setTextViewColor(check_result=true, typeView, record) } private fun setValue(historyEntry: HistoryRecord, valueView: TextView) { @@ -285,7 +285,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { "" } // Set some color - setTextViewColor(includeresult=false, valueView, historyEntry) + setTextViewColor(check_result=false, valueView, historyEntry) } override fun getItemCount(): Int { From d966254815a50b35d3db231a8226ad4121f32622 Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Sat, 30 Oct 2021 01:14:17 +0200 Subject: [PATCH 4/5] klint --- .../omnipod/dash/ui/DashPodHistoryActivity.kt | 57 +++++++++++-------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt index f0b5709ea5..82d885f7fa 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt @@ -56,47 +56,48 @@ 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 } } + private fun filterHistory(group: PumpHistoryEntryGroup) { filteredHistoryList.clear() aapsLogger.debug(LTag.PUMP, "Items on full list: {}", fullHistoryList.size) @@ -227,7 +228,7 @@ 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 @@ -241,6 +242,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { OmnipodCommandType.SET_TEMPORARY_BASAL -> { android.graphics.Color.WHITE } + else -> // Other android.graphics.Color.LTGRAY @@ -251,7 +253,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { private fun setType(record: HistoryRecord, typeView: TextView) { typeView.text = resourceHelper.gs(record.commandType.resourceId) // Set some color, include result - setTextViewColor(check_result=true, typeView, record) + setTextViewColor(check_result = true, typeView, record) } private fun setValue(historyEntry: HistoryRecord, valueView: TextView) { @@ -268,24 +270,27 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { resourceHelper.gs(R.string.omnipod_common_history_tbr_value, it.rate, it.duration) } ?: "n/a" } - OmnipodCommandType.SET_BOLUS -> { + + OmnipodCommandType.SET_BOLUS -> { val bolus = historyEntry.record as BolusRecord bolus?.let { resourceHelper.gs(R.string.omnipod_common_history_bolus_value, it.amout) } ?: "n/a" } + 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 - setTextViewColor(check_result=false, valueView, historyEntry) + setTextViewColor(check_result = false, valueView, historyEntry) } override fun getItemCount(): Int { @@ -293,6 +298,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { } inner class HistoryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val timeView: TextView = itemView.findViewById(R.id.omnipod_history_time) val typeView: TextView = itemView.findViewById(R.id.omnipod_history_source) val valueView: TextView = itemView.findViewById(R.id.omnipod_history_description) @@ -303,17 +309,18 @@ 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 } } companion object { + private var selectedGroup: PumpHistoryEntryGroup = PumpHistoryEntryGroup.All const val DAYS_TO_DISPLAY = 5 } From c68491ba78447b193e833e322dc8c546ec430f1d Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Sun, 31 Oct 2021 00:22:50 +0200 Subject: [PATCH 5/5] fix deactivation --- .../omnipod/dash/OmnipodDashPumpPlugin.kt | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt index 4db2aa2bc1..f320cc0150 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt @@ -310,8 +310,8 @@ class OmnipodDashPumpPlugin @Inject constructor( ) private fun checkPodKaput(): Completable = Completable.defer { - val tbr = pumpSync.expectedPumpState().temporaryBasal if (podStateManager.isPodKaput) { + val tbr = pumpSync.expectedPumpState().temporaryBasal if (tbr == null || tbr.rate != 0.0) { pumpSync.syncTemporaryBasalWithPumpId( timestamp = System.currentTimeMillis(), @@ -340,20 +340,23 @@ class OmnipodDashPumpPlugin @Inject constructor( aapsLogger.info(LTag.PUMP, "syncBolusWithPumpId on CANCEL_BOLUS returned: $sync") } } - showNotification( - Notification.OMNIPOD_POD_FAULT, - podStateManager.alarmType.toString(), - Notification.URGENT, - R.raw.boluserror - ) - if (!podStateManager.alarmSynced) { - pumpSync.insertAnnouncement( - error = podStateManager.alarmType?.toString() ?: "Unknown pod failure", - pumpId = Random.Default.nextLong(), - pumpType = PumpType.OMNIPOD_DASH, - pumpSerial = serialNumber() + + podStateManager.alarmType?.let { + showNotification( + Notification.OMNIPOD_POD_FAULT, + it.toString(), + Notification.URGENT, + R.raw.boluserror ) - podStateManager.alarmSynced = true + if (!podStateManager.alarmSynced) { + pumpSync.insertAnnouncement( + error = it.toString(), + pumpId = Random.Default.nextLong(), + pumpType = PumpType.OMNIPOD_DASH, + pumpSerial = serialNumber() + ) + podStateManager.alarmSynced = true + } } } Completable.complete() @@ -1165,14 +1168,14 @@ class OmnipodDashPumpPlugin @Inject constructor( val ret = executeProgrammingCommand( historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD), command = omnipodManager.deactivatePod().ignoreElements(), - checkNoActiveCommand = false, - post = createFakeTBRWhenNoActivePod(), + checkNoActiveCommand = false ).doOnComplete { if (podStateManager.activeCommand != null) { success = false + } else { + podStateManager.reset() + rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT)) } - podStateManager.reset() - rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT)) }.toPumpEnactResult() if (!success) { ret.success(false)