Daggerize AapsPodStateManager
This commit is contained in:
parent
da2c2110da
commit
1787afda98
11 changed files with 113 additions and 132 deletions
|
@ -1,7 +1,11 @@
|
||||||
package info.nightscout.androidaps.dependencyInjection
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
|
import dagger.Provides
|
||||||
import dagger.android.ContributesAndroidInjector
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager
|
||||||
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.dialogs.PodHistoryActivity
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodHistoryActivity
|
||||||
|
@ -11,8 +15,13 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.In
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitPodRefreshAction
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitPodRefreshAction
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.PodInfoFragment
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.PodInfoFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.removepod.RemoveActionFragment
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.removepod.RemoveActionFragment
|
||||||
|
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.comm.AapsPodStateManager
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsPodStateManager
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
|
@ -31,13 +40,20 @@ abstract class OmnipodModule {
|
||||||
// Service
|
// Service
|
||||||
@ContributesAndroidInjector
|
@ContributesAndroidInjector
|
||||||
abstract fun omnipodCommunicationManagerProvider(): OmnipodCommunicationManager
|
abstract fun omnipodCommunicationManagerProvider(): OmnipodCommunicationManager
|
||||||
|
@ContributesAndroidInjector abstract fun aapsOmnipodManagerProvider(): AapsOmnipodManager
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
@ContributesAndroidInjector abstract fun omnipodUITaskProvider(): OmnipodUITask
|
@ContributesAndroidInjector abstract fun omnipodUITaskProvider(): OmnipodUITask
|
||||||
@ContributesAndroidInjector abstract fun initPodRefreshAction(): InitPodRefreshAction
|
@ContributesAndroidInjector abstract fun initPodRefreshAction(): InitPodRefreshAction
|
||||||
@ContributesAndroidInjector abstract fun podStateManager(): PodStateManager
|
@ContributesAndroidInjector abstract fun podStateManager(): PodStateManager
|
||||||
@ContributesAndroidInjector abstract fun initPodTask(): InitPodTask
|
@ContributesAndroidInjector abstract fun initPodTask(): InitPodTask
|
||||||
|
@ContributesAndroidInjector abstract fun omnipodPumpPlugin(): OmnipodPumpPlugin
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun initAapsPodStateManager(): AapsPodStateManager
|
companion object {
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun podStateManagerProvider(aapsLogger: AAPSLogger, sp: SP, omnipodPumpStatus: OmnipodPumpStatus,
|
||||||
|
rxBus: RxBusWrapper, resourceHelper: ResourceHelper): PodStateManager =
|
||||||
|
AapsPodStateManager(aapsLogger, sp, omnipodPumpStatus, rxBus, resourceHelper)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyL
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData
|
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.OmnipodStatusRequest
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState
|
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.dialogs.PodManagementActivity
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus
|
||||||
|
@ -60,6 +61,7 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
@Inject lateinit var omnipodPumpPlugin: OmnipodPumpPlugin
|
@Inject lateinit var omnipodPumpPlugin: OmnipodPumpPlugin
|
||||||
@Inject lateinit var warnColors: WarnColors
|
@Inject lateinit var warnColors: WarnColors
|
||||||
@Inject lateinit var omnipodPumpStatus: OmnipodPumpStatus
|
@Inject lateinit var omnipodPumpStatus: OmnipodPumpStatus
|
||||||
|
@Inject lateinit var podStateManager: PodStateManager
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var omnipodUtil: OmnipodUtil
|
@Inject lateinit var omnipodUtil: OmnipodUtil
|
||||||
@Inject lateinit var rileyLinkServiceData: RileyLinkServiceData
|
@Inject lateinit var rileyLinkServiceData: RileyLinkServiceData
|
||||||
|
@ -264,27 +266,27 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
omnipodPumpStatus.podAvailable = false
|
omnipodPumpStatus.podAvailable = false
|
||||||
omnipodPumpStatus.podNumber == null
|
omnipodPumpStatus.podNumber == null
|
||||||
} else if (driverState == OmnipodDriverState.Initalized_PodInitializing) {
|
} else if (driverState == OmnipodDriverState.Initalized_PodInitializing) {
|
||||||
omnipod_pod_address.text = omnipodPumpStatus.podStateManager.address.toString()
|
omnipod_pod_address.text = podStateManager.address.toString()
|
||||||
omnipod_pod_lot.text = "-"
|
omnipod_pod_lot.text = "-"
|
||||||
omnipod_pod_tid.text = "-"
|
omnipod_pod_tid.text = "-"
|
||||||
omnipod_pod_fw_version.text = "-"
|
omnipod_pod_fw_version.text = "-"
|
||||||
omnipod_pod_expiry.text = "-"
|
omnipod_pod_expiry.text = "-"
|
||||||
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_initalizing) + " (" + omnipodPumpStatus.podStateManager.getSetupProgress().name + ")"
|
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_initalizing) + " (" + podStateManager.getSetupProgress().name + ")"
|
||||||
omnipodPumpStatus.podAvailable = false
|
omnipodPumpStatus.podAvailable = false
|
||||||
omnipodPumpStatus.podNumber == omnipodPumpStatus.podStateManager.address.toString()
|
omnipodPumpStatus.podNumber == podStateManager.address.toString()
|
||||||
} else {
|
} else {
|
||||||
omnipodPumpStatus.podLotNumber = "" + omnipodPumpStatus.podStateManager.lot
|
omnipodPumpStatus.podLotNumber = "" + podStateManager.lot
|
||||||
omnipodPumpStatus.podAvailable = true
|
omnipodPumpStatus.podAvailable = true
|
||||||
omnipod_pod_address.text = omnipodPumpStatus.podStateManager.address.toString()
|
omnipod_pod_address.text = podStateManager.address.toString()
|
||||||
omnipod_pod_lot.text = if (omnipodPumpStatus.podStateManager.lot == null) "" else omnipodPumpStatus.podStateManager.lot.toString()
|
omnipod_pod_lot.text = if (podStateManager.lot == null) "" else podStateManager.lot.toString()
|
||||||
omnipod_pod_tid.text = if (omnipodPumpStatus.podStateManager.tid == null) "" else omnipodPumpStatus.podStateManager.tid.toString()
|
omnipod_pod_tid.text = if (podStateManager.tid == null) "" else podStateManager.tid.toString()
|
||||||
if (omnipodPumpStatus.podStateManager.pmVersion == null || omnipodPumpStatus.podStateManager.piVersion == null) {
|
if (podStateManager.pmVersion == null || podStateManager.piVersion == null) {
|
||||||
omnipod_pod_fw_version.text = ""
|
omnipod_pod_fw_version.text = ""
|
||||||
} else {
|
} else {
|
||||||
omnipod_pod_fw_version.text = omnipodPumpStatus.podStateManager.pmVersion.toString() + " / " + omnipodPumpStatus.podStateManager.piVersion.toString()
|
omnipod_pod_fw_version.text = podStateManager.pmVersion.toString() + " / " + podStateManager.piVersion.toString()
|
||||||
}
|
}
|
||||||
omnipod_pod_expiry.text = omnipodPumpStatus.podStateManager.expiryDateAsString
|
omnipod_pod_expiry.text = podStateManager.expiryDateAsString
|
||||||
omnipodPumpStatus.podNumber = omnipodPumpStatus.podStateManager.address.toString()
|
omnipodPumpStatus.podNumber = podStateManager.address.toString()
|
||||||
|
|
||||||
var podDeviceState = omnipodPumpStatus.podDeviceState
|
var podDeviceState = omnipodPumpStatus.podDeviceState
|
||||||
|
|
||||||
|
@ -327,13 +329,13 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (omnipodPumpStatus.podStateManager.isSetupCompleted) {
|
if (podStateManager.isSetupCompleted) {
|
||||||
if (omnipodPumpStatus.podStateManager.lastDeliveryStatus != null) {
|
if (podStateManager.lastDeliveryStatus != null) {
|
||||||
stateText += " (last delivery status: " + omnipodPumpStatus.podStateManager.lastDeliveryStatus.name + ")"
|
stateText += " (last delivery status: " + podStateManager.lastDeliveryStatus.name + ")"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (omnipodPumpStatus.podStateManager.isPaired) {
|
if (podStateManager.isPaired) {
|
||||||
stateText += " (setup progress: " + omnipodPumpStatus.podStateManager.setupProgress.name + ")"
|
stateText += " (setup progress: " + podStateManager.setupProgress.name + ")"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPumpPluginInterface, RileyLinkPumpDevice {
|
public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPumpPluginInterface, RileyLinkPumpDevice {
|
||||||
|
|
||||||
// TODO Dagger (maybe done)
|
// TODO Dagger (maybe done)
|
||||||
|
@Inject protected PodStateManager podStateManager;
|
||||||
private static OmnipodPumpPlugin plugin = null;
|
private static OmnipodPumpPlugin plugin = null;
|
||||||
private RileyLinkServiceData rileyLinkServiceData;
|
private RileyLinkServiceData rileyLinkServiceData;
|
||||||
private ServiceTaskExecutor serviceTaskExecutor;
|
private ServiceTaskExecutor serviceTaskExecutor;
|
||||||
|
@ -149,6 +150,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
PumpType.Insulet_Omnipod,
|
PumpType.Insulet_Omnipod,
|
||||||
injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy
|
injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy
|
||||||
);
|
);
|
||||||
|
injector.androidInjector().inject(this);
|
||||||
this.rileyLinkServiceData = rileyLinkServiceData;
|
this.rileyLinkServiceData = rileyLinkServiceData;
|
||||||
this.serviceTaskExecutor = serviceTaskExecutor;
|
this.serviceTaskExecutor = serviceTaskExecutor;
|
||||||
|
|
||||||
|
@ -197,6 +199,10 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
if (isOmnipodEros) {
|
if (isOmnipodEros) {
|
||||||
|
|
||||||
|
// We can't do this in PodStateManager itself, because JodaTimeAndroid.init() hasn't been called yet
|
||||||
|
// When PodStateManager is created, which causes an IllegalArgumentException for DateTimeZones not being recognized
|
||||||
|
podStateManager.loadPodState();
|
||||||
|
|
||||||
serviceConnection = new ServiceConnection() {
|
serviceConnection = new ServiceConnection() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -486,8 +492,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
@Override
|
@Override
|
||||||
public boolean isSuspended() {
|
public boolean isSuspended() {
|
||||||
|
|
||||||
return (omnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) ||
|
return omnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod ||
|
||||||
(omnipodUtil.getPodStateManager().hasState() && omnipodUtil.getPodStateManager().isSuspended());
|
!podStateManager.isSetupCompleted() || podStateManager.isSuspended();
|
||||||
|
|
||||||
// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) ||
|
// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) ||
|
||||||
// (omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended());
|
// (omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended());
|
||||||
|
@ -613,8 +619,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
|
|
||||||
private void initializePump(boolean realInit) {
|
private void initializePump(boolean realInit) {
|
||||||
|
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMP, getLogPrefix() + "initializePump - start");
|
aapsLogger.info(LTag.PUMP, getLogPrefix() + "initializePump - start");
|
||||||
|
|
||||||
// TODO ccc
|
// TODO ccc
|
||||||
|
@ -622,7 +626,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
setRefreshButtonEnabled(false);
|
setRefreshButtonEnabled(false);
|
||||||
|
|
||||||
PodStateManager podStateManager = omnipodUtil.getPodStateManager();
|
|
||||||
if (podStateManager.isPaired()) {
|
if (podStateManager.isPaired()) {
|
||||||
aapsLogger.debug(LTag.PUMP, "PodStateManager (saved): " + podStateManager);
|
aapsLogger.debug(LTag.PUMP, "PodStateManager (saved): " + podStateManager);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ 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;
|
||||||
|
|
|
@ -15,6 +15,7 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.defs.PodActionType
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.defs.PodActionType
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.model.FullInitPodWizardModel
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.model.FullInitPodWizardModel
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.model.RemovePodWizardModel
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.model.RemovePodWizardModel
|
||||||
|
@ -42,6 +43,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
@Inject lateinit var omnipodUtil: OmnipodUtil
|
@Inject lateinit var omnipodUtil: OmnipodUtil
|
||||||
|
@Inject lateinit var podStateManager: PodStateManager
|
||||||
@Inject lateinit var injector: HasAndroidInjector
|
@Inject lateinit var injector: HasAndroidInjector
|
||||||
|
|
||||||
private var initPodChanged = false
|
private var initPodChanged = false
|
||||||
|
@ -98,7 +100,6 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
wizardPagerContext.clearContext()
|
wizardPagerContext.clearContext()
|
||||||
wizardPagerContext.pagerSettings = pagerSettings
|
wizardPagerContext.pagerSettings = pagerSettings
|
||||||
val podStateManager = omnipodUtil.getPodStateManager()
|
|
||||||
val isFullInit = !podStateManager.isPaired || podStateManager.setupProgress.isBefore(SetupProgress.PRIMING_FINISHED)
|
val isFullInit = !podStateManager.isPaired || podStateManager.setupProgress.isBefore(SetupProgress.PRIMING_FINISHED)
|
||||||
if (isFullInit) {
|
if (isFullInit) {
|
||||||
wizardPagerContext.wizardModel = FullInitPodWizardModel(applicationContext)
|
wizardPagerContext.wizardModel = FullInitPodWizardModel(applicationContext)
|
||||||
|
@ -150,11 +151,11 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refreshButtons() {
|
fun refreshButtons() {
|
||||||
initpod_init_pod.isEnabled = !omnipodUtil.podStateManager.isPaired() ||
|
initpod_init_pod.isEnabled = !podStateManager.isPaired() ||
|
||||||
omnipodUtil.getPodStateManager().getSetupProgress().isBefore(SetupProgress.COMPLETED)
|
podStateManager.getSetupProgress().isBefore(SetupProgress.COMPLETED)
|
||||||
|
|
||||||
initpod_remove_pod.isEnabled = omnipodUtil.podStateManager.hasState() && omnipodUtil.podStateManager.isPaired
|
initpod_remove_pod.isEnabled = podStateManager.hasState() && podStateManager.isPaired
|
||||||
initpod_reset_pod.isEnabled = omnipodUtil.podStateManager.hasState()
|
initpod_reset_pod.isEnabled = podStateManager.hasState()
|
||||||
|
|
||||||
if (omnipodUtil.getDriverState() == OmnipodDriverState.NotInitalized) {
|
if (omnipodUtil.getDriverState() == OmnipodDriverState.NotInitalized) {
|
||||||
// if rileylink is not running we disable all operations
|
// if rileylink is not running we disable all operations
|
||||||
|
|
|
@ -16,6 +16,7 @@ import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity;
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.defs.PodActionType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.defs.PodActionType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState;
|
||||||
|
@ -33,6 +34,7 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish
|
||||||
private PodActionType actionType;
|
private PodActionType actionType;
|
||||||
|
|
||||||
@Inject OmnipodUtil omnipodUtil;
|
@Inject OmnipodUtil omnipodUtil;
|
||||||
|
@Inject PodStateManager podStateManager;
|
||||||
@Inject AAPSLogger aapsLogger;
|
@Inject AAPSLogger aapsLogger;
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
|
|
||||||
|
@ -58,7 +60,7 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if (actionType == PodActionType.InitPod) {
|
if (actionType == PodActionType.InitPod) {
|
||||||
if (omnipodUtil.getPodStateManager().getSetupProgress().isBefore(SetupProgress.COMPLETED)) {
|
if (podStateManager.getSetupProgress().isBefore(SetupProgress.COMPLETED)) {
|
||||||
omnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodInitializing);
|
omnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodInitializing);
|
||||||
} else {
|
} else {
|
||||||
omnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodAttached);
|
omnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodAttached);
|
||||||
|
|
|
@ -30,6 +30,7 @@ public class PodInfoFragment extends DaggerFragment {
|
||||||
private static final String ARG_KEY = "key";
|
private static final String ARG_KEY = "key";
|
||||||
|
|
||||||
@Inject OmnipodUtil omnipodUtil;
|
@Inject OmnipodUtil omnipodUtil;
|
||||||
|
@Inject PodStateManager podStateManager;
|
||||||
|
|
||||||
private PageFragmentCallbacks mCallbacks;
|
private PageFragmentCallbacks mCallbacks;
|
||||||
private String mKey;
|
private String mKey;
|
||||||
|
@ -84,9 +85,6 @@ public class PodInfoFragment extends DaggerFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean createDataOfPod() {
|
private boolean createDataOfPod() {
|
||||||
|
|
||||||
PodStateManager podStateManager = omnipodUtil.getPodStateManager();
|
|
||||||
|
|
||||||
if (podStateManager == null)
|
if (podStateManager == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -96,7 +94,7 @@ public class PodInfoFragment extends DaggerFragment {
|
||||||
if (podStateManager.getLot() != null) {
|
if (podStateManager.getLot() != null) {
|
||||||
mCurrentReviewItems.add(new ReviewItem("LOT", "" + podStateManager.getLot(), "35"));
|
mCurrentReviewItems.add(new ReviewItem("LOT", "" + podStateManager.getLot(), "35"));
|
||||||
}
|
}
|
||||||
if(podStateManager.getTid() != null) {
|
if (podStateManager.getTid() != null) {
|
||||||
mCurrentReviewItems.add(new ReviewItem("TID", "" + podStateManager.getLot(), "36"));
|
mCurrentReviewItems.add(new ReviewItem("TID", "" + podStateManager.getLot(), "36"));
|
||||||
}
|
}
|
||||||
if (podStateManager.getPiVersion() != null) {
|
if (podStateManager.getPiVersion() != null) {
|
||||||
|
|
|
@ -16,7 +16,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
|
||||||
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;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange;
|
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange;
|
||||||
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;
|
||||||
|
@ -46,7 +45,6 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
public Double tempBasalAmount = 0.0d;
|
public Double tempBasalAmount = 0.0d;
|
||||||
public Integer tempBasalLength;
|
public Integer tempBasalLength;
|
||||||
public long tempBasalPumpId;
|
public long tempBasalPumpId;
|
||||||
public PodStateManager podStateManager;
|
|
||||||
public PumpType pumpType;
|
public PumpType pumpType;
|
||||||
|
|
||||||
public String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
public String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
||||||
|
@ -141,7 +139,6 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
", tempBasalEnd=" + tempBasalEnd +
|
", tempBasalEnd=" + tempBasalEnd +
|
||||||
", tempBasalAmount=" + tempBasalAmount +
|
", tempBasalAmount=" + tempBasalAmount +
|
||||||
", tempBasalLength=" + tempBasalLength +
|
", tempBasalLength=" + tempBasalLength +
|
||||||
", podStateManager=" + podStateManager +
|
|
||||||
", regexMac='" + regexMac + '\'' +
|
", regexMac='" + regexMac + '\'' +
|
||||||
", podNumber='" + podNumber + '\'' +
|
", podNumber='" + podNumber + '\'' +
|
||||||
", podDeviceState=" + podDeviceState +
|
", podDeviceState=" + podDeviceState +
|
||||||
|
|
|
@ -9,6 +9,9 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.Event;
|
import info.nightscout.androidaps.events.Event;
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
|
@ -21,24 +24,23 @@ 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.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.plugins.pump.omnipod.util.OmnipodUtil;
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class AapsPodStateManager extends PodStateManager {
|
public class AapsPodStateManager extends PodStateManager {
|
||||||
|
|
||||||
private final AAPSLogger aapsLogger;
|
private final AAPSLogger aapsLogger;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final OmnipodUtil omnipodUtil;
|
|
||||||
private final OmnipodPumpStatus omnipodPumpStatus;
|
private final OmnipodPumpStatus omnipodPumpStatus;
|
||||||
private final RxBusWrapper rxBus;
|
private final RxBusWrapper rxBus;
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
|
|
||||||
public AapsPodStateManager(AAPSLogger aapsLogger, SP sp, OmnipodUtil omnipodUtil,
|
@Inject
|
||||||
OmnipodPumpStatus omnipodPumpStatus, RxBusWrapper rxBus,
|
public AapsPodStateManager(AAPSLogger aapsLogger, SP sp, OmnipodPumpStatus omnipodPumpStatus,
|
||||||
ResourceHelper resourceHelper) {
|
RxBusWrapper rxBus, ResourceHelper resourceHelper) {
|
||||||
super(aapsLogger);
|
super(aapsLogger);
|
||||||
|
|
||||||
if (aapsLogger == null) {
|
if (aapsLogger == null) {
|
||||||
|
@ -47,9 +49,6 @@ public class AapsPodStateManager extends PodStateManager {
|
||||||
if (sp == null) {
|
if (sp == null) {
|
||||||
throw new IllegalArgumentException("sp can not be null");
|
throw new IllegalArgumentException("sp can not be null");
|
||||||
}
|
}
|
||||||
if (omnipodUtil == null) {
|
|
||||||
throw new IllegalArgumentException("omnipodUtil can not be null");
|
|
||||||
}
|
|
||||||
if (omnipodPumpStatus == null) {
|
if (omnipodPumpStatus == null) {
|
||||||
throw new IllegalArgumentException("omnipodPumpStatus can not be null");
|
throw new IllegalArgumentException("omnipodPumpStatus can not be null");
|
||||||
}
|
}
|
||||||
|
@ -62,7 +61,6 @@ public class AapsPodStateManager extends PodStateManager {
|
||||||
|
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
this.omnipodUtil = omnipodUtil;
|
|
||||||
this.omnipodPumpStatus = omnipodPumpStatus;
|
this.omnipodPumpStatus = omnipodPumpStatus;
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
|
@ -80,58 +78,56 @@ public class AapsPodStateManager extends PodStateManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void notifyPodStateChanged() {
|
protected void notifyPodStateChanged() {
|
||||||
if (omnipodPumpStatus != null) {
|
if (!hasState()) {
|
||||||
if (!hasState()) {
|
omnipodPumpStatus.ackAlertsText = null;
|
||||||
omnipodPumpStatus.ackAlertsText = null;
|
omnipodPumpStatus.ackAlertsAvailable = false;
|
||||||
omnipodPumpStatus.ackAlertsAvailable = false;
|
omnipodPumpStatus.lastBolusTime = null;
|
||||||
omnipodPumpStatus.lastBolusTime = null;
|
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 EventOmnipodAcknowledgeAlertsChanged());
|
sendEvent(new EventOmnipodPumpValuesChanged());
|
||||||
sendEvent(new EventOmnipodPumpValuesChanged());
|
sendEvent(new EventRefreshOverview("Omnipod Pump", false));
|
||||||
sendEvent(new EventRefreshOverview("Omnipod Pump", false));
|
} else {
|
||||||
} else {
|
// Update active alerts
|
||||||
// Update active alerts
|
if (hasActiveAlerts()) {
|
||||||
if (hasActiveAlerts()) {
|
List<String> alerts = getTranslatedActiveAlerts();
|
||||||
List<String> alerts = getTranslatedActiveAlerts();
|
String alertsText = TextUtils.join("\n", alerts);
|
||||||
String alertsText = TextUtils.join("\n", alerts);
|
|
||||||
|
|
||||||
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());
|
sendEvent(new EventOmnipodAcknowledgeAlertsChanged());
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (omnipodPumpStatus.ackAlertsAvailable || StringUtils.isNotEmpty(omnipodPumpStatus.ackAlertsText)) {
|
|
||||||
omnipodPumpStatus.ackAlertsText = null;
|
|
||||||
omnipodPumpStatus.ackAlertsAvailable = false;
|
|
||||||
sendEvent(new EventOmnipodAcknowledgeAlertsChanged());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (omnipodPumpStatus.ackAlertsAvailable || StringUtils.isNotEmpty(omnipodPumpStatus.ackAlertsText)) {
|
||||||
|
omnipodPumpStatus.ackAlertsText = null;
|
||||||
|
omnipodPumpStatus.ackAlertsAvailable = false;
|
||||||
|
sendEvent(new EventOmnipodAcknowledgeAlertsChanged());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Date lastBolusStartTime = getLastBolusStartTime() == null ? null : getLastBolusStartTime().toDate();
|
Date lastBolusStartTime = getLastBolusStartTime() == null ? null : getLastBolusStartTime().toDate();
|
||||||
Double lastBolusAmount = getLastBolusAmount();
|
Double lastBolusAmount = getLastBolusAmount();
|
||||||
|
|
||||||
// Update other info: last bolus, units remaining, suspended
|
// Update other info: last bolus, units remaining, suspended
|
||||||
if (Objects.equals(lastBolusStartTime, omnipodPumpStatus.lastBolusTime) //
|
if (Objects.equals(lastBolusStartTime, omnipodPumpStatus.lastBolusTime) //
|
||||||
|| !Objects.equals(lastBolusAmount, omnipodPumpStatus.lastBolusAmount) //
|
|| !Objects.equals(lastBolusAmount, omnipodPumpStatus.lastBolusAmount) //
|
||||||
|| !isReservoirStatusUpToDate(omnipodPumpStatus, getReservoirLevel())
|
|| !isReservoirStatusUpToDate(omnipodPumpStatus, getReservoirLevel())
|
||||||
|| isSuspended() != PumpStatusType.Suspended.equals(omnipodPumpStatus.pumpStatusType)) {
|
|| isSuspended() != PumpStatusType.Suspended.equals(omnipodPumpStatus.pumpStatusType)) {
|
||||||
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();
|
||||||
omnipodPumpStatus.pumpStatusType = isSuspended() ? PumpStatusType.Suspended : PumpStatusType.Running;
|
omnipodPumpStatus.pumpStatusType = isSuspended() ? PumpStatusType.Suspended : PumpStatusType.Running;
|
||||||
sendEvent(new EventOmnipodPumpValuesChanged());
|
sendEvent(new EventOmnipodPumpValuesChanged());
|
||||||
|
|
||||||
if (isSuspended() != PumpStatusType.Suspended.equals(omnipodPumpStatus.pumpStatusType)) {
|
if (isSuspended() != PumpStatusType.Suspended.equals(omnipodPumpStatus.pumpStatusType)) {
|
||||||
sendEvent(new EventRefreshOverview("Omnipod Pump", false));
|
sendEvent(new EventRefreshOverview("Omnipod Pump", false));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
omnipodUtil.notifyDeviceStatusChanged();
|
rxBus.send(new EventOmnipodDeviceStatusChange(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getTranslatedActiveAlerts() {
|
private List<String> getTranslatedActiveAlerts() {
|
||||||
|
|
|
@ -7,6 +7,8 @@ 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;
|
||||||
|
@ -26,9 +28,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunication
|
||||||
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.driver.comm.AapsOmnipodManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsPodStateManager;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUIComm;
|
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.driver.ui.OmnipodUIPostprocessor;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||||
|
|
||||||
|
@ -43,6 +45,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
@Inject OmnipodPumpStatus omnipodPumpStatus;
|
@Inject OmnipodPumpStatus omnipodPumpStatus;
|
||||||
@Inject OmnipodUtil omnipodUtil;
|
@Inject OmnipodUtil omnipodUtil;
|
||||||
@Inject OmnipodUIPostprocessor omnipodUIPostprocessor;
|
@Inject OmnipodUIPostprocessor omnipodUIPostprocessor;
|
||||||
|
@Inject PodStateManager podStateManager;
|
||||||
|
|
||||||
private static RileyLinkOmnipodService instance;
|
private static RileyLinkOmnipodService instance;
|
||||||
|
|
||||||
|
@ -60,12 +63,10 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static RileyLinkOmnipodService getInstance() {
|
public static RileyLinkOmnipodService getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
aapsLogger.warn(LTag.PUMPCOMM, "onConfigurationChanged");
|
aapsLogger.warn(LTag.PUMPCOMM, "onConfigurationChanged");
|
||||||
|
@ -109,12 +110,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
private void initializeErosOmnipodManager() {
|
private void initializeErosOmnipodManager() {
|
||||||
AapsOmnipodManager instance = AapsOmnipodManager.getInstance();
|
AapsOmnipodManager instance = AapsOmnipodManager.getInstance();
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
PodStateManager podStateManager = new AapsPodStateManager(aapsLogger, sp, omnipodUtil, omnipodPumpStatus, rxBus, resourceHelper);
|
|
||||||
podStateManager.loadPodState();
|
|
||||||
omnipodUtil.setPodStateManager(podStateManager);
|
|
||||||
|
|
||||||
OmnipodCommunicationManager omnipodCommunicationService = new OmnipodCommunicationManager(injector, rfspy);
|
OmnipodCommunicationManager omnipodCommunicationService = new OmnipodCommunicationManager(injector, rfspy);
|
||||||
//omnipodCommunicationService.setPumpStatus(omnipodPumpStatus);
|
|
||||||
this.omnipodCommunicationManager = omnipodCommunicationService;
|
this.omnipodCommunicationManager = omnipodCommunicationService;
|
||||||
|
|
||||||
aapsOmnipodManager = new AapsOmnipodManager(omnipodCommunicationService, podStateManager, omnipodPumpStatus,
|
aapsOmnipodManager = new AapsOmnipodManager(omnipodCommunicationService, podStateManager, omnipodPumpStatus,
|
||||||
|
@ -123,10 +119,9 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUtil, omnipodUIPostprocessor, aapsOmnipodManager);
|
omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUtil, omnipodUIPostprocessor, aapsOmnipodManager);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
omnipodUtil.setPodStateManager(instance.getPodStateManager());
|
|
||||||
aapsOmnipodManager = instance;
|
aapsOmnipodManager = instance;
|
||||||
}
|
}
|
||||||
omnipodUtil.notifyDeviceStatusChanged();
|
rxBus.send(new EventOmnipodDeviceStatusChange(podStateManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -52,13 +52,13 @@ public class OmnipodUtil {
|
||||||
private OmnipodPodType omnipodPodType;
|
private OmnipodPodType omnipodPodType;
|
||||||
private OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
|
private OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public OmnipodUtil(
|
public OmnipodUtil(
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
RxBusWrapper rxBus,
|
RxBusWrapper rxBus,
|
||||||
RileyLinkUtil rileyLinkUtil,
|
RileyLinkUtil rileyLinkUtil,
|
||||||
OmnipodPumpStatus omnipodPumpStatus,
|
OmnipodPumpStatus omnipodPumpStatus,
|
||||||
|
PodStateManager podStateManager,
|
||||||
SP sp,
|
SP sp,
|
||||||
ActivePluginProvider activePlugins
|
ActivePluginProvider activePlugins
|
||||||
) {
|
) {
|
||||||
|
@ -70,22 +70,18 @@ public class OmnipodUtil {
|
||||||
this.activePlugins = activePlugins;
|
this.activePlugins = activePlugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isLowLevelDebug() {
|
public boolean isLowLevelDebug() {
|
||||||
return lowLevelDebug;
|
return lowLevelDebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setLowLevelDebug(boolean lowLevelDebug) {
|
public void setLowLevelDebug(boolean lowLevelDebug) {
|
||||||
this.lowLevelDebug = lowLevelDebug;
|
this.lowLevelDebug = lowLevelDebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public OmnipodCommandType getCurrentCommand() {
|
public OmnipodCommandType getCurrentCommand() {
|
||||||
return currentCommand;
|
return currentCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setCurrentCommand(OmnipodCommandType currentCommand) {
|
public void setCurrentCommand(OmnipodCommandType currentCommand) {
|
||||||
this.currentCommand = currentCommand;
|
this.currentCommand = currentCommand;
|
||||||
|
|
||||||
|
@ -100,12 +96,10 @@ public class OmnipodUtil {
|
||||||
MainApp.gs(R.string.omnipod_error_operation_not_possible_no_configuration), (Runnable) null);
|
MainApp.gs(R.string.omnipod_error_operation_not_possible_no_configuration), (Runnable) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public OmnipodDriverState getDriverState() {
|
public OmnipodDriverState getDriverState() {
|
||||||
return driverState;
|
return driverState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setDriverState(OmnipodDriverState state) {
|
public void setDriverState(OmnipodDriverState state) {
|
||||||
if (driverState == state)
|
if (driverState == state)
|
||||||
return;
|
return;
|
||||||
|
@ -123,7 +117,6 @@ public class OmnipodUtil {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Gson createGson() {
|
private Gson createGson() {
|
||||||
GsonBuilder gsonBuilder = new GsonBuilder()
|
GsonBuilder gsonBuilder = new GsonBuilder()
|
||||||
.registerTypeAdapter(DateTime.class, (JsonSerializer<DateTime>) (dateTime, typeOfSrc, context) ->
|
.registerTypeAdapter(DateTime.class, (JsonSerializer<DateTime>) (dateTime, typeOfSrc, context) ->
|
||||||
|
@ -138,16 +131,8 @@ public class OmnipodUtil {
|
||||||
return gsonBuilder.create();
|
return gsonBuilder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPodStateManager(PodStateManager podStateManager) {
|
|
||||||
if (podStateManager == null) {
|
|
||||||
throw new IllegalArgumentException("Pod state manager can not be null");
|
|
||||||
}
|
|
||||||
omnipodPumpStatus.podStateManager = podStateManager;
|
|
||||||
notifyDeviceStatusChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void notifyDeviceStatusChanged() {
|
public void notifyDeviceStatusChanged() {
|
||||||
rxBus.send(new EventOmnipodDeviceStatusChange(omnipodPumpStatus.podStateManager));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,41 +140,26 @@ public class OmnipodUtil {
|
||||||
omnipodPumpStatus.podDeviceState = podDeviceState;
|
omnipodPumpStatus.podDeviceState = podDeviceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setOmnipodPodType(OmnipodPodType omnipodPodType) {
|
public void setOmnipodPodType(OmnipodPodType omnipodPodType) {
|
||||||
this.omnipodPodType = omnipodPodType;
|
this.omnipodPodType = omnipodPodType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public OmnipodPodType getOmnipodPodType() {
|
public OmnipodPodType getOmnipodPodType() {
|
||||||
return this.omnipodPodType;
|
return this.omnipodPodType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PodDeviceState getPodDeviceState() {
|
public PodDeviceState getPodDeviceState() {
|
||||||
return omnipodPumpStatus.podDeviceState;
|
return omnipodPumpStatus.podDeviceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PodStateManager getPodStateManager() {
|
|
||||||
if (omnipodPumpStatus.podStateManager == null) {
|
|
||||||
aapsLogger.error("OmnipodUtil.getPodStateManager was called, but podStateManager is null");
|
|
||||||
throw new IllegalStateException("Pod state manager is null");
|
|
||||||
}
|
|
||||||
return omnipodPumpStatus.podStateManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isOmnipodEros() {
|
public boolean isOmnipodEros() {
|
||||||
return this.activePlugins.getActivePump().model() == PumpType.Insulet_Omnipod;
|
return this.activePlugins.getActivePump().model() == PumpType.Insulet_Omnipod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isOmnipodDash() {
|
public boolean isOmnipodDash() {
|
||||||
return this.activePlugins.getActivePump().model() == PumpType.Insulet_Omnipod_Dash;
|
return this.activePlugins.getActivePump().model() == PumpType.Insulet_Omnipod_Dash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setPumpType(PumpType pumpType_) {
|
public void setPumpType(PumpType pumpType_) {
|
||||||
omnipodPumpStatus.pumpType = pumpType_;
|
omnipodPumpStatus.pumpType = pumpType_;
|
||||||
}
|
}
|
||||||
|
@ -198,7 +168,6 @@ public class OmnipodUtil {
|
||||||
return omnipodPumpStatus.pumpType;
|
return omnipodPumpStatus.pumpType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Gson getGsonInstance() {
|
public Gson getGsonInstance() {
|
||||||
return this.gsonInstance;
|
return this.gsonInstance;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue