- Allow resetting pairingParameters in PodStateManager if the setup state is ADDRESS_ASSIGNED
- Improve pod status screen - Improve event dispatching in AapsPodStateManager (send less events) - Add more FIXMEs and TODOs
This commit is contained in:
parent
a0ca8cf9cc
commit
341474295f
11 changed files with 73 additions and 79 deletions
|
@ -45,6 +45,7 @@ import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import kotlinx.android.synthetic.main.omnipod_fragment.*
|
import kotlinx.android.synthetic.main.omnipod_fragment.*
|
||||||
|
import org.apache.commons.lang3.StringUtils
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class OmnipodFragment : DaggerFragment() {
|
class OmnipodFragment : DaggerFragment() {
|
||||||
|
@ -87,11 +88,6 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
omnipod_rl_status.text = resourceHelper.gs(RileyLinkServiceState.NotStarted.getResourceId(RileyLinkTargetDevice.Omnipod))
|
|
||||||
|
|
||||||
omnipod_pod_status.setTextColor(Color.WHITE)
|
|
||||||
omnipod_pod_status.text = "{fa-bed}"
|
|
||||||
|
|
||||||
omnipod_pod_mgmt.setOnClickListener {
|
omnipod_pod_mgmt.setOnClickListener {
|
||||||
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
|
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
|
||||||
startActivity(Intent(context, PodManagementActivity::class.java))
|
startActivity(Intent(context, PodManagementActivity::class.java))
|
||||||
|
@ -147,10 +143,6 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_lastconnection.setTextColor(Color.WHITE)
|
omnipod_lastconnection.setTextColor(Color.WHITE)
|
||||||
|
|
||||||
setVisibilityOfPodDebugButton()
|
|
||||||
|
|
||||||
updateGUI()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@ -181,6 +173,7 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
.subscribe({
|
.subscribe({
|
||||||
setVisibilityOfPodDebugButton()
|
setVisibilityOfPodDebugButton()
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, { fabricPrivacy.logException(it) })
|
||||||
|
updateGUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setVisibilityOfPodDebugButton() {
|
fun setVisibilityOfPodDebugButton() {
|
||||||
|
@ -212,12 +205,10 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
private fun setDeviceStatus() {
|
private fun setDeviceStatus() {
|
||||||
//val omnipodPumpStatus: OmnipodPumpStatus = OmnipodUtil.getPumpStatus()
|
|
||||||
// omnipodPumpStatus.rileyLinkServiceState = checkStatusSet(omnipodPumpStatus.rileyLinkServiceState,
|
|
||||||
// RileyLinkUtil.getServiceState()) as RileyLinkServiceState?
|
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMP, "setDeviceStatus: [pumpStatus={}]", omnipodPumpStatus)
|
aapsLogger.info(LTag.PUMP, "setDeviceStatus: [pumpStatus={}]", omnipodPumpStatus)
|
||||||
|
|
||||||
|
val errors = ArrayList<String>();
|
||||||
|
|
||||||
val rileyLinkServiceState = rileyLinkServiceData.rileyLinkServiceState
|
val rileyLinkServiceState = rileyLinkServiceData.rileyLinkServiceState
|
||||||
|
|
||||||
val resourceId = rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.Omnipod)
|
val resourceId = rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.Omnipod)
|
||||||
|
@ -228,22 +219,18 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
|
rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
|
||||||
rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
|
rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
|
||||||
rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
||||||
rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump))
|
rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.Omnipod))
|
||||||
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
||||||
}
|
}
|
||||||
omnipod_rl_status.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE)
|
omnipod_rl_status.setTextColor(if (rileyLinkServiceState.isError || rileyLinkError != null) Color.RED else Color.WHITE)
|
||||||
|
|
||||||
// omnipodPumpStatus.rileyLinkError = checkStatusSet(omnipodPumpStatus.rileyLinkError,
|
if (rileyLinkError != null) {
|
||||||
// RileyLinkUtil.getError()) as RileyLinkError?
|
errors.add(resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.Omnipod)))
|
||||||
|
}
|
||||||
omnipod_errors.text =
|
val rileyLinkErrorInfo = omnipodPumpStatus.errorInfo
|
||||||
rileyLinkError?.let {
|
if (rileyLinkErrorInfo != null) {
|
||||||
resourceHelper.gs(it.getResourceId(RileyLinkTargetDevice.Omnipod))
|
errors.add(rileyLinkErrorInfo)
|
||||||
} ?: "-"
|
}
|
||||||
|
|
||||||
val driverState = omnipodUtil.getDriverState();
|
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMP, "getDriverState: [driverState={}]", driverState)
|
|
||||||
|
|
||||||
if (!podStateManager.hasState() || !podStateManager.isPaired) {
|
if (!podStateManager.hasState() || !podStateManager.isPaired) {
|
||||||
if (podStateManager.hasState()) {
|
if (podStateManager.hasState()) {
|
||||||
|
@ -262,7 +249,6 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
omnipodPumpStatus.podNumber == null
|
omnipodPumpStatus.podNumber == null
|
||||||
} else {
|
} else {
|
||||||
omnipodPumpStatus.podLotNumber = "" + podStateManager.lot
|
|
||||||
omnipod_pod_address.text = podStateManager.address.toString()
|
omnipod_pod_address.text = podStateManager.address.toString()
|
||||||
omnipod_pod_lot.text = podStateManager.lot.toString()
|
omnipod_pod_lot.text = podStateManager.lot.toString()
|
||||||
omnipod_pod_tid.text = podStateManager.tid.toString()
|
omnipod_pod_tid.text = podStateManager.tid.toString()
|
||||||
|
@ -270,24 +256,30 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
omnipod_pod_expiry.text = podStateManager.expiryDateAsString
|
omnipod_pod_expiry.text = podStateManager.expiryDateAsString
|
||||||
omnipodPumpStatus.podNumber = podStateManager.address.toString()
|
omnipodPumpStatus.podNumber = podStateManager.address.toString()
|
||||||
|
|
||||||
var stateText: String?
|
val stateText: String
|
||||||
|
|
||||||
if (podStateManager.hasFaultEvent()) {
|
when {
|
||||||
val faultEventCode = podStateManager.faultEvent.faultEventCode
|
podStateManager.hasFaultEvent() -> {
|
||||||
stateText = resourceHelper.gs(R.string.omnipod_pod_status_pod_fault) + " (" + faultEventCode.value + " " + faultEventCode.name + ")"
|
val faultEventCode = podStateManager.faultEvent.faultEventCode
|
||||||
} else if (podStateManager.isSetupCompleted) {
|
stateText = resourceHelper.gs(R.string.omnipod_pod_status_pod_fault)
|
||||||
stateText = resourceHelper.gs(R.string.omnipod_pod_status_pod_running)
|
errors.add(resourceHelper.gs(R.string.omnipod_pod_status_pod_fault_description, faultEventCode.value, faultEventCode.name))
|
||||||
if (podStateManager.lastDeliveryStatus != null) {
|
}
|
||||||
stateText += " (last delivery status: " + podStateManager.lastDeliveryStatus.name + ")"
|
|
||||||
|
podStateManager.isSetupCompleted -> {
|
||||||
|
stateText = resourceHelper.gs(R.string.omnipod_pod_status_pod_running, if (podStateManager.lastDeliveryStatus == null) null else podStateManager.lastDeliveryStatus.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
stateText = resourceHelper.gs(R.string.omnipod_pod_setup_in_progress, podStateManager.setupProgress.name)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
stateText = resourceHelper.gs(R.string.omnipod_pod_setup_in_progress)
|
|
||||||
stateText += " (setup progress: " + podStateManager.setupProgress.name + ")"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_pod_status.text = stateText
|
omnipod_pod_status.text = stateText
|
||||||
}
|
}
|
||||||
|
|
||||||
|
omnipod_pod_status.setTextColor(if (podStateManager.hasFaultEvent()) Color.RED else Color.WHITE)
|
||||||
|
omnipod_errors.text = if (errors.size == 0) "-" else StringUtils.join(errors, System.lineSeparator())
|
||||||
|
|
||||||
val status = commandQueue.spannedStatus()
|
val status = commandQueue.spannedStatus()
|
||||||
if (status.toString() == "") {
|
if (status.toString() == "") {
|
||||||
omnipod_queue.visibility = View.GONE
|
omnipod_queue.visibility = View.GONE
|
||||||
|
@ -397,10 +389,10 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
omnipod_lastconnection.setTextColor(Color.WHITE)
|
omnipod_lastconnection.setTextColor(Color.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_errors.text = omnipodPumpStatus.errorInfo
|
|
||||||
|
|
||||||
updateAcknowledgeAlerts()
|
updateAcknowledgeAlerts()
|
||||||
|
|
||||||
|
setVisibilityOfPodDebugButton()
|
||||||
|
|
||||||
omnipod_refresh.isEnabled = podStateManager.isPaired
|
omnipod_refresh.isEnabled = podStateManager.isPaired
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -605,6 +605,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FIXME do we actually need this? If a user presses refresh during an action,
|
||||||
|
// I suppose the GetStatusCommand would just be queued?
|
||||||
private void setRefreshButtonEnabled(boolean enabled) {
|
private void setRefreshButtonEnabled(boolean enabled) {
|
||||||
rxBus.send(new EventOmnipodRefreshButtonState(enabled));
|
rxBus.send(new EventOmnipodRefreshButtonState(enabled));
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@ import com.google.gson.JsonDeserializer;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
import com.google.gson.JsonSerializer;
|
import com.google.gson.JsonSerializer;
|
||||||
|
|
||||||
import net.danlew.android.joda.JodaTimeAndroid;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
|
@ -79,7 +77,7 @@ public abstract class PodStateManager {
|
||||||
if (!hasState()) {
|
if (!hasState()) {
|
||||||
throw new IllegalStateException("Cannot set pairing parameters: podState is null");
|
throw new IllegalStateException("Cannot set pairing parameters: podState is null");
|
||||||
}
|
}
|
||||||
if (isPaired()) {
|
if (isPaired() && getSetupProgress().isAfter(SetupProgress.ADDRESS_ASSIGNED)) {
|
||||||
throw new IllegalStateException("Cannot set pairing parameters: pairing parameters have already been set");
|
throw new IllegalStateException("Cannot set pairing parameters: pairing parameters have already been set");
|
||||||
}
|
}
|
||||||
if (piVersion == null) {
|
if (piVersion == null) {
|
||||||
|
@ -125,11 +123,11 @@ public abstract class PodStateManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void increaseMessageNumber() {
|
public final void increaseMessageNumber() {
|
||||||
setAndStore(() -> podState.setMessageNumber((podState.getMessageNumber() + 1) & 0b1111));
|
setAndStore(() -> podState.setMessageNumber((podState.getMessageNumber() + 1) & 0b1111), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void increasePacketNumber() {
|
public final void increasePacketNumber() {
|
||||||
setAndStore(() -> podState.setPacketNumber((podState.getPacketNumber() + 1) & 0b11111));
|
setAndStore(() -> podState.setPacketNumber((podState.getPacketNumber() + 1) & 0b11111), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final synchronized void resyncNonce(int syncWord, int sentNonce, int sequenceNumber) {
|
public final synchronized void resyncNonce(int syncWord, int sentNonce, int sequenceNumber) {
|
||||||
|
@ -144,7 +142,7 @@ public abstract class PodStateManager {
|
||||||
int seed = ((sum & 0xFFFF) ^ syncWord);
|
int seed = ((sum & 0xFFFF) ^ syncWord);
|
||||||
NonceState nonceState = new NonceState(podState.getLot(), podState.getTid(), (byte) (seed & 0xFF));
|
NonceState nonceState = new NonceState(podState.getLot(), podState.getTid(), (byte) (seed & 0xFF));
|
||||||
|
|
||||||
setAndStore(() -> podState.setNonceState(nonceState));
|
setAndStore(() -> podState.setNonceState(nonceState), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final synchronized int getCurrentNonce() {
|
public final synchronized int getCurrentNonce() {
|
||||||
|
@ -158,7 +156,7 @@ public abstract class PodStateManager {
|
||||||
if (!isPaired()) {
|
if (!isPaired()) {
|
||||||
throw new IllegalStateException("Cannot advance to next nonce: Pod is not paired yet");
|
throw new IllegalStateException("Cannot advance to next nonce: Pod is not paired yet");
|
||||||
}
|
}
|
||||||
setAndStore(() -> podState.getNonceState().advanceToNextNonce());
|
setAndStore(() -> podState.getNonceState().advanceToNextNonce(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final DateTime getLastSuccessfulCommunication() {
|
public final DateTime getLastSuccessfulCommunication() {
|
||||||
|
@ -178,7 +176,7 @@ public abstract class PodStateManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean hasFaultEvent() {
|
public final boolean hasFaultEvent() {
|
||||||
return getSafe(() -> podState.getFaultEvent()) != null;
|
return podState != null && podState.getFaultEvent() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final PodInfoFaultEvent getFaultEvent() {
|
public final PodInfoFaultEvent getFaultEvent() {
|
||||||
|
@ -202,6 +200,9 @@ public abstract class PodStateManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean hasActiveAlerts() {
|
public final boolean hasActiveAlerts() {
|
||||||
|
if (podState == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
AlertSet activeAlerts = podState.getActiveAlerts();
|
AlertSet activeAlerts = podState.getActiveAlerts();
|
||||||
return activeAlerts != null && activeAlerts.size() > 0;
|
return activeAlerts != null && activeAlerts.size() > 0;
|
||||||
}
|
}
|
||||||
|
@ -358,12 +359,18 @@ public abstract class PodStateManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAndStore(Runnable runnable) {
|
private void setAndStore(Runnable runnable) {
|
||||||
|
setAndStore(runnable, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAndStore(Runnable runnable, boolean notifyPodStateChanged) {
|
||||||
if (!hasState()) {
|
if (!hasState()) {
|
||||||
throw new IllegalStateException("Cannot mutate PodState: podState is null");
|
throw new IllegalStateException("Cannot mutate PodState: podState is null");
|
||||||
}
|
}
|
||||||
runnable.run();
|
runnable.run();
|
||||||
storePodState();
|
storePodState();
|
||||||
notifyPodStateChanged();
|
if (notifyPodStateChanged) {
|
||||||
|
notifyPodStateChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storePodState() {
|
private void storePodState() {
|
||||||
|
|
|
@ -11,8 +11,6 @@ import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
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.RileyLinkUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
|
|
||||||
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.defs.RileyLinkTargetDevice;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
|
||||||
|
@ -27,13 +25,14 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OmnipodPumpStatus extends PumpStatus {
|
public class OmnipodPumpStatus extends PumpStatus {
|
||||||
// TODO remove all fields that can also be obtained via PodStateManager
|
// TODO remove all fields that can also be obtained via PodStateManager
|
||||||
|
// We can probably get rid of this class altogether
|
||||||
|
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final RileyLinkUtil rileyLinkUtil;
|
private final RileyLinkUtil rileyLinkUtil;
|
||||||
private final RxBusWrapper rxBus;
|
private final RxBusWrapper rxBus;
|
||||||
|
|
||||||
public String errorDescription = null;
|
public String rileyLinkErrorDescription = null;
|
||||||
public String rileyLinkAddress = null;
|
public String rileyLinkAddress = null;
|
||||||
public boolean inPreInit = true;
|
public boolean inPreInit = true;
|
||||||
|
|
||||||
|
@ -58,7 +57,6 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
public boolean beepSMBEnabled = true;
|
public boolean beepSMBEnabled = true;
|
||||||
public boolean beepTBREnabled = true;
|
public boolean beepTBREnabled = true;
|
||||||
public boolean podDebuggingOptionsEnabled = false;
|
public boolean podDebuggingOptionsEnabled = false;
|
||||||
public String podLotNumber = "???";
|
|
||||||
public boolean timeChangeEventEnabled = true;
|
public boolean timeChangeEventEnabled = true;
|
||||||
|
|
||||||
public OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
|
public OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
|
||||||
|
@ -77,7 +75,6 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
initSettings();
|
initSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initSettings() {
|
public void initSettings() {
|
||||||
this.activeProfileName = "";
|
this.activeProfileName = "";
|
||||||
|
@ -87,11 +84,10 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
this.pumpType = PumpType.Insulet_Omnipod;
|
this.pumpType = PumpType.Insulet_Omnipod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For Omnipod, this method only returns a RileyLink error description
|
||||||
|
@Override
|
||||||
public String getErrorInfo() {
|
public String getErrorInfo() {
|
||||||
//verifyConfiguration();
|
return this.rileyLinkErrorDescription;
|
||||||
|
|
||||||
return (this.errorDescription == null) ? "-" : this.errorDescription;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,7 +120,7 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "OmnipodPumpStatus{" +
|
return "OmnipodPumpStatus{" +
|
||||||
"errorDescription='" + errorDescription + '\'' +
|
"rileyLinkErrorDescription='" + rileyLinkErrorDescription + '\'' +
|
||||||
", rileyLinkAddress='" + rileyLinkAddress + '\'' +
|
", rileyLinkAddress='" + rileyLinkAddress + '\'' +
|
||||||
", inPreInit=" + inPreInit +
|
", inPreInit=" + inPreInit +
|
||||||
", currentBasal=" + currentBasal +
|
", currentBasal=" + currentBasal +
|
||||||
|
|
|
@ -23,8 +23,6 @@ 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.AlertType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
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.driver.OmnipodPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodAcknowledgeAlertsChanged;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
|
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
@ -85,8 +83,6 @@ public class AapsPodStateManager extends PodStateManager {
|
||||||
omnipodPumpStatus.lastBolusAmount = null;
|
omnipodPumpStatus.lastBolusAmount = null;
|
||||||
omnipodPumpStatus.reservoirRemainingUnits = 0.0;
|
omnipodPumpStatus.reservoirRemainingUnits = 0.0;
|
||||||
omnipodPumpStatus.pumpStatusType = PumpStatusType.Suspended;
|
omnipodPumpStatus.pumpStatusType = PumpStatusType.Suspended;
|
||||||
sendEvent(new EventOmnipodAcknowledgeAlertsChanged());
|
|
||||||
sendEvent(new EventOmnipodPumpValuesChanged());
|
|
||||||
sendEvent(new EventRefreshOverview("Omnipod Pump", false));
|
sendEvent(new EventRefreshOverview("Omnipod Pump", false));
|
||||||
} else {
|
} else {
|
||||||
// Update active alerts
|
// Update active alerts
|
||||||
|
@ -97,14 +93,11 @@ public class AapsPodStateManager extends PodStateManager {
|
||||||
if (!omnipodPumpStatus.ackAlertsAvailable || !alertsText.equals(omnipodPumpStatus.ackAlertsText)) {
|
if (!omnipodPumpStatus.ackAlertsAvailable || !alertsText.equals(omnipodPumpStatus.ackAlertsText)) {
|
||||||
omnipodPumpStatus.ackAlertsAvailable = true;
|
omnipodPumpStatus.ackAlertsAvailable = true;
|
||||||
omnipodPumpStatus.ackAlertsText = TextUtils.join("\n", alerts);
|
omnipodPumpStatus.ackAlertsText = TextUtils.join("\n", alerts);
|
||||||
|
|
||||||
sendEvent(new EventOmnipodAcknowledgeAlertsChanged());
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (omnipodPumpStatus.ackAlertsAvailable || StringUtils.isNotEmpty(omnipodPumpStatus.ackAlertsText)) {
|
if (omnipodPumpStatus.ackAlertsAvailable || StringUtils.isNotEmpty(omnipodPumpStatus.ackAlertsText)) {
|
||||||
omnipodPumpStatus.ackAlertsText = null;
|
omnipodPumpStatus.ackAlertsText = null;
|
||||||
omnipodPumpStatus.ackAlertsAvailable = false;
|
omnipodPumpStatus.ackAlertsAvailable = false;
|
||||||
sendEvent(new EventOmnipodAcknowledgeAlertsChanged());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,15 +112,15 @@ public class AapsPodStateManager extends PodStateManager {
|
||||||
omnipodPumpStatus.lastBolusTime = lastBolusStartTime;
|
omnipodPumpStatus.lastBolusTime = lastBolusStartTime;
|
||||||
omnipodPumpStatus.lastBolusAmount = lastBolusAmount;
|
omnipodPumpStatus.lastBolusAmount = lastBolusAmount;
|
||||||
omnipodPumpStatus.reservoirRemainingUnits = getReservoirLevel() == null ? 75.0 : getReservoirLevel();
|
omnipodPumpStatus.reservoirRemainingUnits = getReservoirLevel() == null ? 75.0 : getReservoirLevel();
|
||||||
|
boolean sendRefreshOverviewEvent = isSuspended() != PumpStatusType.Suspended.equals(omnipodPumpStatus.pumpStatusType);
|
||||||
omnipodPumpStatus.pumpStatusType = isSuspended() ? PumpStatusType.Suspended : PumpStatusType.Running;
|
omnipodPumpStatus.pumpStatusType = isSuspended() ? PumpStatusType.Suspended : PumpStatusType.Running;
|
||||||
sendEvent(new EventOmnipodPumpValuesChanged());
|
|
||||||
|
|
||||||
if (isSuspended() != PumpStatusType.Suspended.equals(omnipodPumpStatus.pumpStatusType)) {
|
if (sendRefreshOverviewEvent) {
|
||||||
sendEvent(new EventRefreshOverview("Omnipod Pump", false));
|
sendEvent(new EventRefreshOverview("Omnipod Pump", false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rxBus.send(new EventOmnipodDeviceStatusChange(this));
|
sendEvent(new EventOmnipodPumpValuesChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getTranslatedActiveAlerts() {
|
private List<String> getTranslatedActiveAlerts() {
|
||||||
|
|
|
@ -191,6 +191,7 @@ public class OmnipodUITask {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FIXME a lot of this is not needed anymore since introducing PodStateManager
|
||||||
public void postProcess(OmnipodUIPostprocessor postprocessor) {
|
public void postProcess(OmnipodUIPostprocessor postprocessor) {
|
||||||
|
|
||||||
EventOmnipodDeviceStatusChange statusChange;
|
EventOmnipodDeviceStatusChange statusChange;
|
||||||
|
|
|
@ -5,4 +5,5 @@ import info.nightscout.androidaps.events.Event
|
||||||
/**
|
/**
|
||||||
* Created by andy on 04.06.2018.
|
* Created by andy on 04.06.2018.
|
||||||
*/
|
*/
|
||||||
|
// FIXME can be removed, we should just use EventOmnipodPumpValuesChanged
|
||||||
class EventOmnipodAcknowledgeAlertsChanged : Event()
|
class EventOmnipodAcknowledgeAlertsChanged : Event()
|
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManage
|
||||||
/**
|
/**
|
||||||
* Created by andy on 4.8.2019
|
* Created by andy on 4.8.2019
|
||||||
*/
|
*/
|
||||||
|
// FIXME can be removed, we should just use EventOmnipodPumpValuesChanged
|
||||||
class EventOmnipodDeviceStatusChange : Event {
|
class EventOmnipodDeviceStatusChange : Event {
|
||||||
|
|
||||||
var rileyLinkServiceState: RileyLinkServiceState? = null
|
var rileyLinkServiceState: RileyLinkServiceState? = null
|
||||||
|
|
|
@ -7,8 +7,6 @@ import android.os.IBinder;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
@ -164,17 +162,17 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
|
|
||||||
public boolean verifyConfiguration() {
|
public boolean verifyConfiguration() {
|
||||||
try {
|
try {
|
||||||
omnipodPumpStatus.errorDescription = "-";
|
omnipodPumpStatus.rileyLinkErrorDescription = null;
|
||||||
|
|
||||||
String rileyLinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
String rileyLinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
||||||
|
|
||||||
if (StringUtils.isEmpty(rileyLinkAddress)) {
|
if (StringUtils.isEmpty(rileyLinkAddress)) {
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "RileyLink address invalid: no address");
|
aapsLogger.debug(LTag.PUMPCOMM, "RileyLink address invalid: no address");
|
||||||
omnipodPumpStatus.errorDescription = resourceHelper.gs(R.string.medtronic_error_rileylink_address_invalid);
|
omnipodPumpStatus.rileyLinkErrorDescription = resourceHelper.gs(R.string.omnipod_error_rileylink_address_invalid);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (!rileyLinkAddress.matches(omnipodPumpStatus.regexMac)) {
|
if (!rileyLinkAddress.matches(omnipodPumpStatus.regexMac)) {
|
||||||
omnipodPumpStatus.errorDescription = resourceHelper.gs(R.string.medtronic_error_rileylink_address_invalid);
|
omnipodPumpStatus.rileyLinkErrorDescription = resourceHelper.gs(R.string.omnipod_error_rileylink_address_invalid);
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "RileyLink address invalid: {}", rileyLinkAddress);
|
aapsLogger.debug(LTag.PUMPCOMM, "RileyLink address invalid: {}", rileyLinkAddress);
|
||||||
} else {
|
} else {
|
||||||
if (!rileyLinkAddress.equals(this.omnipodPumpStatus.rileyLinkAddress)) {
|
if (!rileyLinkAddress.equals(this.omnipodPumpStatus.rileyLinkAddress)) {
|
||||||
|
@ -199,7 +197,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
this.omnipodPumpStatus.errorDescription = ex.getMessage();
|
this.omnipodPumpStatus.rileyLinkErrorDescription = ex.getMessage();
|
||||||
aapsLogger.error(LTag.PUMPCOMM, "Error on Verification: " + ex.getMessage(), ex);
|
aapsLogger.error(LTag.PUMPCOMM, "Error on Verification: " + ex.getMessage(), ex);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -575,7 +575,7 @@
|
||||||
android:layout_weight="1.5"
|
android:layout_weight="1.5"
|
||||||
android:gravity="end"
|
android:gravity="end"
|
||||||
android:paddingRight="5dp"
|
android:paddingRight="5dp"
|
||||||
android:text="@string/medtronic_errors"
|
android:text="@string/omnipod_errors"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -1864,10 +1864,11 @@
|
||||||
<string name="omnipod_pod_address">Pod Address</string>
|
<string name="omnipod_pod_address">Pod Address</string>
|
||||||
<string name="omnipod_pod_expiry">Pod Expires</string>
|
<string name="omnipod_pod_expiry">Pod Expires</string>
|
||||||
<string name="omnipod_pod_status_no_pod_connected">No Pod connected</string>
|
<string name="omnipod_pod_status_no_pod_connected">No Pod connected</string>
|
||||||
<string name="omnipod_pod_setup_in_progress">Pod setup in progress</string>
|
<string name="omnipod_pod_setup_in_progress">Pod setup in progress (setup progress: %1$s)</string>
|
||||||
<string name="omnipod_pod_status_not_initalized">Pod not initialized</string>
|
<string name="omnipod_pod_status_not_initalized">Pod not initialized</string>
|
||||||
<string name="omnipod_pod_status_pod_fault">!!! Pod Fault</string>
|
<string name="omnipod_pod_status_pod_fault">Pod Fault</string>
|
||||||
<string name="omnipod_pod_status_pod_running">Pod running</string>
|
<string name="omnipod_pod_status_pod_fault_description">Pod Fault: %1$s %2$s</string>
|
||||||
|
<string name="omnipod_pod_status_pod_running">Pod running (last delivery status: %1$s)</string>
|
||||||
<string name="omnipod_pod_active_alerts">Active Pod Alerts</string>
|
<string name="omnipod_pod_active_alerts">Active Pod Alerts</string>
|
||||||
<string name="omnipod_ack_short">Ack Alerts</string>
|
<string name="omnipod_ack_short">Ack Alerts</string>
|
||||||
<string name="omnipod_last_bolus" translatable="false">%1$.2f %2$s (%3$s)</string>
|
<string name="omnipod_last_bolus" translatable="false">%1$.2f %2$s (%3$s)</string>
|
||||||
|
@ -1881,6 +1882,7 @@
|
||||||
|
|
||||||
|
|
||||||
<!-- Omnipod - Error -->
|
<!-- Omnipod - Error -->
|
||||||
|
<string name="omnipod_error_rileylink_address_invalid">RileyLink Address invalid.</string>
|
||||||
<string name="omnipod_error_operation_not_possible_no_configuration">Operation is not possible.\n\nYou need to configure Omnipod first, before you can use this operation.</string>
|
<string name="omnipod_error_operation_not_possible_no_configuration">Operation is not possible.\n\nYou need to configure Omnipod first, before you can use this operation.</string>
|
||||||
<string name="omnipod_error_operation_not_possible_no_profile">Operation is not possible.\n\n You need to wait few minutes, until AAPS tries to set profile for first time.</string>
|
<string name="omnipod_error_operation_not_possible_no_profile">Operation is not possible.\n\n You need to wait few minutes, until AAPS tries to set profile for first time.</string>
|
||||||
<string name="omnipod_error_illegal_init_action_type">Illegal PodInitActionType: %1$s</string>
|
<string name="omnipod_error_illegal_init_action_type">Illegal PodInitActionType: %1$s</string>
|
||||||
|
@ -1987,5 +1989,6 @@
|
||||||
<string name="omnipod_pod_lot">LOT</string>
|
<string name="omnipod_pod_lot">LOT</string>
|
||||||
<string name="omnipod_pod_tid">TID</string>
|
<string name="omnipod_pod_tid">TID</string>
|
||||||
<string name="omnipod_pod_fw_version">PM / PI version</string>
|
<string name="omnipod_pod_fw_version">PM / PI version</string>
|
||||||
|
<string name="omnipod_errors">Errors</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue