Always create NS announcements for Pod faults & some cleanup
This commit is contained in:
parent
7e8b395ca7
commit
f6a82e01d7
|
@ -79,6 +79,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSe
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.util.TimeUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodActiveAlertsChanged;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodFaultEventChanged;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodPumpValuesChanged;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodTbrChanged;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.manager.AapsOmnipodManager;
|
||||
|
@ -248,12 +249,9 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
getCommandQueue().customCommand(new CommandUpdateAlertConfiguration(), null);
|
||||
}
|
||||
|
||||
if (aapsOmnipodManager.isAutomaticallyAcknowledgeAlertsEnabled() && podStateManager.isPodActivationCompleted() && !podStateManager.isPodDead()) {
|
||||
AlertSet activeAlerts = podStateManager.getActiveAlerts();
|
||||
|
||||
if (activeAlerts != null && activeAlerts.size() > 0 && !getCommandQueue().isCustomCommandInQueue(CommandAcknowledgeAlerts.class)) {
|
||||
queueAcknowledgeAlertsCommand();
|
||||
}
|
||||
if (aapsOmnipodManager.isAutomaticallyAcknowledgeAlertsEnabled() && podStateManager.isPodActivationCompleted() && !podStateManager.isPodDead() &&
|
||||
podStateManager.getActiveAlerts().size() > 0 && !getCommandQueue().isCustomCommandInQueue(CommandAcknowledgeAlerts.class)) {
|
||||
queueAcknowledgeAlertsCommand();
|
||||
}
|
||||
|
||||
doPodCheck();
|
||||
|
@ -294,6 +292,11 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> handleActivePodAlerts(), fabricPrivacy::logException)
|
||||
);
|
||||
disposables.add(rxBus
|
||||
.toObservable(EventOmnipodFaultEventChanged.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> handlePodFaultEvent(), fabricPrivacy::logException)
|
||||
);
|
||||
disposables.add(rxBus
|
||||
.toObservable(EventPreferenceChange.class)
|
||||
.observeOn(Schedulers.io())
|
||||
|
@ -364,7 +367,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
private void handleActivePodAlerts() {
|
||||
if (podStateManager.isPodActivationCompleted() && !podStateManager.isPodDead()) {
|
||||
AlertSet activeAlerts = podStateManager.getActiveAlerts();
|
||||
if (activeAlerts != null && activeAlerts.size() > 0) {
|
||||
if (activeAlerts.size() > 0) {
|
||||
String alerts = TextUtils.join(", ", aapsOmnipodUtil.getTranslatedActiveAlerts(podStateManager));
|
||||
String notificationText = resourceHelper.gq(R.plurals.omnipod_pod_alerts, activeAlerts.size(), alerts);
|
||||
Notification notification = new Notification(Notification.OMNIPOD_POD_ALERTS, notificationText, Notification.URGENT);
|
||||
|
@ -378,6 +381,13 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
}
|
||||
}
|
||||
|
||||
private void handlePodFaultEvent() {
|
||||
if (podStateManager.isPodFaulted()) {
|
||||
String notificationText = resourceHelper.gs(R.string.omnipod_pod_status_pod_fault_description, podStateManager.getFaultEventCode().getValue(), podStateManager.getFaultEventCode().name());
|
||||
nsUpload.uploadError(notificationText);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
|
@ -586,6 +596,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
// if enforceNew is true, current temp basal is cancelled and new TBR set (duration is prolonged),
|
||||
// if false and the same rate is requested enacted=false and success=true is returned and TBR is not changed
|
||||
@Override
|
||||
@NonNull
|
||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer
|
||||
durationInMinutes, Profile profile, boolean enforceNew) {
|
||||
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute: rate: {}, duration={}", absoluteRate, durationInMinutes);
|
||||
|
@ -621,6 +632,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
||||
TemporaryBasal tbrCurrent = readTBR();
|
||||
|
||||
|
@ -689,7 +701,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
return pump;
|
||||
}
|
||||
|
||||
@Override public ManufacturerType manufacturer() {
|
||||
@Override @NonNull public ManufacturerType manufacturer() {
|
||||
return pumpType.getManufacturer();
|
||||
}
|
||||
|
||||
|
@ -747,14 +759,10 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
public void executeCustomAction(CustomActionType customActionType) {
|
||||
OmnipodCustomActionType mcat = (OmnipodCustomActionType) customActionType;
|
||||
|
||||
switch (mcat) {
|
||||
case RESET_RILEY_LINK_CONFIGURATION:
|
||||
serviceTaskExecutor.startTask(new ResetRileyLinkConfigurationTask(getInjector()));
|
||||
break;
|
||||
|
||||
default:
|
||||
aapsLogger.warn(LTag.PUMP, "Unknown custom action: " + mcat);
|
||||
break;
|
||||
if (mcat == OmnipodCustomActionType.RESET_RILEY_LINK_CONFIGURATION) {
|
||||
serviceTaskExecutor.startTask(new ResetRileyLinkConfigurationTask(getInjector()));
|
||||
} else {
|
||||
aapsLogger.warn(LTag.PUMP, "Unknown custom action: " + mcat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -238,15 +238,6 @@ public abstract class PodStateManager {
|
|||
return getSafe(() -> podState.getLastUpdatedFromResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the Pod State contains a fault event. Is the Pod state does not contain
|
||||
* a fault event, this does NOT necessarily mean that the Pod is not faulted. For a reliable
|
||||
* indication on whether or not the pod is faulted, see {@link #isPodFaulted() isPodFaulted()}
|
||||
*/
|
||||
public final boolean isFaulted() {
|
||||
return podState != null && podState.getFaultEventCode() != null;
|
||||
}
|
||||
|
||||
public final FaultEventCode getFaultEventCode() {
|
||||
return getSafe(() -> podState.getFaultEventCode());
|
||||
}
|
||||
|
@ -559,7 +550,10 @@ public abstract class PodStateManager {
|
|||
if (status instanceof PodInfoDetailedStatus) {
|
||||
PodInfoDetailedStatus detailedStatus = (PodInfoDetailedStatus) status;
|
||||
if (detailedStatus.isFaulted()) {
|
||||
podState.setFaultEventCode(detailedStatus.getFaultEventCode());
|
||||
if (!Objects.equals(podState.getFaultEventCode(), detailedStatus.getFaultEventCode())) {
|
||||
podState.setFaultEventCode(detailedStatus.getFaultEventCode());
|
||||
onFaultEventChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -575,6 +569,11 @@ public abstract class PodStateManager {
|
|||
// Can be overridden in subclasses
|
||||
}
|
||||
|
||||
protected void onFaultEventChanged() {
|
||||
// Deliberately left empty
|
||||
// Can be overridden in subclasses
|
||||
}
|
||||
|
||||
private void setAndStore(Runnable runnable) {
|
||||
setSafe(runnable);
|
||||
storePodState();
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.event
|
||||
|
||||
import info.nightscout.androidaps.events.Event
|
||||
|
||||
/**
|
||||
* Created by andy on 04.06.2018.
|
||||
*/
|
||||
class EventOmnipodFaultEventChanged : Event()
|
|
@ -8,6 +8,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.definition.OmnipodStorageKeys;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodActiveAlertsChanged;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodFaultEventChanged;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodTbrChanged;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
|
@ -40,4 +41,8 @@ public class AapsPodStateManager extends PodStateManager {
|
|||
@Override protected void onActiveAlertsChanged() {
|
||||
rxBus.send(new EventOmnipodActiveAlertsChanged());
|
||||
}
|
||||
|
||||
@Override protected void onFaultEventChanged() {
|
||||
rxBus.send(new EventOmnipodFaultEventChanged());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
})
|
||||
}
|
||||
|
||||
if (podStateManager.isFaulted) {
|
||||
if (podStateManager.isPodFaulted) {
|
||||
val faultEventCode = podStateManager.faultEventCode
|
||||
errors.add(resourceHelper.gs(R.string.omnipod_pod_status_pod_fault_description, faultEventCode.value, faultEventCode.name))
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
<string name="omnipod_pod_status_pod_fault">Pod fault</string>
|
||||
<string name="omnipod_pod_status_activation_time_exceeded">Activation time exceeded</string>
|
||||
<string name="omnipod_pod_status_inactive">Inactive</string>
|
||||
<string name="omnipod_pod_status_pod_fault_description">Pod fault: %1$s %2$s</string>
|
||||
<string name="omnipod_pod_status_pod_fault_description">Pod fault: %1$03d %2$s</string>
|
||||
|
||||
<!-- Omnipod - Alerts -->
|
||||
<string name="omnipod_alert_finish_pairing_reminder">Finish pairing reminder</string>
|
||||
|
|
Loading…
Reference in a new issue