Read TBR in Omnipod tab from PodStateManager instead of TreatmentsPlugin, fix crash and some small improvements
This commit is contained in:
parent
0dac395b1a
commit
75fa81f945
|
@ -52,9 +52,7 @@ public class CancelDeliveryAction implements OmnipodAction<StatusResponse> {
|
|||
|
||||
StatusResponse statusResponse = communicationService.exchangeMessages(StatusResponse.class, podStateManager,
|
||||
new OmnipodMessage(podStateManager.getAddress(), messageBlocks, podStateManager.getMessageNumber()));
|
||||
if (deliveryTypes.contains(DeliveryType.TEMP_BASAL)) {
|
||||
podStateManager.setLastTempBasal(null, null, null);
|
||||
}
|
||||
|
||||
return statusResponse;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,6 +404,11 @@ public abstract class PodStateManager {
|
|||
podState.setReservoirLevel(statusResponse.getReservoirLevel());
|
||||
podState.setTotalTicksDelivered(statusResponse.getTicksDelivered());
|
||||
podState.setPodProgressStatus(statusResponse.getPodProgressStatus());
|
||||
if (!statusResponse.getDeliveryStatus().isTbrRunning()) {
|
||||
podState.setLastTempBasalStartTime(null);
|
||||
podState.setLastTempBasalAmount(null);
|
||||
podState.setLastTempBasalDuration(null);
|
||||
}
|
||||
podState.setLastUpdatedFromResponse(DateTime.now());
|
||||
});
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ class OmnipodFragment : DaggerFragment() {
|
|||
omnipod_pod_tid.text = podStateManager.tid.toString()
|
||||
omnipod_pod_firmware_version.text = resourceHelper.gs(R.string.omnipod_pod_firmware_version_value, podStateManager.pmVersion.toString(), podStateManager.piVersion.toString())
|
||||
val expiresAt = podStateManager.expiresAt
|
||||
omnipod_pod_expiry.text = if (expiresAt == null) "???" else dateUtil.dateAndTimeString(expiresAt.toDate())
|
||||
omnipod_pod_expiry.text = if (expiresAt == null) "-" else dateUtil.dateAndTimeString(expiresAt.toDate())
|
||||
|
||||
if (podStateManager.hasFaultEvent()) {
|
||||
val faultEventCode = podStateManager.faultEvent.faultEventCode
|
||||
|
@ -254,13 +254,30 @@ class OmnipodFragment : DaggerFragment() {
|
|||
val now = DateTime.now()
|
||||
|
||||
// base basal rate
|
||||
omnipod_base_basal_rate.text = resourceHelper.gs(R.string.pump_basebasalrate, omnipodPumpPlugin.model().determineCorrectBasalSize(podStateManager.basalSchedule.rateAt(Duration(now.withTimeAtStartOfDay(), now))))
|
||||
omnipod_base_basal_rate.text = if (podStateManager.isPodActivationCompleted) {
|
||||
resourceHelper.gs(R.string.pump_basebasalrate, omnipodPumpPlugin.model().determineCorrectBasalSize(podStateManager.basalSchedule.rateAt(Duration(now.withTimeAtStartOfDay(), now))))
|
||||
} else {
|
||||
"-"
|
||||
}
|
||||
|
||||
omnipod_tempbasal.text = if (aapsOmnipodManager.hasSuspendedFakeTbr()) "-" else activePlugin.activeTreatments
|
||||
.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() ?: "-"
|
||||
// Temp basal
|
||||
val lastTempBasalStartTime = podStateManager.lastTempBasalStartTime;
|
||||
val lastTempBasalAmount = podStateManager.lastTempBasalAmount
|
||||
val lastTempBasalDuration = podStateManager.lastTempBasalDuration;
|
||||
if (lastTempBasalStartTime != null && lastTempBasalAmount != null && lastTempBasalDuration != null) {
|
||||
val endTime = lastTempBasalStartTime.plus(lastTempBasalDuration);
|
||||
val minutesRunning = Duration(lastTempBasalStartTime, now).standardMinutes
|
||||
omnipod_tempbasal.text = if (endTime.isAfter(now)) {
|
||||
resourceHelper.gs(R.string.omnipod_temp_basal, lastTempBasalAmount, dateUtil.timeString(lastTempBasalStartTime.millis), minutesRunning, lastTempBasalDuration.standardMinutes)
|
||||
} else {
|
||||
"-"
|
||||
}
|
||||
} else {
|
||||
omnipod_tempbasal.text = "-"
|
||||
}
|
||||
|
||||
// total delivered
|
||||
omnipod_total_delivered.text = if (podStateManager.isPodActivationCompleted && podStateManager.totalInsulinDelivered != null) { // Null check for backwards compatibility
|
||||
omnipod_total_delivered.text = if (podStateManager.isPodActivationCompleted && podStateManager.totalInsulinDelivered != null) {
|
||||
resourceHelper.gs(R.string.omnipod_total_delivered, podStateManager.totalInsulinDelivered - OmnipodConstants.POD_SETUP_UNITS);
|
||||
} else {
|
||||
"-"
|
||||
|
@ -288,7 +305,7 @@ class OmnipodFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
private fun updateLastConnection() {
|
||||
if (podStateManager.isPodInitialized && podStateManager.lastSuccessfulCommunication != null) { // Null check for backwards compatibility
|
||||
if (podStateManager.isPodInitialized && podStateManager.lastSuccessfulCommunication != null) {
|
||||
omnipod_lastconnection.text = readableDuration(podStateManager.lastSuccessfulCommunication)
|
||||
omnipod_lastconnection.setTextColor(Color.WHITE)
|
||||
/*
|
||||
|
@ -388,7 +405,7 @@ class OmnipodFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
private fun updateAcknowledgeAlertsButton() {
|
||||
if (podStateManager.isPodInitialized && podStateManager.hasActiveAlerts() && !podStateManager.isPodDead) {
|
||||
if (podStateManager.isPodActivationCompleted && podStateManager.hasActiveAlerts() && !podStateManager.isPodDead) {
|
||||
omnipod_button_acknowledge_active_alerts.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||
} else {
|
||||
omnipod_button_acknowledge_active_alerts.isEnabled = false
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
<string name="omnipod_pod_active_alerts">Active Pod alerts</string>
|
||||
<string name="omnipod_acknowledge_active_alerts_short">Ack alerts</string>
|
||||
<string name="omnipod_last_bolus" translatable="false">%1$.2f %2$s (%3$s)</string>
|
||||
<string name="omnipod_temp_basal" translatable="false">%1$.2fU/h @%2$s (%3$d/%4$d minutes)</string>
|
||||
|
||||
|
||||
<!-- Omnipod - Dialogs -->
|
||||
|
@ -103,9 +104,9 @@
|
|||
<string name="omnipod_cmd_discard_pod_desc">If you press <b>OK</b>, the Pod state will be forcibly reset and you will not be able to communicate with the Pod anymore. Do this only if you can not communicate with the Pod anymore. If you can still communicate with the Pod, please use the <b>Deactivate Pod</b> option.\n\nIf you wish to proceed, please make sure to also remove the Pod from your body.</string>
|
||||
<string name="omnipod_cmd_pod_history_na">Pod History not available at the moment.</string>
|
||||
<string name="omnipod_init_pod_wizard_step1_title">Fill the Pod</string>
|
||||
<string name="omnipod_init_pod_wizard_step1_desc">\nFill the new Pod with enough insulin for 3 days.\n\nListen for two beeps from the Pod during the filling process. These indicate that the minimum amount of 85U has been inserted. Be sure to completely empty the fill syringe, even after hearing the two beeps.\n\nAfter filling the Pod, please press <b>Next</b>.\n\n<b>Note:</b> do not remove the Pod\'s needle cap at this time.</string>
|
||||
<string name="omnipod_init_pod_wizard_step1_desc">\nFill the new Pod with enough insulin for 3 days.\n\nListen for two beeps from the Pod during the filling process. These indicate that the minimum amount of 85U has been inserted. Be sure to completely empty the fill syringe, even after hearing the two beeps.\n\nAfter filling the Pod, please press <b>Next</b>.\n\n<b>Note:</b> do not remove the Pod\'s needle cap at this time.\n<b>Note:</b> please place the RileyLink in an upright position and place the Pod a few inches away.</string>
|
||||
<string name="omnipod_init_pod_wizard_step2_title">Priming</string>
|
||||
<string name="omnipod_init_pod_wizard_step2_action_header">Trying to pair with the new Pod and prime it.\n\nWhen all items are checked, you can press <b>Next</b>.\n\n<b>Note:</b> please keep the Pod and the RileyLink a few inches apart at this time.</string>
|
||||
<string name="omnipod_init_pod_wizard_step2_action_header">Trying to pair with the new Pod and prime it.\n\nWhen all items are checked, you can press <b>Next</b>.\n\n<b>Note:</b> please place the RileyLink in an upright position and place the Pod a few inches away it.</string>
|
||||
<string name="omnipod_init_pod_wizard_step3_title">Attach the Pod</string>
|
||||
<string name="omnipod_init_pod_wizard_step3_desc">\nPrepare the infusion site. Remove the Pod\'s needle cap and adhesive backing and attach the Pod to the infusion site.\n\nIf the cannula sticks out, please press <b>Cancel</b> and discard your Pod.\n\nPress <b>Next</b> to insert the cannula and begin basal delivery.</string>
|
||||
<string name="omnipod_init_pod_wizard_step4_title">Inserting cannula</string>
|
||||
|
|
Loading…
Reference in a new issue