- daggerizing omnipod
This commit is contained in:
parent
b1a220499d
commit
4d39cbba95
53 changed files with 962 additions and 621 deletions
|
@ -39,6 +39,8 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.Radi
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.*
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.*
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment
|
import info.nightscout.androidaps.plugins.treatments.Treatment
|
||||||
import info.nightscout.androidaps.queue.CommandQueue
|
import info.nightscout.androidaps.queue.CommandQueue
|
||||||
import info.nightscout.androidaps.queue.commands.*
|
import info.nightscout.androidaps.queue.commands.*
|
||||||
|
@ -195,7 +197,7 @@ interface AppComponent : AndroidInjector<MainApp> {
|
||||||
|
|
||||||
fun injectGraphData(graphData: GraphData)
|
fun injectGraphData(graphData: GraphData)
|
||||||
|
|
||||||
//Medtronic
|
// Medtronic
|
||||||
fun injectRileyLinkCommunicationManager(rileyLinkCommunicationManager: RileyLinkCommunicationManager)
|
fun injectRileyLinkCommunicationManager(rileyLinkCommunicationManager: RileyLinkCommunicationManager)
|
||||||
fun injectMedtronicCommunicationManager(medtronicCommunicationManager: MedtronicCommunicationManager)
|
fun injectMedtronicCommunicationManager(medtronicCommunicationManager: MedtronicCommunicationManager)
|
||||||
fun injectMedtronicUITask(medtronicUITask: MedtronicUITask)
|
fun injectMedtronicUITask(medtronicUITask: MedtronicUITask)
|
||||||
|
@ -211,6 +213,11 @@ interface AppComponent : AndroidInjector<MainApp> {
|
||||||
fun injectSendAndListen(sendAndListen: SendAndListen)
|
fun injectSendAndListen(sendAndListen: SendAndListen)
|
||||||
fun injectSetPreamble(setPreamble: SetPreamble)
|
fun injectSetPreamble(setPreamble: SetPreamble)
|
||||||
fun injectRadioPacket(radioPacket: RadioPacket)
|
fun injectRadioPacket(radioPacket: RadioPacket)
|
||||||
|
fun injectOmnipodUITask(omnipodUITask: OmnipodUITask)
|
||||||
|
|
||||||
|
|
||||||
|
// Omnipod
|
||||||
|
fun injectOmnipodCommunicationManager(omnipodCommunicationManager: OmnipodCommunicationManager)
|
||||||
|
|
||||||
@Component.Builder
|
@Component.Builder
|
||||||
interface Builder {
|
interface Builder {
|
||||||
|
|
|
@ -56,6 +56,8 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.Radi
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.*
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.*
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment
|
import info.nightscout.androidaps.plugins.treatments.Treatment
|
||||||
import info.nightscout.androidaps.queue.CommandQueue
|
import info.nightscout.androidaps.queue.CommandQueue
|
||||||
import info.nightscout.androidaps.queue.commands.*
|
import info.nightscout.androidaps.queue.commands.*
|
||||||
|
@ -307,6 +309,8 @@ open class AppModule {
|
||||||
|
|
||||||
// Omnipod
|
// Omnipod
|
||||||
@ContributesAndroidInjector fun aapsOmnipodManagerInjector(): AapsOmnipodManager
|
@ContributesAndroidInjector fun aapsOmnipodManagerInjector(): AapsOmnipodManager
|
||||||
|
@ContributesAndroidInjector fun omnipodCommunicationManagerProvider(): OmnipodCommunicationManager
|
||||||
|
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider
|
fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider
|
||||||
|
|
|
@ -38,6 +38,7 @@ import info.nightscout.androidaps.plugins.pump.danaR.DanaRFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightFragment
|
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.RileyLinkStatusDeviceMedtronic
|
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.RileyLinkStatusDeviceMedtronic
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpFragment
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpFragment
|
||||||
import info.nightscout.androidaps.plugins.source.BGSourceFragment
|
import info.nightscout.androidaps.plugins.source.BGSourceFragment
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsFragment
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsFragment
|
||||||
|
|
|
@ -44,6 +44,7 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
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;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
@ -57,11 +58,14 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpInterface, ConstraintsInterface {
|
public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpInterface, ConstraintsInterface {
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
protected HasAndroidInjector injector;
|
||||||
protected AAPSLogger aapsLogger;
|
protected AAPSLogger aapsLogger;
|
||||||
protected RxBusWrapper rxBus;
|
protected RxBusWrapper rxBus;
|
||||||
protected ActivePluginProvider activePlugin;
|
protected ActivePluginProvider activePlugin;
|
||||||
protected Context context;
|
protected Context context;
|
||||||
protected FabricPrivacy fabricPrivacy;
|
protected FabricPrivacy fabricPrivacy;
|
||||||
|
protected ResourceHelper resourceHelper;
|
||||||
|
protected CommandQueueProvider commandQueue;
|
||||||
protected SP sp;
|
protected SP sp;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -99,7 +103,9 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
||||||
this.activePlugin = activePlugin;
|
this.activePlugin = activePlugin;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.fabricPrivacy = fabricPrivacy;
|
this.fabricPrivacy = fabricPrivacy;
|
||||||
|
this.resourceHelper = resourceHelper;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
|
this.commandQueue = commandQueue;
|
||||||
|
|
||||||
pumpDescription.setPumpDescription(pumpType);
|
pumpDescription.setPumpDescription(pumpType);
|
||||||
this.pumpType = pumpType;
|
this.pumpType = pumpType;
|
||||||
|
@ -109,12 +115,6 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
||||||
|
|
||||||
public abstract void initPumpStatusData();
|
public abstract void initPumpStatusData();
|
||||||
|
|
||||||
public abstract void resetRileyLinkConfiguration();
|
|
||||||
|
|
||||||
public abstract void doTuneUpDevice();
|
|
||||||
|
|
||||||
public abstract RileyLinkService getRileyLinkService();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
@ -464,6 +464,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
||||||
|
|
||||||
public void setPumpType(PumpType pumpType) {
|
public void setPumpType(PumpType pumpType) {
|
||||||
this.pumpType = pumpType;
|
this.pumpType = pumpType;
|
||||||
|
this.pumpDescription.setPumpDescription(pumpType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,14 @@ package info.nightscout.androidaps.plugins.pump.common.data;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 4/28/18.
|
* Created by andy on 4/28/18.
|
||||||
|
@ -13,6 +18,8 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
|
||||||
public abstract class PumpStatus {
|
public abstract class PumpStatus {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// connection
|
// connection
|
||||||
public long lastDataTime;
|
public long lastDataTime;
|
||||||
public long lastConnection = 0L;
|
public long lastConnection = 0L;
|
||||||
|
@ -49,16 +56,20 @@ public abstract class PumpStatus {
|
||||||
public int tempBasalRatio = 0;
|
public int tempBasalRatio = 0;
|
||||||
public int tempBasalRemainMin = 0;
|
public int tempBasalRemainMin = 0;
|
||||||
public Date tempBasalStart;
|
public Date tempBasalStart;
|
||||||
|
private PumpType pumpType;
|
||||||
//protected PumpDescription pumpDescription;
|
//protected PumpDescription pumpDescription;
|
||||||
|
|
||||||
|
|
||||||
public PumpStatus() {
|
public PumpStatus(PumpType pumpType) {
|
||||||
// public PumpStatus(PumpDescription pumpDescription) {
|
// public PumpStatus(PumpDescription pumpDescription) {
|
||||||
// this.pumpDescription = pumpDescription;
|
// this.pumpDescription = pumpDescription;
|
||||||
|
|
||||||
// this.initSettings();
|
// this.initSettings();
|
||||||
|
this.pumpType = pumpType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void initSettings();
|
||||||
|
|
||||||
|
|
||||||
public void setLastCommunicationToNow() {
|
public void setLastCommunicationToNow() {
|
||||||
this.lastDataTime = DateUtil.now();
|
this.lastDataTime = DateUtil.now();
|
||||||
|
|
|
@ -41,14 +41,22 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
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.common.ManufacturerType;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.GattAttributes;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.GattAttributes;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.LocationHelper;
|
import info.nightscout.androidaps.plugins.pump.common.utils.LocationHelper;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpConfigurationChanged;
|
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpConfigurationChanged;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@ -61,7 +69,7 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
||||||
@Inject ResourceHelper resourceHelper;
|
@Inject ResourceHelper resourceHelper;
|
||||||
@Inject RileyLinkUtil rileyLinkUtil;
|
@Inject RileyLinkUtil rileyLinkUtil;
|
||||||
// TODO change this. Currently verifyConfiguration uses MDT data not only RL
|
// TODO change this. Currently verifyConfiguration uses MDT data not only RL
|
||||||
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
// @Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
||||||
@Inject ActivePluginProvider activePlugin;
|
@Inject ActivePluginProvider activePlugin;
|
||||||
|
|
||||||
private static final int PERMISSION_REQUEST_COARSE_LOCATION = 30241; // arbitrary.
|
private static final int PERMISSION_REQUEST_COARSE_LOCATION = 30241; // arbitrary.
|
||||||
|
@ -113,16 +121,25 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
||||||
|
|
||||||
//RileyLinkUtil.getRileyLinkSelectPreference().setSummary(bleAddress);
|
//RileyLinkUtil.getRileyLinkSelectPreference().setSummary(bleAddress);
|
||||||
|
|
||||||
if (activePlugin.getActivePump().manufacturer()== ManufacturerType.Medtronic) {
|
// TODO refactor this
|
||||||
medtronicPumpPlugin.getRileyLinkService().verifyConfiguration(); // force reloading of address
|
|
||||||
|
PumpInterface activePump = activePlugin.getActivePump();
|
||||||
|
|
||||||
|
if (activePump.manufacturer()== ManufacturerType.Medtronic) {
|
||||||
|
RileyLinkPumpDevice rileyLinkPump = (RileyLinkPumpDevice)activePump;
|
||||||
|
rileyLinkPump.getRileyLinkService().verifyConfiguration(); // force reloading of address
|
||||||
|
|
||||||
rxBus.send(new EventMedtronicPumpConfigurationChanged());
|
rxBus.send(new EventMedtronicPumpConfigurationChanged());
|
||||||
|
|
||||||
} else if (activePlugin.getActivePump().manufacturer()== ManufacturerType.Insulet) {
|
} else if (activePlugin.getActivePump().manufacturer()== ManufacturerType.Insulet) {
|
||||||
OmnipodPumpStatus pumpStatus = OmnipodUtil.getPumpStatus();
|
if (activePump.model()== PumpType.Insulet_Omnipod_Dash) {
|
||||||
pumpStatus.verifyConfiguration();
|
aapsLogger.error("Omnipod Dash not yet implemented.");
|
||||||
|
} else {
|
||||||
|
RileyLinkPumpDevice rileyLinkPump = (RileyLinkPumpDevice)activePump;
|
||||||
|
rileyLinkPump.getRileyLinkService().verifyConfiguration(); // force reloading of address
|
||||||
|
|
||||||
rxBus.send(new EventOmnipodPumpValuesChanged());
|
rxBus.send(new EventOmnipodPumpValuesChanged());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
|
|
|
@ -22,6 +22,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
|
import info.nightscout.androidaps.utils.Round;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +35,7 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
@Inject protected AAPSLogger aapsLogger;
|
@Inject protected AAPSLogger aapsLogger;
|
||||||
@Inject protected SP sp;
|
@Inject protected SP sp;
|
||||||
|
|
||||||
@Inject MedtronicPumpStatus medtronicPumpStatus;
|
//@Inject MedtronicPumpStatus medtronicPumpStatus;
|
||||||
@Inject RileyLinkServiceData rileyLinkServiceData;
|
@Inject RileyLinkServiceData rileyLinkServiceData;
|
||||||
@Inject ServiceTaskExecutor serviceTaskExecutor;
|
@Inject ServiceTaskExecutor serviceTaskExecutor;
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
return sendAndListen(msg, timeout_ms, repeatCount, 0, extendPreamble_ms, clazz);
|
return sendAndListen(msg, timeout_ms, repeatCount, 0, extendPreamble_ms, clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <E extends RLMessage> E sendAndListen(RLMessage msg, int timeout_ms, int repeatCount, int retryCount, Integer extendPreamble_ms, Class<E> clazz)
|
protected <E extends RLMessage> E sendAndListen(RLMessage msg, int timeout_ms, int repeatCount, int retryCount, Integer extendPreamble_ms, Class<E> clazz)
|
||||||
throws RileyLinkCommunicationException {
|
throws RileyLinkCommunicationException {
|
||||||
|
|
||||||
// internal flag
|
// internal flag
|
||||||
|
@ -129,6 +130,9 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
public abstract <E extends RLMessage> E createResponseMessage(byte[] payload, Class<E> clazz);
|
public abstract <E extends RLMessage> E createResponseMessage(byte[] payload, Class<E> clazz);
|
||||||
|
|
||||||
|
|
||||||
|
public abstract void setPumpDeviceState(PumpDeviceState pumpDeviceState);
|
||||||
|
|
||||||
|
|
||||||
public void wakeUp(boolean force) {
|
public void wakeUp(boolean force) {
|
||||||
wakeUp(receiverDeviceAwakeForMinutes, force);
|
wakeUp(receiverDeviceAwakeForMinutes, force);
|
||||||
}
|
}
|
||||||
|
@ -150,7 +154,7 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
// **** FIXME: this wakeup doesn't seem to work well... must revisit
|
// **** FIXME: this wakeup doesn't seem to work well... must revisit
|
||||||
// receiverDeviceAwakeForMinutes = duration_minutes;
|
// receiverDeviceAwakeForMinutes = duration_minutes;
|
||||||
|
|
||||||
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.WakingUp);
|
setPumpDeviceState(PumpDeviceState.WakingUp);
|
||||||
|
|
||||||
if (force)
|
if (force)
|
||||||
nextWakeUpRequired = 0L;
|
nextWakeUpRequired = 0L;
|
||||||
|
@ -208,7 +212,7 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
double[] scanFrequencies = rileyLinkServiceData.rileyLinkTargetFrequency.getScanFrequencies();
|
double[] scanFrequencies = rileyLinkServiceData.rileyLinkTargetFrequency.getScanFrequencies();
|
||||||
|
|
||||||
if (scanFrequencies.length == 1) {
|
if (scanFrequencies.length == 1) {
|
||||||
return RileyLinkUtil.isSame(scanFrequencies[0], frequency);
|
return Round.isSame(scanFrequencies[0], frequency);
|
||||||
} else {
|
} else {
|
||||||
return (scanFrequencies[0] <= frequency && scanFrequencies[scanFrequencies.length - 1] >= frequency);
|
return (scanFrequencies[0] <= frequency && scanFrequencies[scanFrequencies.length - 1] >= frequency);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import javax.inject.Singleton;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.encoding.Encoding4b6b;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.encoding.Encoding4b6b;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.encoding.Encoding4b6bGeoff;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.encoding.Encoding4b6bGeoff;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkEncodingType;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkEncodingType;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkTargetFrequency;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.BleAdvertisedData;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.BleAdvertisedData;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceResult;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceResult;
|
||||||
|
@ -37,6 +38,9 @@ public class RileyLinkUtil {
|
||||||
private RileyLinkEncodingType encoding;
|
private RileyLinkEncodingType encoding;
|
||||||
private Encoding4b6b encoding4b6b;
|
private Encoding4b6b encoding4b6b;
|
||||||
|
|
||||||
|
// TODO maybe not needed
|
||||||
|
private RileyLinkTargetFrequency rileyLinkTargetFrequency;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RileyLinkUtil() {
|
public RileyLinkUtil() {
|
||||||
}
|
}
|
||||||
|
@ -154,4 +158,8 @@ public class RileyLinkUtil {
|
||||||
public Encoding4b6b getEncoding4b6b() {
|
public Encoding4b6b getEncoding4b6b() {
|
||||||
return encoding4b6b;
|
return encoding4b6b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRileyLinkTargetFrequency(RileyLinkTargetFrequency rileyLinkTargetFrequency_) {
|
||||||
|
this.rileyLinkTargetFrequency = rileyLinkTargetFrequency_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,7 +363,7 @@ public class RFSpy {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.selectedTargetFrequency = frequency;
|
//this.selectedTargetFrequency = frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,19 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs;
|
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService;
|
||||||
|
|
||||||
public interface RileyLinkPumpDevice {
|
public interface RileyLinkPumpDevice {
|
||||||
|
|
||||||
|
void setIsBusy(boolean isBusy_);
|
||||||
|
|
||||||
|
boolean isBusy();
|
||||||
|
|
||||||
|
void resetRileyLinkConfiguration();
|
||||||
|
|
||||||
|
boolean hasTuneUp();
|
||||||
|
|
||||||
|
void doTuneUpDevice();
|
||||||
|
|
||||||
|
RileyLinkService getRileyLinkService();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,15 @@ import java.util.Locale;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.android.support.DaggerFragment;
|
import dagger.android.support.DaggerFragment;
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
|
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
|
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
||||||
|
@ -23,6 +31,7 @@ import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,12 +40,17 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
|
||||||
public class RileyLinkStatusGeneralFragment extends DaggerFragment implements RefreshableInterface {
|
public class RileyLinkStatusGeneralFragment extends DaggerFragment implements RefreshableInterface {
|
||||||
|
|
||||||
// TODO fix this is not correct
|
@Inject ActivePluginProvider activePlugin;
|
||||||
@Inject RileyLinkUtil rileyLinkUtil;
|
|
||||||
@Inject MedtronicUtil medtronicUtil;
|
|
||||||
@Inject MedtronicPumpStatus medtronicPumpStatus;
|
|
||||||
@Inject ResourceHelper resourceHelper;
|
@Inject ResourceHelper resourceHelper;
|
||||||
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
@Inject MedtronicUtil medtronicUtil;
|
||||||
|
@Inject AAPSLogger aapsLogger;
|
||||||
|
|
||||||
|
// TODO fix this is not correct
|
||||||
|
//@Inject RileyLinkUtil rileyLinkUtil;
|
||||||
|
//@Inject MedtronicUtil medtronicUtil;
|
||||||
|
//@Inject MedtronicPumpStatus medtronicPumpStatus;
|
||||||
|
|
||||||
|
//@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
||||||
@Inject RileyLinkServiceData rileyLinkServiceData;
|
@Inject RileyLinkServiceData rileyLinkServiceData;
|
||||||
|
|
||||||
TextView connectionStatus;
|
TextView connectionStatus;
|
||||||
|
@ -51,10 +65,10 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
|
||||||
TextView lastDeviceContact;
|
TextView lastDeviceContact;
|
||||||
TextView firmwareVersion;
|
TextView firmwareVersion;
|
||||||
|
|
||||||
RileyLinkServiceData rileyLinkServiceData;
|
//RileyLinkServiceData rileyLinkServiceData;
|
||||||
|
|
||||||
MedtronicPumpStatus medtronicPumpStatus;
|
//MedtronicPumpStatus medtronicPumpStatus;
|
||||||
OmnipodPumpStatus omnipodPumpStatus;
|
//OmnipodPumpStatus omnipodPumpStatus;
|
||||||
boolean first = false;
|
boolean first = false;
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,7 +83,6 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
rileyLinkServiceData = RileyLinkUtil.getRileyLinkServiceData();
|
|
||||||
|
|
||||||
this.connectionStatus = getActivity().findViewById(R.id.rls_t1_connection_status);
|
this.connectionStatus = getActivity().findViewById(R.id.rls_t1_connection_status);
|
||||||
this.configuredAddress = getActivity().findViewById(R.id.rls_t1_configured_address);
|
this.configuredAddress = getActivity().findViewById(R.id.rls_t1_configured_address);
|
||||||
|
@ -129,14 +142,19 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
|
||||||
// TODO add handling for Omnipod pump status
|
// TODO add handling for Omnipod pump status
|
||||||
// TODO refactor this Omnipod
|
// TODO refactor this Omnipod
|
||||||
|
|
||||||
if (medtronicPumpStatus != null) {
|
PumpPluginAbstract pumpPlugin = (PumpPluginAbstract)activePlugin.getActivePump();
|
||||||
|
|
||||||
|
//if (activePlugin)
|
||||||
|
|
||||||
|
|
||||||
|
if (pumpPlugin.manufacturer()== ManufacturerType.Medtronic) {
|
||||||
|
MedtronicPumpStatus medtronicPumpStatus = (MedtronicPumpStatus)pumpPlugin.getPumpStatusData();
|
||||||
|
|
||||||
this.deviceType.setText(resourceHelper.gs(RileyLinkTargetDevice.MedtronicPump.getResourceId()));
|
this.deviceType.setText(resourceHelper.gs(RileyLinkTargetDevice.MedtronicPump.getResourceId()));
|
||||||
this.deviceModel.setText(medtronicPumpPlugin.getPumpDescription().pumpType.getDescription());
|
this.deviceModel.setText(pumpPlugin.getPumpType().getDescription());
|
||||||
this.serialNumber.setText(medtronicPumpStatus.serialNumber);
|
this.serialNumber.setText(medtronicPumpStatus.serialNumber);
|
||||||
this.pumpFrequency.setText(resourceHelper.gs(medtronicPumpStatus.pumpFrequency.equals("medtronic_pump_frequency_us_ca") ? R.string.medtronic_pump_frequency_us_ca : R.string.medtronic_pump_frequency_worldwide));
|
this.pumpFrequency.setText(resourceHelper.gs(medtronicPumpStatus.pumpFrequency.equals("medtronic_pump_frequency_us_ca") ? R.string.medtronic_pump_frequency_us_ca : R.string.medtronic_pump_frequency_worldwide));
|
||||||
|
|
||||||
// TODO extend when Omnipod used
|
|
||||||
|
|
||||||
if (medtronicUtil.getMedtronicPumpModel() != null)
|
if (medtronicUtil.getMedtronicPumpModel() != null)
|
||||||
this.connectedDevice.setText("Medtronic " + medtronicUtil.getMedtronicPumpModel().getPumpModel());
|
this.connectedDevice.setText("Medtronic " + medtronicUtil.getMedtronicPumpModel().getPumpModel());
|
||||||
else
|
else
|
||||||
|
@ -150,35 +168,42 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
|
||||||
this.lastDeviceContact.setText(StringUtil.toDateTimeString(new LocalDateTime(
|
this.lastDeviceContact.setText(StringUtil.toDateTimeString(new LocalDateTime(
|
||||||
medtronicPumpStatus.lastDataTime)));
|
medtronicPumpStatus.lastDataTime)));
|
||||||
else
|
else
|
||||||
this.lastDeviceContact.setText("Never");
|
this.lastDeviceContact.setText(resourceHelper.gs(R.string.common_never));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// if (OmnipodUtil.isOmnipodDash())
|
OmnipodPumpStatus omnipodPumpStatus = (OmnipodPumpStatus)pumpPlugin.getPumpStatusData();
|
||||||
// TODO add handling for Omnipod Dash pump status
|
|
||||||
this.omnipodPumpStatus = OmnipodUtil.getPumpStatus();
|
|
||||||
|
|
||||||
if (omnipodPumpStatus != null) {
|
this.deviceType.setText(resourceHelper.gs(RileyLinkTargetDevice.Omnipod.getResourceId()));
|
||||||
this.deviceType.setText(MainApp.gs(RileyLinkTargetDevice.Omnipod.getResourceId()));
|
this.deviceModel.setText(pumpPlugin.getPumpType() == PumpType.Insulet_Omnipod ? "Eros" : "Dash");
|
||||||
this.deviceModel.setText(omnipodPumpStatus.pumpType == PumpType.Insulet_Omnipod ? "Eros" : "Dash");
|
|
||||||
this.pumpFrequency.setText(MainApp.gs(R.string.omnipod_frequency));
|
|
||||||
|
|
||||||
if (omnipodPumpStatus.podAvailable) {
|
if (pumpPlugin.getPumpType()== PumpType.Insulet_Omnipod_Dash) {
|
||||||
this.serialNumber.setText(omnipodPumpStatus.podLotNumber);
|
aapsLogger.error("Omnipod Dash not yet supported !!!");
|
||||||
this.connectedDevice.setText(omnipodPumpStatus.pumpType == PumpType.Insulet_Omnipod ? "Eros Pod" : "Dash Pod");
|
|
||||||
} else {
|
this.pumpFrequency.setText("-");
|
||||||
this.serialNumber.setText("??");
|
} else {
|
||||||
this.connectedDevice.setText("-");
|
|
||||||
|
this.pumpFrequency.setText(resourceHelper.gs(R.string.omnipod_frequency));
|
||||||
|
|
||||||
|
if (omnipodPumpStatus != null) {
|
||||||
|
|
||||||
|
if (omnipodPumpStatus.podAvailable) {
|
||||||
|
this.serialNumber.setText(omnipodPumpStatus.podLotNumber);
|
||||||
|
this.connectedDevice.setText(omnipodPumpStatus.pumpType == PumpType.Insulet_Omnipod ? "Eros Pod" : "Dash Pod");
|
||||||
|
} else {
|
||||||
|
this.serialNumber.setText("??");
|
||||||
|
this.connectedDevice.setText("-");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rileyLinkServiceData.lastGoodFrequency != null)
|
||||||
|
this.lastUsedFrequency.setText(String.format(Locale.ENGLISH, "%.2f MHz",
|
||||||
|
rileyLinkServiceData.lastGoodFrequency));
|
||||||
|
|
||||||
|
if (omnipodPumpStatus.lastConnection != 0)
|
||||||
|
this.lastDeviceContact.setText(StringUtil.toDateTimeString(new LocalDateTime(
|
||||||
|
omnipodPumpStatus.lastDataTime)));
|
||||||
|
else
|
||||||
|
this.lastDeviceContact.setText(resourceHelper.gs(R.string.common_never));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rileyLinkServiceData.lastGoodFrequency != null)
|
|
||||||
this.lastUsedFrequency.setText(String.format(Locale.ENGLISH, "%.2f MHz",
|
|
||||||
rileyLinkServiceData.lastGoodFrequency));
|
|
||||||
|
|
||||||
if (omnipodPumpStatus.lastConnection != 0)
|
|
||||||
this.lastDeviceContact.setText(StringUtil.toDateTimeString(new LocalDateTime(
|
|
||||||
omnipodPumpStatus.lastDataTime)));
|
|
||||||
else
|
|
||||||
this.lastDeviceContact.setText(MainApp.gs(R.string.common_never));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.android.DaggerService;
|
import dagger.android.DaggerService;
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
|
@ -27,6 +29,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,9 +43,10 @@ public abstract class RileyLinkService extends DaggerService {
|
||||||
@Inject protected Context context;
|
@Inject protected Context context;
|
||||||
@Inject protected RxBusWrapper rxBus;
|
@Inject protected RxBusWrapper rxBus;
|
||||||
@Inject protected RileyLinkUtil rileyLinkUtil;
|
@Inject protected RileyLinkUtil rileyLinkUtil;
|
||||||
@Inject protected MedtronicUtil medtronicUtil; // TODO should be avoided here as it's MDT
|
@Inject protected HasAndroidInjector injector;
|
||||||
|
@Inject protected ResourceHelper resourceHelper;
|
||||||
@Inject protected RileyLinkServiceData rileyLinkServiceData;
|
@Inject protected RileyLinkServiceData rileyLinkServiceData;
|
||||||
@Inject protected MedtronicPumpStatus medtronicPumpStatus;
|
@Inject protected ActivePluginProvider activePlugin;
|
||||||
|
|
||||||
@NotNull protected RileyLinkBLE rileyLinkBLE; // android-bluetooth management, must be set in initRileyLinkServiceData
|
@NotNull protected RileyLinkBLE rileyLinkBLE; // android-bluetooth management, must be set in initRileyLinkServiceData
|
||||||
protected BluetoothAdapter bluetoothAdapter;
|
protected BluetoothAdapter bluetoothAdapter;
|
||||||
|
@ -202,11 +206,13 @@ public abstract class RileyLinkService extends DaggerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// FIXME: This needs to be run in a session so that is interruptable, has a separate thread, etc.
|
// FIXME: This needs to be run in a session so that is interruptable, has a separate thread, etc.
|
||||||
public void doTuneUpDevice() {
|
public void doTuneUpDevice() {
|
||||||
|
|
||||||
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.TuneUpDevice);
|
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.TuneUpDevice);
|
||||||
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
|
|
||||||
double lastGoodFrequency = 0.0d;
|
double lastGoodFrequency = 0.0d;
|
||||||
|
|
||||||
|
@ -238,6 +244,9 @@ public abstract class RileyLinkService extends DaggerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public abstract void setPumpDeviceState(PumpDeviceState pumpDeviceState);
|
||||||
|
|
||||||
|
|
||||||
public void disconnectRileyLink() {
|
public void disconnectRileyLink() {
|
||||||
|
|
||||||
if (rileyLinkBLE.isConnected()) {
|
if (rileyLinkBLE.isConnected()) {
|
||||||
|
@ -272,4 +281,6 @@ public abstract class RileyLinkService extends DaggerService {
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract boolean verifyConfiguration();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,18 @@ import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
|
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
|
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkTargetFrequency;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
||||||
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.common.hw.rileylink.service.data.ServiceTransport;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
||||||
|
import info.nightscout.androidaps.utils.Round;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,56 +66,53 @@ public class InitializePumpManagerTask extends ServiceTask {
|
||||||
lastGoodFrequency = rileyLinkServiceData.lastGoodFrequency;
|
lastGoodFrequency = rileyLinkServiceData.lastGoodFrequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Omnipod/Dagger needs refactoring
|
// TODO Omnipod/Dagger needs refactoring
|
||||||
|
RileyLinkCommunicationManager rileyLinkCommunicationManager = ((RileyLinkPumpDevice) activePlugin.getActivePump()).getRileyLinkService().getDeviceCommunicationManager();
|
||||||
|
|
||||||
if (MedtronicUtil.isMedtronicPump()) {
|
if (activePlugin.getActivePump().manufacturer() == ManufacturerType.Medtronic) {
|
||||||
RileyLinkCommunicationManager rileyLinkCommunicationManager = ((PumpPluginAbstract) activePlugin.getActivePump()).getRileyLinkService().getDeviceCommunicationManager();
|
|
||||||
|
if ((lastGoodFrequency > 0.0d)
|
||||||
|
&& rileyLinkCommunicationManager.isValidFrequency(lastGoodFrequency)) {
|
||||||
|
|
||||||
|
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.RileyLinkReady);
|
||||||
|
|
||||||
|
aapsLogger.info(LTag.PUMPCOMM, "Setting radio frequency to {} MHz", lastGoodFrequency);
|
||||||
|
|
||||||
|
rileyLinkCommunicationManager.setRadioFrequencyForPump(lastGoodFrequency);
|
||||||
|
|
||||||
|
boolean foundThePump = rileyLinkCommunicationManager.tryToConnectToDevice();
|
||||||
|
|
||||||
|
if (foundThePump) {
|
||||||
|
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.PumpConnectorReady);
|
||||||
|
} else {
|
||||||
|
rileyLinkServiceData.setServiceState(RileyLinkServiceState.PumpConnectorError,
|
||||||
|
RileyLinkError.NoContactWithDevice);
|
||||||
|
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_tunePump, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_tunePump, context);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (!Round.isSame(lastGoodFrequency, RileyLinkTargetFrequency.Omnipod.getScanFrequencies()[0])) {
|
||||||
|
lastGoodFrequency = RileyLinkTargetFrequency.Omnipod.getScanFrequencies()[0];
|
||||||
|
lastGoodFrequency = Math.round(lastGoodFrequency * 1000d) / 1000d;
|
||||||
|
|
||||||
|
rileyLinkServiceData.lastGoodFrequency = lastGoodFrequency;
|
||||||
|
}
|
||||||
|
|
||||||
if ((lastGoodFrequency > 0.0d)
|
|
||||||
&& rileyLinkCommunicationManager.isValidFrequency(lastGoodFrequency)) {
|
|
||||||
|
|
||||||
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.RileyLinkReady);
|
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.RileyLinkReady);
|
||||||
|
rileyLinkUtil.setRileyLinkTargetFrequency(RileyLinkTargetFrequency.Omnipod);
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMPCOMM, "Setting radio frequency to {} MHz", lastGoodFrequency);
|
aapsLogger.info(LTag.PUMPCOMM, "Setting radio frequency to {} MHz", lastGoodFrequency);
|
||||||
|
|
||||||
rileyLinkCommunicationManager.setRadioFrequencyForPump(lastGoodFrequency);
|
rileyLinkCommunicationManager.setRadioFrequencyForPump(lastGoodFrequency);
|
||||||
|
|
||||||
boolean foundThePump = rileyLinkCommunicationManager.tryToConnectToDevice();
|
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.PumpConnectorReady);
|
||||||
|
|
||||||
if (foundThePump) {
|
|
||||||
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.PumpConnectorReady);
|
|
||||||
} else {
|
|
||||||
rileyLinkServiceData.setServiceState(RileyLinkServiceState.PumpConnectorError,
|
|
||||||
RileyLinkError.NoContactWithDevice);
|
|
||||||
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_tunePump, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_tunePump, context);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (!RileyLinkUtil.isSame(lastGoodFrequency, RileyLinkTargetFrequency.Omnipod.getScanFrequencies()[0])) {
|
|
||||||
lastGoodFrequency = RileyLinkTargetFrequency.Omnipod.getScanFrequencies()[0];
|
|
||||||
lastGoodFrequency = Math.round(lastGoodFrequency * 1000d) / 1000d;
|
|
||||||
|
|
||||||
RileyLinkUtil.getRileyLinkServiceData().lastGoodFrequency = lastGoodFrequency;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RileyLinkUtil.setServiceState(RileyLinkServiceState.RileyLinkReady);
|
|
||||||
RileyLinkUtil.setRileyLinkTargetFrequency(RileyLinkTargetFrequency.Omnipod);
|
|
||||||
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
LOG.info("Setting radio frequency to {} MHz", lastGoodFrequency);
|
|
||||||
|
|
||||||
RileyLinkUtil.getRileyLinkCommunicationManager().setRadioFrequencyForPump(lastGoodFrequency);
|
|
||||||
|
|
||||||
|
|
||||||
LOG.error("TRYYYYYY TO CONNECT IF AVAILABLE");
|
|
||||||
|
|
||||||
RileyLinkUtil.setServiceState(RileyLinkServiceState.PumpConnectorReady);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
|
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
|
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventRefreshButtonState;
|
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventRefreshButtonState;
|
||||||
|
@ -12,31 +20,32 @@ import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtro
|
||||||
public class ResetRileyLinkConfigurationTask extends PumpTask {
|
public class ResetRileyLinkConfigurationTask extends PumpTask {
|
||||||
|
|
||||||
private static final String TAG = "ResetRileyLinkTask";
|
private static final String TAG = "ResetRileyLinkTask";
|
||||||
|
@Inject ActivePluginProvider activePlugin;
|
||||||
|
@Inject RxBusWrapper rxBus;
|
||||||
|
|
||||||
|
public ResetRileyLinkConfigurationTask(HasAndroidInjector injector) {
|
||||||
public ResetRileyLinkConfigurationTask() {
|
super(injector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ResetRileyLinkConfigurationTask(ServiceTransport transport) {
|
public ResetRileyLinkConfigurationTask(HasAndroidInjector injector, ServiceTransport transport) {
|
||||||
super(transport);
|
super(injector, transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// TODO Omnipod refactor this
|
// this is intended only for RL supported pump, so we can cast to PumpPluginAbstract
|
||||||
if (MedtronicUtil.isMedtronicPump()) {
|
RileyLinkPumpDevice pumpAbstract = (RileyLinkPumpDevice)activePlugin.getActivePump();
|
||||||
RxBus.Companion.getINSTANCE().send(new EventRefreshButtonState(false));
|
|
||||||
MedtronicPumpPlugin.isBusy = true;
|
rxBus.send(new EventRefreshButtonState(false));
|
||||||
RileyLinkMedtronicService.getInstance().resetRileyLinkConfiguration();
|
|
||||||
MedtronicPumpPlugin.isBusy = false;
|
pumpAbstract.setIsBusy(true);
|
||||||
RxBus.Companion.getINSTANCE().send(new EventRefreshButtonState(true));
|
pumpAbstract.resetRileyLinkConfiguration();
|
||||||
} else if (OmnipodUtil.isOmnipodEros()) {
|
pumpAbstract.setIsBusy(false);
|
||||||
OmnipodPumpPlugin.isBusy = true;
|
|
||||||
RileyLinkOmnipodService.getInstance().resetRileyLinkConfiguration();
|
rxBus.send(new EventRefreshButtonState(true));
|
||||||
OmnipodPumpPlugin.isBusy = false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventRefreshButtonState(true));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
|
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventRefreshButtonState;
|
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventRefreshButtonState;
|
||||||
|
@ -34,9 +35,10 @@ public class WakeAndTuneTask extends PumpTask {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PumpPluginAbstract pump = (PumpPluginAbstract) activePlugin.getActivePump();
|
PumpPluginAbstract pump = (PumpPluginAbstract) activePlugin.getActivePump();
|
||||||
|
RileyLinkPumpDevice pumpDevice = (RileyLinkPumpDevice)pump;
|
||||||
rxBus.send(new EventRefreshButtonState(false));
|
rxBus.send(new EventRefreshButtonState(false));
|
||||||
MedtronicPumpPlugin.isBusy = true;
|
MedtronicPumpPlugin.isBusy = true;
|
||||||
pump.doTuneUpDevice();
|
pumpDevice.doTuneUpDevice();
|
||||||
MedtronicPumpPlugin.isBusy = false;
|
MedtronicPumpPlugin.isBusy = false;
|
||||||
rxBus.send(new EventRefreshButtonState(true));
|
rxBus.send(new EventRefreshButtonState(true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
||||||
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.common.hw.rileylink.service.tasks.ResetRileyLinkConfigurationTask;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ResetRileyLinkConfigurationTask;
|
||||||
|
@ -95,7 +96,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
* @author Andy Rozman (andy.rozman@gmail.com)
|
* @author Andy Rozman (andy.rozman@gmail.com)
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInterface {
|
public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInterface, RileyLinkPumpDevice {
|
||||||
|
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final RileyLinkUtil rileyLinkUtil;
|
private final RileyLinkUtil rileyLinkUtil;
|
||||||
|
@ -244,6 +245,11 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
rileyLinkMedtronicService.resetRileyLinkConfiguration();
|
rileyLinkMedtronicService.resetRileyLinkConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasTuneUp() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public void doTuneUpDevice() {
|
@Override public void doTuneUpDevice() {
|
||||||
rileyLinkMedtronicService.doTuneUpDevice();
|
rileyLinkMedtronicService.doTuneUpDevice();
|
||||||
}
|
}
|
||||||
|
@ -339,6 +345,11 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIsBusy(boolean isBusy_) {
|
||||||
|
isBusy = isBusy_;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBusy() {
|
public boolean isBusy() {
|
||||||
if (displayConnectionMessages)
|
if (displayConnectionMessages)
|
||||||
|
|
|
@ -92,6 +92,11 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
return (E) pumpMessage;
|
return (E) pumpMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPumpDeviceState(PumpDeviceState pumpDeviceState) {
|
||||||
|
this.medtronicPumpStatus.setPumpDeviceState(pumpDeviceState);
|
||||||
|
}
|
||||||
|
|
||||||
public void setDoWakeUpBeforeCommand(boolean doWakeUp) {
|
public void setDoWakeUpBeforeCommand(boolean doWakeUp) {
|
||||||
this.doWakeUpBeforeCommand = doWakeUp;
|
this.doWakeUpBeforeCommand = doWakeUp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentService;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentService;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
import info.nightscout.androidaps.utils.Round;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
|
|
||||||
|
@ -655,7 +656,7 @@ public class MedtronicHistoryData {
|
||||||
|
|
||||||
Treatment treatment = (Treatment) dbObjectBase;
|
Treatment treatment = (Treatment) dbObjectBase;
|
||||||
|
|
||||||
if (RileyLinkUtil.isSame(treatment.insulin, 0d)) {
|
if (Round.isSame(treatment.insulin, 0d)) {
|
||||||
removeList.add(dbObjectBase);
|
removeList.add(dbObjectBase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,13 +60,12 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MedtronicPumpStatus(
|
public MedtronicPumpStatus(ResourceHelper resourceHelper,
|
||||||
ResourceHelper resourceHelper,
|
|
||||||
SP sp,
|
SP sp,
|
||||||
RxBusWrapper rxBus,
|
RxBusWrapper rxBus,
|
||||||
RileyLinkUtil rileyLinkUtil
|
RileyLinkUtil rileyLinkUtil
|
||||||
) {
|
) {
|
||||||
super();
|
super(PumpType.Medtronic_522_722);
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
|
@ -75,7 +74,7 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initSettings() {
|
public void initSettings() {
|
||||||
|
|
||||||
this.activeProfileName = "STD";
|
this.activeProfileName = "STD";
|
||||||
this.reservoirRemainingUnits = 75d;
|
this.reservoirRemainingUnits = 75d;
|
||||||
|
@ -122,7 +121,6 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
medtronicPumpMap.put("723", PumpType.Medtronic_523_723_Revel);
|
medtronicPumpMap.put("723", PumpType.Medtronic_523_723_Revel);
|
||||||
medtronicPumpMap.put("554", PumpType.Medtronic_554_754_Veo);
|
medtronicPumpMap.put("554", PumpType.Medtronic_554_754_Veo);
|
||||||
medtronicPumpMap.put("754", PumpType.Medtronic_554_754_Veo);
|
medtronicPumpMap.put("754", PumpType.Medtronic_554_754_Veo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, PumpType> getMedtronicPumpMap() {
|
public Map<String, PumpType> getMedtronicPumpMap() {
|
||||||
|
|
|
@ -38,8 +38,6 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
*/
|
*/
|
||||||
public class RileyLinkMedtronicService extends RileyLinkService {
|
public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
|
|
||||||
@Inject HasAndroidInjector injector;
|
|
||||||
@Inject ResourceHelper resourceHelper;
|
|
||||||
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
||||||
@Inject MedtronicUtil medtronicUtil;
|
@Inject MedtronicUtil medtronicUtil;
|
||||||
@Inject MedtronicUIPostprocessor medtronicUIPostprocessor;
|
@Inject MedtronicUIPostprocessor medtronicUIPostprocessor;
|
||||||
|
@ -120,6 +118,12 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPumpDeviceState(PumpDeviceState pumpDeviceState) {
|
||||||
|
this.medtronicPumpStatus.setPumpDeviceState(pumpDeviceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public MedtronicUIComm getMedtronicUIComm() {
|
public MedtronicUIComm getMedtronicUIComm() {
|
||||||
return medtronicUIComm;
|
return medtronicUIComm;
|
||||||
}
|
}
|
||||||
|
@ -236,7 +240,8 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
} else {
|
} else {
|
||||||
PumpType pumpType = medtronicPumpStatus.getMedtronicPumpMap().get(pumpTypePart);
|
PumpType pumpType = medtronicPumpStatus.getMedtronicPumpMap().get(pumpTypePart);
|
||||||
medtronicPumpStatus.medtronicDeviceType = medtronicPumpStatus.getMedtronicDeviceTypeMap().get(pumpTypePart);
|
medtronicPumpStatus.medtronicDeviceType = medtronicPumpStatus.getMedtronicDeviceTypeMap().get(pumpTypePart);
|
||||||
medtronicPumpPlugin.getPumpDescription().setPumpDescription(pumpType);
|
//medtronicPumpPlugin.getPumpDescription().setPumpDescription(pumpType);
|
||||||
|
medtronicPumpPlugin.setPumpType(pumpType);
|
||||||
|
|
||||||
if (pumpTypePart.startsWith("7"))
|
if (pumpTypePart.startsWith("7"))
|
||||||
medtronicPumpStatus.reservoirFullUnits = 300;
|
medtronicPumpStatus.reservoirFullUnits = 300;
|
||||||
|
|
|
@ -68,6 +68,7 @@ public class MedtronicUtil {
|
||||||
this.medtronicPumpStatus = medtronicPumpStatus;
|
this.medtronicPumpStatus = medtronicPumpStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public LocalTime getTimeFrom30MinInterval(int interval) {
|
public LocalTime getTimeFrom30MinInterval(int interval) {
|
||||||
if (interval % 2 == 0) {
|
if (interval % 2 == 0) {
|
||||||
return new LocalTime(interval / 2, 0);
|
return new LocalTime(interval / 2, 0);
|
||||||
|
|
|
@ -7,7 +7,6 @@ import android.os.Handler
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.MainApp
|
import info.nightscout.androidaps.MainApp
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
|
@ -17,16 +16,13 @@ import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.L
|
import info.nightscout.androidaps.logging.L
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
|
||||||
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.dialogs.PodManagementActivity
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity
|
||||||
|
@ -38,16 +34,15 @@ import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpVa
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefreshButtonState
|
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefreshButtonState
|
||||||
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
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.*
|
import info.nightscout.androidaps.utils.*
|
||||||
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import kotlinx.android.synthetic.main.omnipod_fragment.*
|
import kotlinx.android.synthetic.main.omnipod_fragment.*
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class OmnipodFragment : DaggerFragment() {
|
class OmnipodFragment : DaggerFragment() {
|
||||||
|
@ -61,6 +56,7 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@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
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -100,19 +96,19 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
omnipod_pod_status.text = "{fa-bed}"
|
omnipod_pod_status.text = "{fa-bed}"
|
||||||
|
|
||||||
omnipod_pod_mgmt.setOnClickListener {
|
omnipod_pod_mgmt.setOnClickListener {
|
||||||
if (OmnipodUtil.getPumpStatus().verifyConfiguration()) {
|
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
|
||||||
startActivity(Intent(context, PodManagementActivity::class.java))
|
startActivity(Intent(context, PodManagementActivity::class.java))
|
||||||
} else {
|
} else {
|
||||||
OmnipodUtil.displayNotConfiguredDialog(context)
|
displayNotConfiguredDialog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_refresh.setOnClickListener {
|
omnipod_refresh.setOnClickListener {
|
||||||
if (!OmnipodUtil.getPumpStatus().verifyConfiguration()) {
|
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() != true) {
|
||||||
OmnipodUtil.displayNotConfiguredDialog(context)
|
OmnipodUtil.displayNotConfiguredDialog(context)
|
||||||
} else {
|
} else {
|
||||||
omnipod_refresh.isEnabled = false
|
omnipod_refresh.isEnabled = false
|
||||||
OmnipodUtil.getPlugin().addPodStatusRequest(OmnipodStatusRequest.GetPodState);
|
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequest.GetPodState);
|
||||||
commandQueue.readStatus("Clicked Refresh", object : Callback() {
|
commandQueue.readStatus("Clicked Refresh", object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
activity?.runOnUiThread { omnipod_refresh.isEnabled = true }
|
activity?.runOnUiThread { omnipod_refresh.isEnabled = true }
|
||||||
|
@ -122,26 +118,26 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_stats.setOnClickListener {
|
omnipod_stats.setOnClickListener {
|
||||||
if (OmnipodUtil.getPumpStatus().verifyConfiguration()) {
|
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
|
||||||
startActivity(Intent(context, RileyLinkStatusActivity::class.java))
|
startActivity(Intent(context, RileyLinkStatusActivity::class.java))
|
||||||
} else {
|
} else {
|
||||||
OmnipodUtil.displayNotConfiguredDialog(context)
|
displayNotConfiguredDialog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_pod_active_alerts_ack.setOnClickListener {
|
omnipod_pod_active_alerts_ack.setOnClickListener {
|
||||||
if (!OmnipodUtil.getPumpStatus().verifyConfiguration()) {
|
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() != true) {
|
||||||
OmnipodUtil.displayNotConfiguredDialog(context)
|
displayNotConfiguredDialog()
|
||||||
} else {
|
} else {
|
||||||
omnipod_pod_active_alerts_ack.isEnabled = false
|
omnipod_pod_active_alerts_ack.isEnabled = false
|
||||||
OmnipodUtil.getPlugin().addPodStatusRequest(OmnipodStatusRequest.AcknowledgeAlerts);
|
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequest.AcknowledgeAlerts);
|
||||||
commandQueue.readStatus("Clicked Alert Ack", null)
|
commandQueue.readStatus("Clicked Alert Ack", null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_pod_debug.setOnClickListener {
|
omnipod_pod_debug.setOnClickListener {
|
||||||
if (!OmnipodUtil.getPumpStatus().verifyConfiguration()) {
|
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() != true) {
|
||||||
OmnipodUtil.displayNotConfiguredDialog(context)
|
displayNotConfiguredDialog()
|
||||||
} else {
|
} else {
|
||||||
// val readPulseLog = AapsOmnipodManager.getInstance().readPulseLog()
|
// val readPulseLog = AapsOmnipodManager.getInstance().readPulseLog()
|
||||||
//
|
//
|
||||||
|
@ -150,7 +146,7 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
//
|
//
|
||||||
|
|
||||||
omnipod_pod_debug.isEnabled = false
|
omnipod_pod_debug.isEnabled = false
|
||||||
OmnipodUtil.getPlugin().addPodStatusRequest(OmnipodStatusRequest.GetPodPulseLog);
|
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequest.GetPodPulseLog);
|
||||||
commandQueue.readStatus("Clicked Refresh", object : Callback() {
|
commandQueue.readStatus("Clicked Refresh", object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
activity?.runOnUiThread { omnipod_pod_debug.isEnabled = true }
|
activity?.runOnUiThread { omnipod_pod_debug.isEnabled = true }
|
||||||
|
@ -189,7 +185,7 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventOmnipodAcknowledgeAlertsChanged::class.java)
|
.toObservable(EventOmnipodAcknowledgeAlertsChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({ updateAcknowledgeAlerts(OmnipodUtil.getPumpStatus()) }, { fabricPrivacy.logException(it) })
|
.subscribe({ updateAcknowledgeAlerts() }, { fabricPrivacy.logException(it) })
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventPreferenceChange::class.java)
|
.toObservable(EventPreferenceChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
|
@ -210,6 +206,13 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun displayNotConfiguredDialog() {
|
||||||
|
context?.let {
|
||||||
|
OKDialog.show(it, resourceHelper.gs(R.string.combo_warning),
|
||||||
|
resourceHelper.gs(R.string.omnipod_error_operation_not_possible_no_configuration), null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
disposable.clear()
|
disposable.clear()
|
||||||
|
@ -219,28 +222,32 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
private fun setDeviceStatus() {
|
private fun setDeviceStatus() {
|
||||||
val pumpStatus: OmnipodPumpStatus = OmnipodUtil.getPumpStatus()
|
//val omnipodPumpStatus: OmnipodPumpStatus = OmnipodUtil.getPumpStatus()
|
||||||
pumpStatus.rileyLinkServiceState = checkStatusSet(pumpStatus.rileyLinkServiceState,
|
// omnipodPumpStatus.rileyLinkServiceState = checkStatusSet(omnipodPumpStatus.rileyLinkServiceState,
|
||||||
RileyLinkUtil.getServiceState()) as RileyLinkServiceState?
|
// RileyLinkUtil.getServiceState()) as RileyLinkServiceState?
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMP,"setDeviceStatus: [pumpStatus={}]", pumpStatus)
|
|
||||||
|
|
||||||
val resourceId = pumpStatus.rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.Omnipod)
|
|
||||||
val rileyLinkError = RileyLinkUtil.getError()
|
aapsLogger.info(LTag.PUMP,"setDeviceStatus: [pumpStatus={}]", omnipodPumpStatus)
|
||||||
|
|
||||||
|
val resourceId = omnipodPumpStatus.rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.Omnipod)
|
||||||
|
val rileyLinkError = omnipodPumpPlugin.rileyLinkService?.error
|
||||||
|
|
||||||
omnipod_rl_status.text =
|
omnipod_rl_status.text =
|
||||||
when {
|
when {
|
||||||
pumpStatus.rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
|
omnipodPumpStatus.rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
|
||||||
pumpStatus.rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
|
omnipodPumpStatus.rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
|
||||||
pumpStatus.rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
omnipodPumpStatus.rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
||||||
pumpStatus.rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump))
|
omnipodPumpStatus.rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump))
|
||||||
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
||||||
}
|
}
|
||||||
omnipod_rl_status.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE)
|
omnipod_rl_status.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE)
|
||||||
|
|
||||||
pumpStatus.rileyLinkError = checkStatusSet(pumpStatus.rileyLinkError, RileyLinkUtil.getError()) as RileyLinkError?
|
// omnipodPumpStatus.rileyLinkError = checkStatusSet(omnipodPumpStatus.rileyLinkError,
|
||||||
|
// RileyLinkUtil.getError()) as RileyLinkError?
|
||||||
|
|
||||||
omnipod_errors.text =
|
omnipod_errors.text =
|
||||||
pumpStatus.rileyLinkError?.let {
|
omnipodPumpStatus.rileyLinkError?.let {
|
||||||
resourceHelper.gs(it.getResourceId(RileyLinkTargetDevice.Omnipod))
|
resourceHelper.gs(it.getResourceId(RileyLinkTargetDevice.Omnipod))
|
||||||
} ?: "-"
|
} ?: "-"
|
||||||
|
|
||||||
|
@ -252,31 +259,31 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
omnipod_pod_address.text = resourceHelper.gs(R.string.omnipod_pod_name_no_info)
|
omnipod_pod_address.text = resourceHelper.gs(R.string.omnipod_pod_name_no_info)
|
||||||
omnipod_pod_expiry.text = "-"
|
omnipod_pod_expiry.text = "-"
|
||||||
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_not_initalized)
|
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_not_initalized)
|
||||||
pumpStatus.podAvailable = false
|
omnipodPumpStatus.podAvailable = false
|
||||||
pumpStatus.podNumber == null
|
omnipodPumpStatus.podNumber == null
|
||||||
} else if (driverState == OmnipodDriverState.Initalized_NoPod) {
|
} else if (driverState == OmnipodDriverState.Initalized_NoPod) {
|
||||||
omnipod_pod_address.text = resourceHelper.gs(R.string.omnipod_pod_name_no_info)
|
omnipod_pod_address.text = resourceHelper.gs(R.string.omnipod_pod_name_no_info)
|
||||||
omnipod_pod_expiry.text = "-"
|
omnipod_pod_expiry.text = "-"
|
||||||
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_no_pod_connected)
|
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_no_pod_connected)
|
||||||
pumpStatus.podAvailable = false
|
omnipodPumpStatus.podAvailable = false
|
||||||
pumpStatus.podNumber == null
|
omnipodPumpStatus.podNumber == null
|
||||||
} else if (driverState == OmnipodDriverState.Initalized_PodInitializing) {
|
} else if (driverState == OmnipodDriverState.Initalized_PodInitializing) {
|
||||||
omnipod_pod_address.text = pumpStatus.podSessionState.address.toString()
|
omnipod_pod_address.text = omnipodPumpStatus.podSessionState.address.toString()
|
||||||
omnipod_pod_expiry.text = "-"
|
omnipod_pod_expiry.text = "-"
|
||||||
omnipod_pod_status.text = OmnipodUtil.getPodSessionState().getSetupProgress().name
|
omnipod_pod_status.text = omnipodPumpStatus.podSessionState.getSetupProgress().name
|
||||||
pumpStatus.podAvailable = false
|
omnipodPumpStatus.podAvailable = false
|
||||||
pumpStatus.podNumber == pumpStatus.podSessionState.address.toString()
|
omnipodPumpStatus.podNumber == omnipodPumpStatus.podSessionState.address.toString()
|
||||||
}else {
|
}else {
|
||||||
pumpStatus.podLotNumber = "" + pumpStatus.podSessionState.lot
|
omnipodPumpStatus.podLotNumber = "" + omnipodPumpStatus.podSessionState.lot
|
||||||
pumpStatus.podAvailable = true
|
omnipodPumpStatus.podAvailable = true
|
||||||
omnipod_pod_address.text = pumpStatus.podSessionState.address.toString()
|
omnipod_pod_address.text = omnipodPumpStatus.podSessionState.address.toString()
|
||||||
omnipod_pod_expiry.text = pumpStatus.podSessionState.expiryDateAsString
|
omnipod_pod_expiry.text = omnipodPumpStatus.podSessionState.expiryDateAsString
|
||||||
pumpStatus.podNumber = pumpStatus.podSessionState.address.toString()
|
omnipodPumpStatus.podNumber = omnipodPumpStatus.podSessionState.address.toString()
|
||||||
|
|
||||||
//pumpStatus.podSessionState = checkStatusSet(pumpStatus.podSessionState,
|
//pumpStatus.podSessionState = checkStatusSet(pumpStatus.podSessionState,
|
||||||
// OmnipodUtil.getPodSessionState()) as PodSessionState?
|
// OmnipodUtil.getPodSessionState()) as PodSessionState?
|
||||||
|
|
||||||
var podDeviceState = pumpStatus.podDeviceState
|
var podDeviceState = omnipodPumpStatus.podDeviceState
|
||||||
|
|
||||||
when (podDeviceState) {
|
when (podDeviceState) {
|
||||||
null,
|
null,
|
||||||
|
@ -307,7 +314,7 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
else -> aapsLogger.warn(LTag.PUMP,"Unknown pump state: " + pumpStatus.podDeviceState)
|
else -> aapsLogger.warn(LTag.PUMP,"Unknown pump state: " + omnipodPumpStatus.podDeviceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -371,8 +378,8 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
// GUI functions
|
// GUI functions
|
||||||
fun updateGUI() {
|
fun updateGUI() {
|
||||||
val plugin = omnipodPumpPlugin
|
val plugin = omnipodPumpPlugin
|
||||||
val pumpStatus = OmnipodUtil.getPumpStatus()
|
//val omnipodPumpStatus = OmnipodUtil.getPumpStatus()
|
||||||
var pumpType = OmnipodUtil.getPumpType()
|
var pumpType = omnipodPumpStatus.pumpType
|
||||||
|
|
||||||
if (pumpType==null) {
|
if (pumpType==null) {
|
||||||
aapsLogger.warn(LTag.PUMP,"PumpType was not set, reseting to Omnipod.")
|
aapsLogger.warn(LTag.PUMP,"PumpType was not set, reseting to Omnipod.")
|
||||||
|
@ -381,12 +388,12 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
|
|
||||||
setDeviceStatus()
|
setDeviceStatus()
|
||||||
|
|
||||||
if (pumpStatus.podAvailable) {
|
if (omnipodPumpStatus.podAvailable) {
|
||||||
// last connection
|
// last connection
|
||||||
if (pumpStatus.lastConnection != 0L) {
|
if (omnipodPumpStatus.lastConnection != 0L) {
|
||||||
//val minAgo = DateUtil.minAgo(pumpStatus.lastConnection)
|
//val minAgo = DateUtil.minAgo(pumpStatus.lastConnection)
|
||||||
val min = (System.currentTimeMillis() - pumpStatus.lastConnection) / 1000 / 60
|
val min = (System.currentTimeMillis() - omnipodPumpStatus.lastConnection) / 1000 / 60
|
||||||
if (pumpStatus.lastConnection + 60 * 1000 > System.currentTimeMillis()) {
|
if (omnipodPumpStatus.lastConnection + 60 * 1000 > System.currentTimeMillis()) {
|
||||||
omnipod_lastconnection.setText(R.string.combo_pump_connected_now)
|
omnipod_lastconnection.setText(R.string.combo_pump_connected_now)
|
||||||
//omnipod_lastconnection.setTextColor(Color.WHITE)
|
//omnipod_lastconnection.setTextColor(Color.WHITE)
|
||||||
} else { //if (pumpStatus.lastConnection + 30 * 60 * 1000 < System.currentTimeMillis()) {
|
} else { //if (pumpStatus.lastConnection + 30 * 60 * 1000 < System.currentTimeMillis()) {
|
||||||
|
@ -413,19 +420,19 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// last bolus
|
// last bolus
|
||||||
val bolus = pumpStatus.lastBolusAmount
|
val bolus = omnipodPumpStatus.lastBolusAmount
|
||||||
val bolusTime = pumpStatus.lastBolusTime
|
val bolusTime = omnipodPumpStatus.lastBolusTime
|
||||||
if (bolus != null && bolusTime != null && pumpStatus.podAvailable) {
|
if (bolus != null && bolusTime != null && omnipodPumpStatus.podAvailable) {
|
||||||
val agoMsc = System.currentTimeMillis() - pumpStatus.lastBolusTime.time
|
val agoMsc = System.currentTimeMillis() - omnipodPumpStatus.lastBolusTime.time
|
||||||
val bolusMinAgo = agoMsc.toDouble() / 60.0 / 1000.0
|
val bolusMinAgo = agoMsc.toDouble() / 60.0 / 1000.0
|
||||||
val unit = resourceHelper.gs(R.string.insulin_unit_shortname)
|
val unit = resourceHelper.gs(R.string.insulin_unit_shortname)
|
||||||
val ago: String
|
val ago: String
|
||||||
if (agoMsc < 60 * 1000) {
|
if (agoMsc < 60 * 1000) {
|
||||||
ago = resourceHelper.gs(R.string.combo_pump_connected_now)
|
ago = resourceHelper.gs(R.string.combo_pump_connected_now)
|
||||||
} else if (bolusMinAgo < 60) {
|
} else if (bolusMinAgo < 60) {
|
||||||
ago = DateUtil.minAgo(resourceHelper, pumpStatus.lastBolusTime.time)
|
ago = DateUtil.minAgo(resourceHelper, omnipodPumpStatus.lastBolusTime.time)
|
||||||
} else {
|
} else {
|
||||||
ago = DateUtil.hourAgo(pumpStatus.lastBolusTime.time, resourceHelper)
|
ago = DateUtil.hourAgo(omnipodPumpStatus.lastBolusTime.time, resourceHelper)
|
||||||
}
|
}
|
||||||
omnipod_lastbolus.text = resourceHelper.gs(R.string.omnipod_last_bolus, pumpType.determineCorrectBolusSize(bolus), unit, ago)
|
omnipod_lastbolus.text = resourceHelper.gs(R.string.omnipod_last_bolus, pumpType.determineCorrectBolusSize(bolus), unit, ago)
|
||||||
} else {
|
} else {
|
||||||
|
@ -439,12 +446,12 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() ?: ""
|
.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() ?: ""
|
||||||
|
|
||||||
// reservoir
|
// reservoir
|
||||||
if (RileyLinkUtil.isSame(pumpStatus.reservoirRemainingUnits, 75.0)) {
|
if (Round.isSame(omnipodPumpStatus.reservoirRemainingUnits, 75.0)) {
|
||||||
omnipod_reservoir.text = resourceHelper.gs(R.string.omnipod_reservoir_over50)
|
omnipod_reservoir.text = resourceHelper.gs(R.string.omnipod_reservoir_over50)
|
||||||
} else {
|
} else {
|
||||||
omnipod_reservoir.text = resourceHelper.gs(R.string.omnipod_reservoir_left, pumpStatus.reservoirRemainingUnits)
|
omnipod_reservoir.text = resourceHelper.gs(R.string.omnipod_reservoir_left, omnipodPumpStatus.reservoirRemainingUnits)
|
||||||
}
|
}
|
||||||
warnColors.setColorInverse(omnipod_reservoir, pumpStatus.reservoirRemainingUnits, 50.0, 20.0)
|
warnColors.setColorInverse(omnipod_reservoir, omnipodPumpStatus.reservoirRemainingUnits, 50.0, 20.0)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
omnipod_basabasalrate.text = ""
|
omnipod_basabasalrate.text = ""
|
||||||
|
@ -455,20 +462,18 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
omnipod_lastconnection.setTextColor(Color.WHITE)
|
omnipod_lastconnection.setTextColor(Color.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_errors.text = pumpStatus.errorInfo
|
omnipod_errors.text = omnipodPumpStatus.errorInfo
|
||||||
|
|
||||||
updateAcknowledgeAlerts(pumpStatus)
|
updateAcknowledgeAlerts()
|
||||||
|
|
||||||
omnipod_refresh.isEnabled = pumpStatus.podAvailable
|
omnipod_refresh.isEnabled = omnipodPumpStatus.podAvailable
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun updateAcknowledgeAlerts(pumpStatus: OmnipodPumpStatus) {
|
private fun updateAcknowledgeAlerts() {
|
||||||
if (pumpStatus != null) {
|
omnipod_pod_active_alerts_ack.isEnabled = omnipodPumpStatus.ackAlertsAvailable
|
||||||
omnipod_pod_active_alerts_ack.isEnabled = pumpStatus.ackAlertsAvailable
|
omnipod_pod_active_alerts.text = omnipodPumpStatus.ackAlertsText
|
||||||
omnipod_pod_active_alerts.text = pumpStatus.ackAlertsText
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import android.os.SystemClock;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.joda.time.LocalDateTime;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -49,10 +48,14 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNo
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
|
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ResetRileyLinkConfigurationTask;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ResetRileyLinkConfigurationTask;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
||||||
|
@ -60,13 +63,11 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.pod
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPodType;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
|
||||||
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.state.PodSessionState;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
||||||
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;
|
||||||
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.OmnipodUIComm;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
|
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
|
||||||
|
@ -75,9 +76,10 @@ import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodS
|
||||||
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;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
|
||||||
import info.nightscout.androidaps.utils.TimeChangeType;
|
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
@ -87,16 +89,20 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
* @author Andy Rozman (andy.rozman@gmail.com)
|
* @author Andy Rozman (andy.rozman@gmail.com)
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPumpPluginInterface {
|
public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPumpPluginInterface, RileyLinkPumpDevice {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||||
|
|
||||||
private static OmnipodPumpPlugin plugin = null;
|
private static OmnipodPumpPlugin plugin = null;
|
||||||
private RileyLinkOmnipodService omnipodService;
|
private RileyLinkServiceData rileyLinkServiceData;
|
||||||
protected OmnipodPumpStatus pumpStatusLocal = null;
|
private ServiceTaskExecutor serviceTaskExecutor;
|
||||||
|
private RileyLinkOmnipodService rileyLinkOmnipodService;
|
||||||
|
private OmnipodUtil omnipodUtil;
|
||||||
|
protected OmnipodPumpStatus omnipodPumpStatus = null;
|
||||||
protected OmnipodUIComm omnipodUIComm;
|
protected OmnipodUIComm omnipodUIComm;
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
|
||||||
// variables for handling statuses and history
|
// variables for handling statuses and history
|
||||||
protected boolean firstRun = true;
|
protected boolean firstRun = true;
|
||||||
protected boolean isRefresh = false;
|
protected boolean isRefresh = false;
|
||||||
|
@ -126,9 +132,13 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
Context context,
|
Context context,
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
ActivePluginProvider activePlugin,
|
ActivePluginProvider activePlugin,
|
||||||
info.nightscout.androidaps.utils.sharedPreferences.SP sp,
|
SP sp,
|
||||||
|
OmnipodUtil omnipodUtil,
|
||||||
|
OmnipodPumpStatus omnipodPumpStatus,
|
||||||
CommandQueueProvider commandQueue,
|
CommandQueueProvider commandQueue,
|
||||||
FabricPrivacy fabricPrivacy) {
|
FabricPrivacy fabricPrivacy,
|
||||||
|
RileyLinkServiceData rileyLinkServiceData,
|
||||||
|
ServiceTaskExecutor serviceTaskExecutor) {
|
||||||
|
|
||||||
super(new PluginDescription() //
|
super(new PluginDescription() //
|
||||||
.mainType(PluginType.PUMP) //
|
.mainType(PluginType.PUMP) //
|
||||||
|
@ -140,9 +150,13 @@ 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
|
||||||
);
|
);
|
||||||
|
this.rileyLinkServiceData = rileyLinkServiceData;
|
||||||
|
this.serviceTaskExecutor = serviceTaskExecutor;
|
||||||
|
|
||||||
displayConnectionMessages = false;
|
displayConnectionMessages = false;
|
||||||
OmnipodPumpPlugin.plugin = this;
|
OmnipodPumpPlugin.plugin = this;
|
||||||
|
this.omnipodUtil = omnipodUtil;
|
||||||
|
this.omnipodPumpStatus = omnipodPumpStatus;
|
||||||
|
|
||||||
//OmnipodUtil.setDriverState();
|
//OmnipodUtil.setDriverState();
|
||||||
|
|
||||||
|
@ -156,13 +170,14 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
// // TODO ccc
|
// // TODO ccc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
serviceConnection = new ServiceConnection() {
|
serviceConnection = new ServiceConnection() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMP, "RileyLinkOmnipodService is disconnected");
|
aapsLogger.debug(LTag.PUMP, "RileyLinkOmnipodService is disconnected");
|
||||||
omnipodService = null;
|
rileyLinkOmnipodService = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -170,34 +185,43 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMP, "RileyLinkOmnipodService is connected");
|
aapsLogger.debug(LTag.PUMP, "RileyLinkOmnipodService is connected");
|
||||||
RileyLinkOmnipodService.LocalBinder mLocalBinder = (RileyLinkOmnipodService.LocalBinder) service;
|
RileyLinkOmnipodService.LocalBinder mLocalBinder = (RileyLinkOmnipodService.LocalBinder) service;
|
||||||
omnipodService = mLocalBinder.getServiceInstance();
|
rileyLinkOmnipodService = mLocalBinder.getServiceInstance();
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
|
|
||||||
if (pumpStatusLocal != null) {
|
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMP, "Starting OmniPod-RileyLink service");
|
|
||||||
if (OmnipodUtil.getPumpStatus().setNotInPreInit()) {
|
|
||||||
if (omnipodCommunicationManager == null) {
|
|
||||||
omnipodCommunicationManager = AapsOmnipodManager.getInstance();
|
|
||||||
omnipodCommunicationManager.setPumpStatus(pumpStatusLocal);
|
|
||||||
omnipodServiceRunning = true;
|
|
||||||
} else {
|
|
||||||
omnipodCommunicationManager.setPumpStatus(pumpStatusLocal);
|
|
||||||
}
|
|
||||||
|
|
||||||
OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros);
|
|
||||||
OmnipodUtil.setPlugin(OmnipodPumpPlugin.this);
|
|
||||||
|
|
||||||
omnipodUIComm = new OmnipodUIComm(omnipodCommunicationManager, plugin, pumpStatusLocal);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SystemClock.sleep(5000);
|
SystemClock.sleep(5000);
|
||||||
|
|
||||||
|
aapsLogger.debug(LTag.PUMP, "Starting Omnipod-RileyLink service");
|
||||||
|
if (rileyLinkOmnipodService.setNotInPreInit()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// if (OmnipodPumpPlugin.this.omnipodPumpStatus != null) {
|
||||||
|
//
|
||||||
|
// aapsLogger.debug(LTag.PUMP, "Starting OmniPod-RileyLink service");
|
||||||
|
// if (omnipodService.setNotInPreInit()) {
|
||||||
|
// if (omnipodCommunicationManager == null) {
|
||||||
|
// omnipodCommunicationManager = AapsOmnipodManager.getInstance();
|
||||||
|
// omnipodCommunicationManager.setPumpStatus(OmnipodPumpPlugin.this.omnipodPumpStatus);
|
||||||
|
// omnipodServiceRunning = true;
|
||||||
|
// } else {
|
||||||
|
// omnipodCommunicationManager.setPumpStatus(OmnipodPumpPlugin.this.omnipodPumpStatus);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// omnipodUtil.setOmnipodPodType(OmnipodPodType.Eros);
|
||||||
|
// //omnipodUtil.setPlugin(OmnipodPumpPlugin.this);
|
||||||
|
//
|
||||||
|
// omnipodUIComm = new OmnipodUIComm(omnipodCommunicationManager, plugin, OmnipodPumpPlugin.this.omnipodPumpStatus);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// SystemClock.sleep(5000);
|
||||||
|
//}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -214,6 +238,15 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
CommandQueueProvider commandQueue,
|
CommandQueueProvider commandQueue,
|
||||||
FabricPrivacy fabricPrivacy) {
|
FabricPrivacy fabricPrivacy) {
|
||||||
super(pluginDescription, pumpType, injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy);
|
super(pluginDescription, pumpType, injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy);
|
||||||
|
|
||||||
|
// this.rileyLinkUtil = rileyLinkUtil;
|
||||||
|
// this.medtronicUtil = medtronicUtil;
|
||||||
|
// this.sp = sp;
|
||||||
|
// this.medtronicPumpStatus = medtronicPumpStatus;
|
||||||
|
// this.medtronicHistoryData = medtronicHistoryData;
|
||||||
|
// this.rileyLinkServiceData = rileyLinkServiceData;
|
||||||
|
// this.serviceTaskExecutor = serviceTaskExecutor;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -237,10 +270,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
(event.isChanged(getResourceHelper(), R.string.key_omnipod_pod_debugging_options_enabled)) ||
|
(event.isChanged(getResourceHelper(), R.string.key_omnipod_pod_debugging_options_enabled)) ||
|
||||||
(event.isChanged(getResourceHelper(), R.string.key_omnipod_beep_smb_enabled)) ||
|
(event.isChanged(getResourceHelper(), R.string.key_omnipod_beep_smb_enabled)) ||
|
||||||
(event.isChanged(getResourceHelper(), R.string.key_omnipod_timechange_enabled)))
|
(event.isChanged(getResourceHelper(), R.string.key_omnipod_timechange_enabled)))
|
||||||
refreshConfiguration();
|
rileyLinkOmnipodService.verifyConfiguration();
|
||||||
}, fabricPrivacy::logException)
|
}, fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
refreshConfiguration();
|
//rileyLinkOmnipodService.verifyConfiguration();
|
||||||
|
//initPumpStatusData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
|
@ -248,11 +282,12 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private void refreshConfiguration() {
|
// private void refreshConfiguration() {
|
||||||
if (pumpStatusLocal != null) {
|
// if (pumpStatusLocal != null) {
|
||||||
pumpStatusLocal.refreshConfiguration();
|
// pumpStatusLocal.refreshConfiguration();
|
||||||
}
|
// }
|
||||||
}
|
// verifyConfiguration()
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
|
@ -268,27 +303,17 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
@Override
|
@Override
|
||||||
public void initPumpStatusData() {
|
public void initPumpStatusData() {
|
||||||
|
|
||||||
this.pumpStatusLocal = new OmnipodPumpStatus(pumpDescription);
|
omnipodPumpStatus.lastConnection = sp.getLong(RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
|
||||||
if (omnipodCommunicationManager != null) {
|
omnipodPumpStatus.lastDataTime = omnipodPumpStatus.lastConnection;
|
||||||
omnipodCommunicationManager.setPumpStatus(pumpStatusLocal);
|
omnipodPumpStatus.previousConnection = omnipodPumpStatus.lastConnection;
|
||||||
}
|
|
||||||
|
|
||||||
OmnipodUtil.setPumpStatus(pumpStatusLocal);
|
if (rileyLinkOmnipodService != null) rileyLinkOmnipodService.verifyConfiguration();
|
||||||
|
|
||||||
pumpStatusLocal.lastConnection = SP.getLong(RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
|
aapsLogger.debug(LTag.PUMP, "initPumpStatusData: " + this.omnipodPumpStatus);
|
||||||
pumpStatusLocal.lastDataTime = new LocalDateTime(pumpStatusLocal.lastConnection);
|
|
||||||
pumpStatusLocal.previousConnection = pumpStatusLocal.lastConnection;
|
|
||||||
|
|
||||||
pumpStatusLocal.refreshConfiguration();
|
// set first Omnipod Pump Start
|
||||||
|
if (!sp.contains(OmnipodConst.Statistics.FirstPumpStart)) {
|
||||||
|
sp.putLong(OmnipodConst.Statistics.FirstPumpStart, System.currentTimeMillis());
|
||||||
aapsLogger.debug(LTag.PUMP, "initPumpStatusData: {}", this.pumpStatusLocal);
|
|
||||||
|
|
||||||
this.pumpStatus = pumpStatusLocal;
|
|
||||||
|
|
||||||
// set first Omnipod Start
|
|
||||||
if (!SP.contains(OmnipodConst.Statistics.FirstPumpStart)) {
|
|
||||||
SP.putLong(OmnipodConst.Statistics.FirstPumpStart, System.currentTimeMillis());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -324,7 +349,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
if (System.currentTimeMillis() > this.nextPodCheck) {
|
if (System.currentTimeMillis() > this.nextPodCheck) {
|
||||||
if (OmnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) {
|
if (OmnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) {
|
||||||
Notification notification = new Notification(Notification.OMNIPOD_POD_NOT_ATTACHED, MainApp.gs(R.string.omnipod_error_pod_not_attached), Notification.NORMAL);
|
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));
|
rxBus.send(new EventNewNotification(notification));
|
||||||
} else {
|
} else {
|
||||||
rxBus.send(new EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED));
|
rxBus.send(new EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED));
|
||||||
|
@ -340,6 +365,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
return RileyLinkOmnipodService.class;
|
return RileyLinkOmnipodService.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PumpStatus getPumpStatusData() {
|
||||||
|
return this.omnipodPumpStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String deviceID() {
|
public String deviceID() {
|
||||||
|
@ -350,7 +380,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
// Pump Plugin
|
// Pump Plugin
|
||||||
|
|
||||||
private boolean isServiceSet() {
|
private boolean isServiceSet() {
|
||||||
return omnipodService != null;
|
return rileyLinkOmnipodService != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -369,7 +399,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
if (isServiceSet()) {
|
if (isServiceSet()) {
|
||||||
|
|
||||||
if (isBusy || !pumpStatusLocal.podAvailable)
|
if (isBusy || !omnipodPumpStatus.podAvailable)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (busyTimestamps.size() > 0) {
|
if (busyTimestamps.size() > 0) {
|
||||||
|
@ -384,6 +414,30 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetRileyLinkConfiguration() {
|
||||||
|
rileyLinkOmnipodService.resetRileyLinkConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasTuneUp() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doTuneUpDevice() {
|
||||||
|
rileyLinkOmnipodService.doTuneUpDevice();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RileyLinkOmnipodService getRileyLinkService() {
|
||||||
|
return rileyLinkOmnipodService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private synchronized void clearBusyQueue() {
|
private synchronized void clearBusyQueue() {
|
||||||
|
|
||||||
if (busyTimestamps.size() == 0) {
|
if (busyTimestamps.size() == 0) {
|
||||||
|
@ -415,7 +469,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
if (displayConnectionMessages)
|
if (displayConnectionMessages)
|
||||||
aapsLogger.debug(LTag.PUMP, getLogPrefix() + "isConnected");
|
aapsLogger.debug(LTag.PUMP, getLogPrefix() + "isConnected");
|
||||||
return isServiceSet() && omnipodService.isInitialized();
|
return isServiceSet() && rileyLinkOmnipodService.isInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -423,15 +477,15 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
public boolean isConnecting() {
|
public boolean isConnecting() {
|
||||||
if (displayConnectionMessages)
|
if (displayConnectionMessages)
|
||||||
aapsLogger.debug(LTag.PUMP, getLogPrefix() + "isConnecting");
|
aapsLogger.debug(LTag.PUMP, getLogPrefix() + "isConnecting");
|
||||||
return !isServiceSet() || !omnipodService.isInitialized();
|
return !isServiceSet() || !rileyLinkOmnipodService.isInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSuspended() {
|
public boolean isSuspended() {
|
||||||
|
|
||||||
return (OmnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) ||
|
return (omnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) ||
|
||||||
(OmnipodUtil.getPodSessionState() != null && OmnipodUtil.getPodSessionState().isSuspended());
|
(omnipodUtil.getPodSessionState() != null && omnipodUtil.getPodSessionState().isSuspended());
|
||||||
|
|
||||||
// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) ||
|
// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) ||
|
||||||
// (OmnipodUtil.getPodSessionState() != null && OmnipodUtil.getPodSessionState().isSuspended());
|
// (OmnipodUtil.getPodSessionState() != null && OmnipodUtil.getPodSessionState().isSuspended());
|
||||||
|
@ -494,7 +548,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
Notification notification = new Notification(
|
Notification notification = new Notification(
|
||||||
Notification.TIME_OR_TIMEZONE_CHANGE,
|
Notification.TIME_OR_TIMEZONE_CHANGE,
|
||||||
MainApp.gs(R.string.time_or_timezone_change),
|
resourceHelper.gs(R.string.time_or_timezone_change),
|
||||||
Notification.INFO, 60);
|
Notification.INFO, 60);
|
||||||
rxBus.send(new EventNewNotification(notification));
|
rxBus.send(new EventNewNotification(notification));
|
||||||
|
|
||||||
|
@ -565,16 +619,16 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
PodSessionState podSessionState = null;
|
PodSessionState podSessionState = null;
|
||||||
|
|
||||||
if (OmnipodUtil.getPodSessionState() != null) {
|
if (omnipodUtil.getPodSessionState() != null) {
|
||||||
podSessionState = OmnipodUtil.getPodSessionState();
|
podSessionState = omnipodUtil.getPodSessionState();
|
||||||
} else {
|
} else {
|
||||||
String podState = SP.getString(OmnipodConst.Prefs.PodState, null);
|
String podState = sp.getString(OmnipodConst.Prefs.PodState, null);
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMP, "PodSessionState-SP: loaded from SharedPreferences: " + podState);
|
aapsLogger.info(LTag.PUMP, "PodSessionState-SP: loaded from SharedPreferences: " + podState);
|
||||||
|
|
||||||
if (podState != null) {
|
if (podState != null) {
|
||||||
podSessionState = OmnipodUtil.getGsonInstance().fromJson(podState, PodSessionState.class);
|
podSessionState = OmnipodUtil.getGsonInstance().fromJson(podState, PodSessionState.class);
|
||||||
OmnipodUtil.setPodSessionState(podSessionState);
|
omnipodUtil.setPodSessionState(podSessionState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,8 +683,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
public long lastDataTime() {
|
public long lastDataTime() {
|
||||||
getPodPumpStatusObject();
|
getPodPumpStatusObject();
|
||||||
|
|
||||||
if (pumpStatusLocal.lastConnection != 0) {
|
if (omnipodPumpStatus.lastConnection != 0) {
|
||||||
return pumpStatusLocal.lastConnection;
|
return omnipodPumpStatus.lastConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
return System.currentTimeMillis();
|
return System.currentTimeMillis();
|
||||||
|
@ -662,17 +716,17 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
|
|
||||||
protected OmnipodPumpStatus getPodPumpStatusObject() {
|
protected OmnipodPumpStatus getPodPumpStatusObject() {
|
||||||
if (pumpStatusLocal == null) {
|
if (omnipodPumpStatus == null) {
|
||||||
// FIXME I don't know why this happens
|
// FIXME I don't know why this happens
|
||||||
|
|
||||||
aapsLogger.warn(LTag.PUMP, "!!!! Reset Pump Status Local");
|
aapsLogger.warn(LTag.PUMP, "!!!! Reset Pump Status Local");
|
||||||
pumpStatusLocal = OmnipodUtil.getPumpStatus();
|
// pumpStatusLocal = OmnipodUtil.getPumpStatus();
|
||||||
if (omnipodCommunicationManager != null) {
|
// if (omnipodCommunicationManager != null) {
|
||||||
omnipodCommunicationManager.setPumpStatus(pumpStatusLocal);
|
// omnipodCommunicationManager.setPumpStatus(pumpStatusLocal);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
return pumpStatusLocal;
|
return omnipodPumpStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -744,9 +798,9 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
|
|
||||||
private void incrementStatistics(String statsKey) {
|
private void incrementStatistics(String statsKey) {
|
||||||
long currentCount = SP.getLong(statsKey, 0L);
|
long currentCount = sp.getLong(statsKey, 0L);
|
||||||
currentCount++;
|
currentCount++;
|
||||||
SP.putLong(statsKey, currentCount);
|
sp.putLong(statsKey, currentCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -823,14 +877,14 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
protected TempBasalPair readTBR() {
|
protected TempBasalPair readTBR() {
|
||||||
// TODO we can do it like this or read status from pod ??
|
// TODO we can do it like this or read status from pod ??
|
||||||
if (pumpStatusLocal.tempBasalEnd < System.currentTimeMillis()) {
|
if (omnipodPumpStatus.tempBasalEnd < System.currentTimeMillis()) {
|
||||||
// TBR done
|
// TBR done
|
||||||
pumpStatusLocal.clearTemporaryBasal();
|
omnipodPumpStatus.clearTemporaryBasal();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pumpStatusLocal.getTemporaryBasal();
|
return omnipodPumpStatus.getTemporaryBasal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -955,7 +1009,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
switch (mcat) {
|
switch (mcat) {
|
||||||
|
|
||||||
case ResetRileyLinkConfiguration: {
|
case ResetRileyLinkConfiguration: {
|
||||||
ServiceTaskExecutor.startTask(new ResetRileyLinkConfigurationTask());
|
serviceTaskExecutor.startTask(new ResetRileyLinkConfigurationTask(getInjector()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -968,10 +1022,10 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
@Override
|
@Override
|
||||||
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||||
|
|
||||||
aapsLogger.warn(LTag.PUMP, getLogPrefix() + "Time, Date and/or TimeZone changed. [changeType=" + timeChangeType.name() + ", eventHandlingEnabled=" + pumpStatusLocal.timeChangeEventEnabled + "]");
|
aapsLogger.warn(LTag.PUMP, getLogPrefix() + "Time, Date and/or TimeZone changed. [changeType=" + timeChangeType.name() + ", eventHandlingEnabled=" + omnipodPumpStatus.timeChangeEventEnabled + "]");
|
||||||
|
|
||||||
if (OmnipodUtil.getDriverState() == OmnipodDriverState.Initalized_PodAttached) {
|
if (OmnipodUtil.getDriverState() == OmnipodDriverState.Initalized_PodAttached) {
|
||||||
if (pumpStatusLocal.timeChangeEventEnabled) {
|
if (omnipodPumpStatus.timeChangeEventEnabled) {
|
||||||
aapsLogger.info(LTag.PUMP, getLogPrefix() + "Time,and/or TimeZone changed event received and will be consumed by driver.");
|
aapsLogger.info(LTag.PUMP, getLogPrefix() + "Time,and/or TimeZone changed event received and will be consumed by driver.");
|
||||||
this.hasTimeDateOrTimeZoneChanged = true;
|
this.hasTimeDateOrTimeZoneChanged = true;
|
||||||
}
|
}
|
||||||
|
@ -982,9 +1036,9 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
public boolean isUnreachableAlertTimeoutExceeded(long unreachableTimeoutMilliseconds) {
|
public boolean isUnreachableAlertTimeoutExceeded(long unreachableTimeoutMilliseconds) {
|
||||||
getPodPumpStatusObject();
|
getPodPumpStatusObject();
|
||||||
|
|
||||||
if (pumpStatusLocal.lastConnection != 0 || pumpStatusLocal.lastErrorConnection != 0) {
|
if (omnipodPumpStatus.lastConnection != 0 || omnipodPumpStatus.lastErrorConnection != 0) {
|
||||||
if (pumpStatusLocal.lastConnection + unreachableTimeoutMilliseconds < System.currentTimeMillis()) {
|
if (omnipodPumpStatus.lastConnection + unreachableTimeoutMilliseconds < System.currentTimeMillis()) {
|
||||||
if (pumpStatusLocal.lastErrorConnection > pumpStatusLocal.lastConnection) {
|
if (omnipodPumpStatus.lastErrorConnection > omnipodPumpStatus.lastConnection) {
|
||||||
// We exceeded the alert threshold, and our last connection failed
|
// We exceeded the alert threshold, and our last connection failed
|
||||||
// We should show an alert
|
// We should show an alert
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -8,9 +8,13 @@ import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RLMessage;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RLMessage;
|
||||||
|
@ -22,8 +26,10 @@ import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicConverter;
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicConverter;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder;
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.OmnipodAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.OmnipodAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.MessageBlock;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.MessageBlock;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
||||||
|
@ -44,6 +50,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalRes
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceOutOfSyncException;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceOutOfSyncException;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceResyncException;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceResyncException;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NotEnoughDataException;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NotEnoughDataException;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.exception.OmnipodException;
|
import info.nightscout.androidaps.plugins.pump.omnipod.exception.OmnipodException;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodFaultException;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodFaultException;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodReturnedErrorResponseException;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodReturnedErrorResponseException;
|
||||||
|
@ -51,26 +58,25 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodReturne
|
||||||
/**
|
/**
|
||||||
* Created by andy on 6/29/18.
|
* Created by andy on 6/29/18.
|
||||||
*/
|
*/
|
||||||
// FIXME should be named OmnipodCommunicationManager
|
public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
||||||
public class OmnipodCommunicationService extends RileyLinkCommunicationManager {
|
|
||||||
|
|
||||||
@Inject AAPSLogger aapsLogger;
|
@Inject AAPSLogger aapsLogger;
|
||||||
@Inject MedtronicPumpStatus medtronicPumpStatus;
|
@Inject OmnipodPumpStatus omnipodPumpStatus;
|
||||||
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
@Inject OmnipodPumpPlugin omnipodPumpPlugin;
|
||||||
@Inject MedtronicConverter medtronicConverter;
|
|
||||||
@Inject MedtronicUtil medtronicUtil;
|
|
||||||
@Inject MedtronicPumpHistoryDecoder medtronicPumpHistoryDecoder;
|
|
||||||
@Inject RileyLinkServiceData rileyLinkServiceData;
|
@Inject RileyLinkServiceData rileyLinkServiceData;
|
||||||
@Inject ServiceTaskExecutor serviceTaskExecutor;
|
@Inject ServiceTaskExecutor serviceTaskExecutor;
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public OmnipodCommunicationService(RFSpy rfspy) {
|
//private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||||
super(rfspy);
|
|
||||||
|
public OmnipodCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) {
|
||||||
|
super(injector, rfspy);
|
||||||
|
omnipodPumpStatus.previousConnection = sp.getLong(
|
||||||
|
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
protected void configurePumpSpecificSettings() {
|
// protected void configurePumpSpecificSettings() {
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean tryToConnectToDevice() {
|
public boolean tryToConnectToDevice() {
|
||||||
|
@ -83,6 +89,14 @@ public class OmnipodCommunicationService extends RileyLinkCommunicationManager {
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public PumpStatus getPumpStatus() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean isDeviceReachable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasTunning() {
|
public boolean hasTunning() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -93,6 +107,11 @@ public class OmnipodCommunicationService extends RileyLinkCommunicationManager {
|
||||||
return (E) new OmnipodPacket(payload);
|
return (E) new OmnipodPacket(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPumpDeviceState(PumpDeviceState pumpDeviceState) {
|
||||||
|
this.omnipodPumpStatus.setPumpDeviceState(pumpDeviceState);
|
||||||
|
}
|
||||||
|
|
||||||
public <T extends MessageBlock> T sendCommand(Class<T> responseClass, PodState podState, MessageBlock command) {
|
public <T extends MessageBlock> T sendCommand(Class<T> responseClass, PodState podState, MessageBlock command) {
|
||||||
return sendCommand(responseClass, podState, command, true);
|
return sendCommand(responseClass, podState, command, true);
|
||||||
}
|
}
|
||||||
|
@ -120,10 +139,10 @@ public class OmnipodCommunicationService extends RileyLinkCommunicationManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized <T extends MessageBlock> T exchangeMessages(Class<T> responseClass, PodState podState, OmnipodMessage message, Integer addressOverride, Integer ackAddressOverride, boolean automaticallyResyncNonce) {
|
public synchronized <T extends MessageBlock> T exchangeMessages(Class<T> responseClass, PodState podState, OmnipodMessage message, Integer addressOverride, Integer ackAddressOverride, boolean automaticallyResyncNonce) {
|
||||||
if (isLoggingEnabled()) {
|
|
||||||
LOG.debug("Exchanging OmnipodMessage [responseClass={}, podState={}, message={}, addressOverride={}, ackAddressOverride={}, automaticallyResyncNonce={}]: {}", //
|
aapsLogger.debug(LTag.PUMPCOMM,"Exchanging OmnipodMessage [responseClass={}, podState={}, message={}, addressOverride={}, ackAddressOverride={}, automaticallyResyncNonce={}]: {}", //
|
||||||
responseClass.getSimpleName(), podState, message, addressOverride, ackAddressOverride, automaticallyResyncNonce, message);
|
responseClass.getSimpleName(), podState, message, addressOverride, ackAddressOverride, automaticallyResyncNonce, message);
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; 2 > i; i++) {
|
for (int i = 0; 2 > i; i++) {
|
||||||
|
|
||||||
|
@ -216,9 +235,8 @@ public class OmnipodCommunicationService extends RileyLinkCommunicationManager {
|
||||||
// so it's impossible for the pod to have received the message
|
// so it's impossible for the pod to have received the message
|
||||||
newException.setCertainFailure(!lastPacket);
|
newException.setCertainFailure(!lastPacket);
|
||||||
|
|
||||||
if (isLoggingEnabled()) {
|
|
||||||
LOG.debug("Caught exception in transportMessages. Set certainFailure to {} because encodedMessage.length={}", newException.isCertainFailure(), encodedMessage.length);
|
aapsLogger.debug(LTag.PUMPCOMM,"Caught exception in transportMessages. Set certainFailure to {} because encodedMessage.length={}", newException.isCertainFailure(), encodedMessage.length);
|
||||||
}
|
|
||||||
|
|
||||||
throw newException;
|
throw newException;
|
||||||
}
|
}
|
||||||
|
@ -263,9 +281,7 @@ public class OmnipodCommunicationService extends RileyLinkCommunicationManager {
|
||||||
throw new NotEnoughDataException(receivedMessageData);
|
throw new NotEnoughDataException(receivedMessageData);
|
||||||
} else if (messageBlocks.size() > 1) {
|
} else if (messageBlocks.size() > 1) {
|
||||||
// BS: don't expect this to happen
|
// BS: don't expect this to happen
|
||||||
if (isLoggingEnabled()) {
|
aapsLogger.error(LTag.PUMPCOMM,"Received more than one message block: {}", messageBlocks.toString());
|
||||||
LOG.error("Received more than one message block: {}", messageBlocks.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return messageBlocks.get(0);
|
return messageBlocks.get(0);
|
||||||
|
@ -292,14 +308,10 @@ public class OmnipodCommunicationService extends RileyLinkCommunicationManager {
|
||||||
if (RileyLinkBLEError.Timeout.equals(ex.getErrorCode())) {
|
if (RileyLinkBLEError.Timeout.equals(ex.getErrorCode())) {
|
||||||
quiet = true;
|
quiet = true;
|
||||||
} else {
|
} else {
|
||||||
if (isLoggingEnabled()) {
|
aapsLogger.debug(LTag.PUMPCOMM,"Ignoring exception in ackUntilQuiet", ex);
|
||||||
LOG.debug("Ignoring exception in ackUntilQuiet", ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (OmnipodException ex) {
|
} catch (OmnipodException ex) {
|
||||||
if (isLoggingEnabled()) {
|
aapsLogger.debug(LTag.PUMPCOMM,"Ignoring exception in ackUntilQuiet", ex);
|
||||||
LOG.debug("Ignoring exception in ackUntilQuiet", ex);
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new CommunicationException(CommunicationException.Type.UNEXPECTED_EXCEPTION, ex);
|
throw new CommunicationException(CommunicationException.Type.UNEXPECTED_EXCEPTION, ex);
|
||||||
}
|
}
|
||||||
|
@ -323,9 +335,7 @@ public class OmnipodCommunicationService extends RileyLinkCommunicationManager {
|
||||||
try {
|
try {
|
||||||
response = sendAndListen(packet, responseTimeoutMilliseconds, repeatCount, 9, preambleExtensionMilliseconds, OmnipodPacket.class);
|
response = sendAndListen(packet, responseTimeoutMilliseconds, repeatCount, 9, preambleExtensionMilliseconds, OmnipodPacket.class);
|
||||||
} catch (RileyLinkCommunicationException | OmnipodException ex) {
|
} catch (RileyLinkCommunicationException | OmnipodException ex) {
|
||||||
if (isLoggingEnabled()) {
|
aapsLogger.debug(LTag.PUMPCOMM,"Ignoring exception in exchangePackets", ex);
|
||||||
LOG.debug("Ignoring exception in exchangePackets", ex);
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new CommunicationException(CommunicationException.Type.UNEXPECTED_EXCEPTION, ex);
|
throw new CommunicationException(CommunicationException.Type.UNEXPECTED_EXCEPTION, ex);
|
||||||
}
|
}
|
||||||
|
@ -345,7 +355,4 @@ public class OmnipodCommunicationService extends RileyLinkCommunicationManager {
|
||||||
throw new CommunicationException(CommunicationException.Type.TIMEOUT);
|
throw new CommunicationException(CommunicationException.Type.TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLoggingEnabled() {
|
|
||||||
return L.isEnabled(L.PUMPCOMM);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,12 @@ import java.util.EnumSet;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.AcknowledgeAlertsAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.AcknowledgeAlertsAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.AssignAddressAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.AssignAddressAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.BolusAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.BolusAction;
|
||||||
|
@ -44,7 +49,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceOutOf
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.exception.OmnipodException;
|
import info.nightscout.androidaps.plugins.pump.omnipod.exception.OmnipodException;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodFaultException;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodFaultException;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.Completable;
|
import io.reactivex.Completable;
|
||||||
import io.reactivex.Flowable;
|
import io.reactivex.Flowable;
|
||||||
import io.reactivex.Single;
|
import io.reactivex.Single;
|
||||||
|
@ -55,17 +61,25 @@ import io.reactivex.subjects.SingleSubject;
|
||||||
public class OmnipodManager {
|
public class OmnipodManager {
|
||||||
private static final int ACTION_VERIFICATION_TRIES = 3;
|
private static final int ACTION_VERIFICATION_TRIES = 3;
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
//private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||||
|
|
||||||
protected final OmnipodCommunicationService communicationService;
|
protected final OmnipodCommunicationManager communicationService;
|
||||||
private final PodStateChangedHandler podStateChangedHandler;
|
private final PodStateChangedHandler podStateChangedHandler;
|
||||||
protected PodSessionState podState;
|
protected PodSessionState podState;
|
||||||
|
|
||||||
private ActiveBolusData activeBolusData;
|
private ActiveBolusData activeBolusData;
|
||||||
private final Object bolusDataMutex = new Object();
|
private final Object bolusDataMutex = new Object();
|
||||||
|
|
||||||
public OmnipodManager(OmnipodCommunicationService communicationService, PodSessionState podState,
|
private HasAndroidInjector injector;
|
||||||
|
@Inject AAPSLogger aapsLogger;
|
||||||
|
@Inject SP sp;
|
||||||
|
|
||||||
|
public OmnipodManager(HasAndroidInjector injector,
|
||||||
|
OmnipodCommunicationManager communicationService,
|
||||||
|
PodSessionState podState,
|
||||||
PodStateChangedHandler podStateChangedHandler) {
|
PodStateChangedHandler podStateChangedHandler) {
|
||||||
|
this.injector = injector;
|
||||||
|
this.injector.androidInjector().inject(this);
|
||||||
if (communicationService == null) {
|
if (communicationService == null) {
|
||||||
throw new IllegalArgumentException("Communication service cannot be null");
|
throw new IllegalArgumentException("Communication service cannot be null");
|
||||||
}
|
}
|
||||||
|
@ -77,8 +91,10 @@ public class OmnipodManager {
|
||||||
this.podStateChangedHandler = podStateChangedHandler;
|
this.podStateChangedHandler = podStateChangedHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OmnipodManager(OmnipodCommunicationService communicationService, PodSessionState podState) {
|
public OmnipodManager(HasAndroidInjector injector,
|
||||||
this(communicationService, podState, null);
|
OmnipodCommunicationManager communicationService,
|
||||||
|
PodSessionState podState) {
|
||||||
|
this(injector, communicationService, podState, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Single<SetupActionResult> pairAndPrime() {
|
public synchronized Single<SetupActionResult> pairAndPrime() {
|
||||||
|
@ -239,7 +255,7 @@ public class OmnipodManager {
|
||||||
return executeAndVerify(() -> {
|
return executeAndVerify(() -> {
|
||||||
StatusResponse statusResponse = communicationService.executeAction(new CancelDeliveryAction(podState, deliveryTypes, acknowledgementBeep));
|
StatusResponse statusResponse = communicationService.executeAction(new CancelDeliveryAction(podState, deliveryTypes, acknowledgementBeep));
|
||||||
if (isLoggingEnabled()) {
|
if (isLoggingEnabled()) {
|
||||||
LOG.info("Status response after cancel delivery[types={}]: {}", deliveryTypes.toString(), statusResponse.toString());
|
aapsLogger.info(LTag.PUMPCOMM,"Status response after cancel delivery[types={}]: {}", deliveryTypes.toString(), statusResponse.toString());
|
||||||
}
|
}
|
||||||
return statusResponse;
|
return statusResponse;
|
||||||
});
|
});
|
||||||
|
@ -267,7 +283,7 @@ public class OmnipodManager {
|
||||||
|
|
||||||
// Catch uncertain exceptions as we still want to report bolus progress indication
|
// Catch uncertain exceptions as we still want to report bolus progress indication
|
||||||
if (isLoggingEnabled()) {
|
if (isLoggingEnabled()) {
|
||||||
LOG.error("Caught exception[certainFailure=false] in bolus", ex);
|
aapsLogger.error(LTag.PUMPCOMM,"Caught exception[certainFailure=false] in bolus", ex);
|
||||||
}
|
}
|
||||||
commandDeliveryStatus = CommandDeliveryStatus.UNCERTAIN_FAILURE;
|
commandDeliveryStatus = CommandDeliveryStatus.UNCERTAIN_FAILURE;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -320,12 +336,12 @@ public class OmnipodManager {
|
||||||
unitsNotDelivered = ex.getFaultEvent().getInsulinNotDelivered();
|
unitsNotDelivered = ex.getFaultEvent().getInsulinNotDelivered();
|
||||||
|
|
||||||
if (isLoggingEnabled()) {
|
if (isLoggingEnabled()) {
|
||||||
LOG.debug("Caught PodFaultException in bolus completion verification", ex);
|
aapsLogger.debug(LTag.PUMPCOMM,"Caught PodFaultException in bolus completion verification", ex);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (isLoggingEnabled()) {
|
if (isLoggingEnabled()) {
|
||||||
LOG.debug("Ignoring exception in bolus completion verification", ex);
|
aapsLogger.debug(LTag.PUMPCOMM,"Ignoring exception in bolus completion verification", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -434,9 +450,9 @@ public class OmnipodManager {
|
||||||
try {
|
try {
|
||||||
PodInfoResponse podInfoResponse = communicationService.executeAction(new GetPodInfoAction(podState, PodInfoType.RECENT_PULSE_LOG));
|
PodInfoResponse podInfoResponse = communicationService.executeAction(new GetPodInfoAction(podState, PodInfoType.RECENT_PULSE_LOG));
|
||||||
PodInfoRecentPulseLog pulseLogInfo = podInfoResponse.getPodInfo();
|
PodInfoRecentPulseLog pulseLogInfo = podInfoResponse.getPodInfo();
|
||||||
LOG.info("Retrieved pulse log from the pod: {}", pulseLogInfo.toString());
|
aapsLogger.info(LTag.PUMPCOMM,"Retrieved pulse log from the pod: {}", pulseLogInfo.toString());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOG.warn("Failed to retrieve pulse log from the pod", ex);
|
aapsLogger.warn(LTag.PUMPCOMM,"Failed to retrieve pulse log from the pod", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +461,7 @@ public class OmnipodManager {
|
||||||
communicationService.executeAction(new DeactivatePodAction(podState, true));
|
communicationService.executeAction(new DeactivatePodAction(podState, true));
|
||||||
} catch (PodFaultException ex) {
|
} catch (PodFaultException ex) {
|
||||||
if (isLoggingEnabled()) {
|
if (isLoggingEnabled()) {
|
||||||
LOG.info("Ignoring PodFaultException in deactivatePod", ex);
|
aapsLogger.info(LTag.PUMPCOMM,"Ignoring PodFaultException in deactivatePod", ex);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
logCommandExecutionFinished("deactivatePod");
|
logCommandExecutionFinished("deactivatePod");
|
||||||
|
@ -456,13 +472,13 @@ public class OmnipodManager {
|
||||||
|
|
||||||
public void resetPodState(boolean forcedByUser) {
|
public void resetPodState(boolean forcedByUser) {
|
||||||
if (isLoggingEnabled()) {
|
if (isLoggingEnabled()) {
|
||||||
LOG.warn("resetPodState has been called. forcedByUser={}", forcedByUser);
|
aapsLogger.warn(LTag.PUMPCOMM,"resetPodState has been called. forcedByUser={}", forcedByUser);
|
||||||
}
|
}
|
||||||
podState = null;
|
podState = null;
|
||||||
SP.remove(OmnipodConst.Prefs.PodState);
|
sp.remove(OmnipodConst.Prefs.PodState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OmnipodCommunicationService getCommunicationService() {
|
public OmnipodCommunicationManager getCommunicationService() {
|
||||||
return communicationService;
|
return communicationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +515,7 @@ public class OmnipodManager {
|
||||||
throw originalException;
|
throw originalException;
|
||||||
} else {
|
} else {
|
||||||
if (isLoggingEnabled()) {
|
if (isLoggingEnabled()) {
|
||||||
LOG.warn("Caught exception in executeAndVerify. Verifying command by using cancel none command to verify nonce", originalException);
|
aapsLogger.warn(LTag.PUMPCOMM,"Caught exception in executeAndVerify. Verifying command by using cancel none command to verify nonce", originalException);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -507,13 +523,13 @@ public class OmnipodManager {
|
||||||
StatusResponse statusResponse = communicationService.sendCommand(StatusResponse.class, podState,
|
StatusResponse statusResponse = communicationService.sendCommand(StatusResponse.class, podState,
|
||||||
new CancelDeliveryCommand(podState.getCurrentNonce(), BeepType.NO_BEEP, DeliveryType.NONE), false);
|
new CancelDeliveryCommand(podState.getCurrentNonce(), BeepType.NO_BEEP, DeliveryType.NONE), false);
|
||||||
if (isLoggingEnabled()) {
|
if (isLoggingEnabled()) {
|
||||||
LOG.info("Command status resolved to SUCCESS. Status response after cancelDelivery[types=DeliveryType.NONE]: {}", statusResponse);
|
aapsLogger.info(LTag.PUMPCOMM,"Command status resolved to SUCCESS. Status response after cancelDelivery[types=DeliveryType.NONE]: {}", statusResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
return statusResponse;
|
return statusResponse;
|
||||||
} catch (NonceOutOfSyncException verificationException) {
|
} catch (NonceOutOfSyncException verificationException) {
|
||||||
if (isLoggingEnabled()) {
|
if (isLoggingEnabled()) {
|
||||||
LOG.error("Command resolved to FAILURE (CERTAIN_FAILURE)", verificationException);
|
aapsLogger.error(LTag.PUMPCOMM,"Command resolved to FAILURE (CERTAIN_FAILURE)", verificationException);
|
||||||
}
|
}
|
||||||
if (originalException instanceof OmnipodException) {
|
if (originalException instanceof OmnipodException) {
|
||||||
((OmnipodException) originalException).setCertainFailure(true);
|
((OmnipodException) originalException).setCertainFailure(true);
|
||||||
|
@ -525,7 +541,7 @@ public class OmnipodManager {
|
||||||
}
|
}
|
||||||
} catch (Exception verificationException) {
|
} catch (Exception verificationException) {
|
||||||
if (isLoggingEnabled()) {
|
if (isLoggingEnabled()) {
|
||||||
LOG.error("Command unresolved (UNCERTAIN_FAILURE)", verificationException);
|
aapsLogger.error(LTag.PUMPCOMM,"Command unresolved (UNCERTAIN_FAILURE)", verificationException);
|
||||||
}
|
}
|
||||||
throw originalException;
|
throw originalException;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -566,18 +582,19 @@ public class OmnipodManager {
|
||||||
|
|
||||||
private void logStartingCommandExecution(String action) {
|
private void logStartingCommandExecution(String action) {
|
||||||
if (isLoggingEnabled()) {
|
if (isLoggingEnabled()) {
|
||||||
LOG.debug("Starting command execution for action: " + action);
|
aapsLogger.debug(LTag.PUMPCOMM,"Starting command execution for action: " + action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logCommandExecutionFinished(String action) {
|
private void logCommandExecutionFinished(String action) {
|
||||||
if (isLoggingEnabled()) {
|
if (isLoggingEnabled()) {
|
||||||
LOG.debug("Command execution finished for action: " + action);
|
aapsLogger.debug(LTag.PUMPCOMM,"Command execution finished for action: " + action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO remove this
|
||||||
private boolean isLoggingEnabled() {
|
private boolean isLoggingEnabled() {
|
||||||
return L.isEnabled(L.PUMP);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Duration calculateBolusDuration(double units, double deliveryRate) {
|
private static Duration calculateBolusDuration(double units, double deliveryRate) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.comm.action;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.AcknowledgeAlertsCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.AcknowledgeAlertsCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSet;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSet;
|
||||||
|
@ -32,7 +32,7 @@ public class AcknowledgeAlertsAction implements OmnipodAction<StatusResponse> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatusResponse execute(OmnipodCommunicationService communicationService) {
|
public StatusResponse execute(OmnipodCommunicationManager communicationService) {
|
||||||
return communicationService.sendCommand(StatusResponse.class, podState,
|
return communicationService.sendCommand(StatusResponse.class, podState,
|
||||||
new AcknowledgeAlertsCommand(podState.getCurrentNonce(), alerts));
|
new AcknowledgeAlertsCommand(podState.getCurrentNonce(), alerts));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.joda.time.DateTimeZone;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.AssignAddressCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.AssignAddressCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.VersionResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.VersionResponse;
|
||||||
|
@ -28,7 +28,7 @@ public class AssignAddressAction implements OmnipodAction<PodSessionState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodSessionState execute(OmnipodCommunicationService communicationService) {
|
public PodSessionState execute(OmnipodCommunicationManager communicationService) {
|
||||||
PodSetupState setupState = new PodSetupState(address, 0x00, 0x00);
|
PodSetupState setupState = new PodSetupState(address, 0x00, 0x00);
|
||||||
|
|
||||||
AssignAddressCommand assignAddress = new AssignAddressCommand(setupState.getAddress());
|
AssignAddressCommand assignAddress = new AssignAddressCommand(setupState.getAddress());
|
||||||
|
|
|
@ -4,7 +4,7 @@ import org.joda.time.Duration;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.BolusExtraCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.BolusExtraCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.SetInsulinScheduleCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.SetInsulinScheduleCommand;
|
||||||
|
@ -40,7 +40,7 @@ public class BolusAction implements OmnipodAction<StatusResponse> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatusResponse execute(OmnipodCommunicationService communicationService) {
|
public StatusResponse execute(OmnipodCommunicationManager communicationService) {
|
||||||
BolusDeliverySchedule bolusDeliverySchedule = new BolusDeliverySchedule(units, timeBetweenPulses);
|
BolusDeliverySchedule bolusDeliverySchedule = new BolusDeliverySchedule(units, timeBetweenPulses);
|
||||||
SetInsulinScheduleCommand setInsulinScheduleCommand = new SetInsulinScheduleCommand(
|
SetInsulinScheduleCommand setInsulinScheduleCommand = new SetInsulinScheduleCommand(
|
||||||
podState.getCurrentNonce(), bolusDeliverySchedule);
|
podState.getCurrentNonce(), bolusDeliverySchedule);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.MessageBlock;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.MessageBlock;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.CancelDeliveryCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.CancelDeliveryCommand;
|
||||||
|
@ -33,7 +33,7 @@ public class CancelDeliveryAction implements OmnipodAction<StatusResponse> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatusResponse execute(OmnipodCommunicationService communicationService) {
|
public StatusResponse execute(OmnipodCommunicationManager communicationService) {
|
||||||
List<MessageBlock> messageBlocks = new ArrayList<>();
|
List<MessageBlock> messageBlocks = new ArrayList<>();
|
||||||
|
|
||||||
if (acknowledgementBeep && deliveryTypes.size() > 1) {
|
if (acknowledgementBeep && deliveryTypes.size() > 1) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.comm.action;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.ConfigureAlertsCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.ConfigureAlertsCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertConfiguration;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertConfiguration;
|
||||||
|
@ -25,7 +25,7 @@ public class ConfigureAlertsAction implements OmnipodAction<StatusResponse> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatusResponse execute(OmnipodCommunicationService communicationService) {
|
public StatusResponse execute(OmnipodCommunicationManager communicationService) {
|
||||||
ConfigureAlertsCommand configureAlertsCommand = new ConfigureAlertsCommand(podState.getCurrentNonce(), alertConfigurations);
|
ConfigureAlertsCommand configureAlertsCommand = new ConfigureAlertsCommand(podState.getCurrentNonce(), alertConfigurations);
|
||||||
StatusResponse statusResponse = communicationService.sendCommand(StatusResponse.class, podState, configureAlertsCommand);
|
StatusResponse statusResponse = communicationService.sendCommand(StatusResponse.class, podState, configureAlertsCommand);
|
||||||
for (AlertConfiguration alertConfiguration : alertConfigurations) {
|
for (AlertConfiguration alertConfiguration : alertConfigurations) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import org.joda.time.DateTime;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.ConfigurePodCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.ConfigurePodCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.VersionResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.VersionResponse;
|
||||||
|
@ -25,7 +25,7 @@ public class ConfigurePodAction implements OmnipodAction<VersionResponse> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VersionResponse execute(OmnipodCommunicationService communicationService) {
|
public VersionResponse execute(OmnipodCommunicationManager communicationService) {
|
||||||
if (!podState.getSetupProgress().equals(SetupProgress.ADDRESS_ASSIGNED)) {
|
if (!podState.getSetupProgress().equals(SetupProgress.ADDRESS_ASSIGNED)) {
|
||||||
throw new IllegalSetupProgressException(SetupProgress.ADDRESS_ASSIGNED, podState.getSetupProgress());
|
throw new IllegalSetupProgressException(SetupProgress.ADDRESS_ASSIGNED, podState.getSetupProgress());
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.comm.action;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.DeactivatePodCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.DeactivatePodCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryType;
|
||||||
|
@ -23,7 +23,7 @@ public class DeactivatePodAction implements OmnipodAction<StatusResponse> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatusResponse execute(OmnipodCommunicationService communicationService) {
|
public StatusResponse execute(OmnipodCommunicationManager communicationService) {
|
||||||
if (!podState.isSuspended() && !podState.hasFaultEvent()) {
|
if (!podState.isSuspended() && !podState.hasFaultEvent()) {
|
||||||
try {
|
try {
|
||||||
communicationService.executeAction(new CancelDeliveryAction(podState,
|
communicationService.executeAction(new CancelDeliveryAction(podState,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.comm.action;
|
package info.nightscout.androidaps.plugins.pump.omnipod.comm.action;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.GetStatusCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.GetStatusCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoResponse;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
|
||||||
|
@ -23,7 +23,7 @@ public class GetPodInfoAction implements OmnipodAction<PodInfoResponse> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PodInfoResponse execute(OmnipodCommunicationService communicationService) {
|
public PodInfoResponse execute(OmnipodCommunicationManager communicationService) {
|
||||||
return communicationService.sendCommand(PodInfoResponse.class, podState, new GetStatusCommand(podInfoType));
|
return communicationService.sendCommand(PodInfoResponse.class, podState, new GetStatusCommand(podInfoType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.comm.action;
|
package info.nightscout.androidaps.plugins.pump.omnipod.comm.action;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.GetStatusCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.GetStatusCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
|
||||||
|
@ -18,7 +18,7 @@ public class GetStatusAction implements OmnipodAction<StatusResponse> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatusResponse execute(OmnipodCommunicationService communicationService) {
|
public StatusResponse execute(OmnipodCommunicationManager communicationService) {
|
||||||
return communicationService.sendCommand(StatusResponse.class, podState, new GetStatusCommand(PodInfoType.NORMAL));
|
return communicationService.sendCommand(StatusResponse.class, podState, new GetStatusCommand(PodInfoType.NORMAL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.comm.action;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.InsertCannulaService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.InsertCannulaService;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress;
|
||||||
|
@ -45,7 +45,7 @@ public class InsertCannulaAction implements OmnipodAction<StatusResponse> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatusResponse execute(OmnipodCommunicationService communicationService) {
|
public StatusResponse execute(OmnipodCommunicationManager communicationService) {
|
||||||
if (podState.getSetupProgress().isBefore(SetupProgress.PRIMING_FINISHED)) {
|
if (podState.getSetupProgress().isBefore(SetupProgress.PRIMING_FINISHED)) {
|
||||||
throw new IllegalSetupProgressException(SetupProgress.PRIMING_FINISHED, podState.getSetupProgress());
|
throw new IllegalSetupProgressException(SetupProgress.PRIMING_FINISHED, podState.getSetupProgress());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.comm.action;
|
package info.nightscout.androidaps.plugins.pump.omnipod.comm.action;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
|
|
||||||
public interface OmnipodAction<T> {
|
public interface OmnipodAction<T> {
|
||||||
T execute(OmnipodCommunicationService communicationService);
|
T execute(OmnipodCommunicationManager communicationService);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.comm.action;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.PrimeService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.PrimeService;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus;
|
||||||
|
@ -39,7 +39,7 @@ public class PrimeAction implements OmnipodAction<StatusResponse> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatusResponse execute(OmnipodCommunicationService communicationService) {
|
public StatusResponse execute(OmnipodCommunicationManager communicationService) {
|
||||||
if (podState.getSetupProgress().isBefore(SetupProgress.POD_CONFIGURED)) {
|
if (podState.getSetupProgress().isBefore(SetupProgress.POD_CONFIGURED)) {
|
||||||
throw new IllegalSetupProgressException(SetupProgress.POD_CONFIGURED, podState.getSetupProgress());
|
throw new IllegalSetupProgressException(SetupProgress.POD_CONFIGURED, podState.getSetupProgress());
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import org.joda.time.Duration;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.BasalScheduleExtraCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.BasalScheduleExtraCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.SetInsulinScheduleCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.SetInsulinScheduleCommand;
|
||||||
|
@ -39,7 +39,7 @@ public class SetBasalScheduleAction implements OmnipodAction<StatusResponse> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatusResponse execute(OmnipodCommunicationService communicationService) {
|
public StatusResponse execute(OmnipodCommunicationManager communicationService) {
|
||||||
SetInsulinScheduleCommand setBasal = new SetInsulinScheduleCommand(podState.getCurrentNonce(), basalSchedule, scheduleOffset);
|
SetInsulinScheduleCommand setBasal = new SetInsulinScheduleCommand(podState.getCurrentNonce(), basalSchedule, scheduleOffset);
|
||||||
BasalScheduleExtraCommand extraCommand = new BasalScheduleExtraCommand(basalSchedule, scheduleOffset,
|
BasalScheduleExtraCommand extraCommand = new BasalScheduleExtraCommand(basalSchedule, scheduleOffset,
|
||||||
acknowledgementBeep, confidenceReminder, Duration.ZERO);
|
acknowledgementBeep, confidenceReminder, Duration.ZERO);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.joda.time.Duration;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.MessageBlock;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.MessageBlock;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.SetInsulinScheduleCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.SetInsulinScheduleCommand;
|
||||||
|
@ -37,7 +37,7 @@ public class SetTempBasalAction implements OmnipodAction<StatusResponse> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatusResponse execute(OmnipodCommunicationService communicationService) {
|
public StatusResponse execute(OmnipodCommunicationManager communicationService) {
|
||||||
List<MessageBlock> messageBlocks = Arrays.asList( //
|
List<MessageBlock> messageBlocks = Arrays.asList( //
|
||||||
new SetInsulinScheduleCommand(podState.getCurrentNonce(), rate, duration),
|
new SetInsulinScheduleCommand(podState.getCurrentNonce(), rate, duration),
|
||||||
new TempBasalExtraCommand(rate, duration, acknowledgementBeep, completionBeep, Duration.ZERO));
|
new TempBasalExtraCommand(rate, duration, acknowledgementBeep, completionBeep, Duration.ZERO));
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.joda.time.Duration;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.BolusAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.BolusAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.ConfigureAlertsAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.ConfigureAlertsAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.SetBasalScheduleAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.SetBasalScheduleAction;
|
||||||
|
@ -18,13 +18,13 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionStat
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||||
|
|
||||||
public class InsertCannulaService {
|
public class InsertCannulaService {
|
||||||
public StatusResponse programInitialBasalSchedule(OmnipodCommunicationService communicationService,
|
public StatusResponse programInitialBasalSchedule(OmnipodCommunicationManager communicationService,
|
||||||
PodSessionState podState, BasalSchedule basalSchedule) {
|
PodSessionState podState, BasalSchedule basalSchedule) {
|
||||||
return communicationService.executeAction(new SetBasalScheduleAction(podState, basalSchedule,
|
return communicationService.executeAction(new SetBasalScheduleAction(podState, basalSchedule,
|
||||||
true, podState.getScheduleOffset(), false));
|
true, podState.getScheduleOffset(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatusResponse executeExpirationRemindersAlertCommand(OmnipodCommunicationService communicationService,
|
public StatusResponse executeExpirationRemindersAlertCommand(OmnipodCommunicationManager communicationService,
|
||||||
PodSessionState podState) {
|
PodSessionState podState) {
|
||||||
AlertConfiguration lowReservoirAlertConfiguration = AlertConfigurationFactory.createLowReservoirAlertConfiguration(OmnipodConst.LOW_RESERVOIR_ALERT);
|
AlertConfiguration lowReservoirAlertConfiguration = AlertConfigurationFactory.createLowReservoirAlertConfiguration(OmnipodConst.LOW_RESERVOIR_ALERT);
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class InsertCannulaService {
|
||||||
return new ConfigureAlertsAction(podState, alertConfigurations).execute(communicationService);
|
return new ConfigureAlertsAction(podState, alertConfigurations).execute(communicationService);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatusResponse executeInsertionBolusCommand(OmnipodCommunicationService communicationService, PodSessionState podState) {
|
public StatusResponse executeInsertionBolusCommand(OmnipodCommunicationManager communicationService, PodSessionState podState) {
|
||||||
return communicationService.executeAction(new BolusAction(podState, OmnipodConst.POD_CANNULA_INSERTION_BOLUS_UNITS,
|
return communicationService.executeAction(new BolusAction(podState, OmnipodConst.POD_CANNULA_INSERTION_BOLUS_UNITS,
|
||||||
Duration.standardSeconds(1), false, false));
|
Duration.standardSeconds(1), false, false));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import org.joda.time.Duration;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.BolusAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.BolusAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.ConfigureAlertsAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.ConfigureAlertsAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
||||||
|
@ -17,20 +17,20 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||||
|
|
||||||
public class PrimeService {
|
public class PrimeService {
|
||||||
|
|
||||||
public StatusResponse executeDisableTab5Sub16FaultConfigCommand(OmnipodCommunicationService communicationService, PodSessionState podState) {
|
public StatusResponse executeDisableTab5Sub16FaultConfigCommand(OmnipodCommunicationManager communicationService, PodSessionState podState) {
|
||||||
FaultConfigCommand faultConfigCommand = new FaultConfigCommand(podState.getCurrentNonce(), (byte) 0x00, (byte) 0x00);
|
FaultConfigCommand faultConfigCommand = new FaultConfigCommand(podState.getCurrentNonce(), (byte) 0x00, (byte) 0x00);
|
||||||
OmnipodMessage faultConfigMessage = new OmnipodMessage(podState.getAddress(),
|
OmnipodMessage faultConfigMessage = new OmnipodMessage(podState.getAddress(),
|
||||||
Collections.singletonList(faultConfigCommand), podState.getMessageNumber());
|
Collections.singletonList(faultConfigCommand), podState.getMessageNumber());
|
||||||
return communicationService.exchangeMessages(StatusResponse.class, podState, faultConfigMessage);
|
return communicationService.exchangeMessages(StatusResponse.class, podState, faultConfigMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatusResponse executeFinishSetupReminderAlertCommand(OmnipodCommunicationService communicationService, PodSessionState podState) {
|
public StatusResponse executeFinishSetupReminderAlertCommand(OmnipodCommunicationManager communicationService, PodSessionState podState) {
|
||||||
AlertConfiguration finishSetupReminderAlertConfiguration = AlertConfigurationFactory.createFinishSetupReminderAlertConfiguration();
|
AlertConfiguration finishSetupReminderAlertConfiguration = AlertConfigurationFactory.createFinishSetupReminderAlertConfiguration();
|
||||||
return communicationService.executeAction(new ConfigureAlertsAction(podState,
|
return communicationService.executeAction(new ConfigureAlertsAction(podState,
|
||||||
Collections.singletonList(finishSetupReminderAlertConfiguration)));
|
Collections.singletonList(finishSetupReminderAlertConfiguration)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatusResponse executePrimeBolusCommand(OmnipodCommunicationService communicationService, PodSessionState podState) {
|
public StatusResponse executePrimeBolusCommand(OmnipodCommunicationManager communicationService, PodSessionState podState) {
|
||||||
return communicationService.executeAction(new BolusAction(podState, OmnipodConst.POD_PRIME_BOLUS_UNITS,
|
return communicationService.executeAction(new BolusAction(podState, OmnipodConst.POD_PRIME_BOLUS_UNITS,
|
||||||
Duration.standardSeconds(1), false, false));
|
Duration.standardSeconds(1), false, false));
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@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
|
||||||
|
|
||||||
private var initPodChanged = false
|
private var initPodChanged = false
|
||||||
private var podSessionFullyInitalized = false
|
private var podSessionFullyInitalized = false
|
||||||
|
@ -103,7 +103,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
wizardPagerContext.clearContext()
|
wizardPagerContext.clearContext()
|
||||||
wizardPagerContext.pagerSettings = pagerSettings
|
wizardPagerContext.pagerSettings = pagerSettings
|
||||||
val podSessionState = OmnipodUtil.getPodSessionState()
|
val podSessionState = omnipodUtil.getPodSessionState()
|
||||||
val isFullInit = podSessionState == null || podSessionState.setupProgress.isBefore(SetupProgress.PRIMING_FINISHED)
|
val isFullInit = podSessionState == null || podSessionState.setupProgress.isBefore(SetupProgress.PRIMING_FINISHED)
|
||||||
if (isFullInit) {
|
if (isFullInit) {
|
||||||
wizardPagerContext.wizardModel = FullInitPodWizardModel(applicationContext)
|
wizardPagerContext.wizardModel = FullInitPodWizardModel(applicationContext)
|
||||||
|
@ -140,7 +140,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
fun resetPodAction() {
|
fun resetPodAction() {
|
||||||
OKDialog.showConfirmation(this,
|
OKDialog.showConfirmation(this,
|
||||||
MainApp.gs(R.string.omnipod_cmd_reset_pod_desc), Thread {
|
resourceHelper.gs(R.string.omnipod_cmd_reset_pod_desc), Thread {
|
||||||
AapsOmnipodManager.getInstance().resetPodStatus()
|
AapsOmnipodManager.getInstance().resetPodStatus()
|
||||||
OmnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod)
|
OmnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod)
|
||||||
refreshButtons()
|
refreshButtons()
|
||||||
|
@ -155,10 +155,10 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refreshButtons() {
|
fun refreshButtons() {
|
||||||
initpod_init_pod.isEnabled = (OmnipodUtil.getPodSessionState() == null ||
|
initpod_init_pod.isEnabled = (omnipodUtil.getPodSessionState() == null ||
|
||||||
OmnipodUtil.getPodSessionState().getSetupProgress().isBefore(SetupProgress.COMPLETED))
|
omnipodUtil.getPodSessionState().getSetupProgress().isBefore(SetupProgress.COMPLETED))
|
||||||
|
|
||||||
val isPodSessionActive = (OmnipodUtil.getPodSessionState() != null)
|
val isPodSessionActive = (omnipodUtil.getPodSessionState() != null)
|
||||||
|
|
||||||
initpod_remove_pod.isEnabled = isPodSessionActive
|
initpod_remove_pod.isEnabled = isPodSessionActive
|
||||||
initpod_reset_pod.isEnabled = isPodSessionActive
|
initpod_reset_pod.isEnabled = isPodSessionActive
|
||||||
|
|
|
@ -30,6 +30,8 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish
|
||||||
private PodManagementActivity podManagementActivity;
|
private PodManagementActivity podManagementActivity;
|
||||||
private PodActionType actionType;
|
private PodActionType actionType;
|
||||||
|
|
||||||
|
OmnipodUtil omnipodUtil;
|
||||||
|
|
||||||
public InitPodRefreshAction(PodManagementActivity podManagementActivity, PodActionType actionType) {
|
public InitPodRefreshAction(PodManagementActivity podManagementActivity, PodActionType actionType) {
|
||||||
this.podManagementActivity = podManagementActivity;
|
this.podManagementActivity = podManagementActivity;
|
||||||
this.actionType = actionType;
|
this.actionType = actionType;
|
||||||
|
@ -51,14 +53,14 @@ 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.getPodSessionState().getSetupProgress().isBefore(SetupProgress.COMPLETED)) {
|
if (omnipodUtil.getPodSessionState().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);
|
||||||
uploadCareportalEvent(System.currentTimeMillis(), CareportalEvent.SITECHANGE);
|
uploadCareportalEvent(System.currentTimeMillis(), CareportalEvent.SITECHANGE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
OmnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod);
|
omnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod);
|
||||||
}
|
}
|
||||||
|
|
||||||
podManagementActivity.refreshButtons();
|
podManagementActivity.refreshButtons();
|
||||||
|
|
|
@ -29,6 +29,9 @@ import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.android.support.DaggerFragment;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FirmwareVersion;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FirmwareVersion;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
||||||
|
@ -38,9 +41,11 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||||
/**
|
/**
|
||||||
* Created by andy on 12/11/2019
|
* Created by andy on 12/11/2019
|
||||||
*/
|
*/
|
||||||
public class PodInfoFragment extends Fragment {
|
public class PodInfoFragment extends DaggerFragment {
|
||||||
private static final String ARG_KEY = "key";
|
private static final String ARG_KEY = "key";
|
||||||
|
|
||||||
|
@Inject OmnipodUtil omnipodUtil;
|
||||||
|
|
||||||
private PageFragmentCallbacks mCallbacks;
|
private PageFragmentCallbacks mCallbacks;
|
||||||
private String mKey;
|
private String mKey;
|
||||||
private PodInfoPage mPage;
|
private PodInfoPage mPage;
|
||||||
|
@ -95,7 +100,7 @@ public class PodInfoFragment extends Fragment {
|
||||||
|
|
||||||
private boolean createDataOfPod() {
|
private boolean createDataOfPod() {
|
||||||
|
|
||||||
PodSessionState podSessionState = OmnipodUtil.getPodSessionState();
|
PodSessionState podSessionState = omnipodUtil.getPodSessionState();
|
||||||
|
|
||||||
// PodSessionState podSessionState = new PodSessionState(DateTimeZone.UTC,
|
// PodSessionState podSessionState = new PodSessionState(DateTimeZone.UTC,
|
||||||
// 483748738,
|
// 483748738,
|
||||||
|
|
|
@ -6,28 +6,43 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
|
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.RileyLinkError;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
||||||
|
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.events.EventMedtronicDeviceStatusChange;
|
||||||
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.PodSessionState;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
||||||
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;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 4.8.2019
|
* Created by andy on 4.8.2019
|
||||||
*/
|
*/
|
||||||
|
@Singleton
|
||||||
public class OmnipodPumpStatus extends PumpStatus {
|
public class OmnipodPumpStatus extends PumpStatus {
|
||||||
|
|
||||||
private static Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
//private static Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||||
|
private final ResourceHelper resourceHelper;
|
||||||
|
private final info.nightscout.androidaps.utils.sharedPreferences.SP sp;
|
||||||
|
private final RileyLinkUtil rileyLinkUtil;
|
||||||
|
private final RxBusWrapper rxBus;
|
||||||
|
|
||||||
public String errorDescription = null;
|
public String errorDescription = null;
|
||||||
public String rileyLinkAddress = null;
|
public String rileyLinkAddress = null;
|
||||||
|
@ -43,6 +58,7 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
public Integer tempBasalLength;
|
public Integer tempBasalLength;
|
||||||
public long tempBasalPumpId;
|
public long tempBasalPumpId;
|
||||||
public PodSessionState podSessionState;
|
public PodSessionState podSessionState;
|
||||||
|
public PumpType pumpType;
|
||||||
|
|
||||||
private boolean rileyLinkAddressChanged = false;
|
private boolean rileyLinkAddressChanged = false;
|
||||||
private String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
private String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
||||||
|
@ -64,9 +80,19 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
public boolean timeChangeEventEnabled = true;
|
public boolean timeChangeEventEnabled = true;
|
||||||
|
|
||||||
public OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
|
public OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
|
||||||
|
private PumpDeviceState pumpDeviceState;
|
||||||
|
|
||||||
public OmnipodPumpStatus(PumpDescription pumpDescription) {
|
@Inject
|
||||||
super(pumpDescription);
|
public OmnipodPumpStatus(ResourceHelper resourceHelper,
|
||||||
|
info.nightscout.androidaps.utils.sharedPreferences.SP sp,
|
||||||
|
RxBusWrapper rxBus,
|
||||||
|
RileyLinkUtil rileyLinkUtil) {
|
||||||
|
super(PumpType.Insulet_Omnipod);
|
||||||
|
this.resourceHelper = resourceHelper;
|
||||||
|
this.sp = sp;
|
||||||
|
this.rxBus = rxBus;
|
||||||
|
this.rileyLinkUtil = rileyLinkUtil;
|
||||||
|
initSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,91 +101,28 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
this.activeProfileName = "";
|
this.activeProfileName = "";
|
||||||
this.reservoirRemainingUnits = 75d;
|
this.reservoirRemainingUnits = 75d;
|
||||||
this.batteryRemaining = 75;
|
this.batteryRemaining = 75;
|
||||||
this.lastConnection = SP.getLong(OmnipodConst.Statistics.LastGoodPumpCommunicationTime, 0L);
|
this.lastConnection = sp.getLong(OmnipodConst.Statistics.LastGoodPumpCommunicationTime, 0L);
|
||||||
this.lastDataTime = new LocalDateTime(this.lastConnection);
|
this.lastDataTime = this.lastConnection;
|
||||||
this.pumpType = PumpType.Insulet_Omnipod;
|
this.pumpType = PumpType.Insulet_Omnipod;
|
||||||
this.podAvailable = false;
|
this.podAvailable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean verifyConfiguration() {
|
|
||||||
try {
|
|
||||||
|
|
||||||
this.errorDescription = "-";
|
|
||||||
|
|
||||||
String rileyLinkAddress = SP.getString(RileyLinkConst.Prefs.RileyLinkAddress, null);
|
|
||||||
|
|
||||||
if (rileyLinkAddress == null) {
|
|
||||||
if (isLogEnabled())
|
|
||||||
LOG.debug("RileyLink address invalid: null");
|
|
||||||
this.errorDescription = MainApp.gs(R.string.medtronic_error_rileylink_address_invalid);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (!rileyLinkAddress.matches(regexMac)) {
|
|
||||||
this.errorDescription = MainApp.gs(R.string.medtronic_error_rileylink_address_invalid);
|
|
||||||
if (isLogEnabled())
|
|
||||||
LOG.debug("RileyLink address invalid: {}", rileyLinkAddress);
|
|
||||||
} else {
|
|
||||||
if (!rileyLinkAddress.equals(this.rileyLinkAddress)) {
|
|
||||||
this.rileyLinkAddress = rileyLinkAddress;
|
|
||||||
rileyLinkAddressChanged = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.beepBasalEnabled = SP.getBoolean(OmnipodConst.Prefs.BeepBasalEnabled, true);
|
|
||||||
this.beepBolusEnabled = SP.getBoolean(OmnipodConst.Prefs.BeepBolusEnabled, true);
|
|
||||||
this.beepSMBEnabled = SP.getBoolean(OmnipodConst.Prefs.BeepSMBEnabled, true);
|
|
||||||
this.beepTBREnabled = SP.getBoolean(OmnipodConst.Prefs.BeepTBREnabled, true);
|
|
||||||
this.podDebuggingOptionsEnabled = SP.getBoolean(OmnipodConst.Prefs.PodDebuggingOptionsEnabled, false);
|
|
||||||
this.timeChangeEventEnabled = SP.getBoolean(OmnipodConst.Prefs.TimeChangeEventEnabled, true);
|
|
||||||
|
|
||||||
LOG.debug("Beeps [basal={}, bolus={}, SMB={}, TBR={}]", this.beepBasalEnabled, this.beepBolusEnabled, this.beepSMBEnabled, this.beepTBREnabled);
|
|
||||||
|
|
||||||
reconfigureService();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
|
||||||
this.errorDescription = ex.getMessage();
|
|
||||||
LOG.error("Error on Verification: " + ex.getMessage(), ex);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private boolean reconfigureService() {
|
|
||||||
|
|
||||||
if (!inPreInit && OmnipodUtil.getOmnipodService() != null) {
|
|
||||||
|
|
||||||
if (rileyLinkAddressChanged) {
|
|
||||||
OmnipodUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkNewAddressSet);
|
|
||||||
rileyLinkAddressChanged = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (!rileyLinkAddressChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getErrorInfo() {
|
public String getErrorInfo() {
|
||||||
verifyConfiguration();
|
//verifyConfiguration();
|
||||||
|
|
||||||
return (this.errorDescription == null) ? "-" : this.errorDescription;
|
return (this.errorDescription == null) ? "-" : this.errorDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void refreshConfiguration() {
|
|
||||||
verifyConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// public boolean setNotInPreInit() {
|
||||||
public boolean setNotInPreInit() {
|
// this.inPreInit = false;
|
||||||
this.inPreInit = false;
|
//
|
||||||
|
// return reconfigureService();
|
||||||
return reconfigureService();
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void clearTemporaryBasal() {
|
public void clearTemporaryBasal() {
|
||||||
|
@ -230,7 +193,22 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
", tempBasalRatio=" + tempBasalRatio +
|
", tempBasalRatio=" + tempBasalRatio +
|
||||||
", tempBasalRemainMin=" + tempBasalRemainMin +
|
", tempBasalRemainMin=" + tempBasalRemainMin +
|
||||||
", tempBasalStart=" + tempBasalStart +
|
", tempBasalStart=" + tempBasalStart +
|
||||||
", pumpDescription=" + pumpDescription +
|
", pumpType=" + pumpType +
|
||||||
"} ";
|
"} ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PumpDeviceState getPumpDeviceState() {
|
||||||
|
return pumpDeviceState;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setPumpDeviceState(PumpDeviceState pumpDeviceState) {
|
||||||
|
this.pumpDeviceState = pumpDeviceState;
|
||||||
|
|
||||||
|
rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(pumpDeviceState, RileyLinkTargetDevice.Omnipod));
|
||||||
|
|
||||||
|
rxBus.send(new EventMedtronicDeviceStatusChange(pumpDeviceState));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,17 +6,12 @@ import android.text.TextUtils;
|
||||||
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.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
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 dagger.android.HasAndroidInjector;
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
@ -33,7 +28,6 @@ import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
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.events.EventOverviewBolusProgress;
|
||||||
|
@ -43,7 +37,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.SetupActionResult;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.SetupActionResult;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
||||||
|
@ -81,12 +75,12 @@ import info.nightscout.androidaps.plugins.pump.omnipod.exception.OmnipodExceptio
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodFaultException;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodFaultException;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodReturnedErrorResponseException;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodReturnedErrorResponseException;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
|
|
||||||
public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface {
|
public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||||
|
|
||||||
|
private OmnipodUtil omnipodUtil;
|
||||||
AAPSLogger aapsLogger;
|
AAPSLogger aapsLogger;
|
||||||
RxBusWrapper rxBus;
|
RxBusWrapper rxBus;
|
||||||
ResourceHelper resourceHelper;
|
ResourceHelper resourceHelper;
|
||||||
|
@ -106,23 +100,26 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AapsOmnipodManager(OmnipodCommunicationService communicationService,
|
public AapsOmnipodManager(OmnipodCommunicationManager communicationService,
|
||||||
PodSessionState podState,
|
PodSessionState podState,
|
||||||
OmnipodPumpStatus _pumpStatus,
|
OmnipodPumpStatus _pumpStatus,
|
||||||
|
OmnipodUtil omnipodUtil,
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
RxBusWrapper rxBus,
|
RxBusWrapper rxBus,
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
HasAndroidInjector injector,
|
HasAndroidInjector injector,
|
||||||
ActivePluginProvider activePlugin) {
|
ActivePluginProvider activePlugin) {
|
||||||
|
this.omnipodUtil = omnipodUtil;
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.injector = injector;
|
this.injector = injector;
|
||||||
this.activePlugin = activePlugin;
|
this.activePlugin = activePlugin;
|
||||||
this.pumpStatus = _pumpStatus;
|
this.pumpStatus = _pumpStatus;
|
||||||
|
|
||||||
delegate = new OmnipodManager(communicationService, podState, podSessionState -> {
|
delegate = new OmnipodManager(communicationService, podState, podSessionState -> {
|
||||||
// Handle pod state changes
|
// Handle pod state changes
|
||||||
OmnipodUtil.setPodSessionState(podSessionState);
|
omnipodUtil.setPodSessionState(podSessionState);
|
||||||
updatePumpStatus(podSessionState);
|
updatePumpStatus(podSessionState);
|
||||||
});
|
});
|
||||||
instance = this;
|
instance = this;
|
||||||
|
@ -260,7 +257,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
|
|
||||||
podInitReceiver.returnInitTaskStatus(PodInitActionType.DeactivatePodWizardStep, true, null);
|
podInitReceiver.returnInitTaskStatus(PodInitActionType.DeactivatePodWizardStep, true, null);
|
||||||
|
|
||||||
OmnipodUtil.setPodSessionState(null);
|
this.omnipodUtil.setPodSessionState(null);
|
||||||
|
|
||||||
return new PumpEnactResult(injector).success(true).enacted(true);
|
return new PumpEnactResult(injector).success(true).enacted(true);
|
||||||
}
|
}
|
||||||
|
@ -301,7 +298,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
|
|
||||||
reportImplicitlyCanceledTbr();
|
reportImplicitlyCanceledTbr();
|
||||||
|
|
||||||
OmnipodUtil.setPodSessionState(null);
|
this.omnipodUtil.setPodSessionState(null);
|
||||||
|
|
||||||
addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.ResetPodState, null);
|
addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.ResetPodState, null);
|
||||||
|
|
||||||
|
@ -457,7 +454,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
@Override
|
@Override
|
||||||
public void setPumpStatus(OmnipodPumpStatus pumpStatus) {
|
public void setPumpStatus(OmnipodPumpStatus pumpStatus) {
|
||||||
this.pumpStatus = pumpStatus;
|
this.pumpStatus = pumpStatus;
|
||||||
this.getCommunicationService().setPumpStatus(pumpStatus);
|
//this.getCommunicationService().setPumpStatus(pumpStatus);
|
||||||
updatePumpStatus(delegate.getPodState());
|
updatePumpStatus(delegate.getPodState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,7 +527,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
return response.getPodInfo();
|
return response.getPodInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OmnipodCommunicationService getCommunicationService() {
|
public OmnipodCommunicationManager getCommunicationService() {
|
||||||
return delegate.getCommunicationService();
|
return delegate.getCommunicationService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,14 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.ui;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUIPostprocessor;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
|
||||||
|
@ -18,18 +24,42 @@ public class OmnipodUIComm {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||||
|
|
||||||
OmnipodCommunicationManagerInterface ocmInstance = null;
|
private final HasAndroidInjector injector;
|
||||||
OmnipodUIPostprocessor uiPostprocessor; // = new OmnipodUIPostprocessor();
|
private final AAPSLogger aapsLogger;
|
||||||
|
private final OmnipodUtil omnipodUtil;
|
||||||
|
private final OmnipodCommunicationManagerInterface omnipodCommunicationManager;
|
||||||
|
private final OmnipodUIPostprocessor omnipodUIPostprocessor;
|
||||||
|
|
||||||
|
|
||||||
|
//OmnipodCommunicationManagerInterface ocmInstance = null;
|
||||||
|
//OmnipodUIPostprocessor uiPostprocessor; // = new OmnipodUIPostprocessor();
|
||||||
|
|
||||||
|
|
||||||
|
public OmnipodUIComm(
|
||||||
|
HasAndroidInjector injector,
|
||||||
|
AAPSLogger aapsLogger,
|
||||||
|
OmnipodUtil omnipodUtil,
|
||||||
|
OmnipodUIPostprocessor omnipodUIPostprocessor,
|
||||||
|
OmnipodCommunicationManagerInterface omnipodCommunicationManager
|
||||||
|
) {
|
||||||
|
this.injector = injector;
|
||||||
|
this.aapsLogger = aapsLogger;
|
||||||
|
this.omnipodUtil = omnipodUtil;
|
||||||
|
this.omnipodUIPostprocessor = omnipodUIPostprocessor;
|
||||||
|
this.omnipodCommunicationManager = omnipodCommunicationManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private OmnipodCommunicationManagerInterface getCommunicationManager() {
|
private OmnipodCommunicationManagerInterface getCommunicationManager() {
|
||||||
return ocmInstance;
|
return omnipodCommunicationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OmnipodUIComm(OmnipodCommunicationManagerInterface communicationManager, OmnipodPumpPluginInterface plugin, OmnipodPumpStatus status) {
|
// public OmnipodUIComm(OmnipodCommunicationManagerInterface communicationManager, OmnipodPumpPluginInterface plugin, OmnipodPumpStatus status) {
|
||||||
ocmInstance = communicationManager;
|
// ocmInstance = communicationManager;
|
||||||
uiPostprocessor = new OmnipodUIPostprocessor(plugin, status);
|
// uiPostprocessor = new OmnipodUIPostprocessor(plugin, status);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public OmnipodUITask executeCommand(OmnipodCommandType commandType, Object... parameters) {
|
public OmnipodUITask executeCommand(OmnipodCommandType commandType, Object... parameters) {
|
||||||
|
@ -37,9 +67,9 @@ public class OmnipodUIComm {
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.warn("Execute Command: " + commandType.name());
|
LOG.warn("Execute Command: " + commandType.name());
|
||||||
|
|
||||||
OmnipodUITask task = new OmnipodUITask(commandType, parameters);
|
OmnipodUITask task = new OmnipodUITask(injector, commandType, parameters);
|
||||||
|
|
||||||
OmnipodUtil.setCurrentCommand(commandType);
|
omnipodUtil.setCurrentCommand(commandType);
|
||||||
|
|
||||||
// new Thread(() -> {
|
// new Thread(() -> {
|
||||||
// LOG.warn("@@@ Start Thread");
|
// LOG.warn("@@@ Start Thread");
|
||||||
|
@ -73,7 +103,7 @@ public class OmnipodUIComm {
|
||||||
LOG.warn("Reply not received for " + commandType);
|
LOG.warn("Reply not received for " + commandType);
|
||||||
}
|
}
|
||||||
|
|
||||||
task.postProcess(uiPostprocessor);
|
task.postProcess(omnipodUIPostprocessor);
|
||||||
|
|
||||||
return task;
|
return task;
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,27 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.ui;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
||||||
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.PodInitActionType;
|
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.PodInitReceiver;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodResponseType;
|
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.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.OmnipodUtil;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||||
|
@ -25,7 +34,14 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||||
|
|
||||||
public class OmnipodUITask {
|
public class OmnipodUITask {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
@Inject RxBusWrapper rxBus;
|
||||||
|
@Inject AAPSLogger aapsLogger;
|
||||||
|
@Inject OmnipodPumpStatus omnipodPumpStatus;
|
||||||
|
@Inject OmnipodUtil omnipodUtil;
|
||||||
|
|
||||||
|
private final HasAndroidInjector injector;
|
||||||
|
|
||||||
|
//private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||||
|
|
||||||
public OmnipodCommandType commandType;
|
public OmnipodCommandType commandType;
|
||||||
public PumpEnactResult returnData;
|
public PumpEnactResult returnData;
|
||||||
|
@ -35,12 +51,16 @@ public class OmnipodUITask {
|
||||||
public Object returnDataObject;
|
public Object returnDataObject;
|
||||||
|
|
||||||
|
|
||||||
public OmnipodUITask(OmnipodCommandType commandType) {
|
public OmnipodUITask(HasAndroidInjector injector, OmnipodCommandType commandType) {
|
||||||
|
this.injector = injector;
|
||||||
|
this.injector.androidInjector().inject(this);
|
||||||
this.commandType = commandType;
|
this.commandType = commandType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public OmnipodUITask(OmnipodCommandType commandType, Object... parameters) {
|
public OmnipodUITask(HasAndroidInjector injector, OmnipodCommandType commandType, Object... parameters) {
|
||||||
|
this.injector = injector;
|
||||||
|
this.injector.androidInjector().inject(this);
|
||||||
this.commandType = commandType;
|
this.commandType = commandType;
|
||||||
this.parameters = parameters;
|
this.parameters = parameters;
|
||||||
}
|
}
|
||||||
|
@ -48,8 +68,8 @@ public class OmnipodUITask {
|
||||||
|
|
||||||
public void execute(OmnipodCommunicationManagerInterface communicationManager) {
|
public void execute(OmnipodCommunicationManagerInterface communicationManager) {
|
||||||
|
|
||||||
if (isLogEnabled())
|
|
||||||
LOG.debug("OmnipodUITask: @@@ In execute. {}", commandType);
|
aapsLogger.debug(LTag.PUMP,"OmnipodUITask: @@@ In execute. {}", commandType);
|
||||||
|
|
||||||
switch (commandType) {
|
switch (commandType) {
|
||||||
|
|
||||||
|
@ -91,8 +111,8 @@ public class OmnipodUITask {
|
||||||
responseType = PodResponseType.Acknowledgment;
|
responseType = PodResponseType.Acknowledgment;
|
||||||
break;
|
break;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (isLogEnabled()) {
|
{
|
||||||
LOG.warn("Failed to retrieve pulse log", ex);
|
aapsLogger.warn(LTag.PUMP,"Failed to retrieve pulse log", ex);
|
||||||
}
|
}
|
||||||
returnDataObject = null;
|
returnDataObject = null;
|
||||||
responseType = PodResponseType.Error;
|
responseType = PodResponseType.Error;
|
||||||
|
@ -129,7 +149,7 @@ public class OmnipodUITask {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
LOG.warn("This commandType is not supported (yet) - {}.", commandType);
|
aapsLogger.warn(LTag.PUMP,"This commandType is not supported (yet) - {}.", commandType);
|
||||||
responseType = PodResponseType.Error;
|
responseType = PodResponseType.Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,33 +203,32 @@ public class OmnipodUITask {
|
||||||
public void postProcess(OmnipodUIPostprocessor postprocessor) {
|
public void postProcess(OmnipodUIPostprocessor postprocessor) {
|
||||||
|
|
||||||
EventOmnipodDeviceStatusChange statusChange;
|
EventOmnipodDeviceStatusChange statusChange;
|
||||||
if (isLogEnabled())
|
|
||||||
LOG.debug("OmnipodUITask: @@@ postProcess. {}", commandType);
|
|
||||||
|
|
||||||
LOG.debug("OmnipodUITask: @@@ postProcess. responseType={}", responseType);
|
aapsLogger.debug(LTag.PUMP,"OmnipodUITask: @@@ postProcess. {}", commandType);
|
||||||
|
aapsLogger.debug(LTag.PUMP,"OmnipodUITask: @@@ postProcess. responseType={}", responseType);
|
||||||
|
|
||||||
if (responseType == PodResponseType.Data || responseType == PodResponseType.Acknowledgment) {
|
if (responseType == PodResponseType.Data || responseType == PodResponseType.Acknowledgment) {
|
||||||
postprocessor.postProcessData(this);
|
postprocessor.postProcessData(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("OmnipodUITask: @@@ postProcess. responseType={}", responseType);
|
aapsLogger.debug(LTag.PUMP,"OmnipodUITask: @@@ postProcess. responseType={}", responseType);
|
||||||
|
|
||||||
if (responseType == PodResponseType.Invalid) {
|
if (responseType == PodResponseType.Invalid) {
|
||||||
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
|
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
|
||||||
"Unsupported command in OmnipodUITask");
|
"Unsupported command in OmnipodUITask");
|
||||||
OmnipodUtil.getPumpStatus().setLastFailedCommunicationToNow();
|
omnipodPumpStatus.setLastFailedCommunicationToNow();
|
||||||
postprocessor.getRxBus().send(statusChange);
|
rxBus.send(statusChange);
|
||||||
} else if (responseType == PodResponseType.Error) {
|
} else if (responseType == PodResponseType.Error) {
|
||||||
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
|
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
|
||||||
errorDescription);
|
errorDescription);
|
||||||
OmnipodUtil.getPumpStatus().setLastFailedCommunicationToNow();
|
omnipodPumpStatus.setLastFailedCommunicationToNow();
|
||||||
postprocessor.getRxBus().send(statusChange);
|
rxBus.send(statusChange);
|
||||||
} else {
|
} else {
|
||||||
OmnipodUtil.getPumpStatus().setLastCommunicationToNow();
|
omnipodPumpStatus.setLastCommunicationToNow();
|
||||||
postprocessor.getRxBus().send(new EventOmnipodPumpValuesChanged());
|
rxBus.send(new EventOmnipodPumpValuesChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
OmnipodUtil.setPodDeviceState(PodDeviceState.Sleeping);
|
omnipodUtil.setPodDeviceState(PodDeviceState.Sleeping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.service;
|
package info.nightscout.androidaps.plugins.pump.omnipod.service;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
@ -9,18 +8,11 @@ import android.os.IBinder;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||||
|
@ -32,16 +24,18 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService;
|
||||||
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.medtronic.MedtronicPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUIPostprocessor;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
||||||
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.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;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,23 +44,24 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
*/
|
*/
|
||||||
public class RileyLinkOmnipodService extends RileyLinkService {
|
public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
|
|
||||||
// @Inject AAPSLogger aapsLogger;
|
|
||||||
// @Inject Context context;
|
|
||||||
@Inject OmnipodPumpPlugin omnipodPumpPlugin;
|
@Inject OmnipodPumpPlugin omnipodPumpPlugin;
|
||||||
// @Inject SP sp;
|
@Inject OmnipodPumpStatus omnipodPumpStatus;
|
||||||
@Inject RxBusWrapper rxBus;
|
@Inject OmnipodUtil omnipodUtil;
|
||||||
@Inject ActivePluginProvider activePlugin;
|
|
||||||
@Inject HasAndroidInjector injector;
|
|
||||||
@Inject ResourceHelper resourceHelper;
|
|
||||||
|
|
||||||
|
//@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
||||||
|
//@Inject MedtronicUtil medtronicUtil;
|
||||||
|
//@Inject MedtronicUIPostprocessor medtronicUIPostprocessor;
|
||||||
|
//@Inject MedtronicPumpStatus medtronicPumpStatus;
|
||||||
|
|
||||||
//private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
private static RileyLinkOmnipodService instance;
|
private static RileyLinkOmnipodService instance;
|
||||||
|
|
||||||
OmnipodCommunicationManagerInterface omnipodCommunicationManager;
|
private OmnipodCommunicationManager omnipodCommunicationManager;
|
||||||
OmnipodPumpStatus pumpStatus = null;
|
private AapsOmnipodManager aapsOmnipodManager;
|
||||||
|
|
||||||
private IBinder mBinder = new LocalBinder();
|
private IBinder mBinder = new LocalBinder();
|
||||||
|
private boolean rileyLinkAddressChanged = false;
|
||||||
|
private boolean inPreInit = true;
|
||||||
|
|
||||||
|
|
||||||
public RileyLinkOmnipodService() {
|
public RileyLinkOmnipodService() {
|
||||||
|
@ -80,15 +75,9 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// public static MedtronicCommunicationManager getCommunicationManager() {
|
|
||||||
// return instance.medtronicCommunicationManager;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
if (isLogEnabled())
|
aapsLogger.warn(LTag.PUMPCOMM,"onConfigurationChanged");
|
||||||
aapsLogger.warn(LTag.PUMPCOMM,"onConfigurationChanged");
|
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,29 +99,20 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
*/
|
*/
|
||||||
public void initRileyLinkServiceData() {
|
public void initRileyLinkServiceData() {
|
||||||
|
|
||||||
rileyLinkServiceData = new RileyLinkServiceData(RileyLinkTargetDevice.Omnipod);
|
// TODO
|
||||||
|
rileyLinkServiceData.targetDevice = RileyLinkTargetDevice.Omnipod;
|
||||||
RileyLinkUtil.setRileyLinkServiceData(rileyLinkServiceData);
|
|
||||||
RileyLinkUtil.setTargetDevice(RileyLinkTargetDevice.Omnipod);
|
|
||||||
|
|
||||||
// get most recently used RileyLink address
|
// get most recently used RileyLink address
|
||||||
rileyLinkServiceData.rileylinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
rileyLinkServiceData.rileylinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
||||||
|
|
||||||
rileyLinkBLE = new RileyLinkBLE(this.context); // or this
|
rileyLinkBLE = new RileyLinkBLE(injector, this); // or this
|
||||||
rfspy = new RFSpy(rileyLinkBLE);
|
rfspy = new RFSpy(injector, rileyLinkBLE);
|
||||||
rfspy.startReader();
|
rfspy.startReader();
|
||||||
|
|
||||||
RileyLinkUtil.setRileyLinkBLE(rileyLinkBLE);
|
|
||||||
|
|
||||||
// init rileyLinkCommunicationManager
|
|
||||||
initializeErosOmnipodManager();
|
initializeErosOmnipodManager();
|
||||||
// TODO Dash
|
|
||||||
|
|
||||||
if (isLogEnabled())
|
aapsLogger.debug(LTag.PUMPCOMM,"RileyLinkOmnipodService newly constructed");
|
||||||
aapsLogger.debug(LTag.PUMPCOMM,"RileyLinkOmnipodService newly constructed");
|
//omnipodPumpStatus = (OmnipodPumpStatus) omnipodPumpPlugin.getPumpStatusData();
|
||||||
OmnipodUtil.setOmnipodService(this);
|
|
||||||
pumpStatus = (OmnipodPumpStatus) omnipodPumpPlugin.getPumpStatusData();
|
|
||||||
//aapsLogger.debug(LTag.PUMPCOMM,"RRRRRRRRRR: " + pumpStatus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeErosOmnipodManager() {
|
private void initializeErosOmnipodManager() {
|
||||||
|
@ -144,18 +124,19 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
String storedPodState = sp.getString(OmnipodConst.Prefs.PodState, null);
|
String storedPodState = sp.getString(OmnipodConst.Prefs.PodState, null);
|
||||||
aapsLogger.info(LTag.PUMPCOMM,"PodSessionState-SP: loaded from SharedPreferences: " + storedPodState);
|
aapsLogger.info(LTag.PUMPCOMM,"PodSessionState-SP: loaded from SharedPreferences: " + storedPodState);
|
||||||
podState = gson.fromJson(storedPodState, PodSessionState.class);
|
podState = gson.fromJson(storedPodState, PodSessionState.class);
|
||||||
OmnipodUtil.setPodSessionState(podState);
|
omnipodUtil.setPodSessionState(podState);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
aapsLogger.error(LTag.PUMPCOMM,"Could not deserialize Pod state", ex);
|
aapsLogger.error(LTag.PUMPCOMM,"Could not deserialize Pod state", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OmnipodCommunicationService omnipodCommunicationService = new OmnipodCommunicationService(rfspy);
|
OmnipodCommunicationManager omnipodCommunicationService = new OmnipodCommunicationManager(injector, rfspy);
|
||||||
omnipodCommunicationService.setPumpStatus(pumpStatus);
|
//omnipodCommunicationService.setPumpStatus(omnipodPumpStatus);
|
||||||
|
this.omnipodCommunicationManager = omnipodCommunicationService;
|
||||||
|
|
||||||
omnipodCommunicationManager = new AapsOmnipodManager(omnipodCommunicationService, podState, pumpStatus,
|
this.aapsOmnipodManager = new AapsOmnipodManager(omnipodCommunicationService, podState, omnipodPumpStatus,
|
||||||
aapsLogger, rxBus, resourceHelper, injector, activePlugin);
|
omnipodUtil, aapsLogger, rxBus, resourceHelper, injector, activePlugin);
|
||||||
} else {
|
} else {
|
||||||
omnipodCommunicationManager = AapsOmnipodManager.getInstance();
|
aapsOmnipodManager = AapsOmnipodManager.getInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,11 +148,16 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RileyLinkCommunicationManager getDeviceCommunicationManager() {
|
public RileyLinkCommunicationManager getDeviceCommunicationManager() {
|
||||||
if (omnipodCommunicationManager instanceof AapsOmnipodManager) { // Eros
|
// if (omnipodCommunicationManager instanceof AapsOmnipodManager) { // Eros
|
||||||
return ((AapsOmnipodManager) omnipodCommunicationManager).getCommunicationService();
|
// return ((AapsOmnipodManager) omnipodCommunicationManager).getCommunicationService();
|
||||||
}
|
// }
|
||||||
// FIXME is this correct for Dash?
|
// // FIXME is this correct for Dash?
|
||||||
return (RileyLinkCommunicationManager) omnipodCommunicationManager;
|
return omnipodCommunicationManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPumpDeviceState(PumpDeviceState pumpDeviceState) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,7 +174,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
// PumpInterface - REMOVE
|
// PumpInterface - REMOVE
|
||||||
|
|
||||||
public boolean isInitialized() {
|
public boolean isInitialized() {
|
||||||
return RileyLinkServiceState.isReady(RileyLinkUtil.getRileyLinkServiceData().serviceState);
|
return RileyLinkServiceState.isReady(rileyLinkServiceData.rileyLinkServiceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,7 +194,70 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean isLogEnabled() {
|
|
||||||
return L.isEnabled(L.PUMPCOMM);
|
|
||||||
|
public boolean verifyConfiguration() {
|
||||||
|
try {
|
||||||
|
//String regexSN = "[0-9]{6}";
|
||||||
|
String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
||||||
|
|
||||||
|
omnipodPumpStatus.errorDescription = "-";
|
||||||
|
|
||||||
|
String rileyLinkAddress = info.nightscout.androidaps.utils.SP.getString(RileyLinkConst.Prefs.RileyLinkAddress, null);
|
||||||
|
|
||||||
|
if (rileyLinkAddress == null) {
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM,"RileyLink address invalid: null");
|
||||||
|
omnipodPumpStatus.errorDescription = resourceHelper.gs(R.string.medtronic_error_rileylink_address_invalid);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (!rileyLinkAddress.matches(regexMac)) {
|
||||||
|
omnipodPumpStatus.errorDescription = resourceHelper.gs(R.string.medtronic_error_rileylink_address_invalid);
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM,"RileyLink address invalid: {}", rileyLinkAddress);
|
||||||
|
} else {
|
||||||
|
if (!rileyLinkAddress.equals(this.omnipodPumpStatus.rileyLinkAddress)) {
|
||||||
|
this.omnipodPumpStatus.rileyLinkAddress = rileyLinkAddress;
|
||||||
|
rileyLinkAddressChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.omnipodPumpStatus.beepBasalEnabled = sp.getBoolean(OmnipodConst.Prefs.BeepBasalEnabled, true);
|
||||||
|
this.omnipodPumpStatus.beepBolusEnabled = sp.getBoolean(OmnipodConst.Prefs.BeepBolusEnabled, true);
|
||||||
|
this.omnipodPumpStatus.beepSMBEnabled = sp.getBoolean(OmnipodConst.Prefs.BeepSMBEnabled, true);
|
||||||
|
this.omnipodPumpStatus.beepTBREnabled = sp.getBoolean(OmnipodConst.Prefs.BeepTBREnabled, true);
|
||||||
|
this.omnipodPumpStatus.podDebuggingOptionsEnabled = sp.getBoolean(OmnipodConst.Prefs.PodDebuggingOptionsEnabled, false);
|
||||||
|
this.omnipodPumpStatus.timeChangeEventEnabled = sp.getBoolean(OmnipodConst.Prefs.TimeChangeEventEnabled, true);
|
||||||
|
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM,"Beeps [basal={}, bolus={}, SMB={}, TBR={}]", this.omnipodPumpStatus.beepBasalEnabled, this.omnipodPumpStatus.beepBolusEnabled, this.omnipodPumpStatus.beepSMBEnabled, this.omnipodPumpStatus.beepTBREnabled);
|
||||||
|
|
||||||
|
reconfigureService();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
this.omnipodPumpStatus.errorDescription = ex.getMessage();
|
||||||
|
aapsLogger.error(LTag.PUMPCOMM,"Error on Verification: " + ex.getMessage(), ex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean reconfigureService() {
|
||||||
|
|
||||||
|
if (!inPreInit) {
|
||||||
|
|
||||||
|
if (rileyLinkAddressChanged) {
|
||||||
|
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkNewAddressSet, this);
|
||||||
|
rileyLinkAddressChanged = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (!rileyLinkAddressChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setNotInPreInit() {
|
||||||
|
this.inPreInit = false;
|
||||||
|
|
||||||
|
return reconfigureService();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,16 +18,19 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
||||||
|
@ -46,26 +49,41 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog;
|
||||||
* Created by andy on 4/8/19.
|
* Created by andy on 4/8/19.
|
||||||
*/
|
*/
|
||||||
// FIXME
|
// FIXME
|
||||||
public class OmnipodUtil extends RileyLinkUtil {
|
@Singleton
|
||||||
|
public class OmnipodUtil {
|
||||||
|
|
||||||
@Inject RxBusWrapper rxBus;
|
//@Inject RxBusWrapper rxBus;
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||||
|
|
||||||
private static boolean lowLevelDebug = true;
|
private static boolean lowLevelDebug = true;
|
||||||
private static RileyLinkOmnipodService omnipodService;
|
private static RileyLinkOmnipodService omnipodService;
|
||||||
private static OmnipodPumpStatus omnipodPumpStatus;
|
//private static OmnipodPumpStatus omnipodPumpStatus;
|
||||||
private static OmnipodCommandType currentCommand;
|
private static OmnipodCommandType currentCommand;
|
||||||
private static Gson gsonInstance = createGson();
|
private static Gson gsonInstance = createGson();
|
||||||
//private static PodSessionState podSessionState;
|
//private static PodSessionState podSessionState;
|
||||||
//private static PodDeviceState podDeviceState;
|
//private static PodDeviceState podDeviceState;
|
||||||
private static OmnipodPumpPluginInterface omnipodPumpPlugin;
|
//private static OmnipodPumpPluginInterface omnipodPumpPlugin;
|
||||||
private static OmnipodPodType omnipodPodType;
|
private static OmnipodPodType omnipodPodType;
|
||||||
private static OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
|
private static OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
|
||||||
private static PumpType pumpType;
|
//private static PumpType pumpType;
|
||||||
|
|
||||||
public static Gson getGsonInstance() {
|
private final AAPSLogger aapsLogger;
|
||||||
return gsonInstance;
|
private final RxBusWrapper rxBus;
|
||||||
|
private final RileyLinkUtil rileyLinkUtil;
|
||||||
|
private final OmnipodPumpStatus omnipodPumpStatus;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public OmnipodUtil(
|
||||||
|
AAPSLogger aapsLogger,
|
||||||
|
RxBusWrapper rxBus,
|
||||||
|
RileyLinkUtil rileyLinkUtil,
|
||||||
|
OmnipodPumpStatus omnipodPumpStatus
|
||||||
|
) {
|
||||||
|
this.aapsLogger = aapsLogger;
|
||||||
|
this.rxBus = rxBus;
|
||||||
|
this.rileyLinkUtil = rileyLinkUtil;
|
||||||
|
this.omnipodPumpStatus = omnipodPumpStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int makeUnsignedShort(int b2, int b1) {
|
public static int makeUnsignedShort(int b2, int b1) {
|
||||||
|
@ -113,14 +131,14 @@ public class OmnipodUtil extends RileyLinkUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static OmnipodCommunicationManagerInterface getOmnipodCommunicationManager() {
|
// public static OmnipodCommunicationManagerInterface getOmnipodCommunicationManager() {
|
||||||
return (OmnipodCommunicationManagerInterface) RileyLinkUtil.rileyLinkCommunicationManager;
|
// return (OmnipodCommunicationManagerInterface) RileyLinkUtil.rileyLinkCommunicationManager;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
public static RileyLinkOmnipodService getOmnipodService() {
|
// public static RileyLinkOmnipodService getOmnipodService() {
|
||||||
return OmnipodUtil.omnipodService;
|
// return OmnipodUtil.omnipodService;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
public static void setOmnipodService(RileyLinkOmnipodService medtronicService) {
|
public static void setOmnipodService(RileyLinkOmnipodService medtronicService) {
|
||||||
|
@ -133,12 +151,11 @@ public class OmnipodUtil extends RileyLinkUtil {
|
||||||
|
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
public static void setCurrentCommand(OmnipodCommandType currentCommand) {
|
public void setCurrentCommand(OmnipodCommandType currentCommand) {
|
||||||
OmnipodUtil.currentCommand = currentCommand;
|
OmnipodUtil.currentCommand = currentCommand;
|
||||||
|
|
||||||
if (currentCommand != null)
|
if (currentCommand != null)
|
||||||
historyRileyLink.add(new RLHistoryItem(currentCommand));
|
rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(currentCommand));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,10 +170,10 @@ public class OmnipodUtil extends RileyLinkUtil {
|
||||||
OKDialog.showConfirmation(context, MainApp.gs(R.string.combo_warning),
|
OKDialog.showConfirmation(context, MainApp.gs(R.string.combo_warning),
|
||||||
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 static OmnipodPumpStatus getPumpStatus() {
|
// public static OmnipodPumpStatus getPumpStatus() {
|
||||||
return omnipodPumpStatus;
|
// return omnipodPumpStatus;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static OmnipodDriverState getDriverState() {
|
public static OmnipodDriverState getDriverState() {
|
||||||
return OmnipodUtil.driverState;
|
return OmnipodUtil.driverState;
|
||||||
|
@ -178,9 +195,9 @@ public class OmnipodUtil extends RileyLinkUtil {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPumpStatus(OmnipodPumpStatus omnipodPumpStatus) {
|
// public static void setPumpStatus(OmnipodPumpStatus omnipodPumpStatus) {
|
||||||
OmnipodUtil.omnipodPumpStatus = omnipodPumpStatus;
|
// OmnipodUtil.omnipodPumpStatus = omnipodPumpStatus;
|
||||||
}
|
// }
|
||||||
|
|
||||||
private static Gson createGson() {
|
private static Gson createGson() {
|
||||||
GsonBuilder gsonBuilder = new GsonBuilder()
|
GsonBuilder gsonBuilder = new GsonBuilder()
|
||||||
|
@ -196,27 +213,27 @@ public class OmnipodUtil extends RileyLinkUtil {
|
||||||
return gsonBuilder.create();
|
return gsonBuilder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPodSessionState(PodSessionState podSessionState) {
|
public void setPodSessionState(PodSessionState podSessionState) {
|
||||||
omnipodPumpStatus.podSessionState = podSessionState;
|
omnipodPumpStatus.podSessionState = podSessionState;
|
||||||
omnipodPumpPlugin.getRxBus().send(new EventOmnipodDeviceStatusChange(podSessionState));
|
rxBus.send(new EventOmnipodDeviceStatusChange(podSessionState));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void setPodDeviceState(PodDeviceState podDeviceState) {
|
public void setPodDeviceState(PodDeviceState podDeviceState) {
|
||||||
omnipodPumpStatus.podDeviceState = podDeviceState;
|
omnipodPumpStatus.podDeviceState = podDeviceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
// @NotNull
|
||||||
public static OmnipodPumpPluginInterface getPlugin() {
|
// public static OmnipodPumpPluginInterface getPlugin() {
|
||||||
return OmnipodUtil.omnipodPumpPlugin;
|
// return OmnipodUtil.omnipodPumpPlugin;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
// @NotNull
|
||||||
public static void setPlugin(OmnipodPumpPluginInterface pumpPlugin) {
|
// public static void setPlugin(OmnipodPumpPluginInterface pumpPlugin) {
|
||||||
OmnipodUtil.omnipodPumpPlugin = pumpPlugin;
|
// OmnipodUtil.omnipodPumpPlugin = pumpPlugin;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
public static void setOmnipodPodType(OmnipodPodType omnipodPodType) {
|
public static void setOmnipodPodType(OmnipodPodType omnipodPodType) {
|
||||||
|
@ -227,29 +244,38 @@ public class OmnipodUtil extends RileyLinkUtil {
|
||||||
return omnipodPodType;
|
return omnipodPodType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PodDeviceState getPodDeviceState() {
|
public PodDeviceState getPodDeviceState() {
|
||||||
return omnipodPumpStatus.podDeviceState;
|
return omnipodPumpStatus.podDeviceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static PodSessionState getPodSessionState() {
|
public PodSessionState getPodSessionState() {
|
||||||
return omnipodPumpStatus.podSessionState;
|
return omnipodPumpStatus.podSessionState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOmnipodEros() {
|
// public static boolean isOmnipodEros() {
|
||||||
return OmnipodPumpPlugin.getPlugin().isEnabled(PluginType.PUMP);
|
// return OmnipodPumpPlugin.getPlugin().isEnabled(PluginType.PUMP);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static boolean isOmnipodDash() {
|
||||||
|
// return OmnipodDashPumpPlugin.getPlugin().isEnabled(PluginType.PUMP);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
public void setPumpType(PumpType pumpType_) {
|
||||||
|
omnipodPumpStatus.pumpType = pumpType_;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOmnipodDash() {
|
public PumpType getPumpType() {
|
||||||
return OmnipodDashPumpPlugin.getPlugin().isEnabled(PluginType.PUMP);
|
return omnipodPumpStatus.pumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Gson getGsonInstance() {
|
||||||
|
return gsonInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void setPumpType(PumpType pumpType) {
|
|
||||||
OmnipodUtil.pumpType = pumpType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PumpType getPumpType() {
|
|
||||||
return pumpType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
|
@ -22,7 +21,6 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
||||||
|
@ -30,7 +28,6 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodFragment;
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodFragment;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||||
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.defs.OmnipodPodType;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
|
||||||
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.events.EventOmnipodRefreshButtonState;
|
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefreshButtonState;
|
||||||
|
@ -98,9 +95,9 @@ public class OmnipodDashPumpPlugin extends OmnipodPumpPlugin implements OmnipodP
|
||||||
omnipodCommunicationManager = OmnipodDashCommunicationManager.getInstance();
|
omnipodCommunicationManager = OmnipodDashCommunicationManager.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipodUIComm = new OmnipodUIComm(omnipodCommunicationManager, this, this.pumpStatusLocal);
|
// DG omnipodUIComm = new OmnipodUIComm(omnipodCommunicationManager, this, this.omnipodPumpStatus);
|
||||||
|
|
||||||
OmnipodUtil.setPlugin(this);
|
//OmnipodUtil.setPlugin(this);
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
// serviceConnection = new ServiceConnection() {
|
// serviceConnection = new ServiceConnection() {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.utils.SP;
|
||||||
/**
|
/**
|
||||||
* Created by andy on 4.8.2019
|
* Created by andy on 4.8.2019
|
||||||
*/
|
*/
|
||||||
|
// TODO refactor to use dagger, just commented out errors
|
||||||
public class OmnipodDashCommunicationManager implements OmnipodCommunicationManagerInterface {
|
public class OmnipodDashCommunicationManager implements OmnipodCommunicationManagerInterface {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||||
|
@ -34,8 +35,8 @@ public class OmnipodDashCommunicationManager implements OmnipodCommunicationMana
|
||||||
|
|
||||||
public OmnipodDashCommunicationManager(Context context, RFSpy rfspy) {
|
public OmnipodDashCommunicationManager(Context context, RFSpy rfspy) {
|
||||||
omnipodCommunicationManager = this;
|
omnipodCommunicationManager = this;
|
||||||
OmnipodUtil.getPumpStatus().previousConnection = SP.getLong(
|
// OmnipodUtil.getPumpStatus().previousConnection = SP.getLong(
|
||||||
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
|
// RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,21 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod_dash.driver;
|
package info.nightscout.androidaps.plugins.pump.omnipod_dash.driver;
|
||||||
|
|
||||||
public class OmnipodDashPumpStatus {
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
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.driver.OmnipodPumpStatus;
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class OmnipodDashPumpStatus extends OmnipodPumpStatus {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public OmnipodDashPumpStatus(ResourceHelper resourceHelper, SP sp, RxBusWrapper rxBus, RileyLinkUtil rileyLinkUtil) {
|
||||||
|
super(resourceHelper, sp, rxBus, rileyLinkUtil);
|
||||||
|
this.pumpType = PumpType.Insulet_Omnipod_Dash;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue