MDT refactor pass 10
This commit is contained in:
parent
7e712bd612
commit
85558620fc
|
@ -31,7 +31,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistor
|
|||
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.service.RileyLinkService;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceNotification;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceResult;
|
||||
|
@ -50,9 +49,7 @@ public class RileyLinkUtil {
|
|||
public List<RLHistoryItem> historyRileyLink = new ArrayList<>();
|
||||
public RileyLinkCommunicationManager rileyLinkCommunicationManager;
|
||||
static ServiceTask currentTask;
|
||||
private RileyLinkBLE rileyLinkBLE;
|
||||
private RileyLinkServiceData rileyLinkServiceData;
|
||||
private RileyLinkService rileyLinkService;
|
||||
private RileyLinkTargetFrequency rileyLinkTargetFrequency;
|
||||
|
||||
private RileyLinkTargetDevice targetDevice;
|
||||
|
@ -112,15 +109,6 @@ public class RileyLinkUtil {
|
|||
setServiceState(newState, null);
|
||||
}
|
||||
|
||||
|
||||
public RileyLinkError getError() {
|
||||
if (rileyLinkServiceData != null)
|
||||
return rileyLinkServiceData.errorCode;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public RileyLinkServiceState getServiceState() {
|
||||
return workWithServiceState(null, null, false);
|
||||
}
|
||||
|
@ -156,23 +144,12 @@ public class RileyLinkUtil {
|
|||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public RileyLinkBLE getRileyLinkBLE() {
|
||||
return rileyLinkBLE;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public void setRileyLinkBLE(RileyLinkBLE rileyLinkBLEIn) {
|
||||
rileyLinkBLE = rileyLinkBLEIn;
|
||||
}
|
||||
|
||||
|
||||
public RileyLinkServiceData getRileyLinkServiceData() {
|
||||
return rileyLinkServiceData;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public void setRileyLinkServiceData(RileyLinkServiceData rileyLinkServiceData) {
|
||||
this.rileyLinkServiceData = rileyLinkServiceData;
|
||||
}
|
||||
|
@ -182,22 +159,6 @@ public class RileyLinkUtil {
|
|||
return rileyLinkServiceData.tuneUpDone;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RileyLinkService getRileyLinkService() {
|
||||
return rileyLinkService;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public void setRileyLinkService(RileyLinkService rileyLinkService) {
|
||||
this.rileyLinkService = rileyLinkService;
|
||||
}
|
||||
|
||||
public static boolean sendNotification(ServiceNotification notification, Integer clientHashcode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// FIXME remove ?
|
||||
public static void setCurrentTask(ServiceTask task) {
|
||||
if (currentTask == null) {
|
||||
|
|
|
@ -51,7 +51,6 @@ public abstract class RileyLinkService extends DaggerService {
|
|||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
rileyLinkUtil.setRileyLinkService(this);
|
||||
rileyLinkUtil.setEncoding(getEncoding());
|
||||
initRileyLinkServiceData();
|
||||
|
||||
|
@ -94,10 +93,7 @@ public abstract class RileyLinkService extends DaggerService {
|
|||
super.onDestroy();
|
||||
//LOG.error("I die! I die!");
|
||||
|
||||
if (rileyLinkBLE != null) {
|
||||
rileyLinkBLE.disconnect(); // dispose of Gatt (disconnect and close)
|
||||
rileyLinkBLE = null;
|
||||
}
|
||||
rileyLinkBLE.disconnect(); // dispose of Gatt (disconnect and close)
|
||||
|
||||
if (mBroadcastReceiver != null) {
|
||||
mBroadcastReceiver.unregisterBroadcasts();
|
||||
|
@ -162,11 +158,6 @@ public abstract class RileyLinkService extends DaggerService {
|
|||
// returns true if our Rileylink configuration changed
|
||||
public boolean reconfigureRileyLink(String deviceAddress) {
|
||||
|
||||
if (rileyLinkBLE == null) {
|
||||
rileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothInitializing);
|
||||
return false;
|
||||
}
|
||||
|
||||
rileyLinkUtil.setServiceState(RileyLinkServiceState.RileyLinkInitializing);
|
||||
|
||||
if (rileyLinkBLE.isConnected()) {
|
||||
|
@ -191,7 +182,7 @@ public abstract class RileyLinkService extends DaggerService {
|
|||
if (rileyLinkUtil.getServiceState() == RileyLinkServiceState.NotStarted) {
|
||||
if (!bluetoothInit()) {
|
||||
aapsLogger.error("RileyLink can't get activated, Bluetooth is not functioning correctly. {}",
|
||||
rileyLinkUtil.getError() != null ? rileyLinkUtil.getError().name() : "Unknown error (null)");
|
||||
getError() != null ? getError().name() : "Unknown error (null)");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -245,15 +236,15 @@ public abstract class RileyLinkService extends DaggerService {
|
|||
|
||||
public void disconnectRileyLink() {
|
||||
|
||||
if (this.rileyLinkBLE != null && this.rileyLinkBLE.isConnected()) {
|
||||
this.rileyLinkBLE.disconnect();
|
||||
if (rileyLinkBLE.isConnected()) {
|
||||
rileyLinkBLE.disconnect();
|
||||
rileyLinkServiceData.rileylinkAddress = null;
|
||||
}
|
||||
|
||||
rileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothReady);
|
||||
}
|
||||
|
||||
public RileyLinkBLE getRileyLinkBLE() {
|
||||
@NotNull public RileyLinkBLE getRileyLinkBLE() {
|
||||
return rileyLinkBLE;
|
||||
}
|
||||
|
||||
|
@ -270,4 +261,11 @@ public abstract class RileyLinkService extends DaggerService {
|
|||
rfspy.setRileyLinkEncoding(encodingType);
|
||||
}
|
||||
}
|
||||
|
||||
public RileyLinkError getError() {
|
||||
if (rileyLinkServiceData != null)
|
||||
return rileyLinkServiceData.errorCode;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ class MedtronicFragment : DaggerFragment() {
|
|||
rileyLinkUtil.getServiceState()) as RileyLinkServiceState?
|
||||
|
||||
val resourceId = medtronicPumpStatus.rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.MedtronicPump)
|
||||
val rileyLinkError = rileyLinkUtil.getError()
|
||||
val rileyLinkError = medtronicPumpPlugin.rileyLinkService?.error
|
||||
medtronic_rl_status.text =
|
||||
when {
|
||||
medtronicPumpStatus.rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
|
||||
|
@ -189,7 +189,7 @@ class MedtronicFragment : DaggerFragment() {
|
|||
}
|
||||
medtronic_rl_status.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE)
|
||||
|
||||
medtronicPumpStatus.rileyLinkError = checkStatusSet(medtronicPumpStatus.rileyLinkError, rileyLinkUtil.getError()) as RileyLinkError?
|
||||
medtronicPumpStatus.rileyLinkError = checkStatusSet(medtronicPumpStatus.rileyLinkError, medtronicPumpPlugin.rileyLinkService?.error) as RileyLinkError?
|
||||
|
||||
medtronic_errors.text =
|
||||
medtronicPumpStatus.rileyLinkError?.let {
|
||||
|
|
|
@ -85,7 +85,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
|
||||
@Override
|
||||
public <E extends RLMessage> E createResponseMessage(byte[] payload, Class<E> clazz) {
|
||||
PumpMessage pumpMessage = new PumpMessage(payload);
|
||||
PumpMessage pumpMessage = new PumpMessage(aapsLogger, payload);
|
||||
return (E) pumpMessage;
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
return rval;
|
||||
} else {
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "runCommandWithArgs: Pump did not ack Attention packet");
|
||||
return new PumpMessage("No ACK after Attention packet.");
|
||||
return new PumpMessage(aapsLogger, "No ACK after Attention packet.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,7 +262,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
if (shortResponse.commandType != MedtronicCommandType.CommandACK) {
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "runCommandWithFrames: Pump did not ack Attention packet");
|
||||
|
||||
return new PumpMessage("No ACK after start message.");
|
||||
return new PumpMessage(aapsLogger, "No ACK after start message.");
|
||||
} else {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Run command with Frames: Got ACK response for Attention packet");
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
aapsLogger.error(LTag.PUMPBTCOMM, "Run command with Frames FAILED (command={}, response={})", commandType.name(),
|
||||
rval.toString());
|
||||
|
||||
return new PumpMessage("No ACK after frame #" + frameNr);
|
||||
return new PumpMessage(aapsLogger, "No ACK after frame #" + frameNr);
|
||||
} else {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Run command with Frames: Got ACK response for frame #{}", (frameNr));
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
|
||||
public PumpHistoryResult getPumpHistory(PumpHistoryEntry lastEntry, LocalDateTime targetDate) {
|
||||
|
||||
PumpHistoryResult pumpTotalResult = new PumpHistoryResult(lastEntry, targetDate == null ? null
|
||||
PumpHistoryResult pumpTotalResult = new PumpHistoryResult(aapsLogger, lastEntry, targetDate == null ? null
|
||||
: DateTimeUtil.toATechDate(targetDate));
|
||||
|
||||
if (doWakeUpBeforeCommand)
|
||||
|
@ -492,7 +492,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
|
||||
|
||||
private PumpMessage makePumpMessage(MedtronicCommandType messageType, MessageBody messageBody) {
|
||||
PumpMessage msg = new PumpMessage();
|
||||
PumpMessage msg = new PumpMessage(aapsLogger);
|
||||
msg.init(PacketType.Carelink, rileyLinkServiceData.pumpIDBytes, messageType, messageBody);
|
||||
return msg;
|
||||
}
|
||||
|
@ -869,7 +869,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
|
||||
|
||||
public boolean cancelTBR() {
|
||||
return setTBR(new TempBasalPair(aapsLogger, 0.0d, false, 0));
|
||||
return setTBR(new TempBasalPair(0.0d, false, 0));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -619,7 +619,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
|||
tbrRate = tbrPreviousRecord;
|
||||
}
|
||||
|
||||
TempBasalPair tbr = new TempBasalPair(aapsLogger, tbrRate.getHead()[0], tbrDuration.getHead()[0], (ByteUtil.asUINT8(tbrRate
|
||||
TempBasalPair tbr = new TempBasalPair(tbrRate.getHead()[0], tbrDuration.getHead()[0], (ByteUtil.asUINT8(tbrRate
|
||||
.getDatetime()[4]) >> 3) == 0);
|
||||
|
||||
// System.out.println("TBR: amount=" + tbr.getInsulinRate() + ", duration=" + tbr.getDurationMinutes()
|
||||
|
|
|
@ -2,11 +2,8 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
|
|||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.MedtronicHistoryEntry;
|
||||
|
@ -21,8 +18,6 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceTyp
|
|||
|
||||
public class PumpHistoryEntry extends MedtronicHistoryEntry {
|
||||
|
||||
private static Logger LOG = StacktraceLoggerWrapper.getLogger(PumpHistoryEntry.class);
|
||||
|
||||
@Expose
|
||||
private PumpHistoryEntryType entryType;
|
||||
private Integer opCode; // this is set only when we have unknown entry...
|
||||
|
|
|
@ -158,8 +158,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
|||
TempBasalCombined(0xfe, "TBR", PumpHistoryEntryGroup.Basal), //
|
||||
UnknownBasePacket(0xff, "Unknown Base Packet", PumpHistoryEntryGroup.Unknown);
|
||||
|
||||
private static Map<Integer, PumpHistoryEntryType> opCodeMap = new HashMap<Integer, PumpHistoryEntryType>();
|
||||
private static PumpHistoryEntryType tddType;
|
||||
private static Map<Integer, PumpHistoryEntryType> opCodeMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (PumpHistoryEntryType type : values()) {
|
||||
|
@ -171,7 +170,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
|||
|
||||
private int opCode;
|
||||
private String description;
|
||||
private int headLength = 0;
|
||||
private int headLength;
|
||||
private int dateLength;
|
||||
// private MinimedDeviceType deviceType;
|
||||
private int bodyLength;
|
||||
|
@ -181,8 +180,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
|||
private List<SpecialRule> specialRulesHead;
|
||||
private List<SpecialRule> specialRulesBody;
|
||||
private boolean hasSpecialRules = false;
|
||||
private PumpHistoryEntryGroup group = PumpHistoryEntryGroup.Unknown;
|
||||
private static Object TDDType;
|
||||
private PumpHistoryEntryGroup group;
|
||||
|
||||
|
||||
PumpHistoryEntryType(int opCode, String name, PumpHistoryEntryGroup group) {
|
||||
|
@ -400,7 +398,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
|||
int size;
|
||||
|
||||
|
||||
public SpecialRule(MedtronicDeviceType deviceType, int size) {
|
||||
SpecialRule(MedtronicDeviceType deviceType, int size) {
|
||||
this.deviceType = deviceType;
|
||||
this.size = size;
|
||||
}
|
||||
|
|
|
@ -1,24 +1,21 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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.utils.DateTimeUtil;
|
||||
|
||||
/**
|
||||
* History page contains data, sorted from newest to oldest (0=newest..n=oldest)
|
||||
*
|
||||
* <p>
|
||||
* Created by andy on 9/23/18.
|
||||
*/
|
||||
public class PumpHistoryResult {
|
||||
|
||||
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
||||
private final AAPSLogger aapsLogger;
|
||||
|
||||
private boolean searchFinished = false;
|
||||
private PumpHistoryEntry searchEntry = null;
|
||||
|
@ -28,23 +25,22 @@ public class PumpHistoryResult {
|
|||
public List<PumpHistoryEntry> validEntries;
|
||||
|
||||
|
||||
public PumpHistoryResult(PumpHistoryEntry searchEntry, Long targetDate) {
|
||||
public PumpHistoryResult(AAPSLogger aapsLogger, PumpHistoryEntry searchEntry, Long targetDate) {
|
||||
this.aapsLogger = aapsLogger;
|
||||
if (searchEntry != null) {
|
||||
/*
|
||||
* this.searchEntry = searchEntry;
|
||||
* this.searchType = SearchType.LastEntry;
|
||||
* LOG.debug("PumpHistoryResult. Search parameters: Last Entry: " + searchEntry.atechDateTime + " type="
|
||||
* aapsLogger.debug(LTag.PUMPBTCOMM,"PumpHistoryResult. Search parameters: Last Entry: " + searchEntry.atechDateTime + " type="
|
||||
* + searchEntry.getEntryType().name());
|
||||
*/
|
||||
this.searchDate = searchEntry.atechDateTime;
|
||||
this.searchType = SearchType.Date;
|
||||
if (isLogEnabled())
|
||||
LOG.debug("PumpHistoryResult. Search parameters: Date(with searchEntry): " + targetDate);
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "PumpHistoryResult. Search parameters: Date(with searchEntry): " + targetDate);
|
||||
} else if (targetDate != null) {
|
||||
this.searchDate = targetDate;
|
||||
this.searchType = SearchType.Date;
|
||||
if (isLogEnabled())
|
||||
LOG.debug("PumpHistoryResult. Search parameters: Date: " + targetDate);
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "PumpHistoryResult. Search parameters: Date: " + targetDate);
|
||||
}
|
||||
|
||||
// this.unprocessedEntries = new ArrayList<>();
|
||||
|
@ -54,7 +50,7 @@ public class PumpHistoryResult {
|
|||
|
||||
public void addHistoryEntries(List<PumpHistoryEntry> entries, int page) {
|
||||
this.unprocessedEntries = entries;
|
||||
//LOG.debug("PumpHistoryResult. Unprocessed entries: {}", MedtronicUtil.getGsonInstance().toJson(entries));
|
||||
//aapsLogger.debug(LTag.PUMPBTCOMM,"PumpHistoryResult. Unprocessed entries: {}", MedtronicUtil.getGsonInstance().toJson(entries));
|
||||
processEntries();
|
||||
}
|
||||
|
||||
|
@ -66,47 +62,47 @@ public class PumpHistoryResult {
|
|||
|
||||
switch (searchType) {
|
||||
case None:
|
||||
//LOG.debug("PE. None search");
|
||||
//aapsLogger.debug(LTag.PUMPBTCOMM,"PE. None search");
|
||||
this.validEntries.addAll(this.unprocessedEntries);
|
||||
break;
|
||||
|
||||
case LastEntry: {
|
||||
LOG.debug("PE. Last entry search");
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "PE. Last entry search");
|
||||
|
||||
//Collections.sort(this.unprocessedEntries, new PumpHistoryEntry.Comparator());
|
||||
|
||||
LOG.debug("PE. PumpHistoryResult. Search entry date: " + searchEntry.atechDateTime);
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "PE. PumpHistoryResult. Search entry date: " + searchEntry.atechDateTime);
|
||||
|
||||
Long date = searchEntry.atechDateTime;
|
||||
|
||||
for (PumpHistoryEntry unprocessedEntry : unprocessedEntries) {
|
||||
|
||||
if (unprocessedEntry.equals(searchEntry)) {
|
||||
//LOG.debug("PE. Item found {}.", unprocessedEntry);
|
||||
//aapsLogger.debug(LTag.PUMPBTCOMM,"PE. Item found {}.", unprocessedEntry);
|
||||
searchFinished = true;
|
||||
break;
|
||||
}
|
||||
|
||||
//LOG.debug("PE. Entry {} added.", unprocessedEntry);
|
||||
//aapsLogger.debug(LTag.PUMPBTCOMM,"PE. Entry {} added.", unprocessedEntry);
|
||||
this.validEntries.add(unprocessedEntry);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Date: {
|
||||
LOG.debug("PE. Date search: Search date: {}", this.searchDate);
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "PE. Date search: Search date: {}", this.searchDate);
|
||||
|
||||
|
||||
for (PumpHistoryEntry unprocessedEntry : unprocessedEntries) {
|
||||
|
||||
if (unprocessedEntry.atechDateTime == null || unprocessedEntry.atechDateTime == 0) {
|
||||
LOG.debug("PE. PumpHistoryResult. Search entry date: Entry with no date: {}", unprocessedEntry);
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "PE. PumpHistoryResult. Search entry date: Entry with no date: {}", unprocessedEntry);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (unprocessedEntry.isAfter(this.searchDate)) {
|
||||
this.validEntries.add(unprocessedEntry);
|
||||
} else {
|
||||
// LOG.debug("PE. PumpHistoryResult. Not after.. Unprocessed Entry [year={},entry={}]",
|
||||
// aapsLogger.debug(LTag.PUMPBTCOMM,"PE. PumpHistoryResult. Not after.. Unprocessed Entry [year={},entry={}]",
|
||||
// DateTimeUtil.getYear(unprocessedEntry.atechDateTime), unprocessedEntry);
|
||||
if (DateTimeUtil.getYear(unprocessedEntry.atechDateTime) > 2015)
|
||||
olderEntries++;
|
||||
|
@ -123,7 +119,7 @@ public class PumpHistoryResult {
|
|||
|
||||
} // switch
|
||||
|
||||
//LOG.debug("PE. Valid Entries: {}", validEntries);
|
||||
//aapsLogger.debug(LTag.PUMPBTCOMM,"PE. Valid Entries: {}", validEntries);
|
||||
}
|
||||
|
||||
|
||||
|
@ -178,11 +174,4 @@ public class PumpHistoryResult {
|
|||
LastEntry, //
|
||||
Date
|
||||
}
|
||||
|
||||
|
||||
private boolean isLogEnabled() {
|
||||
return L.isEnabled(L.PUMPCOMM);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public enum PacketType {
|
|||
}
|
||||
}
|
||||
|
||||
private byte value = 0;
|
||||
private byte value;
|
||||
|
||||
|
||||
PacketType(int value) {
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
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.hw.rileylink.ble.data.RLMessage;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
|
||||
|
@ -14,9 +11,9 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandTy
|
|||
*/
|
||||
public class PumpMessage implements RLMessage {
|
||||
|
||||
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
||||
private final AAPSLogger aapsLogger;
|
||||
|
||||
public PacketType packetType = PacketType.Carelink;
|
||||
private PacketType packetType = PacketType.Carelink;
|
||||
public byte[] address = new byte[]{0, 0, 0};
|
||||
public MedtronicCommandType commandType;
|
||||
public Byte invalidCommandType;
|
||||
|
@ -26,18 +23,20 @@ public class PumpMessage implements RLMessage {
|
|||
public static final int FRAME_DATA_LENGTH = 64;
|
||||
|
||||
|
||||
public PumpMessage(String error) {
|
||||
public PumpMessage(AAPSLogger aapsLogger, String error) {
|
||||
this.error = error;
|
||||
this.aapsLogger = aapsLogger;
|
||||
}
|
||||
|
||||
|
||||
public PumpMessage(byte[] rxData) {
|
||||
public PumpMessage(AAPSLogger aapsLogger, byte[] rxData) {
|
||||
init(rxData);
|
||||
this.aapsLogger = aapsLogger;
|
||||
}
|
||||
|
||||
|
||||
public PumpMessage() {
|
||||
|
||||
public PumpMessage(AAPSLogger aapsLogger) {
|
||||
this.aapsLogger = aapsLogger;
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,8 +66,7 @@ public class PumpMessage implements RLMessage {
|
|||
if (rxData.length > 4) {
|
||||
this.commandType = MedtronicCommandType.getByCode(rxData[4]);
|
||||
if (this.commandType == MedtronicCommandType.InvalidCommand) {
|
||||
if (isLogEnabled())
|
||||
LOG.error("PumpMessage - Unknown commandType " + rxData[4]);
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "PumpMessage - Unknown commandType " + rxData[4]);
|
||||
}
|
||||
}
|
||||
if (rxData.length > 5) {
|
||||
|
@ -80,7 +78,7 @@ public class PumpMessage implements RLMessage {
|
|||
|
||||
@Override
|
||||
public byte[] getTxData() {
|
||||
byte[] rval = ByteUtil.concat(new byte[]{(byte) packetType.getValue()}, address);
|
||||
byte[] rval = ByteUtil.concat(new byte[]{packetType.getValue()}, address);
|
||||
rval = ByteUtil.concat(rval, commandType.getCommandCode());
|
||||
rval = ByteUtil.concat(rval, messageBody.getTxData());
|
||||
return rval;
|
||||
|
@ -211,10 +209,4 @@ public class PumpMessage implements RLMessage {
|
|||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
private boolean isLogEnabled() {
|
||||
return L.isEnabled(L.PUMPCOMM);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ public class MedtronicUITask {
|
|||
|
||||
|
||||
private TempBasalPair getTBRSettings() {
|
||||
return new TempBasalPair(aapsLogger, getDoubleFromParameters(0), //
|
||||
return new TempBasalPair(getDoubleFromParameters(0), //
|
||||
false, //
|
||||
getIntegerFromParameters(1));
|
||||
}
|
||||
|
|
|
@ -24,8 +24,6 @@ import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpH
|
|||
|
||||
public class DailyTotalsDTO {
|
||||
|
||||
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
||||
|
||||
// bg avg, bg low hi, number Bgs,
|
||||
// Sen Avg, Sen Lo/Hi, Sens Cal/Data = 0/0,
|
||||
// Insulin=19.8[8,9], Basal[10,11], Bolus[13,14], Carbs,
|
||||
|
|
|
@ -19,8 +19,6 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
|||
*/
|
||||
public class TempBasalPair extends info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair {
|
||||
|
||||
private final AAPSLogger aapsLogger;
|
||||
|
||||
/**
|
||||
* This constructor is for use with PumpHistoryDecoder
|
||||
*
|
||||
|
@ -28,10 +26,8 @@ public class TempBasalPair extends info.nightscout.androidaps.plugins.pump.commo
|
|||
* @param startTimeByte
|
||||
* @param isPercent
|
||||
*/
|
||||
public TempBasalPair(AAPSLogger aapsLogger, byte rateByte, int startTimeByte, boolean isPercent) {
|
||||
public TempBasalPair(byte rateByte, int startTimeByte, boolean isPercent) {
|
||||
super();
|
||||
this.aapsLogger = aapsLogger;
|
||||
|
||||
int rateInt = ByteUtil.asUINT8(rateByte);
|
||||
|
||||
if (isPercent)
|
||||
|
@ -45,7 +41,6 @@ public class TempBasalPair extends info.nightscout.androidaps.plugins.pump.commo
|
|||
|
||||
public TempBasalPair(AAPSLogger aapsLogger, byte[] response) {
|
||||
super();
|
||||
this.aapsLogger = aapsLogger;
|
||||
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Received TempBasal response: " + ByteUtil.getHex(response));
|
||||
|
@ -71,9 +66,8 @@ public class TempBasalPair extends info.nightscout.androidaps.plugins.pump.commo
|
|||
}
|
||||
|
||||
|
||||
public TempBasalPair(AAPSLogger aapsLogger, double insulinRate, boolean isPercent, int durationMinutes) {
|
||||
public TempBasalPair(double insulinRate, boolean isPercent, int durationMinutes) {
|
||||
super(insulinRate, isPercent, durationMinutes);
|
||||
this.aapsLogger = aapsLogger;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,10 +44,6 @@ public class MedtronicPumpStatus extends PumpStatus {
|
|||
public RileyLinkError rileyLinkError;
|
||||
public PumpDeviceState pumpDeviceState = PumpDeviceState.NeverContacted;
|
||||
public MedtronicDeviceType medtronicDeviceType = null;
|
||||
public double currentBasal = 0;
|
||||
public int tempBasalInProgress = 0;
|
||||
public int tempBasalRatio = 0;
|
||||
public int tempBasalRemainMin = 0;
|
||||
public Date tempBasalStart;
|
||||
public Double tempBasalAmount = 0.0d;
|
||||
|
||||
|
|
|
@ -108,8 +108,6 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
|||
rfspy = new RFSpy(rileyLinkBLE);
|
||||
rfspy.startReader();
|
||||
|
||||
rileyLinkUtil.setRileyLinkBLE(rileyLinkBLE);
|
||||
|
||||
// init rileyLinkCommunicationManager
|
||||
medtronicCommunicationManager = new MedtronicCommunicationManager(injector, rfspy);
|
||||
medtronicUIComm = new MedtronicUIComm(injector, aapsLogger, medtronicUtil, medtronicUIPostprocessor, medtronicCommunicationManager);
|
||||
|
|
Loading…
Reference in a new issue