MDT refactor pass 5

This commit is contained in:
Milos Kozak 2020-04-27 10:33:03 +02:00
parent e2e0de25bc
commit 3598e00290
9 changed files with 82 additions and 116 deletions

View file

@ -156,11 +156,13 @@ public class RileyLinkUtil {
}
@Deprecated
public RileyLinkBLE getRileyLinkBLE() {
return rileyLinkBLE;
}
@Deprecated
public void setRileyLinkBLE(RileyLinkBLE rileyLinkBLEIn) {
rileyLinkBLE = rileyLinkBLEIn;
}
@ -180,12 +182,13 @@ public class RileyLinkUtil {
return rileyLinkServiceData.tuneUpDone;
}
@Deprecated
public RileyLinkService getRileyLinkService() {
return rileyLinkService;
}
@Deprecated
public void setRileyLinkService(RileyLinkService rileyLinkService) {
this.rileyLinkService = rileyLinkService;
}

View file

@ -5,6 +5,8 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import org.jetbrains.annotations.NotNull;
import javax.inject.Inject;
import dagger.android.DaggerService;
@ -35,10 +37,10 @@ public abstract class RileyLinkService extends DaggerService {
@Inject protected SP sp;
@Inject protected Context context;
@Inject protected RileyLinkUtil rileyLinkUtil;
@Inject protected MedtronicUtil medtronicUtil;
@Inject protected MedtronicUtil medtronicUtil; // TODO should be avoided here as it's MDT
public RileyLinkBLE rileyLinkBLE; // android-bluetooth management
@NotNull protected RileyLinkBLE rileyLinkBLE; // android-bluetooth management, must be set in initRileyLinkServiceData
protected BluetoothAdapter bluetoothAdapter;
protected RFSpy rfspy; // interface for RL xxx Mhz radio.
protected RileyLinkBroadcastReceiver mBroadcastReceiver;
@ -251,6 +253,9 @@ public abstract class RileyLinkService extends DaggerService {
rileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothReady);
}
public RileyLinkBLE getRileyLinkBLE() {
return rileyLinkBLE;
}
/**
* Get Target Device for Service

View file

@ -1,13 +1,18 @@
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
import javax.inject.Inject;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
/**
* Created by geoff on 7/9/16.
*/
public class DiscoverGattServicesTask extends ServiceTask {
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
public boolean needToConnect = false;
@ -26,8 +31,8 @@ public class DiscoverGattServicesTask extends ServiceTask {
public void run() {
if (needToConnect)
RileyLinkUtil.getInstance().getRileyLinkBLE().connectGatt();
medtronicPumpPlugin.getRileyLinkService().getRileyLinkBLE().connectGatt();
RileyLinkUtil.getInstance().getRileyLinkBLE().discoverServices();
medtronicPumpPlugin.getRileyLinkService().getRileyLinkBLE().discoverServices();
}
}

View file

@ -59,10 +59,8 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.WakeAndTuneTask;
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryResult;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUIComm;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask;
import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData;
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfile;
@ -99,7 +97,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
private final RileyLinkUtil rileyLinkUtil;
private final MedtronicUtil medtronicUtil;
private final MedtronicPumpStatus medtronicPumpStatus;
private final MedtronicUIComm medtronicUIComm;
protected static MedtronicPumpPlugin plugin = null;
private RileyLinkMedtronicService rileyLinkMedtronicService;
@ -130,8 +127,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
FabricPrivacy fabricPrivacy,
RileyLinkUtil rileyLinkUtil,
MedtronicUtil medtronicUtil,
MedtronicPumpStatus medtronicPumpStatus,
MedtronicUIComm medtronicUIComm
MedtronicPumpStatus medtronicPumpStatus
) {
super(new PluginDescription() //
@ -150,7 +146,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
this.medtronicUtil = medtronicUtil;
this.sp = sp;
this.medtronicPumpStatus = medtronicPumpStatus;
this.medtronicUIComm = medtronicUIComm;
displayConnectionMessages = false;
@ -486,14 +481,14 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
case BatteryStatus:
case RemainingInsulin: {
medtronicUIComm.executeCommand(refreshType.getKey().getCommandType());
rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(refreshType.getKey().getCommandType());
refreshTypesNeededToReschedule.add(refreshType.getKey());
resetTime = true;
}
break;
case Configuration: {
medtronicUIComm.executeCommand(refreshType.getKey().getCommandType());
rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(refreshType.getKey().getCommandType());
resetTime = true;
}
break;
@ -554,7 +549,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// model (once)
if (medtronicUtil.getMedtronicPumpModel() == null) {
medtronicUIComm.executeCommand(MedtronicCommandType.PumpModel);
rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.PumpModel);
} else {
if (medtronicPumpStatus.medtronicDeviceType != medtronicUtil.getMedtronicPumpModel()) {
aapsLogger.warn(LTag.PUMP, getLogPrefix() + "Configured pump is not the same as one detected.");
@ -570,20 +565,20 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
readPumpHistory();
// remaining insulin (>50 = 4h; 50-20 = 1h; 15m)
medtronicUIComm.executeCommand(MedtronicCommandType.GetRemainingInsulin);
rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.GetRemainingInsulin);
scheduleNextRefresh(MedtronicStatusRefreshType.RemainingInsulin, 10);
// remaining power (1h)
medtronicUIComm.executeCommand(MedtronicCommandType.GetBatteryStatus);
rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.GetBatteryStatus);
scheduleNextRefresh(MedtronicStatusRefreshType.BatteryStatus, 20);
// configuration (once and then if history shows config changes)
medtronicUIComm.executeCommand(MedtronicCommandType.getSettings(medtronicUtil.getMedtronicPumpModel()));
rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.getSettings(medtronicUtil.getMedtronicPumpModel()));
// read profile (once, later its controlled by isThisProfileSet method)
getBasalProfiles();
int errorCount = medtronicUIComm.getInvalidResponsesCount();
int errorCount = rileyLinkMedtronicService.getMedtronicUIComm().getInvalidResponsesCount();
if (errorCount >= 5) {
aapsLogger.error("Number of error counts was 5 or more. Starting tunning.");
@ -607,10 +602,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
private void getBasalProfiles() {
MedtronicUITask medtronicUITask = medtronicUIComm.executeCommand(MedtronicCommandType.GetBasalProfileSTD);
MedtronicUITask medtronicUITask = rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.GetBasalProfileSTD);
if (medtronicUITask.getResponseType() == MedtronicUIResponseType.Error) {
medtronicUIComm.executeCommand(MedtronicCommandType.GetBasalProfileSTD);
rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.GetBasalProfileSTD);
}
}
@ -732,12 +727,12 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
medtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable, rxBus);
medtronicUIComm.executeCommand(MedtronicCommandType.GetRealTimeClock);
rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.GetRealTimeClock);
ClockDTO clock = medtronicUtil.getPumpTime();
if (clock == null) { // retry
medtronicUIComm.executeCommand(MedtronicCommandType.GetRealTimeClock);
rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.GetRealTimeClock);
clock = medtronicUtil.getPumpTime();
}
@ -753,7 +748,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
aapsLogger.info(LTag.PUMP, "MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference is {} s. Set time on pump." + timeDiff);
medtronicUIComm.executeCommand(MedtronicCommandType.SetRealTimeClock);
rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.SetRealTimeClock);
if (clock.timeDifference == 0) {
Notification notification = new Notification(Notification.INSIGHT_DATE_TIME_UPDATED, getResourceHelper().gs(R.string.pump_time_updated), Notification.INFO, 60);
@ -823,7 +818,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Start delivery");
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBolus,
MedtronicUITask responseTask = rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.SetBolus,
detailedBolusInfo.insulin);
Boolean response = (Boolean) responseTask.returnData;
@ -989,7 +984,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// CANCEL
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR);
MedtronicUITask responseTask2 = rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.CancelTBR);
Boolean response = (Boolean) responseTask2.returnData;
@ -1006,7 +1001,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
}
// now start new TBR
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetTemporaryBasal,
MedtronicUITask responseTask = rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.SetTemporaryBasal,
absoluteRate, durationInMinutes);
Boolean response = (Boolean) responseTask.returnData;
@ -1160,7 +1155,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
aapsLogger.debug(LTag.PUMP, "HST: Target Date: " + targetDate);
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.GetHistoryData,
MedtronicUITask responseTask2 = rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.GetHistoryData,
lastPumpHistoryEntry, targetDate);
aapsLogger.debug(LTag.PUMP, "HST: After task");
@ -1300,7 +1295,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
private TempBasalPair readTBR() {
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.ReadTemporaryBasal);
MedtronicUITask responseTask = rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.ReadTemporaryBasal);
if (responseTask.hasData()) {
TempBasalPair tbr = (TempBasalPair) responseTask.returnData;
@ -1350,7 +1345,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
.comment(getResourceHelper().gs(R.string.medtronic_cmd_cant_read_tbr));
}
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR);
MedtronicUITask responseTask2 = rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.CancelTBR);
Boolean response = (Boolean) responseTask2.returnData;
@ -1428,7 +1423,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
.comment(getResourceHelper().gs(R.string.medtronic_cmd_set_profile_pattern_overflow, profileInvalid));
}
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBasalProfileSTD,
MedtronicUITask responseTask = rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.SetBasalProfileSTD,
basalProfile);
Boolean response = (Boolean) responseTask.returnData;

