MDT refactor pass 4
This commit is contained in:
parent
331c1c3ab5
commit
e2e0de25bc
|
@ -11,6 +11,7 @@ interface AAPSLogger {
|
|||
fun debug(tag: LTag, message: String)
|
||||
fun debug(tag: LTag, format: String, vararg arguments: Any?)
|
||||
fun warn(tag: LTag, message: String)
|
||||
fun warn(tag: LTag, format: String, vararg arguments: Any?)
|
||||
fun info(tag: LTag, message: String)
|
||||
fun info(tag: LTag, format: String, vararg arguments: Any?)
|
||||
fun error(tag: LTag, message: String)
|
||||
|
|
|
@ -28,6 +28,10 @@ class AAPSLoggerDebug : AAPSLogger {
|
|||
Log.w(tag.tag, message)
|
||||
}
|
||||
|
||||
override fun warn(tag: LTag, format: String, vararg arguments: Any?) {
|
||||
Log.w(tag.tag, String.format(format, arguments))
|
||||
}
|
||||
|
||||
override fun info(tag: LTag, message: String) {
|
||||
Log.i(tag.tag, message)
|
||||
}
|
||||
|
|
|
@ -35,6 +35,10 @@ class AAPSLoggerProduction : AAPSLogger {
|
|||
}
|
||||
}
|
||||
|
||||
override fun warn(tag: LTag, format: String, vararg arguments: Any?) {
|
||||
LoggerFactory.getLogger(tag.tag).warn(stackLogMarker() + String.format(format, arguments))
|
||||
}
|
||||
|
||||
override fun info(tag: LTag, message: String) {
|
||||
if (L.isEnabled(tag.tag)) {
|
||||
LoggerFactory.getLogger(tag.tag).info(stackLogMarker() + message)
|
||||
|
|
|
@ -26,6 +26,10 @@ class AAPSLoggerTest : AAPSLogger {
|
|||
println("WARN: " + tag.tag + " " + message)
|
||||
}
|
||||
|
||||
override fun warn(tag: LTag, format: String, vararg arguments: Any?) {
|
||||
println("INFO: : " + tag.tag + " " + String.format(format, arguments))
|
||||
}
|
||||
|
||||
override fun info(tag: LTag, message: String) {
|
||||
println("INFO: " + tag.tag + " " + message)
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewB
|
|||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||
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.RileyLinkCommunicationManager;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData;
|
||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
|
@ -111,6 +113,7 @@ 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() {
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException;
|
||||
|
@ -35,13 +32,15 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
|||
*/
|
||||
public abstract class RileyLinkCommunicationManager {
|
||||
|
||||
@Inject MedtronicPumpStatus medtronicPumpStatus;
|
||||
@Inject protected AAPSLogger aapsLogger;
|
||||
@Inject protected SP sp;
|
||||
|
||||
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
||||
@Inject MedtronicPumpStatus medtronicPumpStatus;
|
||||
@Inject RileyLinkUtil rileyLinkUtil;
|
||||
|
||||
private static final int SCAN_TIMEOUT = 1500;
|
||||
private static final int ALLOWED_PUMP_UNREACHABLE = 10 * 60 * 1000; // 10 minutes
|
||||
|
||||
private final int SCAN_TIMEOUT = 1500;
|
||||
private final int ALLOWED_PUMP_UNREACHABLE = 10 * 60 * 1000; // 10 minutes
|
||||
|
||||
protected final HasAndroidInjector injector;
|
||||
protected final RFSpy rfspy;
|
||||
|
@ -61,8 +60,7 @@ public abstract class RileyLinkCommunicationManager {
|
|||
this.injector = injector;
|
||||
injector.androidInjector().inject(this);
|
||||
this.rfspy = rfspy;
|
||||
this.rileyLinkServiceData = RileyLinkUtil.getInstance().getRileyLinkServiceData();
|
||||
RileyLinkUtil.getInstance().setRileyLinkCommunicationManager(this);
|
||||
this.rileyLinkServiceData = rileyLinkUtil.getRileyLinkServiceData();
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,8 +85,7 @@ public abstract class RileyLinkCommunicationManager {
|
|||
throws RileyLinkCommunicationException {
|
||||
|
||||
if (showPumpMessages) {
|
||||
if (isLogEnabled())
|
||||
LOG.info("Sent:" + ByteUtil.shortHexString(msg.getTxData()));
|
||||
aapsLogger.info(LTag.PUMPBTCOMM, "Sent:" + ByteUtil.shortHexString(msg.getTxData()));
|
||||
}
|
||||
|
||||
RFSpyResponse rfSpyResponse = rfspy.transmitThenReceive(new RadioPacket(msg.getTxData()),
|
||||
|
@ -101,7 +98,7 @@ public abstract class RileyLinkCommunicationManager {
|
|||
// Mark this as the last time we heard from the pump.
|
||||
rememberLastGoodDeviceCommunicationTime();
|
||||
} else {
|
||||
LOG.warn("isDeviceReachable. Response is invalid ! [interrupted={}, timeout={}, unknownCommand={}, invalidParam={}]", rfSpyResponse.wasInterrupted(),
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "isDeviceReachable. Response is invalid ! [interrupted={}, timeout={}, unknownCommand={}, invalidParam={}]", rfSpyResponse.wasInterrupted(),
|
||||
rfSpyResponse.wasTimeout(), rfSpyResponse.isUnknownCommand(), rfSpyResponse.isInvalidParam());
|
||||
|
||||
if (rfSpyResponse.wasTimeout()) {
|
||||
|
@ -111,7 +108,7 @@ public abstract class RileyLinkCommunicationManager {
|
|||
long diff = System.currentTimeMillis() - getPumpStatus().lastConnection;
|
||||
|
||||
if (diff > ALLOWED_PUMP_UNREACHABLE) {
|
||||
LOG.warn("We reached max time that Pump can be unreachable. Starting Tuning.");
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "We reached max time that Pump can be unreachable. Starting Tuning.");
|
||||
ServiceTaskExecutor.startTask(new WakeAndTuneTask(injector));
|
||||
timeoutCount = 0;
|
||||
}
|
||||
|
@ -124,8 +121,7 @@ public abstract class RileyLinkCommunicationManager {
|
|||
}
|
||||
|
||||
if (showPumpMessages) {
|
||||
if (isLogEnabled())
|
||||
LOG.info("Received:" + ByteUtil.shortHexString(rfSpyResponse.getRadioResponse().getPayload()));
|
||||
aapsLogger.info(LTag.PUMPBTCOMM, "Received:" + ByteUtil.shortHexString(rfSpyResponse.getRadioResponse().getPayload()));
|
||||
}
|
||||
|
||||
return response;
|
||||
|
@ -162,21 +158,18 @@ public abstract class RileyLinkCommunicationManager {
|
|||
nextWakeUpRequired = 0L;
|
||||
|
||||
if (System.currentTimeMillis() > nextWakeUpRequired) {
|
||||
if (isLogEnabled())
|
||||
LOG.info("Waking pump...");
|
||||
aapsLogger.info(LTag.PUMPBTCOMM, "Waking pump...");
|
||||
|
||||
byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.ReadSimpleData); // simple
|
||||
RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(pumpMsgContent), (byte) 0, (byte) 200,
|
||||
(byte) 0, (byte) 0, 25000, (byte) 0);
|
||||
if (isLogEnabled())
|
||||
LOG.info("wakeup: raw response is " + ByteUtil.shortHexString(resp.getRaw()));
|
||||
aapsLogger.info(LTag.PUMPBTCOMM, "wakeup: raw response is " + ByteUtil.shortHexString(resp.getRaw()));
|
||||
|
||||
// FIXME wakeUp successful !!!!!!!!!!!!!!!!!!
|
||||
|
||||
nextWakeUpRequired = System.currentTimeMillis() + (receiverDeviceAwakeForMinutes * 60 * 1000);
|
||||
} else {
|
||||
if (isLogEnabled())
|
||||
LOG.trace("Last pump communication was recent, not waking pump.");
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Last pump communication was recent, not waking pump.");
|
||||
}
|
||||
|
||||
// long lastGoodPlus = getLastGoodReceiverCommunicationTime() + (receiverDeviceAwakeForMinutes * 60 * 1000);
|
||||
|
@ -233,8 +226,7 @@ public abstract class RileyLinkCommunicationManager {
|
|||
|
||||
|
||||
public double scanForDevice(double[] frequencies) {
|
||||
if (isLogEnabled())
|
||||
LOG.info("Scanning for receiver ({})", receiverDeviceID);
|
||||
aapsLogger.info(LTag.PUMPBTCOMM, "Scanning for receiver ({})", receiverDeviceID);
|
||||
wakeUp(receiverDeviceAwakeForMinutes, false);
|
||||
FrequencyScanResults results = new FrequencyScanResults();
|
||||
|
||||
|
@ -251,7 +243,7 @@ public abstract class RileyLinkCommunicationManager {
|
|||
RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(pumpMsgContent), (byte) 0, (byte) 0,
|
||||
(byte) 0, (byte) 0, 1250, (byte) 0);
|
||||
if (resp.wasTimeout()) {
|
||||
LOG.error("scanForPump: Failed to find pump at frequency {}", frequencies[i]);
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "scanForPump: Failed to find pump at frequency {}", frequencies[i]);
|
||||
} else if (resp.looksLikeRadioPacket()) {
|
||||
RadioResponse radioResponse = new RadioResponse();
|
||||
|
||||
|
@ -265,17 +257,17 @@ public abstract class RileyLinkCommunicationManager {
|
|||
trial.rssiList.add(rssi);
|
||||
trial.successes++;
|
||||
} else {
|
||||
LOG.warn("Failed to parse radio response: " + ByteUtil.shortHexString(resp.getRaw()));
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Failed to parse radio response: " + ByteUtil.shortHexString(resp.getRaw()));
|
||||
trial.rssiList.add(-99);
|
||||
}
|
||||
|
||||
} catch (RileyLinkCommunicationException rle) {
|
||||
LOG.warn("Failed to decode radio response: " + ByteUtil.shortHexString(resp.getRaw()));
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Failed to decode radio response: " + ByteUtil.shortHexString(resp.getRaw()));
|
||||
trial.rssiList.add(-99);
|
||||
}
|
||||
|
||||
} else {
|
||||
LOG.error("scanForPump: raw response is " + ByteUtil.shortHexString(resp.getRaw()));
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "scanForPump: raw response is " + ByteUtil.shortHexString(resp.getRaw()));
|
||||
trial.rssiList.add(-99);
|
||||
}
|
||||
trial.tries++;
|
||||
|
@ -299,7 +291,7 @@ public abstract class RileyLinkCommunicationManager {
|
|||
+ one.frequencyMHz, "" + one.averageRSSI + ", RSSIs =" + one.rssiList));
|
||||
}
|
||||
|
||||
LOG.info(stringBuilder.toString());
|
||||
aapsLogger.info(LTag.PUMPCOMM, stringBuilder.toString());
|
||||
|
||||
results.sort(); // sorts in ascending order
|
||||
|
||||
|
@ -307,11 +299,10 @@ public abstract class RileyLinkCommunicationManager {
|
|||
results.bestFrequencyMHz = bestTrial.frequencyMHz;
|
||||
if (bestTrial.successes > 0) {
|
||||
rfspy.setBaseFrequency(results.bestFrequencyMHz);
|
||||
if (isLogEnabled())
|
||||
LOG.debug("Best frequency found: " + results.bestFrequencyMHz);
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Best frequency found: " + results.bestFrequencyMHz);
|
||||
return results.bestFrequencyMHz;
|
||||
} else {
|
||||
LOG.error("No pump response during scan.");
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "No pump response during scan.");
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
@ -340,22 +331,22 @@ public abstract class RileyLinkCommunicationManager {
|
|||
RadioPacket pkt = new RadioPacket(pumpMsgContent);
|
||||
RFSpyResponse resp = rfspy.transmitThenReceive(pkt, (byte) 0, (byte) 0, (byte) 0, (byte) 0, SCAN_TIMEOUT, (byte) 0);
|
||||
if (resp.wasTimeout()) {
|
||||
LOG.warn("tune_tryFrequency: no pump response at frequency {}", freqMHz);
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: no pump response at frequency {}", freqMHz);
|
||||
} else if (resp.looksLikeRadioPacket()) {
|
||||
RadioResponse radioResponse = new RadioResponse();
|
||||
try {
|
||||
radioResponse.init(resp.getRaw());
|
||||
|
||||
if (radioResponse.isValid()) {
|
||||
LOG.warn("tune_tryFrequency: saw response level {} at frequency {}", radioResponse.rssi, freqMHz);
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: saw response level {} at frequency {}", radioResponse.rssi, freqMHz);
|
||||
return calculateRssi(radioResponse.rssi);
|
||||
} else {
|
||||
LOG.warn("tune_tryFrequency: invalid radio response:"
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: invalid radio response:"
|
||||
+ ByteUtil.shortHexString(radioResponse.getPayload()));
|
||||
}
|
||||
|
||||
} catch (RileyLinkCommunicationException e) {
|
||||
LOG.warn("Failed to decode radio response: " + ByteUtil.shortHexString(resp.getRaw()));
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Failed to decode radio response: " + ByteUtil.shortHexString(resp.getRaw()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,16 +373,13 @@ public abstract class RileyLinkCommunicationManager {
|
|||
}
|
||||
if (betterFrequency == 0.0) {
|
||||
// we've failed... caller should try a full scan for pump
|
||||
if (isLogEnabled())
|
||||
LOG.error("quickTuneForPump: failed to find pump");
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "quickTuneForPump: failed to find pump");
|
||||
} else {
|
||||
rfspy.setBaseFrequency(betterFrequency);
|
||||
if (betterFrequency != startFrequencyMHz) {
|
||||
if (isLogEnabled())
|
||||
LOG.info("quickTuneForPump: new frequency is {}MHz", betterFrequency);
|
||||
aapsLogger.info(LTag.PUMPBTCOMM, "quickTuneForPump: new frequency is {}MHz", betterFrequency);
|
||||
} else {
|
||||
if (isLogEnabled())
|
||||
LOG.info("quickTuneForPump: pump frequency is the same: {}MHz", startFrequencyMHz);
|
||||
aapsLogger.info(LTag.PUMPBTCOMM, "quickTuneForPump: pump frequency is the same: {}MHz", startFrequencyMHz);
|
||||
}
|
||||
}
|
||||
return betterFrequency;
|
||||
|
@ -399,8 +387,7 @@ public abstract class RileyLinkCommunicationManager {
|
|||
|
||||
|
||||
private double quickTunePumpStep(double startFrequencyMHz, double stepSizeMHz) {
|
||||
if (isLogEnabled())
|
||||
LOG.info("Doing quick radio tune for receiver ({})", receiverDeviceID);
|
||||
aapsLogger.info(LTag.PUMPBTCOMM, "Doing quick radio tune for receiver ({})", receiverDeviceID);
|
||||
wakeUp(false);
|
||||
int startRssi = tune_tryFrequency(startFrequencyMHz);
|
||||
double lowerFrequency = startFrequencyMHz - stepSizeMHz;
|
||||
|
@ -438,8 +425,7 @@ public abstract class RileyLinkCommunicationManager {
|
|||
// Might still be zero, but that's fine.
|
||||
}
|
||||
double minutesAgo = (System.currentTimeMillis() - lastGoodReceiverCommunicationTime) / (1000.0 * 60.0);
|
||||
if (isLogEnabled())
|
||||
LOG.trace("Last good pump communication was " + minutesAgo + " minutes ago.");
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Last good pump communication was " + minutesAgo + " minutes ago.");
|
||||
return lastGoodReceiverCommunicationTime;
|
||||
}
|
||||
|
||||
|
@ -449,9 +435,7 @@ public abstract class RileyLinkCommunicationManager {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isLogEnabled() {
|
||||
return L.isEnabled(L.PUMPCOMM);
|
||||
}
|
||||
|
||||
public abstract PumpStatus getPumpStatus();
|
||||
|
||||
public abstract boolean isDeviceReachable();
|
||||
}
|
||||
|
|
|
@ -190,17 +190,6 @@ public class RileyLinkUtil {
|
|||
this.rileyLinkService = rileyLinkService;
|
||||
}
|
||||
|
||||
|
||||
public RileyLinkCommunicationManager getRileyLinkCommunicationManager() {
|
||||
return rileyLinkCommunicationManager;
|
||||
}
|
||||
|
||||
|
||||
void setRileyLinkCommunicationManager(RileyLinkCommunicationManager rileyLinkCommunicationManager) {
|
||||
this.rileyLinkCommunicationManager = rileyLinkCommunicationManager;
|
||||
}
|
||||
|
||||
|
||||
public static boolean sendNotification(ServiceNotification notification, Integer clientHashcode) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -125,7 +125,6 @@ public abstract class RileyLinkService extends DaggerService {
|
|||
|
||||
public abstract RileyLinkCommunicationManager getDeviceCommunicationManager();
|
||||
|
||||
|
||||
// Here is where the wake-lock begins:
|
||||
// We've received a service startCommand, we grab the lock.
|
||||
@Override
|
||||
|
@ -236,7 +235,7 @@ public abstract class RileyLinkService extends DaggerService {
|
|||
// error tuning pump, pump not present ??
|
||||
rileyLinkUtil.setServiceState(RileyLinkServiceState.PumpConnectorError, RileyLinkError.TuneUpOfDeviceFailed);
|
||||
} else {
|
||||
rileyLinkUtil.getRileyLinkCommunicationManager().clearNotConnectedCount();
|
||||
getDeviceCommunicationManager().clearNotConnectedCount();
|
||||
rileyLinkUtil.setServiceState(RileyLinkServiceState.PumpConnectorReady);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,14 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.task
|
|||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||
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.defs.RileyLinkError;
|
||||
|
@ -20,6 +25,8 @@ import info.nightscout.androidaps.utils.SP;
|
|||
*/
|
||||
public class InitializePumpManagerTask extends ServiceTask {
|
||||
|
||||
@Inject ActivePluginProvider activePlugin;
|
||||
|
||||
private static final String TAG = "InitPumpManagerTask";
|
||||
private RileyLinkTargetDevice targetDevice;
|
||||
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
||||
|
@ -54,17 +61,19 @@ public class InitializePumpManagerTask extends ServiceTask {
|
|||
lastGoodFrequency = RileyLinkUtil.getInstance().getRileyLinkServiceData().lastGoodFrequency;
|
||||
}
|
||||
|
||||
RileyLinkCommunicationManager rileyLinkCommunicationManager = ((PumpPluginAbstract)activePlugin.getActivePump()).getRileyLinkService().getDeviceCommunicationManager();
|
||||
|
||||
if ((lastGoodFrequency > 0.0d)
|
||||
&& RileyLinkUtil.getInstance().getRileyLinkCommunicationManager().isValidFrequency(lastGoodFrequency)) {
|
||||
&& rileyLinkCommunicationManager.isValidFrequency(lastGoodFrequency)) {
|
||||
|
||||
RileyLinkUtil.getInstance().setServiceState(RileyLinkServiceState.RileyLinkReady);
|
||||
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
LOG.info("Setting radio frequency to {} MHz", lastGoodFrequency);
|
||||
|
||||
RileyLinkUtil.getInstance().getRileyLinkCommunicationManager().setRadioFrequencyForPump(lastGoodFrequency);
|
||||
rileyLinkCommunicationManager.setRadioFrequencyForPump(lastGoodFrequency);
|
||||
|
||||
boolean foundThePump = RileyLinkUtil.getInstance().getRileyLinkCommunicationManager().tryToConnectToDevice();
|
||||
boolean foundThePump = rileyLinkCommunicationManager.tryToConnectToDevice();
|
||||
|
||||
if (foundThePump) {
|
||||
RileyLinkUtil.getInstance().setServiceState(RileyLinkServiceState.PumpConnectorReady);
|
||||
|
|
|
@ -110,7 +110,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
private Map<MedtronicStatusRefreshType, Long> statusRefreshMap = new HashMap<>();
|
||||
private boolean isInitialized = false;
|
||||
private MedtronicHistoryData medtronicHistoryData;
|
||||
private MedtronicCommunicationManager medtronicCommunicationManager;
|
||||
private PumpHistoryEntry lastPumpHistoryEntry;
|
||||
|
||||
public static boolean isBusy = false;
|
||||
|
@ -316,9 +315,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
return rileyLinkMedtronicService != null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public RileyLinkMedtronicService getRileyLinkMedtronicService() {
|
||||
public RileyLinkMedtronicService getRileyLinkService() {
|
||||
return rileyLinkMedtronicService;
|
||||
}
|
||||
|
||||
|
@ -432,7 +430,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
return false;
|
||||
}
|
||||
|
||||
return (!medtronicCommunicationManager.isDeviceReachable());
|
||||
return (!rileyLinkMedtronicService.getDeviceCommunicationManager().isDeviceReachable());
|
||||
}
|
||||
|
||||
|
||||
|
@ -537,10 +535,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
|
||||
aapsLogger.info(LTag.PUMP, getLogPrefix() + "initializePump - start");
|
||||
|
||||
if (medtronicCommunicationManager == null) {
|
||||
medtronicCommunicationManager = MedtronicCommunicationManager.getInstance();
|
||||
medtronicCommunicationManager.setDoWakeUpBeforeCommand(false);
|
||||
}
|
||||
rileyLinkMedtronicService.getDeviceCommunicationManager().setDoWakeUpBeforeCommand(false);
|
||||
|
||||
setRefreshButtonEnabled(false);
|
||||
|
||||
|
@ -633,11 +628,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
return isProfileSame(profile);
|
||||
} else if (medtronicPumpStatus.basalProfileStatus == BasalProfileStatus.ProfileChanged) {
|
||||
return false;
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
|
||||
return (medtronicPumpStatus.basalProfileStatus != BasalProfileStatus.ProfileOK) || isProfileSame(profile);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,10 +62,10 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
|
||||
@Inject MedtronicPumpStatus medtronicPumpStatus;
|
||||
|
||||
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
||||
private static final int MAX_COMMAND_TRIES = 3;
|
||||
private static final int DEFAULT_TIMEOUT = 2000;
|
||||
private static final long RILEYLINK_TIMEOUT = 15 * 60 * 1000; // 15 min
|
||||
private final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
||||
private final int MAX_COMMAND_TRIES = 3;
|
||||
private final int DEFAULT_TIMEOUT = 2000;
|
||||
private final long RILEYLINK_TIMEOUT = 15 * 60 * 1000; // 15 min
|
||||
|
||||
static MedtronicCommunicationManager medtronicCommunicationManager;
|
||||
String errorMessage;
|
||||
|
@ -102,6 +102,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isDeviceReachable() {
|
||||
return isDeviceReachable(false);
|
||||
}
|
||||
|
|
|
@ -8,13 +8,11 @@ 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.bus.RxBusWrapper;
|
||||
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;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
|
||||
/**
|
||||
* Created by andy on 6/14/18.
|
||||
|
@ -32,13 +30,11 @@ public class MedtronicUIComm {
|
|||
|
||||
@Inject
|
||||
public MedtronicUIComm(
|
||||
HasAndroidInjector injector,
|
||||
AAPSLogger aapsLogger,
|
||||
RxBusWrapper rxBus,
|
||||
ResourceHelper resourceHelper,
|
||||
RileyLinkUtil rileyLinkUtil,
|
||||
MedtronicUtil medtronicUtil,
|
||||
MedtronicUIPostprocessor medtronicUIPostprocessor
|
||||
@NotNull HasAndroidInjector injector,
|
||||
@NotNull AAPSLogger aapsLogger,
|
||||
@NotNull RileyLinkUtil rileyLinkUtil,
|
||||
@NotNull MedtronicUtil medtronicUtil,
|
||||
@NotNull MedtronicUIPostprocessor medtronicUIPostprocessor
|
||||
) {
|
||||
this.injector = injector;
|
||||
this.aapsLogger = aapsLogger;
|
||||
|
|
|
@ -98,8 +98,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RileyLinkCommunicationManager getDeviceCommunicationManager() {
|
||||
public MedtronicCommunicationManager getDeviceCommunicationManager() {
|
||||
return this.medtronicCommunicationManager;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue