This commit is contained in:
Milos Kozak 2021-11-01 08:12:12 +01:00
commit 5d65b34566
2 changed files with 91 additions and 40 deletions

View file

@ -310,8 +310,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
) )
private fun checkPodKaput(): Completable = Completable.defer { private fun checkPodKaput(): Completable = Completable.defer {
val tbr = pumpSync.expectedPumpState().temporaryBasal
if (podStateManager.isPodKaput) { if (podStateManager.isPodKaput) {
val tbr = pumpSync.expectedPumpState().temporaryBasal
if (tbr == null || tbr.rate != 0.0) { if (tbr == null || tbr.rate != 0.0) {
pumpSync.syncTemporaryBasalWithPumpId( pumpSync.syncTemporaryBasalWithPumpId(
timestamp = System.currentTimeMillis(), timestamp = System.currentTimeMillis(),
@ -340,15 +340,17 @@ class OmnipodDashPumpPlugin @Inject constructor(
aapsLogger.info(LTag.PUMP, "syncBolusWithPumpId on CANCEL_BOLUS returned: $sync") aapsLogger.info(LTag.PUMP, "syncBolusWithPumpId on CANCEL_BOLUS returned: $sync")
} }
} }
podStateManager.alarmType?.let {
showNotification( showNotification(
Notification.OMNIPOD_POD_FAULT, Notification.OMNIPOD_POD_FAULT,
podStateManager.alarmType.toString(), it.toString(),
Notification.URGENT, Notification.URGENT,
R.raw.boluserror R.raw.boluserror
) )
if (!podStateManager.alarmSynced) { if (!podStateManager.alarmSynced) {
pumpSync.insertAnnouncement( pumpSync.insertAnnouncement(
error = podStateManager.alarmType?.toString() ?: "Unknown pod failure", error = it.toString(),
pumpId = Random.Default.nextLong(), pumpId = Random.Default.nextLong(),
pumpType = PumpType.OMNIPOD_DASH, pumpType = PumpType.OMNIPOD_DASH,
pumpSerial = serialNumber() pumpSerial = serialNumber()
@ -356,6 +358,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
podStateManager.alarmSynced = true podStateManager.alarmSynced = true
} }
} }
}
Completable.complete() Completable.complete()
} }
@ -1165,14 +1168,14 @@ class OmnipodDashPumpPlugin @Inject constructor(
val ret = executeProgrammingCommand( val ret = executeProgrammingCommand(
historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD), historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD),
command = omnipodManager.deactivatePod().ignoreElements(), command = omnipodManager.deactivatePod().ignoreElements(),
checkNoActiveCommand = false, checkNoActiveCommand = false
post = createFakeTBRWhenNoActivePod(),
).doOnComplete { ).doOnComplete {
if (podStateManager.activeCommand != null) { if (podStateManager.activeCommand != null) {
success = false success = false
} } else {
podStateManager.reset() podStateManager.reset()
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT)) rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT))
}
}.toPumpEnactResult() }.toPumpEnactResult()
if (!success) { if (!success) {
ret.success(false) ret.success(false)

View file

@ -97,6 +97,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
PumpHistoryEntryGroup.Unknown PumpHistoryEntryGroup.Unknown
} }
} }
private fun filterHistory(group: PumpHistoryEntryGroup) { private fun filterHistory(group: PumpHistoryEntryGroup) {
filteredHistoryList.clear() filteredHistoryList.clear()
aapsLogger.debug(LTag.PUMP, "Items on full list: {}", fullHistoryList.size) aapsLogger.debug(LTag.PUMP, "Items on full list: {}", fullHistoryList.size)
@ -208,8 +209,48 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
} }
} }
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
}
// On success set color
val textColor = when (record.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
}
textview.setTextColor(textColor)
}
private fun setType(record: HistoryRecord, typeView: TextView) { private fun setType(record: HistoryRecord, typeView: TextView) {
typeView.text = resourceHelper.gs(record.commandType.resourceId) typeView.text = resourceHelper.gs(record.commandType.resourceId)
// Set some color, include result
setTextViewColor(check_result = true, typeView, record)
} }
private fun setValue(historyEntry: HistoryRecord, valueView: TextView) { private fun setValue(historyEntry: HistoryRecord, valueView: TextView) {
@ -226,12 +267,14 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
resourceHelper.gs(R.string.omnipod_common_history_tbr_value, it.rate, it.duration) resourceHelper.gs(R.string.omnipod_common_history_tbr_value, it.rate, it.duration)
} }
} }
OmnipodCommandType.SET_BOLUS -> { OmnipodCommandType.SET_BOLUS -> {
val bolus = historyEntry.record as BolusRecord val bolus = historyEntry.record as BolusRecord
bolus.let { bolus.let {
resourceHelper.gs(R.string.omnipod_common_history_bolus_value, it.amout) resourceHelper.gs(R.string.omnipod_common_history_bolus_value, it.amout)
} }
} }
OmnipodCommandType.SET_BASAL_PROFILE, OmnipodCommandType.SET_BASAL_PROFILE,
OmnipodCommandType.SET_TIME, OmnipodCommandType.SET_TIME,
OmnipodCommandType.INSERT_CANNULA, OmnipodCommandType.INSERT_CANNULA,
@ -239,9 +282,12 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
val basal = historyEntry.record as BasalValuesRecord val basal = historyEntry.record as BasalValuesRecord
ProfileUtil.getBasalProfilesDisplayable(basal.segments.toTypedArray(), PumpType.OMNIPOD_DASH) ProfileUtil.getBasalProfilesDisplayable(basal.segments.toTypedArray(), PumpType.OMNIPOD_DASH)
} }
else -> else ->
"" ""
} }
// Set some color
setTextViewColor(check_result = false, valueView, historyEntry)
} }
override fun getItemCount(): Int { override fun getItemCount(): Int {
@ -249,6 +295,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
} }
inner class HistoryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { inner class HistoryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val timeView: TextView = itemView.findViewById(R.id.omnipod_history_time) val timeView: TextView = itemView.findViewById(R.id.omnipod_history_time)
val typeView: TextView = itemView.findViewById(R.id.omnipod_history_source) val typeView: TextView = itemView.findViewById(R.id.omnipod_history_source)
val valueView: TextView = itemView.findViewById(R.id.omnipod_history_description) val valueView: TextView = itemView.findViewById(R.id.omnipod_history_description)
@ -270,6 +317,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
} }
companion object { companion object {
private var selectedGroup: PumpHistoryEntryGroup = PumpHistoryEntryGroup.All private var selectedGroup: PumpHistoryEntryGroup = PumpHistoryEntryGroup.All
const val DAYS_TO_DISPLAY = 5 const val DAYS_TO_DISPLAY = 5
} }