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