Some Omnipod cleanup after merge

This commit is contained in:
Bart Sopers 2020-08-16 17:05:32 +02:00
parent 5d3426dc70
commit 100f8fe235
11 changed files with 66 additions and 250 deletions

View file

@ -17,16 +17,17 @@ 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.events.EventRileyLinkDeviceStatusChange
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
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodStatusRequest
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity
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.EventOmnipodRefreshButtonState
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst
@ -78,7 +79,7 @@ class OmnipodFragment : DaggerFragment() {
init {
refreshLoop = Runnable {
activity?.runOnUiThread { updateGUI() }
activity?.runOnUiThread { updateUi() }
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
}
}
@ -155,27 +156,24 @@ class OmnipodFragment : DaggerFragment() {
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ omnipod_refresh.isEnabled = it.newState }, { fabricPrivacy.logException(it) })
disposable += rxBus
.toObservable(EventOmnipodDeviceStatusChange::class.java)
.toObservable(EventRileyLinkDeviceStatusChange::class.java)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
aapsLogger.info(LTag.PUMP, "onStatusEvent(EventOmnipodDeviceStatusChange): {}", it)
setDeviceStatus()
}, { fabricPrivacy.logException(it) })
.subscribe({ updateRileyLinkUiElements() }, { fabricPrivacy.logException(it) })
disposable += rxBus
.toObservable(EventOmnipodPumpValuesChanged::class.java)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ updateGUI() }, { fabricPrivacy.logException(it) })
.subscribe({ updateOmipodUiElements() }, { fabricPrivacy.logException(it) })
disposable += rxBus
.toObservable(EventOmnipodAcknowledgeAlertsChanged::class.java)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ updateAcknowledgeAlerts() }, { fabricPrivacy.logException(it) })
.subscribe({ updateAcknowledgeAlertsUiElements() }, { fabricPrivacy.logException(it) })
disposable += rxBus
.toObservable(EventPreferenceChange::class.java)
.observeOn(Schedulers.io())
.subscribe({
setVisibilityOfPodDebugButton()
}, { fabricPrivacy.logException(it) })
updateGUI()
updateUi()
}
fun setVisibilityOfPodDebugButton() {
@ -200,11 +198,14 @@ class OmnipodFragment : DaggerFragment() {
loopHandler.removeCallbacks(refreshLoop)
}
@Synchronized
private fun setDeviceStatus() {
aapsLogger.info(LTag.PUMP, "OmnipodFragment.setDeviceStatus")
fun updateUi() {
updateRileyLinkUiElements()
updateOmipodUiElements()
}
val errors = ArrayList<String>();
@Synchronized
private fun updateRileyLinkUiElements() {
aapsLogger.info(LTag.PUMP, "OmnipodFragment.setDeviceStatus")
val rileyLinkServiceState = rileyLinkServiceData.rileyLinkServiceState
@ -220,7 +221,14 @@ class OmnipodFragment : DaggerFragment() {
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
}
omnipod_rl_status.setTextColor(if (rileyLinkServiceState.isError || rileyLinkError != null) Color.RED else Color.WHITE)
}
fun updateOmipodUiElements() {
updateLastConnectionUiElements()
updateAcknowledgeAlertsUiElements()
setVisibilityOfPodDebugButton()
val errors = ArrayList<String>();
val rileyLinkErrorInfo = omnipodPumpStatus.errorInfo
if (rileyLinkErrorInfo != null) {
errors.add(rileyLinkErrorInfo)
@ -236,6 +244,11 @@ class OmnipodFragment : DaggerFragment() {
omnipod_pod_tid.text = "-"
omnipod_pod_fw_version.text = "-"
omnipod_pod_expiry.text = "-"
omnipod_basabasalrate.text = "-"
omnipod_reservoir.text = "-"
omnipod_tempbasal.text = "-"
omnipod_lastbolus.text = "-"
omnipod_lastconnection.setTextColor(Color.WHITE)
if (podStateManager.hasPodState()) {
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_not_initalized)
} else {
@ -249,7 +262,6 @@ class OmnipodFragment : DaggerFragment() {
omnipod_pod_expiry.text = podStateManager.expiryDateAsString
val stateText: String
when {
podStateManager.hasFaultEvent() -> {
val faultEventCode = podStateManager.faultEvent.faultEventCode
@ -265,28 +277,9 @@ class OmnipodFragment : DaggerFragment() {
stateText = resourceHelper.gs(R.string.omnipod_pod_setup_in_progress, podStateManager.podProgressStatus.name)
}
}
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()
if (status.toString() == "") {
omnipod_queue.visibility = View.GONE
} else {
omnipod_queue.visibility = View.VISIBLE
omnipod_queue.text = status
}
}
// GUI functions
fun updateGUI() {
setDeviceStatus()
if (podStateManager.isPodRunning) {
updateLastConnection()
updateLastConnectionUiElements()
// last bolus
if (podStateManager.lastBolusStartTime != null && podStateManager.lastBolusAmount != null) {
@ -310,24 +303,24 @@ class OmnipodFragment : DaggerFragment() {
omnipod_reservoir.text = resourceHelper.gs(R.string.omnipod_reservoir_left, podStateManager.reservoirLevel)
warnColors.setColorInverse(omnipod_reservoir, podStateManager.reservoirLevel, 50.0, 20.0)
}
} else {
updateLastConnection()
omnipod_basabasalrate.text = "-"
omnipod_reservoir.text = "-"
omnipod_tempbasal.text = "-"
omnipod_lastbolus.text = "-"
omnipod_lastconnection.setTextColor(Color.WHITE)
}
updateAcknowledgeAlerts()
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())
setVisibilityOfPodDebugButton()
val status = commandQueue.spannedStatus()
if (status.toString() == "") {
omnipod_queue.visibility = View.GONE
} else {
omnipod_queue.visibility = View.VISIBLE
omnipod_queue.text = status
}
omnipod_refresh.isEnabled = podStateManager.isPodInitialized
omnipod_refresh.isEnabled = podStateManager.isPodInitialized && podStateManager.podProgressStatus.isAtLeast(PodProgressStatus.PAIRING_COMPLETED)
}
private fun updateLastConnection() {
if (podStateManager.isPodRunning && podStateManager.lastSuccessfulCommunication != null) { // Null check for backwards compatibility
private fun updateLastConnectionUiElements() {
if (podStateManager.isPodInitialized && podStateManager.lastSuccessfulCommunication != null) { // Null check for backwards compatibility
omnipod_lastconnection.text = readableDuration(podStateManager.lastSuccessfulCommunication)
if (omnipodPumpPlugin.isUnreachableAlertTimeoutExceeded(localAlertUtils.pumpUnreachableThreshold())) {
omnipod_lastconnection.setTextColor(Color.RED)
@ -344,6 +337,16 @@ class OmnipodFragment : DaggerFragment() {
}
}
private fun updateAcknowledgeAlertsUiElements() {
if (podStateManager.isPodInitialized && 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 = "-"
}
}
private fun readableDuration(dateTime: DateTime): String {
val min = Duration(dateTime, DateTime.now()).standardMinutes
when {
@ -368,14 +371,4 @@ class OmnipodFragment : DaggerFragment() {
}
}
private fun updateAcknowledgeAlerts() {
if (podStateManager.hasPodState() && 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 = "-"
}
}
}

View file

@ -354,7 +354,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
private void doPodCheck() {
if (System.currentTimeMillis() > this.nextPodCheck) {
if (omnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) {
if (!podStateManager.isPodRunning()) {
Notification notification = new Notification(Notification.OMNIPOD_POD_NOT_ATTACHED, resourceHelper.gs(R.string.omnipod_error_pod_not_attached), Notification.NORMAL);
rxBus.send(new EventNewNotification(notification));
} else {
@ -498,8 +498,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
@Override
public boolean isSuspended() {
return omnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod ||
!podStateManager.isPodRunning() || podStateManager.isSuspended();
return !podStateManager.isPodRunning() || podStateManager.isSuspended();
}
@Override

View file

@ -1,40 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.defs;
import info.nightscout.androidaps.R;
/**
* Created by andy on 4.8.2019
*/
// TODO remove this class and use PumpDeviceState instead
// BS: Actually, don't use PumpDeviceState in Omnipod driver at all; use PodStateManager
// If PumpDeviceState is Omnipod specific; also remove that
public enum PodDeviceState {
// FIXME
NeverContacted(R.string.medtronic_pump_status_never_contacted), //
Sleeping(R.string.medtronic_pump_status_sleeping), //
WakingUp(R.string.medtronic_pump_status_waking_up), //
Active(R.string.medtronic_pump_status_active), //
ErrorWhenCommunicating(R.string.medtronic_pump_status_error_comm), //
TimeoutWhenCommunicating(R.string.medtronic_pump_status_timeout_comm), //
// ProblemContacting(R.string.medtronic_pump_status_problem_contacting), //
PumpUnreachable(R.string.medtronic_pump_status_pump_unreachable), //
InvalidConfiguration(R.string.medtronic_pump_status_invalid_config);
Integer resourceId = null;
PodDeviceState() {
}
PodDeviceState(int resourceId) {
this.resourceId = resourceId;
}
public Integer getResourceId() {
return resourceId;
}
}

View file

@ -14,7 +14,6 @@ import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDevic
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.defs.RileyLinkTargetDevice;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
@ -23,6 +22,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
* Created by andy on 4.8.2019
*/
@Singleton
@Deprecated
public class OmnipodPumpStatus extends PumpStatus {
// TODO remove all fields that can also be obtained via PodStateManager
// We can probably get rid of this class altogether
@ -47,7 +47,6 @@ public class OmnipodPumpStatus extends PumpStatus {
public String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
public PodDeviceState podDeviceState = PodDeviceState.NeverContacted;
public boolean ackAlertsAvailable = false;
public String ackAlertsText = null;
@ -146,7 +145,6 @@ public class OmnipodPumpStatus extends PumpStatus {
", tempBasalAmount=" + tempBasalAmount +
", tempBasalLength=" + tempBasalLength +
", regexMac='" + regexMac + '\'' +
", podDeviceState=" + podDeviceState +
", lastDataTime=" + lastDataTime +
", lastConnection=" + lastConnection +
", previousConnection=" + previousConnection +

View file

@ -25,6 +25,7 @@ import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
@ -151,6 +152,9 @@ public class AapsOmnipodManager implements IOmnipodManager {
}
Disposable disposable = delegate.insertCannula(basalSchedule).subscribe(res -> //
handleSetupActionResult(podInitActionType, podInitReceiver, res, time, profile));
rxBus.send(new EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED));
return new PumpEnactResult(injector).success(true).enacted(true);
} catch (Exception ex) {
String comment = handleAndTranslateException(ex);

View file

@ -4,9 +4,8 @@ import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.pump.common.defs.DeviceCommandExecutor;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.IOmnipodManager;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
/**
* Created by andy on 4.8.2019
@ -15,20 +14,17 @@ public class OmnipodUIComm implements DeviceCommandExecutor {
private final HasAndroidInjector injector;
private final AAPSLogger aapsLogger;
private final OmnipodUtil omnipodUtil;
private final IOmnipodManager omnipodCommunicationManager;
private final OmnipodUIPostprocessor omnipodUIPostprocessor;
public OmnipodUIComm(
HasAndroidInjector injector,
AAPSLogger aapsLogger,
OmnipodUtil omnipodUtil,
OmnipodUIPostprocessor omnipodUIPostprocessor,
IOmnipodManager omnipodCommunicationManager
) {
this.injector = injector;
this.aapsLogger = aapsLogger;
this.omnipodUtil = omnipodUtil;
this.omnipodUIPostprocessor = omnipodUIPostprocessor;
this.omnipodCommunicationManager = omnipodCommunicationManager;
}
@ -40,8 +36,6 @@ public class OmnipodUIComm implements DeviceCommandExecutor {
OmnipodUITask task = new OmnipodUITask(injector, commandType, parameters);
omnipodUtil.setCurrentCommand(commandType);
// new Thread(() -> {
// LOG.warn("@@@ Start Thread");
//

View file

@ -19,6 +19,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
/**
* Created by andy on 4.8.2019
*/
// TODO remove once OmnipodPumpStatus has been removed
@Singleton
public class OmnipodUIPostprocessor {
@ -36,7 +37,6 @@ public class OmnipodUIPostprocessor {
this.rxBus = plugin.getRxBus();
}
// this is mostly intended for command that return certain statuses (Remaining Insulin, ...), and
// where responses won't be directly used
public void postProcessData(OmnipodUITask uiTask) {

View file

@ -10,15 +10,12 @@ 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.data.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.IOmnipodManager;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodResponseType;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
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.util.OmnipodUtil;
/**
@ -191,11 +188,9 @@ public class OmnipodUITask {
}
// FIXME a lot of this is not needed anymore since introducing PodStateManager
// FIXME remove once OmnipodPumpStatus has been removed
public void postProcess(OmnipodUIPostprocessor postprocessor) {
EventOmnipodDeviceStatusChange statusChange;
aapsLogger.debug(LTag.PUMP, "OmnipodUITask: @@@ postProcess. {}", commandType);
aapsLogger.debug(LTag.PUMP, "OmnipodUITask: @@@ postProcess. responseType={}", responseType);
@ -206,22 +201,12 @@ public class OmnipodUITask {
aapsLogger.debug(LTag.PUMP, "OmnipodUITask: @@@ postProcess. responseType={}", responseType);
if (responseType == PodResponseType.Invalid) {
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
"Unsupported command in OmnipodUITask");
omnipodPumpStatus.setLastFailedCommunicationToNow();
rxBus.send(statusChange);
} else if (responseType == PodResponseType.Error) {
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
errorDescription);
omnipodPumpStatus.setLastFailedCommunicationToNow();
rxBus.send(statusChange);
} else {
omnipodPumpStatus.setLastCommunicationToNow();
rxBus.send(new EventOmnipodPumpValuesChanged());
}
omnipodUtil.setPodDeviceState(PodDeviceState.Sleeping);
omnipodUtil.setCurrentCommand(null);
}

View file

@ -1,56 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.events
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange
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.omnipod.defs.OmnipodCommandType
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager
/**
* Created by andy on 4.8.2019
*/
// FIXME Remove in favor of EventRileyLinkDeviceStatusChange and EventOmnipodPumpValuesChanged
class EventOmnipodDeviceStatusChange : EventRileyLinkDeviceStatusChange {
var podStateManager: PodStateManager? = null
var podDeviceState: PodDeviceState? = null
@JvmOverloads
constructor(rileyLinkServiceState: RileyLinkServiceState?, rileyLinkError: RileyLinkError? = null) : super(rileyLinkServiceState, rileyLinkError) {
}
constructor(commandType: OmnipodCommandType?) {
}
constructor(podStateManager: PodStateManager?) {
this.podStateManager = podStateManager
}
constructor(errorDescription: String?) {
this.errorDescription = errorDescription
}
constructor(podDeviceState: PodDeviceState?, errorDescription: String?) {
this.podDeviceState = podDeviceState
this.errorDescription = errorDescription
}
constructor(pumpDeviceState: PumpDeviceState?) {
this.pumpDeviceState = pumpDeviceState
}
constructor(pumpDeviceState: PumpDeviceState?, errorDescription: String?) {
this.pumpDeviceState = pumpDeviceState
this.errorDescription = errorDescription
}
override fun toString(): String {
return ("EventOmnipodDeviceStatusChange [" //
+ "rileyLinkServiceState=" + rileyLinkServiceState
+ ", rileyLinkError=" + rileyLinkError //
+ ", podStateManager=" + podStateManager //
+ ", podDeviceState=" + podDeviceState + "]")
}
}

View file

@ -27,7 +27,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUIComm;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUIPostprocessor;
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.util.OmnipodConst;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
@ -113,12 +113,12 @@ public class RileyLinkOmnipodService extends RileyLinkService {
aapsOmnipodManager = new AapsOmnipodManager(omnipodCommunicationService, podStateManager, omnipodPumpStatus,
omnipodUtil, aapsLogger, rxBus, sp, resourceHelper, injector, activePlugin, this);
omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUtil, omnipodUIPostprocessor, aapsOmnipodManager);
omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUIPostprocessor, aapsOmnipodManager);
} else {
aapsOmnipodManager = instance;
}
rxBus.send(new EventOmnipodDeviceStatusChange(podStateManager));
rxBus.send(new EventOmnipodPumpValuesChanged());
}

View file

@ -17,17 +17,10 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
import info.nightscout.androidaps.logging.AAPSLogger;
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.omnipod.data.RLHistoryItemOmnipod;
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.PodDeviceState;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
@ -41,53 +34,24 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
public class OmnipodUtil {
private final AAPSLogger aapsLogger;
private final RxBusWrapper rxBus;
private final RileyLinkUtil rileyLinkUtil;
private final OmnipodPumpStatus omnipodPumpStatus;
private final ResourceHelper resourceHelper;
private final ActivePluginProvider activePlugins;
private final SP sp;
private boolean lowLevelDebug = true;
private OmnipodCommandType currentCommand;
private Gson gsonInstance = createGson();
private OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
@Inject
public OmnipodUtil(
AAPSLogger aapsLogger,
RxBusWrapper rxBus,
RileyLinkUtil rileyLinkUtil,
OmnipodPumpStatus omnipodPumpStatus,
SP sp,
ResourceHelper resourceHelper,
ActivePluginProvider activePlugins
ResourceHelper resourceHelper
) {
this.aapsLogger = aapsLogger;
this.rxBus = rxBus;
this.rileyLinkUtil = rileyLinkUtil;
this.omnipodPumpStatus = omnipodPumpStatus;
this.sp = sp;
this.resourceHelper = resourceHelper;
this.activePlugins = activePlugins;
}
public boolean isLowLevelDebug() {
return lowLevelDebug;
}
public void setLowLevelDebug(boolean lowLevelDebug) {
this.lowLevelDebug = lowLevelDebug;
}
public OmnipodCommandType getCurrentCommand() {
return currentCommand;
}
public void setCurrentCommand(OmnipodCommandType currentCommand) {
this.currentCommand = currentCommand;
if (currentCommand != null)
rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItemOmnipod(currentCommand));
}
public OmnipodDriverState getDriverState() {
@ -100,15 +64,6 @@ public class OmnipodUtil {
driverState = state;
omnipodPumpStatus.driverState = state;
// TODO maybe remove
// if (OmnipodUtil.omnipodPumpStatus != null) {
// OmnipodUtil.omnipodPumpStatus.driverState = state;
// }
//
// if (OmnipodUtil.omnipodPumpPlugin != null) {
// OmnipodUtil.omnipodPumpPlugin.setDriverState(state);
// }
}
private Gson createGson() {
@ -125,22 +80,6 @@ public class OmnipodUtil {
return gsonBuilder.create();
}
public void setPodDeviceState(PodDeviceState podDeviceState) {
omnipodPumpStatus.podDeviceState = podDeviceState;
}
public PodDeviceState getPodDeviceState() {
return omnipodPumpStatus.podDeviceState;
}
public void setPumpType(PumpType pumpType_) {
omnipodPumpStatus.pumpType = pumpType_;
}
public PumpType getPumpType() {
return omnipodPumpStatus.pumpType;
}
public Gson getGsonInstance() {
return this.gsonInstance;
}