View file

@ -1,15 +1,10 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.ui;
import org.jetbrains.annotations.NotNull;
import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
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.medtronic.comm.MedtronicCommunicationManager;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
@ -17,42 +12,29 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
/**
* Created by andy on 6/14/18.
*/
@Singleton
public class MedtronicUIComm {
@NotNull private final HasAndroidInjector injector;
@NotNull private final AAPSLogger aapsLogger;
@NotNull private final RileyLinkUtil rileyLinkUtil;
@NotNull private final MedtronicUtil medtronicUtil;
MedtronicCommunicationManager mcmInstance = null;
@NotNull private final MedtronicUIPostprocessor medtronicUIPostprocessor;
private final HasAndroidInjector injector;
private final AAPSLogger aapsLogger;
private final MedtronicUtil medtronicUtil;
private final MedtronicCommunicationManager medtronicCommunicationManager;
private final MedtronicUIPostprocessor medtronicUIPostprocessor;
@Inject
public MedtronicUIComm(
@NotNull HasAndroidInjector injector,
@NotNull AAPSLogger aapsLogger,
@NotNull RileyLinkUtil rileyLinkUtil,
@NotNull MedtronicUtil medtronicUtil,
@NotNull MedtronicUIPostprocessor medtronicUIPostprocessor
HasAndroidInjector injector,
AAPSLogger aapsLogger,
MedtronicUtil medtronicUtil,
MedtronicUIPostprocessor medtronicUIPostprocessor,
MedtronicCommunicationManager medtronicCommunicationManager
) {
this.injector = injector;
this.aapsLogger = aapsLogger;
this.rileyLinkUtil = rileyLinkUtil;
this.medtronicUtil = medtronicUtil;
this.medtronicUIPostprocessor = medtronicUIPostprocessor;
this.medtronicCommunicationManager = medtronicCommunicationManager;
}
private MedtronicCommunicationManager getCommunicationManager() {
if (mcmInstance == null) {
mcmInstance = MedtronicCommunicationManager.getInstance();
}
return mcmInstance;
}
public synchronized MedtronicUITask executeCommand(MedtronicCommandType commandType, Object... parameters) {
aapsLogger.warn(LTag.PUMP, "Execute Command: " + commandType.name());
@ -69,7 +51,7 @@ public class MedtronicUIComm {
// LOG.warn("@@@ End Thread");
// });
task.execute(getCommunicationManager());
task.execute(medtronicCommunicationManager);
// for (int i = 0; i < getMaxWaitTime(commandType); i++) {
// synchronized (task) {
@ -99,28 +81,7 @@ public class MedtronicUIComm {
}
/**
* We return 25s as waitTime (17 for wakeUp, and addtional 8 for data retrieval) for normal commands and
* 120s for History. Real time for returning data would be arround 5s, but lets be sure.
*
* @param commandType
* @return
*/
private int getMaxWaitTime(MedtronicCommandType commandType) {
if (commandType == MedtronicCommandType.GetHistoryData)
return 120;
else
return 25;
}
public int getInvalidResponsesCount() {
return getCommunicationManager().getNotConnectedCount();
}
public void startTunning() {
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_tunePump);
return medtronicCommunicationManager.getNotConnectedCount();
}
}

View file

@ -30,7 +30,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
*/
@Singleton
class MedtronicUIPostprocessor {
public class MedtronicUIPostprocessor {
@NotNull private final AAPSLogger aapsLogger;
@NotNull private final RxBusWrapper rxBus;

View file

@ -1,15 +1,13 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.ui;
import org.jetbrains.annotations.NotNull;
import org.joda.time.LocalDateTime;
import org.slf4j.Logger;
import javax.inject.Inject;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfile;
@ -28,11 +26,12 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
public class MedtronicUITask {
@Inject RxBusWrapper rxBus;
@Inject AAPSLogger aapsLogger;
@Inject MedtronicPumpStatus medtronicPumpStatus;
@Inject MedtronicUtil medtronicUtil;
@NotNull private final HasAndroidInjector injector;
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMP);
private final HasAndroidInjector injector;
public MedtronicCommandType commandType;
public Object returnData;
@ -45,14 +44,14 @@ public class MedtronicUITask {
public MedtronicUITask(HasAndroidInjector injector, MedtronicCommandType commandType) {
this.injector = injector;
injector.androidInjector().inject(this);
this.injector.androidInjector().inject(this);
this.commandType = commandType;
}
public MedtronicUITask(HasAndroidInjector injector, MedtronicCommandType commandType, Object... parameters) {
this.injector = injector;
injector.androidInjector().inject(this);
this.injector.androidInjector().inject(this);
this.commandType = commandType;
this.parameters = parameters;
}
@ -60,8 +59,7 @@ public class MedtronicUITask {
public void execute(MedtronicCommunicationManager communicationManager) {
if (isLogEnabled())
LOG.debug("MedtronicUITask: @@@ In execute. {}", commandType);
aapsLogger.debug(LTag.PUMP, "MedtronicUITask: @@@ In execute. {}", commandType);
switch (commandType) {
case PumpModel: {
@ -81,7 +79,7 @@ public class MedtronicUITask {
case GetRealTimeClock: {
returnData = communicationManager.getPumpTime();
MedtronicUtil.getInstance().setPumpTime(null);
medtronicUtil.setPumpTime(null);
}
break;
@ -143,7 +141,7 @@ public class MedtronicUITask {
break;
default: {
LOG.warn("This commandType is not supported (yet) - {}.", commandType);
aapsLogger.warn(LTag.PUMP, "This commandType is not supported (yet) - {}.", commandType);
// invalid = true;
responseType = MedtronicUIResponseType.Invalid;
}
@ -174,12 +172,12 @@ public class MedtronicUITask {
}
public Double getDoubleFromParameters(int index) {
Double getDoubleFromParameters(int index) {
return (Double) parameters[index];
}
public Integer getIntegerFromParameters(int index) {
private Integer getIntegerFromParameters(int index) {
return (Integer) parameters[index];
}
@ -196,25 +194,24 @@ public class MedtronicUITask {
void postProcess(MedtronicUIPostprocessor postprocessor) {
if (isLogEnabled())
LOG.debug("MedtronicUITask: @@@ In execute. {}", commandType);
aapsLogger.debug(LTag.PUMP, "MedtronicUITask: @@@ In execute. {}", commandType);
if (responseType == MedtronicUIResponseType.Data) {
postprocessor.postProcessData(this);
}
if (responseType == MedtronicUIResponseType.Invalid) {
RxBus.Companion.getINSTANCE().send(new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
rxBus.send(new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
"Unsupported command in MedtronicUITask"));
} else if (responseType == MedtronicUIResponseType.Error) {
RxBus.Companion.getINSTANCE().send(new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
rxBus.send(new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
errorDescription));
} else {
RxBus.Companion.getINSTANCE().send(new EventMedtronicPumpValuesChanged());
rxBus.send(new EventMedtronicPumpValuesChanged());
medtronicPumpStatus.setLastCommunicationToNow();
}
MedtronicUtil.getInstance().setCurrentCommand(null);
medtronicUtil.setCurrentCommand(null);
}
@ -223,16 +220,11 @@ public class MedtronicUITask {
}
public Object getParameter(int index) {
Object getParameter(int index) {
return parameters[index];
}
private boolean isLogEnabled() {
return L.isEnabled(L.PUMP);
}
public MedtronicUIResponseType getResponseType() {
return this.responseType;
}

View file

@ -22,6 +22,8 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.Riley
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.MedtronicCommunicationManager;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUIComm;
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.util.MedtronicConst;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
@ -34,8 +36,10 @@ public class RileyLinkMedtronicService extends RileyLinkService {
@Inject HasAndroidInjector injector;
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
@Inject MedtronicUtil medtronicUtil;
@Inject MedtronicUIPostprocessor medtronicUIPostprocessor;
// cache of most recently received set of pump history pages. Probably shouldn't be here.
private MedtronicUIComm medtronicUIComm;
private MedtronicCommunicationManager medtronicCommunicationManager;
private IBinder mBinder = new LocalBinder();
@ -87,6 +91,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
// init rileyLinkCommunicationManager
medtronicCommunicationManager = new MedtronicCommunicationManager(injector, rfspy);
medtronicUIComm = new MedtronicUIComm(injector, aapsLogger, medtronicUtil, medtronicUIPostprocessor, medtronicCommunicationManager);
aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkMedtronicService newly constructed");
medtronicUtil.setMedtronicService(this);
@ -103,6 +108,10 @@ public class RileyLinkMedtronicService extends RileyLinkService {
}
public MedtronicUIComm getMedtronicUIComm() {
return medtronicUIComm;
}
public void setPumpIDString(String pumpID) {
if (pumpID.length() != 6) {
aapsLogger.error("setPumpIDString: invalid pump id string: " + pumpID);

View file

@ -1,7 +1,5 @@
package info.nightscout.androidaps.plugins.pump.medtronic.util;
import android.content.Context;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@ -17,7 +15,6 @@ import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
@ -28,7 +25,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager;
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.ClockDTO;
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.PumpSettingDTO;