Use PodStateManager as a source for displaying info in Omnipod tab (and some other small changes)
This commit is contained in:
parent
c40b64a6ac
commit
0584cbd6af
|
@ -57,8 +57,8 @@ public enum RileyLinkServiceState {
|
|||
}
|
||||
|
||||
|
||||
public static boolean isReady(RileyLinkServiceState serviceState) {
|
||||
return (/* serviceState == RileyLinkReady || */serviceState == PumpConnectorReady);
|
||||
public boolean isReady() {
|
||||
return (this == PumpConnectorReady);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
|||
// PumpInterface - REMOVE
|
||||
|
||||
public boolean isInitialized() {
|
||||
return RileyLinkServiceState.isReady(rileyLinkServiceData.rileyLinkServiceState);
|
||||
return rileyLinkServiceData.rileyLinkServiceState.isReady();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Intent
|
|||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -16,7 +17,6 @@ import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
|||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
||||
|
@ -32,9 +32,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefres
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.Round
|
||||
import info.nightscout.androidaps.utils.LocalAlertUtils
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.WarnColors
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
|
@ -46,6 +45,8 @@ import io.reactivex.disposables.Disposable
|
|||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.android.synthetic.main.omnipod_fragment.*
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.Duration
|
||||
import javax.inject.Inject
|
||||
|
||||
class OmnipodFragment : DaggerFragment() {
|
||||
|
@ -64,6 +65,7 @@ class OmnipodFragment : DaggerFragment() {
|
|||
@Inject lateinit var sp: SP
|
||||
@Inject lateinit var omnipodUtil: OmnipodUtil
|
||||
@Inject lateinit var rileyLinkServiceData: RileyLinkServiceData
|
||||
@Inject lateinit var localAlertUtils: LocalAlertUtils
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
|
@ -187,7 +189,7 @@ class OmnipodFragment : DaggerFragment() {
|
|||
|
||||
private fun displayNotConfiguredDialog() {
|
||||
context?.let {
|
||||
OKDialog.show(it, resourceHelper.gs(R.string.combo_warning),
|
||||
OKDialog.show(it, resourceHelper.gs(R.string.omnipod_warning),
|
||||
resourceHelper.gs(R.string.omnipod_error_operation_not_possible_no_configuration), null)
|
||||
}
|
||||
}
|
||||
|
@ -198,14 +200,9 @@ class OmnipodFragment : DaggerFragment() {
|
|||
loopHandler.removeCallbacks(refreshLoop)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun setDeviceStatus(event: EventOmnipodDeviceStatusChange) {
|
||||
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun setDeviceStatus() {
|
||||
aapsLogger.info(LTag.PUMP, "setDeviceStatus: [pumpStatus={}]", omnipodPumpStatus)
|
||||
aapsLogger.info(LTag.PUMP, "OmnipodFragment.setDeviceStatus")
|
||||
|
||||
val errors = ArrayList<String>();
|
||||
|
||||
|
@ -244,14 +241,12 @@ class OmnipodFragment : DaggerFragment() {
|
|||
} else {
|
||||
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_no_pod_connected)
|
||||
}
|
||||
omnipodPumpStatus.podNumber == null
|
||||
} else {
|
||||
omnipod_pod_address.text = podStateManager.address.toString()
|
||||
omnipod_pod_lot.text = podStateManager.lot.toString()
|
||||
omnipod_pod_tid.text = podStateManager.tid.toString()
|
||||
omnipod_pod_fw_version.text = podStateManager.pmVersion.toString() + " / " + podStateManager.piVersion.toString()
|
||||
omnipod_pod_expiry.text = podStateManager.expiryDateAsString
|
||||
omnipodPumpStatus.podNumber = podStateManager.address.toString()
|
||||
|
||||
val stateText: String
|
||||
|
||||
|
@ -286,103 +281,41 @@ class OmnipodFragment : DaggerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun checkStatusSet(object1: Any?, object2: Any?): Any? {
|
||||
return if (object1 == null) {
|
||||
object2
|
||||
} else {
|
||||
if (object1 != object2) {
|
||||
object2
|
||||
} else
|
||||
object1
|
||||
}
|
||||
}
|
||||
|
||||
// GUI functions
|
||||
fun updateGUI() {
|
||||
val plugin = omnipodPumpPlugin
|
||||
//val omnipodPumpStatus = OmnipodUtil.getPumpStatus()
|
||||
var pumpType = omnipodPumpStatus.pumpType
|
||||
|
||||
if (pumpType == null) {
|
||||
aapsLogger.warn(LTag.PUMP, "PumpType was not set, reseting to Omnipod.")
|
||||
pumpType = PumpType.Insulet_Omnipod;
|
||||
}
|
||||
|
||||
setDeviceStatus()
|
||||
|
||||
if (podStateManager.isPaired) {
|
||||
// last connection
|
||||
// TODO replace with podStateManager.getLastSuccessfulCommunication
|
||||
if (omnipodPumpStatus.lastConnection != 0L) {
|
||||
//val minAgo = DateUtil.minAgo(pumpStatus.lastConnection)
|
||||
val min = (System.currentTimeMillis() - omnipodPumpStatus.lastConnection) / 1000 / 60
|
||||
if (omnipodPumpStatus.lastConnection + 60 * 1000 > System.currentTimeMillis()) {
|
||||
omnipod_lastconnection.setText(R.string.combo_pump_connected_now)
|
||||
//omnipod_lastconnection.setTextColor(Color.WHITE)
|
||||
} else { //if (pumpStatus.lastConnection + 30 * 60 * 1000 < System.currentTimeMillis()) {
|
||||
|
||||
if (min < 60) {
|
||||
omnipod_lastconnection.text = resourceHelper.gs(R.string.minago, min)
|
||||
} else if (min < 1440) {
|
||||
val h = (min / 60).toInt()
|
||||
omnipod_lastconnection.text = (resourceHelper.gq(R.plurals.objective_hours, h, h) + " "
|
||||
+ resourceHelper.gs(R.string.ago))
|
||||
} else {
|
||||
val h = (min / 60).toInt()
|
||||
val d = h / 24
|
||||
// h = h - (d * 24);
|
||||
omnipod_lastconnection.text = (resourceHelper.gq(R.plurals.objective_days, d, d) + " "
|
||||
+ resourceHelper.gs(R.string.ago))
|
||||
}
|
||||
//omnipod_lastconnection.setTextColor(Color.RED)
|
||||
}
|
||||
// } else {
|
||||
// omnipod_lastconnection.text = minAgo
|
||||
// //omnipod_lastconnection.setTextColor(Color.WHITE)
|
||||
// }
|
||||
}
|
||||
if (podStateManager.isSetupCompleted) {
|
||||
updateLastConnection()
|
||||
|
||||
// last bolus
|
||||
// TODO replace with podStateManager.getLastBolus
|
||||
val bolus = omnipodPumpStatus.lastBolusAmount
|
||||
val bolusTime = omnipodPumpStatus.lastBolusTime
|
||||
if (bolus != null && bolusTime != null) {
|
||||
val agoMsc = System.currentTimeMillis() - omnipodPumpStatus.lastBolusTime.time
|
||||
val bolusMinAgo = agoMsc.toDouble() / 60.0 / 1000.0
|
||||
val unit = resourceHelper.gs(R.string.insulin_unit_shortname)
|
||||
val ago: String
|
||||
if (agoMsc < 60 * 1000) {
|
||||
ago = resourceHelper.gs(R.string.combo_pump_connected_now)
|
||||
} else if (bolusMinAgo < 60) {
|
||||
ago = DateUtil.minAgo(resourceHelper, omnipodPumpStatus.lastBolusTime.time)
|
||||
} else {
|
||||
ago = DateUtil.hourAgo(omnipodPumpStatus.lastBolusTime.time, resourceHelper)
|
||||
}
|
||||
omnipod_lastbolus.text = resourceHelper.gs(R.string.omnipod_last_bolus, pumpType.determineCorrectBolusSize(bolus), unit, ago)
|
||||
if (podStateManager.lastBolusStartTime != null && podStateManager.lastBolusAmount != null) {
|
||||
val ago = readableDuration(podStateManager.lastBolusStartTime)
|
||||
omnipod_lastbolus.text = resourceHelper.gs(R.string.omnipod_last_bolus, omnipodPumpPlugin.pumpType.determineCorrectBolusSize(podStateManager.lastBolusAmount), resourceHelper.gs(R.string.insulin_unit_shortname), ago)
|
||||
} else {
|
||||
omnipod_lastbolus.text = ""
|
||||
omnipod_lastbolus.text = "-"
|
||||
}
|
||||
|
||||
// base basal rate
|
||||
omnipod_basabasalrate.text = resourceHelper.gs(R.string.pump_basebasalrate, pumpType.determineCorrectBasalSize(plugin.baseBasalRate))
|
||||
omnipod_basabasalrate.text = resourceHelper.gs(R.string.pump_basebasalrate, omnipodPumpPlugin.pumpType.determineCorrectBasalSize(omnipodPumpPlugin.baseBasalRate))
|
||||
|
||||
omnipod_tempbasal.text = activePlugin.activeTreatments
|
||||
.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() ?: ""
|
||||
|
||||
// reservoir
|
||||
if (Round.isSame(omnipodPumpStatus.reservoirRemainingUnits, 75.0)) {
|
||||
if (podStateManager.reservoirLevel == null) {
|
||||
omnipod_reservoir.text = resourceHelper.gs(R.string.omnipod_reservoir_over50)
|
||||
omnipod_reservoir.setTextColor(Color.WHITE)
|
||||
} else {
|
||||
omnipod_reservoir.text = resourceHelper.gs(R.string.omnipod_reservoir_left, omnipodPumpStatus.reservoirRemainingUnits)
|
||||
omnipod_reservoir.text = resourceHelper.gs(R.string.omnipod_reservoir_left, podStateManager.reservoirLevel)
|
||||
warnColors.setColorInverse(omnipod_reservoir, podStateManager.reservoirLevel, 50.0, 20.0)
|
||||
}
|
||||
warnColors.setColorInverse(omnipod_reservoir, omnipodPumpStatus.reservoirRemainingUnits, 50.0, 20.0)
|
||||
|
||||
} else {
|
||||
omnipod_basabasalrate.text = ""
|
||||
omnipod_reservoir.text = ""
|
||||
omnipod_tempbasal.text = ""
|
||||
omnipod_lastbolus.text = ""
|
||||
omnipod_lastconnection.text = ""
|
||||
updateLastConnection()
|
||||
omnipod_basabasalrate.text = "-"
|
||||
omnipod_reservoir.text = "-"
|
||||
omnipod_tempbasal.text = "-"
|
||||
omnipod_lastbolus.text = "-"
|
||||
omnipod_lastconnection.setTextColor(Color.WHITE)
|
||||
}
|
||||
|
||||
|
@ -393,9 +326,56 @@ class OmnipodFragment : DaggerFragment() {
|
|||
omnipod_refresh.isEnabled = podStateManager.isPaired
|
||||
}
|
||||
|
||||
private fun updateLastConnection() {
|
||||
if (podStateManager.isSetupCompleted && podStateManager.lastSuccessfulCommunication != null) { // Null check for backwards compatibility
|
||||
omnipod_lastconnection.text = readableDuration(podStateManager.lastSuccessfulCommunication)
|
||||
if (omnipodPumpPlugin.isUnreachableAlertTimeoutExceeded(localAlertUtils.pumpUnreachableThreshold())) {
|
||||
omnipod_lastconnection.setTextColor(Color.RED)
|
||||
} else {
|
||||
omnipod_lastconnection.setTextColor(Color.WHITE)
|
||||
}
|
||||
} else {
|
||||
omnipod_lastconnection.setTextColor(Color.WHITE)
|
||||
if (podStateManager.hasState() && podStateManager.lastSuccessfulCommunication != null) {
|
||||
omnipod_lastconnection.text = readableDuration(podStateManager.lastSuccessfulCommunication)
|
||||
} else {
|
||||
omnipod_lastconnection.text = "-"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun readableDuration(dateTime: DateTime): String {
|
||||
val min = Duration(dateTime, DateTime.now()).standardMinutes
|
||||
when {
|
||||
min == 0L -> {
|
||||
return resourceHelper.gs(R.string.omnipod_connected_now)
|
||||
}
|
||||
|
||||
min < 60 -> {
|
||||
return resourceHelper.gs(R.string.minago, min)
|
||||
}
|
||||
|
||||
min < 1440 -> {
|
||||
val h = (min / 60).toInt()
|
||||
return resourceHelper.gq(R.plurals.objective_hours, h, h) + " " + resourceHelper.gs(R.string.ago)
|
||||
}
|
||||
|
||||
else -> {
|
||||
val h = (min / 60).toInt()
|
||||
val d = h / 24
|
||||
return resourceHelper.gq(R.plurals.objective_days, d, d) + " " + resourceHelper.gs(R.string.ago)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateAcknowledgeAlerts() {
|
||||
omnipod_pod_active_alerts_ack.isEnabled = omnipodPumpStatus.ackAlertsAvailable
|
||||
omnipod_pod_active_alerts.text = omnipodPumpStatus.ackAlertsText
|
||||
if (podStateManager.hasState() && podStateManager.hasActiveAlerts()) {
|
||||
omnipod_pod_active_alerts_ack.isEnabled = true
|
||||
omnipod_pod_active_alerts.text = TextUtils.join(System.lineSeparator(), omnipodUtil.getTranslatedActiveAlerts(podStateManager))
|
||||
} else {
|
||||
omnipod_pod_active_alerts_ack.isEnabled = false
|
||||
omnipod_pod_active_alerts.text = "-"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -903,8 +903,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
@NotNull
|
||||
@Override
|
||||
public String serialNumber() {
|
||||
return StringUtils.isNotBlank(omnipodPumpStatus.podNumber) ?
|
||||
omnipodPumpStatus.podNumber : "None";
|
||||
return podStateManager.hasState() ? String.valueOf(podStateManager.getAddress()) : "None";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
|
|
@ -280,9 +280,7 @@ public abstract class PodStateManager {
|
|||
|
||||
public final Duration getScheduleOffset() {
|
||||
DateTime now = getTime();
|
||||
DateTime startOfDay = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(),
|
||||
0, 0, 0, getSafe(() -> podState.getTimeZone()));
|
||||
return new Duration(startOfDay, now);
|
||||
return new Duration(now.withTimeAtStartOfDay(), now);
|
||||
}
|
||||
|
||||
public final BasalSchedule getBasalSchedule() {
|
||||
|
|
|
@ -14,6 +14,7 @@ import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
|||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.defs.PodActionType
|
||||
|
@ -45,6 +46,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
@Inject lateinit var omnipodUtil: OmnipodUtil
|
||||
@Inject lateinit var podStateManager: PodStateManager
|
||||
@Inject lateinit var injector: HasAndroidInjector
|
||||
@Inject lateinit var rileyLinkServiceData: RileyLinkServiceData
|
||||
|
||||
private var initPodChanged = false
|
||||
|
||||
|
@ -152,16 +154,15 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
fun refreshButtons() {
|
||||
initpod_init_pod.isEnabled = !podStateManager.isPaired() ||
|
||||
podStateManager.getSetupProgress().isBefore(SetupProgress.COMPLETED)
|
||||
podStateManager.setupProgress.isBefore(SetupProgress.COMPLETED)
|
||||
|
||||
initpod_remove_pod.isEnabled = podStateManager.hasState() && podStateManager.isPaired
|
||||
initpod_reset_pod.isEnabled = podStateManager.hasState()
|
||||
|
||||
if (omnipodUtil.getDriverState() == OmnipodDriverState.NotInitalized) {
|
||||
// if rileylink is not running we disable all operations
|
||||
if (!rileyLinkServiceData.rileyLinkServiceState.isReady) {
|
||||
// if rileylink is not running we disable all operations that require a RL connection
|
||||
initpod_init_pod.isEnabled = false
|
||||
initpod_remove_pod.isEnabled = false
|
||||
initpod_reset_pod.isEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ public class OmnipodPumpStatus extends PumpStatus {
|
|||
|
||||
public String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
||||
|
||||
public String podNumber;
|
||||
public PodDeviceState podDeviceState = PodDeviceState.NeverContacted;
|
||||
public boolean ackAlertsAvailable = false;
|
||||
public String ackAlertsText = null;
|
||||
|
@ -129,10 +128,7 @@ public class OmnipodPumpStatus extends PumpStatus {
|
|||
", tempBasalAmount=" + tempBasalAmount +
|
||||
", tempBasalLength=" + tempBasalLength +
|
||||
", regexMac='" + regexMac + '\'' +
|
||||
", podNumber='" + podNumber + '\'' +
|
||||
", podDeviceState=" + podDeviceState +
|
||||
", ackAlertsAvailable=" + ackAlertsAvailable +
|
||||
", ackAlertsText='" + ackAlertsText + '\'' +
|
||||
", lastDataTime=" + lastDataTime +
|
||||
", lastConnection=" + lastConnection +
|
||||
", previousConnection=" + previousConnection +
|
||||
|
|
|
@ -496,7 +496,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
}
|
||||
|
||||
podHistory.setSuccess(success);
|
||||
podHistory.setPodSerial(pumpStatus.podNumber);
|
||||
podHistory.setPodSerial(podStateManager.hasState() ? String.valueOf(podStateManager.getAddress()) : "None");
|
||||
|
||||
MainApp.getDbHelper().createOrUpdate(podHistory);
|
||||
|
||||
|
|
|
@ -1,26 +1,16 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.driver.comm;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.Event;
|
||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSet;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSlot;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
|
||||
|
@ -77,30 +67,12 @@ public class AapsPodStateManager extends PodStateManager {
|
|||
@Override
|
||||
protected void notifyPodStateChanged() {
|
||||
if (!hasState()) {
|
||||
omnipodPumpStatus.ackAlertsText = null;
|
||||
omnipodPumpStatus.ackAlertsAvailable = false;
|
||||
omnipodPumpStatus.lastBolusTime = null;
|
||||
omnipodPumpStatus.lastBolusAmount = null;
|
||||
omnipodPumpStatus.reservoirRemainingUnits = 0.0;
|
||||
omnipodPumpStatus.pumpStatusType = PumpStatusType.Suspended;
|
||||
sendEvent(new EventRefreshOverview("Omnipod Pump", false));
|
||||
} else {
|
||||
// Update active alerts
|
||||
if (hasActiveAlerts()) {
|
||||
List<String> alerts = getTranslatedActiveAlerts();
|
||||
String alertsText = TextUtils.join("\n", alerts);
|
||||
|
||||
if (!omnipodPumpStatus.ackAlertsAvailable || !alertsText.equals(omnipodPumpStatus.ackAlertsText)) {
|
||||
omnipodPumpStatus.ackAlertsAvailable = true;
|
||||
omnipodPumpStatus.ackAlertsText = TextUtils.join("\n", alerts);
|
||||
}
|
||||
} else {
|
||||
if (omnipodPumpStatus.ackAlertsAvailable || StringUtils.isNotEmpty(omnipodPumpStatus.ackAlertsText)) {
|
||||
omnipodPumpStatus.ackAlertsText = null;
|
||||
omnipodPumpStatus.ackAlertsAvailable = false;
|
||||
}
|
||||
}
|
||||
|
||||
Date lastBolusStartTime = getLastBolusStartTime() == null ? null : getLastBolusStartTime().toDate();
|
||||
Double lastBolusAmount = getLastBolusAmount();
|
||||
|
||||
|
@ -124,43 +96,6 @@ public class AapsPodStateManager extends PodStateManager {
|
|||
sendEvent(new EventOmnipodPumpValuesChanged());
|
||||
}
|
||||
|
||||
private List<String> getTranslatedActiveAlerts() {
|
||||
List<String> translatedAlerts = new ArrayList<>();
|
||||
AlertSet activeAlerts = getActiveAlerts();
|
||||
|
||||
for (AlertSlot alertSlot : activeAlerts.getAlertSlots()) {
|
||||
translatedAlerts.add(translateAlertType(getConfiguredAlertType(alertSlot)));
|
||||
}
|
||||
return translatedAlerts;
|
||||
}
|
||||
|
||||
|
||||
private String translateAlertType(AlertType alertType) {
|
||||
if (alertType == null) {
|
||||
return getStringResource(R.string.omnipod_alert_unknown_alert);
|
||||
}
|
||||
switch (alertType) {
|
||||
case FINISH_PAIRING_REMINDER:
|
||||
return getStringResource(R.string.omnipod_alert_finish_pairing_reminder);
|
||||
case FINISH_SETUP_REMINDER:
|
||||
return getStringResource(R.string.omnipod_alert_finish_setup_reminder_reminder);
|
||||
case EXPIRATION_ALERT:
|
||||
return getStringResource(R.string.omnipod_alert_expiration);
|
||||
case EXPIRATION_ADVISORY_ALERT:
|
||||
return getStringResource(R.string.omnipod_alert_expiration_advisory);
|
||||
case SHUTDOWN_IMMINENT_ALARM:
|
||||
return getStringResource(R.string.omnipod_alert_shutdown_imminent);
|
||||
case LOW_RESERVOIR_ALERT:
|
||||
return getStringResource(R.string.omnipod_alert_low_reservoir);
|
||||
default:
|
||||
return alertType.name();
|
||||
}
|
||||
}
|
||||
|
||||
private String getStringResource(int id, Object... args) {
|
||||
return resourceHelper.gs(id, args);
|
||||
}
|
||||
|
||||
private static boolean isReservoirStatusUpToDate(OmnipodPumpStatus pumpStatus, Double unitsRemaining) {
|
||||
double expectedUnitsRemaining = unitsRemaining == null ? 75.0 : unitsRemaining;
|
||||
return Math.abs(expectedUnitsRemaining - pumpStatus.reservoirRemainingUnits) < 0.000001;
|
||||
|
|
|
@ -156,7 +156,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
// PumpInterface - REMOVE
|
||||
|
||||
public boolean isInitialized() {
|
||||
return RileyLinkServiceState.isReady(rileyLinkServiceData.rileyLinkServiceState);
|
||||
return rileyLinkServiceData.rileyLinkServiceState.isReady();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@ import org.joda.time.DateTime;
|
|||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.format.ISODateTimeFormat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
|
@ -23,6 +26,9 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
|||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSet;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSlot;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPodType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
|
||||
|
@ -31,6 +37,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange;
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
/**
|
||||
|
@ -43,6 +50,7 @@ public class OmnipodUtil {
|
|||
private final RxBusWrapper rxBus;
|
||||
private final RileyLinkUtil rileyLinkUtil;
|
||||
private final OmnipodPumpStatus omnipodPumpStatus;
|
||||
private final ResourceHelper resourceHelper;
|
||||
private final ActivePluginProvider activePlugins;
|
||||
private final SP sp;
|
||||
|
||||
|
@ -58,8 +66,8 @@ public class OmnipodUtil {
|
|||
RxBusWrapper rxBus,
|
||||
RileyLinkUtil rileyLinkUtil,
|
||||
OmnipodPumpStatus omnipodPumpStatus,
|
||||
PodStateManager podStateManager,
|
||||
SP sp,
|
||||
ResourceHelper resourceHelper,
|
||||
ActivePluginProvider activePlugins
|
||||
) {
|
||||
this.aapsLogger = aapsLogger;
|
||||
|
@ -67,6 +75,7 @@ public class OmnipodUtil {
|
|||
this.rileyLinkUtil = rileyLinkUtil;
|
||||
this.omnipodPumpStatus = omnipodPumpStatus;
|
||||
this.sp = sp;
|
||||
this.resourceHelper = resourceHelper;
|
||||
this.activePlugins = activePlugins;
|
||||
}
|
||||
|
||||
|
@ -174,4 +183,36 @@ public class OmnipodUtil {
|
|||
public SP getSp() {
|
||||
return this.sp;
|
||||
}
|
||||
|
||||
public List<String> getTranslatedActiveAlerts(PodStateManager podStateManager) {
|
||||
List<String> translatedAlerts = new ArrayList<>();
|
||||
AlertSet activeAlerts = podStateManager.getActiveAlerts();
|
||||
|
||||
for (AlertSlot alertSlot : activeAlerts.getAlertSlots()) {
|
||||
translatedAlerts.add(translateAlertType(podStateManager.getConfiguredAlertType(alertSlot)));
|
||||
}
|
||||
return translatedAlerts;
|
||||
}
|
||||
|
||||
private String translateAlertType(AlertType alertType) {
|
||||
if (alertType == null) {
|
||||
return resourceHelper.gs(R.string.omnipod_alert_unknown_alert);
|
||||
}
|
||||
switch (alertType) {
|
||||
case FINISH_PAIRING_REMINDER:
|
||||
return resourceHelper.gs(R.string.omnipod_alert_finish_pairing_reminder);
|
||||
case FINISH_SETUP_REMINDER:
|
||||
return resourceHelper.gs(R.string.omnipod_alert_finish_setup_reminder_reminder);
|
||||
case EXPIRATION_ALERT:
|
||||
return resourceHelper.gs(R.string.omnipod_alert_expiration);
|
||||
case EXPIRATION_ADVISORY_ALERT:
|
||||
return resourceHelper.gs(R.string.omnipod_alert_expiration_advisory);
|
||||
case SHUTDOWN_IMMINENT_ALARM:
|
||||
return resourceHelper.gs(R.string.omnipod_alert_shutdown_imminent);
|
||||
case LOW_RESERVOIR_ALERT:
|
||||
return resourceHelper.gs(R.string.omnipod_alert_low_reservoir);
|
||||
default:
|
||||
return alertType.name();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class LocalAlertUtils @Inject constructor(
|
|||
return T.mins(sp.getInt(resourceHelper.gs(R.string.key_missed_bg_readings_threshold), 30).toLong()).msecs()
|
||||
}
|
||||
|
||||
private fun pumpUnreachableThreshold(): Long {
|
||||
fun pumpUnreachableThreshold(): Long {
|
||||
return T.mins(sp.getInt(resourceHelper.gs(R.string.key_pump_unreachable_threshold), 30).toLong()).msecs()
|
||||
}
|
||||
|
||||
|
|
|
@ -1610,6 +1610,7 @@
|
|||
|
||||
|
||||
<!-- MDT Errors -->
|
||||
<string name="omnipod_warning">Warning</string>
|
||||
<string name="medtronic_errors">Errors</string>
|
||||
<string name="medtronic_error_serial_not_set">Serial # not set.</string>
|
||||
<string name="medtronic_error_serial_invalid">Serial # invalid.</string>
|
||||
|
@ -1857,6 +1858,7 @@
|
|||
<string name="omnipod_config_timechange_enabled">DST/Timezone Detection Enabled</string>
|
||||
|
||||
<!-- Omnipod - Fragment -->
|
||||
<string name="omnipod_connected_now">Now</string>
|
||||
<string name="omnipod_pod_mgmt">Pod Mgmt</string>
|
||||
<string name="omnipod_pod_status">Pod Status</string>
|
||||
<string name="omnipod_reservoir_left">%1$.2f U left</string>
|
||||
|
@ -1943,7 +1945,7 @@
|
|||
<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_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 very close to the RileyLink 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 keep the Pod and the RileyLink a few inches apart at this time.</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