Merge pull request #69 from AAPS-Omnipod/omnipod_eros_dev_upstream_merge
Latest Omnipod updates & enable Omnipod plugin
This commit is contained in:
commit
15247b5fd7
|
@ -42,6 +42,7 @@ import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin
|
|||
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.mdi.MDIPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
|
||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
|
||||
|
@ -155,6 +156,12 @@ abstract class PluginsModule {
|
|||
@IntKey(150)
|
||||
abstract fun bindMedtronicPumpPlugin(plugin: MedtronicPumpPlugin): PluginBase
|
||||
|
||||
@Binds
|
||||
@PumpDriver
|
||||
@IntoMap
|
||||
@IntKey(155)
|
||||
abstract fun bindOmnipodPumpPlugin(plugin: OmnipodPumpPlugin): PluginBase
|
||||
|
||||
@Binds
|
||||
@NotNSClient
|
||||
@IntoMap
|
||||
|
|
|
@ -73,6 +73,7 @@ public class Notification {
|
|||
public static final int CARBS_REQUIRED = 60;
|
||||
public static final int OMNIPOD_POD_SUSPENDED = 61;
|
||||
public static final int OMNIPOD_POD_ALERTS_UPDATED = 62;
|
||||
public static final int OMNIPOD_POD_ALERTS = 63;
|
||||
|
||||
public static final int IMPORTANCE_HIGH = 2;
|
||||
|
||||
|
|
|
@ -18,13 +18,6 @@ android {
|
|||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
|
||||
// OMNIPOD: for usage in Firebase event during testing phase
|
||||
buildConfigField "String", "VERSION", '"2.7-omnipod-0.4.1-SNAPSHOT"'
|
||||
// OMNIPOD: Keep track of what commit from the main repository we're on, these fields aren't actually used anywhere
|
||||
buildConfigField "String", "DEV_VERSION", '"2.7.0-rc4"'
|
||||
buildConfigField "String", "DEV_VERSION_COMMIT", '"7d5dc54656c961660451c4fa4c6ea66bd83a1c46"'
|
||||
buildConfigField "String", "DEV_VERSION_COMMIT_DATE", '"21.8.2020"' // 21st of August
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
|
|
|
@ -4,11 +4,11 @@ import android.content.ComponentName;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
|
@ -52,6 +52,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
|||
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||
|
@ -74,12 +75,15 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.acti
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoRecentPulseLog;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertConfiguration;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSet;
|
||||
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;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.CommandAcknowledgeAlerts;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.CommandHandleTimeChange;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.CommandUpdateAlertConfiguration;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.OmnipodCustomCommand;
|
||||
|
@ -88,6 +92,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.service.RileyLi
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.ui.OmnipodOverviewFragment;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.AapsOmnipodUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodAlertUtil;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.androidaps.queue.commands.CustomCommand;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
|
@ -135,6 +140,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
private final List<CustomAction> customActions = Collections.singletonList(new CustomAction(
|
||||
R.string.omnipod_custom_action_reset_rileylink, OmnipodCustomActionType.RESET_RILEY_LINK_CONFIGURATION, true));
|
||||
private final CompositeDisposable disposables = new CompositeDisposable();
|
||||
private final NSUpload nsUpload;
|
||||
|
||||
// variables for handling statuses and history
|
||||
private boolean firstRun = true;
|
||||
|
@ -169,7 +175,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
AapsOmnipodUtil aapsOmnipodUtil,
|
||||
RileyLinkUtil rileyLinkUtil,
|
||||
OmnipodAlertUtil omnipodAlertUtil,
|
||||
ProfileFunction profileFunction
|
||||
ProfileFunction profileFunction,
|
||||
NSUpload nsUpload
|
||||
) {
|
||||
super(new PluginDescription() //
|
||||
.mainType(PluginType.PUMP) //
|
||||
|
@ -195,6 +202,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
this.rileyLinkUtil = rileyLinkUtil;
|
||||
this.omnipodAlertUtil = omnipodAlertUtil;
|
||||
this.profileFunction = profileFunction;
|
||||
this.nsUpload = nsUpload;
|
||||
|
||||
pumpDescription = new PumpDescription(pumpType);
|
||||
|
||||
|
@ -241,6 +249,11 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
getCommandQueue().customCommand(new CommandUpdateAlertConfiguration(), null);
|
||||
}
|
||||
|
||||
if (aapsOmnipodManager.isAutomaticallyAcknowledgeAlertsEnabled() && podStateManager.isPodActivationCompleted() && !podStateManager.isPodDead() &&
|
||||
podStateManager.getActiveAlerts().size() > 0 && !getCommandQueue().isCustomCommandInQueue(CommandAcknowledgeAlerts.class)) {
|
||||
queueAcknowledgeAlertsCommand();
|
||||
}
|
||||
|
||||
doPodCheck();
|
||||
|
||||
loopHandler.postDelayed(this, STATUS_CHECK_INTERVAL_MILLIS);
|
||||
|
@ -258,13 +271,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
// When PodStateManager is created, which causes an IllegalArgumentException for DateTimeZones not being recognized
|
||||
podStateManager.loadPodState();
|
||||
|
||||
// BS @ 2020-10-17 FIXME: for backwards compatibility; remove before release
|
||||
if (podStateManager.isPodInitialized() &&
|
||||
podStateManager.getActivationProgress() == ActivationProgress.NONE &&
|
||||
podStateManager.getPodProgressStatus().isAtLeast(PodProgressStatus.ABOVE_FIFTY_UNITS)) {
|
||||
podStateManager.setActivationProgress(ActivationProgress.COMPLETED);
|
||||
}
|
||||
|
||||
lastConnectionTimeMillis = sp.getLong(
|
||||
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
|
||||
|
||||
|
@ -281,6 +287,16 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> updateAapsTbr(), fabricPrivacy::logException)
|
||||
);
|
||||
disposables.add(rxBus
|
||||
.toObservable(EventOmnipodActiveAlertsChanged.class)
|
||||
.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())
|
||||
|
@ -294,7 +310,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
event.isChanged(getResourceHelper(), R.string.key_omnipod_time_change_event_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_notification_uncertain_tbr_sound_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_notification_uncertain_smb_sound_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_notification_uncertain_bolus_sound_enabled)) {
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_notification_uncertain_bolus_sound_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_automatically_acknowledge_alerts_enabled)) {
|
||||
aapsOmnipodManager.reloadSettings();
|
||||
} else if (event.isChanged(getResourceHelper(), R.string.key_omnipod_expiration_reminder_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_expiration_reminder_hours_before_shutdown) ||
|
||||
|
@ -347,6 +364,30 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
}
|
||||
}
|
||||
|
||||
private void handleActivePodAlerts() {
|
||||
if (podStateManager.isPodActivationCompleted() && !podStateManager.isPodDead()) {
|
||||
AlertSet activeAlerts = podStateManager.getActiveAlerts();
|
||||
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);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
nsUpload.uploadError(notificationText);
|
||||
|
||||
if (aapsOmnipodManager.isAutomaticallyAcknowledgeAlertsEnabled() && !getCommandQueue().isCustomCommandInQueue(CommandAcknowledgeAlerts.class)) {
|
||||
queueAcknowledgeAlertsCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
@ -359,6 +400,16 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
disposables.clear();
|
||||
}
|
||||
|
||||
private void queueAcknowledgeAlertsCommand() {
|
||||
getCommandQueue().customCommand(new CommandAcknowledgeAlerts(), new Callback() {
|
||||
@Override public void run() {
|
||||
if (result != null) {
|
||||
aapsLogger.debug(LTag.PUMP, "Acknowledge alerts result: {} ({})", result.success, result.comment);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doPodCheck() {
|
||||
if (System.currentTimeMillis() > this.nextPodCheck) {
|
||||
if (!podStateManager.isPodRunning()) {
|
||||
|
@ -484,7 +535,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
// When we activate a new Pod, we just use ProfileFunction to set the currently active profile
|
||||
return true;
|
||||
}
|
||||
return podStateManager.getBasalSchedule().equals(AapsOmnipodManager.mapProfileToBasalSchedule(profile));
|
||||
return Objects.equals(podStateManager.getBasalSchedule(), AapsOmnipodManager.mapProfileToBasalSchedule(profile));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -545,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);
|
||||
|
@ -580,6 +632,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
||||
TemporaryBasal tbrCurrent = readTBR();
|
||||
|
||||
|
@ -648,7 +701,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
return pump;
|
||||
}
|
||||
|
||||
@Override public ManufacturerType manufacturer() {
|
||||
@Override @NonNull public ManufacturerType manufacturer() {
|
||||
return pumpType.getManufacturer();
|
||||
}
|
||||
|
||||
|
@ -706,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -857,7 +906,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
@Override
|
||||
public boolean isUnreachableAlertTimeoutExceeded(long unreachableTimeoutMilliseconds) {
|
||||
// We have a separate notification for when no Pod is active, see doPodCheck()
|
||||
if (podStateManager.isPodActivationCompleted() && podStateManager.getLastSuccessfulCommunication() != null) { // Null check for backwards compatibility
|
||||
if (podStateManager.isPodActivationCompleted() && podStateManager.getLastSuccessfulCommunication() != null) {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
|
||||
if (podStateManager.getLastSuccessfulCommunication().getMillis() + unreachableTimeoutMilliseconds < currentTimeMillis) {
|
||||
|
@ -952,10 +1001,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
aapsLogger.debug(LTag.PUMP, "Not retrieving Pod status on startup: no Pod running");
|
||||
}
|
||||
|
||||
Bundle params = new Bundle();
|
||||
params.putString("version", BuildConfig.VERSION);
|
||||
|
||||
fabricPrivacy.logCustom("OmnipodPumpInit", params);
|
||||
fabricPrivacy.logCustom("OmnipodPumpInit");
|
||||
}
|
||||
|
||||
@NonNull private PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import javax.inject.Provider
|
|||
abstract class OmnipodWizardModule {
|
||||
|
||||
companion object {
|
||||
|
||||
@Provides
|
||||
@OmnipodPluginQualifier
|
||||
fun providesViewModelFactory(@OmnipodPluginQualifier viewModels: MutableMap<Class<out ViewModel>, @JvmSuppressWildcards Provider<ViewModel>>): ViewModelProvider.Factory {
|
||||
|
|
|
@ -20,6 +20,7 @@ public class OmnipodStorageKeys {
|
|||
public static final int NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED = R.string.key_omnipod_notification_uncertain_tbr_sound_enabled;
|
||||
public static final int NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED = R.string.key_omnipod_notification_uncertain_smb_sound_enabled;
|
||||
public static final int NOTIFICATION_UNCERTAIN_BOLUS_SOUND_ENABLED = R.string.key_omnipod_notification_uncertain_bolus_sound_enabled;
|
||||
public static final int AUTOMATICALLY_ACKNOWLEDGE_ALERTS_ENABLED = R.string.key_omnipod_automatically_acknowledge_alerts_enabled;
|
||||
}
|
||||
|
||||
public static class Statistics {
|
||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.definition;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AlertSet {
|
||||
private final List<AlertSlot> alertSlots;
|
||||
|
@ -39,6 +40,17 @@ public class AlertSet {
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AlertSet alertSet = (AlertSet) o;
|
||||
return alertSlots.equals(alertSet.alertSlots);
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return Objects.hash(alertSlots);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AlertSet{" +
|
||||
|
|
|
@ -50,7 +50,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.PodFault
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.PodProgressStatusVerificationFailedException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.PrecedingCommandFailedUncertainlyException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.Flowable;
|
||||
import io.reactivex.Single;
|
||||
|
@ -62,17 +61,16 @@ public class OmnipodManager {
|
|||
private static final int ACTION_VERIFICATION_TRIES = 1;
|
||||
|
||||
private final OmnipodRileyLinkCommunicationManager communicationService;
|
||||
private PodStateManager podStateManager;
|
||||
private final PodStateManager podStateManager;
|
||||
|
||||
private ActiveBolusData activeBolusData;
|
||||
private SingleSubject<Boolean> bolusCommandExecutionSubject;
|
||||
|
||||
private final Object bolusDataMutex = new Object();
|
||||
|
||||
private AAPSLogger aapsLogger;
|
||||
private final AAPSLogger aapsLogger;
|
||||
|
||||
public OmnipodManager(AAPSLogger aapsLogger,
|
||||
SP sp,
|
||||
OmnipodRileyLinkCommunicationManager communicationService,
|
||||
PodStateManager podStateManager) {
|
||||
if (communicationService == null) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
@ -537,7 +528,10 @@ public abstract class PodStateManager {
|
|||
podState.setActivatedAt(activatedAtCalculated);
|
||||
}
|
||||
podState.setSuspended(status.getDeliveryStatus() == DeliveryStatus.SUSPENDED);
|
||||
podState.setActiveAlerts(status.getUnacknowledgedAlerts());
|
||||
if (!Objects.equals(status.getUnacknowledgedAlerts(), podState.getActiveAlerts())) {
|
||||
podState.setActiveAlerts(status.getUnacknowledgedAlerts());
|
||||
onActiveAlertsChanged();
|
||||
}
|
||||
podState.setLastDeliveryStatus(status.getDeliveryStatus());
|
||||
podState.setReservoirLevel(status.getReservoirLevel());
|
||||
podState.setTotalTicksDelivered(status.getTicksDelivered());
|
||||
|
@ -556,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -567,6 +564,16 @@ public abstract class PodStateManager {
|
|||
// Can be overridden in subclasses
|
||||
}
|
||||
|
||||
protected void onActiveAlertsChanged() {
|
||||
// Deliberately left empty
|
||||
// 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 EventOmnipodActiveAlertsChanged : Event()
|
|
@ -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()
|
|
@ -113,6 +113,7 @@ public class AapsOmnipodManager {
|
|||
private boolean notificationUncertainTbrSoundEnabled;
|
||||
private boolean notificationUncertainSmbSoundEnabled;
|
||||
private boolean notificationUncertainBolusSoundEnabled;
|
||||
private boolean automaticallyAcknowledgeAlertsEnabled;
|
||||
|
||||
@Inject
|
||||
public AapsOmnipodManager(OmnipodRileyLinkCommunicationManager communicationService,
|
||||
|
@ -142,7 +143,7 @@ public class AapsOmnipodManager {
|
|||
this.nsUpload = nsUpload;
|
||||
this.profileFunction = profileFunction;
|
||||
|
||||
delegate = new OmnipodManager(aapsLogger, sp, communicationService, podStateManager);
|
||||
delegate = new OmnipodManager(aapsLogger, communicationService, podStateManager);
|
||||
|
||||
reloadSettings();
|
||||
}
|
||||
|
@ -158,6 +159,7 @@ public class AapsOmnipodManager {
|
|||
notificationUncertainTbrSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED, true);
|
||||
notificationUncertainSmbSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED, true);
|
||||
notificationUncertainBolusSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_BOLUS_SOUND_ENABLED, true);
|
||||
automaticallyAcknowledgeAlertsEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.AUTOMATICALLY_ACKNOWLEDGE_ALERTS_ENABLED, false);
|
||||
}
|
||||
|
||||
public PumpEnactResult initializePod() {
|
||||
|
@ -627,6 +629,10 @@ public class AapsOmnipodManager {
|
|||
return notificationUncertainBolusSoundEnabled;
|
||||
}
|
||||
|
||||
public boolean isAutomaticallyAcknowledgeAlertsEnabled() {
|
||||
return automaticallyAcknowledgeAlertsEnabled;
|
||||
}
|
||||
|
||||
public void addBolusToHistory(DetailedBolusInfo originalDetailedBolusInfo) {
|
||||
DetailedBolusInfo detailedBolusInfo = originalDetailedBolusInfo.copy();
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ import info.nightscout.androidaps.logging.AAPSLogger;
|
|||
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;
|
||||
|
||||
|
@ -35,4 +37,12 @@ public class AapsPodStateManager extends PodStateManager {
|
|||
@Override protected void onTbrChanged() {
|
||||
rxBus.send(new EventOmnipodTbrChanged());
|
||||
}
|
||||
|
||||
@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))
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
private fun updateAcknowledgeAlertsButton() {
|
||||
if (podStateManager.isPodRunning && (podStateManager.hasActiveAlerts() || commandQueue.isCustomCommandInQueue(CommandAcknowledgeAlerts::class.java))) {
|
||||
if (!omnipodManager.isAutomaticallyAcknowledgeAlertsEnabled && podStateManager.isPodRunning && (podStateManager.hasActiveAlerts() || commandQueue.isCustomCommandInQueue(CommandAcknowledgeAlerts::class.java))) {
|
||||
omnipod_overview_button_acknowledge_active_alerts.visibility = View.VISIBLE
|
||||
omnipod_overview_button_acknowledge_active_alerts.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||
} else {
|
||||
|
|
|
@ -10,6 +10,7 @@ import javax.inject.Inject
|
|||
|
||||
class PodActivationWizardActivity : OmnipodWizardActivityBase() {
|
||||
companion object {
|
||||
|
||||
const val KEY_START_DESTINATION = "startDestination"
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment
|
|||
import kotlinx.android.synthetic.main.omnipod_wizard_nav_buttons.*
|
||||
|
||||
class AttachPodInfoFragment : InfoFragmentBase() {
|
||||
|
||||
@StringRes
|
||||
override fun getTitleId(): Int = R.string.omnipod_pod_activation_wizard_attach_pod_title
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.R
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.InfoFragmentBase
|
||||
|
||||
class FillPodInfoFragment : InfoFragmentBase() {
|
||||
|
||||
@StringRes
|
||||
override fun getTitleId(): Int = R.string.omnipod_pod_activation_wizard_fill_pod_title
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.view
|
|||
import javax.inject.Inject
|
||||
|
||||
class InitializePodActionFragment : PodActivationActionFragmentBase() {
|
||||
|
||||
@Inject
|
||||
@OmnipodPluginQualifier
|
||||
lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||
|
|
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.view
|
|||
import javax.inject.Inject
|
||||
|
||||
class InsertCannulaActionFragment : PodActivationActionFragmentBase() {
|
||||
|
||||
@Inject
|
||||
@OmnipodPluginQualifier
|
||||
lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||
|
|
|
@ -6,6 +6,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.R
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.InfoFragmentBase
|
||||
|
||||
class PodActivatedInfoFragment : InfoFragmentBase() {
|
||||
|
||||
@StringRes
|
||||
override fun getTitleId(): Int = R.string.omnipod_pod_activation_wizard_pod_activated_title
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import kotlinx.android.synthetic.main.omnipod_wizard_action_page_fragment.*
|
|||
import javax.inject.Inject
|
||||
|
||||
abstract class PodActivationActionFragmentBase : ActionFragmentBase() {
|
||||
|
||||
@Inject
|
||||
protected lateinit var podStateManager: PodStateManager
|
||||
|
||||
|
|
|
@ -6,5 +6,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.viewmode
|
|||
import javax.inject.Inject
|
||||
|
||||
class InitializePodActionViewModel @Inject constructor(private val aapsOmnipodManager: AapsOmnipodManager) : ActionViewModelBase() {
|
||||
|
||||
override fun doExecuteAction(): PumpEnactResult = aapsOmnipodManager.initializePod()
|
||||
}
|
|
@ -7,5 +7,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.viewmode
|
|||
import javax.inject.Inject
|
||||
|
||||
class InsertCannulaActionViewModel @Inject constructor(private val aapsOmnipodManager: AapsOmnipodManager, private val profileFunction: ProfileFunction) : ActionViewModelBase() {
|
||||
|
||||
override fun doExecuteAction(): PumpEnactResult = aapsOmnipodManager.insertCannula(profileFunction.getProfile())
|
||||
}
|
|
@ -7,6 +7,7 @@ import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.R
|
||||
|
||||
abstract class OmnipodWizardActivityBase : NoSplashAppCompatActivity() {
|
||||
|
||||
override fun onBackPressed() {
|
||||
exitActivityAfterConfirmation()
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import kotlinx.android.synthetic.main.omnipod_wizard_action_page_fragment.*
|
|||
import kotlinx.android.synthetic.main.omnipod_wizard_nav_buttons.*
|
||||
|
||||
abstract class ActionFragmentBase : WizardFragmentBase() {
|
||||
|
||||
protected lateinit var viewModel: ActionViewModelBase
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import kotlinx.android.synthetic.main.omnipod_wizard_progress_indication.*
|
|||
import kotlin.math.roundToInt
|
||||
|
||||
abstract class WizardFragmentBase : DaggerFragment() {
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
|
|
|
@ -5,6 +5,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.R
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.activity.OmnipodWizardActivityBase
|
||||
|
||||
class PodDeactivationWizardActivity : OmnipodWizardActivityBase() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import kotlinx.android.synthetic.main.omnipod_wizard_action_page_fragment.*
|
|||
import javax.inject.Inject
|
||||
|
||||
class DeactivatePodActionFragment : ActionFragmentBase() {
|
||||
|
||||
@Inject
|
||||
@OmnipodPluginQualifier
|
||||
lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||
|
|
|
@ -6,6 +6,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.R
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.InfoFragmentBase
|
||||
|
||||
class DeactivatePodInfoFragment : InfoFragmentBase() {
|
||||
|
||||
@StringRes
|
||||
override fun getTitleId(): Int = R.string.omnipod_pod_deactivation_wizard_deactivate_pod_title
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.R
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.InfoFragmentBase
|
||||
|
||||
class PodDeactivatedInfoFragment : InfoFragmentBase() {
|
||||
|
||||
@StringRes
|
||||
override fun getTitleId(): Int = R.string.omnipod_pod_deactivation_wizard_pod_deactivated_title
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.R
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.InfoFragmentBase
|
||||
|
||||
class PodDiscardedInfoFragment : InfoFragmentBase() {
|
||||
|
||||
@StringRes
|
||||
override fun getTitleId(): Int = R.string.omnipod_pod_deactivation_wizard_pod_discarded_title
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import io.reactivex.subjects.SingleSubject
|
|||
import javax.inject.Inject
|
||||
|
||||
class DeactivatePodActionViewModel @Inject constructor(private val aapsOmnipodManager: AapsOmnipodManager, private val commandQueueProvider: CommandQueueProvider) : ActionViewModelBase() {
|
||||
|
||||
override fun doExecuteAction(): PumpEnactResult {
|
||||
val singleSubject = SingleSubject.create<PumpEnactResult>()
|
||||
commandQueueProvider.customCommand(CommandDeactivatePod(), object : Callback() {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<string name="key_omnipod_expiration_reminder_hours_before_shutdown" translatable="false">AAPS.Omnipod.expiration_reminder_hours_before_shutdown</string>
|
||||
<string name="key_omnipod_low_reservoir_alert_enabled" translatable="false">AAPS.Omnipod.low_reservoir_alert_enabled</string>
|
||||
<string name="key_omnipod_low_reservoir_alert_units" translatable="false">AAPS.Omnipod.low_reservoir_alert_units</string>
|
||||
<string name="key_omnipod_automatically_acknowledge_alerts_enabled" translatable="false">AAPS.Omnipod.automatically_acknowledge_alerts_enabled</string>
|
||||
<string name="key_omnipod_notification_uncertain_tbr_sound_enabled" translatable="false">AAPS.Omnipod.notification_uncertain_tbr_sound_enabled</string>
|
||||
<string name="key_omnipod_notification_uncertain_smb_sound_enabled" translatable="false">AAPS.Omnipod.notification_uncertain_smb_sound_enabled</string>
|
||||
<string name="key_omnipod_notification_uncertain_bolus_sound_enabled" translatable="false">AAPS.Omnipod.notification_uncertain_bolus_sound_enabled</string>
|
||||
|
@ -48,6 +49,7 @@
|
|||
<string name="omnipod_config_notification_uncertain_tbr_sound_enabled">Sound for uncertain TBR notifications enabled</string>
|
||||
<string name="omnipod_config_notification_uncertain_smb_sound_enabled">Sound for uncertain SMB notifications enabled</string>
|
||||
<string name="omnipod_config_notification_uncertain_bolus_sound_enabled">Sound for uncertain bolus notifications enabled</string>
|
||||
<string name="omnipod_config_automatically_acknowledge_alerts">Automatically acknowledge Pod alerts</string>
|
||||
<string name="omnipod_preference_category_rileylink">RileyLink</string>
|
||||
<string name="omnipod_preference_category_other">Other</string>
|
||||
<string name="omnipod_preference_category_alerts">Alerts</string>
|
||||
|
@ -63,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>
|
||||
|
@ -265,5 +267,9 @@
|
|||
<item quantity="one">%1$d day</item>
|
||||
<item quantity="other">%1$d days</item>
|
||||
</plurals>
|
||||
<plurals name="omnipod_pod_alerts">
|
||||
<item quantity="one">Pod alert: %1$s</item>
|
||||
<item quantity="other">Pod alerts: %1$s</item>
|
||||
</plurals>
|
||||
|
||||
</resources>
|
|
@ -72,6 +72,11 @@
|
|||
validate:minNumber="5"
|
||||
validate:testType="numericRange" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_omnipod_automatically_acknowledge_alerts_enabled"
|
||||
android:title="@string/omnipod_config_automatically_acknowledge_alerts" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/omnipod_preference_category_notifications">
|
||||
|
|
|
@ -60,7 +60,7 @@ public class OmnipodPumpPluginTest {
|
|||
OmnipodPumpPlugin plugin = new OmnipodPumpPlugin(injector, aapsLogger, rxBusWrapper, null,
|
||||
resourceHelper, activePluginProvider, null, null, aapsOmnipodManager, commandQueueProvider,
|
||||
null, null, null, null, null,
|
||||
rileyLinkUtil, null, null
|
||||
rileyLinkUtil, null, null, null
|
||||
);
|
||||
when(activePluginProvider.getActiveTreatments().getTempBasalFromHistory(anyLong())).thenReturn(null);
|
||||
when(rileyLinkUtil.getRileyLinkHistory()).thenReturn(new ArrayList<>());
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.driver.definition;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
||||
public class AlertSetTest {
|
||||
@Test
|
||||
public void testEquality() {
|
||||
AlertSet set1 = new AlertSet(Arrays.asList(AlertSlot.SLOT0, AlertSlot.SLOT1));
|
||||
AlertSet set2 = new AlertSet(Arrays.asList(AlertSlot.SLOT0, AlertSlot.SLOT1));
|
||||
AlertSet set3 = new AlertSet(Collections.singletonList(AlertSlot.SLOT1));
|
||||
|
||||
assertEquals(set1, set2);
|
||||
assertNotEquals(set1, set3);
|
||||
assertNotEquals(set2, set3);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue