MDT refactor pass 8

This commit is contained in:
Milos Kozak 2020-04-27 14:30:38 +02:00
parent f686c81115
commit 30e7f8ed38
12 changed files with 167 additions and 210 deletions

View file

@ -98,6 +98,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
private final RileyLinkUtil rileyLinkUtil;
private final MedtronicUtil medtronicUtil;
private final MedtronicPumpStatus medtronicPumpStatus;
private final MedtronicHistoryData medtronicHistoryData;
protected static MedtronicPumpPlugin plugin = null;
private RileyLinkMedtronicService rileyLinkMedtronicService;
@ -107,7 +108,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
private boolean isRefresh = false;
private Map<MedtronicStatusRefreshType, Long> statusRefreshMap = new HashMap<>();
private boolean isInitialized = false;
private MedtronicHistoryData medtronicHistoryData;
private PumpHistoryEntry lastPumpHistoryEntry;
public static boolean isBusy = false;
@ -128,7 +128,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
FabricPrivacy fabricPrivacy,
RileyLinkUtil rileyLinkUtil,
MedtronicUtil medtronicUtil,
MedtronicPumpStatus medtronicPumpStatus
MedtronicPumpStatus medtronicPumpStatus,
MedtronicHistoryData medtronicHistoryData
) {
super(new PluginDescription() //
@ -147,6 +148,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
this.medtronicUtil = medtronicUtil;
this.sp = sp;
this.medtronicPumpStatus = medtronicPumpStatus;
this.medtronicHistoryData = medtronicHistoryData;
displayConnectionMessages = false;
@ -181,7 +183,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
@Override
protected void onStart() {
super.onStart();
medtronicHistoryData = new MedtronicHistoryData(aapsLogger, sp, activePlugin);
}
@Deprecated
@ -196,12 +197,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
return "MedtronicPumpPlugin::";
}
public MedtronicHistoryData getMedtronicHistoryData() {
return this.medtronicHistoryData;
}
@Override
public void initPumpStatusData() {
@ -1565,10 +1560,4 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
refreshCustomActionsList();
}
@Deprecated
public MedtronicPumpStatus getMedtronicPumpStatus() {
return medtronicPumpStatus;
}
}

View file

@ -65,6 +65,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
@Inject MedtronicConverter medtronicConverter;
@Inject MedtronicUtil medtronicUtil;
@Inject MedtronicPumpHistoryDecoder medtronicPumpHistoryDecoder;
private final int MAX_COMMAND_TRIES = 3;
private final int DEFAULT_TIMEOUT = 2000;
@ -73,13 +74,11 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
private String errorMessage;
private boolean debugSetCommands = false;
private MedtronicPumpHistoryDecoder pumpHistoryDecoder;
private boolean doWakeUpBeforeCommand = true;
public MedtronicCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) {
super(injector, rfspy);
this.pumpHistoryDecoder = new MedtronicPumpHistoryDecoder();
medtronicPumpStatus.previousConnection = sp.getLong(
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
}
@ -316,7 +315,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
for (int pageNumber = 0; pageNumber < 5; pageNumber++) {
RawHistoryPage rawHistoryPage = new RawHistoryPage();
RawHistoryPage rawHistoryPage = new RawHistoryPage(aapsLogger);
// wakeUp(receiverDeviceAwakeForMinutes, false);
PumpMessage getHistoryMsg = makePumpMessage(MedtronicCommandType.GetHistoryData,
new GetHistoryPageCarelinkMessageBody(pageNumber));
@ -440,8 +439,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
rawHistoryPage.dumpToDebug();
List<PumpHistoryEntry> medtronicHistoryEntries = pumpHistoryDecoder
.processPageAndCreateRecords(rawHistoryPage);
List<PumpHistoryEntry> medtronicHistoryEntries = medtronicPumpHistoryDecoder.processPageAndCreateRecords(rawHistoryPage);
aapsLogger.debug(LTag.PUMPBTCOMM, "getPumpHistory: Found {} history entries.", medtronicHistoryEntries.size());

View file

@ -1,32 +1,32 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import javax.inject.Inject;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
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.defs.MedtronicDeviceType;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
/**
* This file was taken from GGC - GNU Gluco Control (ggc.sourceforge.net), application for diabetes
* management and modified/extended for AAPS.
*
* <p>
* Author: Andy {andy.rozman@gmail.com}
*/
public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> implements MedtronicHistoryDecoderInterface<T> {
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
@Inject AAPSLogger aapsLogger;
@Inject MedtronicUtil medtronicUtil;
protected ByteUtil bitUtils;
@ -34,7 +34,6 @@ public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> i
protected boolean statisticsEnabled = true;
protected Map<Integer, Integer> unknownOpCodes;
protected Map<RecordDecodeStatus, Map<String, String>> mapStatistics;
protected MedtronicDeviceType deviceType;
public MedtronicHistoryDecoder() {
@ -62,8 +61,8 @@ public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> i
// return byteList;
// }
if (MedtronicUtil.getInstance().getMedtronicPumpModel() == null) {
LOG.error("Device Type is not defined.");
if (medtronicUtil.getMedtronicPumpModel() == null) {
aapsLogger.error(LTag.PUMPBTCOMM, "Device Type is not defined.");
return byteList;
}
@ -86,17 +85,16 @@ public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> i
if (!statisticsEnabled)
return;
unknownOpCodes = new HashMap<Integer, Integer>();
mapStatistics = new HashMap<RecordDecodeStatus, Map<String, String>>();
unknownOpCodes = new HashMap<>();
mapStatistics = new HashMap<>();
for (RecordDecodeStatus stat : RecordDecodeStatus.values()) {
mapStatistics.put(stat, new HashMap<String, String>());
mapStatistics.put(stat, new HashMap<>());
}
}
protected void addToStatistics(MedtronicHistoryEntryInterface pumpHistoryEntry, RecordDecodeStatus status,
Integer opCode) {
protected void addToStatistics(MedtronicHistoryEntryInterface pumpHistoryEntry, RecordDecodeStatus status, Integer opCode) {
if (!statisticsEnabled)
return;
@ -120,11 +118,10 @@ public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> i
StringUtil.appendToStringBuilder(sb, "" + unknownEntry.getKey(), ", ");
}
if (isLogEnabled())
LOG.debug("STATISTICS OF PUMP DECODE");
aapsLogger.error(LTag.PUMPBTCOMM, "STATISTICS OF PUMP DECODE");
if (unknownOpCodes.size() > 0) {
LOG.warn("Unknown Op Codes: {}", sb.toString());
aapsLogger.warn(LTag.PUMPBTCOMM, "Unknown Op Codes: {}", sb.toString());
}
for (Map.Entry<RecordDecodeStatus, Map<String, String>> entry : mapStatistics.entrySet()) {
@ -140,12 +137,9 @@ public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> i
String spaces = StringUtils.repeat(" ", 14 - entry.getKey().name().length());
if (isLogEnabled())
LOG.debug(" {}{} - {}. Elements: {}", entry.getKey().name(), spaces, entry.getValue().size(),
sb.toString());
aapsLogger.error(LTag.PUMPBTCOMM, " {}{} - {}. Elements: {}", entry.getKey().name(), spaces, entry.getValue().size(), sb.toString());
} else {
if (isLogEnabled())
LOG.debug(" {} - {}", entry.getKey().name(), entry.getValue().size());
aapsLogger.error(LTag.PUMPBTCOMM, " {} - {}", entry.getKey().name(), entry.getValue().size());
}
}
}
@ -184,9 +178,4 @@ public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> i
return records;
}
protected boolean isLogEnabled() {
return L.isEnabled(L.PUMPCOMM);
}
}

View file

@ -2,11 +2,8 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm.history;
import java.util.Arrays;
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.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.common.utils.CRC;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
@ -16,12 +13,13 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
*/
public class RawHistoryPage {
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMPBTCOMM);
private final AAPSLogger aapsLogger;
private byte[] data = new byte[0];
public RawHistoryPage() {
public RawHistoryPage(AAPSLogger aapsLogger) {
this.aapsLogger = aapsLogger;
}
@ -35,7 +33,7 @@ public class RawHistoryPage {
}
public byte[] getOnlyData() {
byte[] getOnlyData() {
return Arrays.copyOfRange(data, 0, 1022);
}
@ -55,11 +53,11 @@ public class RawHistoryPage {
int crcStored = ByteUtil.toInt(data[1022], data[1023]);
if (crcCalculated != crcStored) {
LOG.error("Stored CRC ({}) is different than calculated ({}), but ignored for now.", crcStored,
crcCalculated);
aapsLogger.error(LTag.PUMPBTCOMM, "Stored CRC ({}) is different than calculated ({}), but ignored for now.", crcStored,
crcCalculated);
} else {
if (MedtronicUtil.getInstance().isLowLevelDebug())
LOG.debug("CRC ok.");
if (MedtronicUtil.isLowLevelDebug())
aapsLogger.debug(LTag.PUMPBTCOMM, "CRC ok.");
}
return crcCalculated == crcStored;
@ -70,7 +68,7 @@ public class RawHistoryPage {
int linesize = 80;
int offset = 0;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
while (offset < data.length) {
int bytesToLog = linesize;
@ -83,7 +81,6 @@ public class RawHistoryPage {
offset += linesize;
}
LOG.debug("History Page Data:\n{}", sb.toString());
aapsLogger.debug(LTag.PUMPBTCOMM, "History Page Data:\n{}", sb.toString());
}
}

View file

@ -17,7 +17,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.RecordDeco
/**
* This file was taken from GGC - GNU Gluco Control (ggc.sourceforge.net), application for diabetes
* management and modified/extended for AAPS.
*
* <p>
* Author: Andy {andy.rozman@gmail.com}
*/
@ -209,8 +209,7 @@ public class MedtronicCGMSHistoryDecoder extends MedtronicHistoryDecoder<CGMSHis
entry.setDateTime(dateTime, getIndex);
}
if (isLogEnabled())
LOG.debug("Record: {}", entry);
LOG.debug("Record: {}", entry);
}
return reversedOutList;

View file

@ -1,16 +1,14 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
import android.util.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import javax.inject.Inject;
import javax.inject.Singleton;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.MedtronicHistoryDecoder;
@ -27,21 +25,26 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
/**
* This file was taken from GGC - GNU Gluco Control (ggc.sourceforge.net), application for diabetes
* management and modified/extended for AAPS.
*
* <p>
* Author: Andy {andy.rozman@gmail.com}
*/
@Singleton
public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHistoryEntry> {
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
private final AAPSLogger aapsLogger;
private final MedtronicUtil medtronicUtil;
private PumpHistoryEntry tbrPreviousRecord;
private PumpHistoryEntry changeTimeRecord;
private MedtronicDeviceType deviceType;
private static final String TAG = "MdtPumpHistoryDecoder";
public MedtronicPumpHistoryDecoder() {
@Inject
public MedtronicPumpHistoryDecoder(
AAPSLogger aapsLogger,
MedtronicUtil medtronicUtil
) {
this.aapsLogger = aapsLogger;
this.medtronicUtil = medtronicUtil;
}
@ -50,15 +53,13 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
int counter = 0;
int record = 0;
boolean incompletePacket = false;
deviceType = MedtronicUtil.getInstance().getMedtronicPumpModel();
boolean incompletePacket;
List<PumpHistoryEntry> outList = new ArrayList<PumpHistoryEntry>();
List<PumpHistoryEntry> outList = new ArrayList<>();
String skipped = null;
int elementStart = 0;
if (dataClear.size() == 0) {
Log.e(TAG, "Empty page.");
aapsLogger.error(LTag.PUMPBTCOMM, "Empty page.");
return outList;
}
@ -76,7 +77,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
continue;
} else {
if (skipped != null) {
Log.w(TAG, " ... Skipped " + skipped);
aapsLogger.warn(LTag.PUMPBTCOMM, " ... Skipped " + skipped);
skipped = null;
}
}
@ -84,7 +85,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
PumpHistoryEntryType entryType = PumpHistoryEntryType.getByCode(opCode);
PumpHistoryEntry pe = new PumpHistoryEntry();
pe.setEntryType(entryType);
pe.setEntryType(medtronicUtil.getMedtronicPumpModel(), entryType);
pe.setOffset(counter);
counter++;
@ -93,11 +94,11 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
break;
}
List<Byte> listRawData = new ArrayList<Byte>();
List<Byte> listRawData = new ArrayList<>();
listRawData.add((byte) opCode);
if (entryType == PumpHistoryEntryType.UnabsorbedInsulin
|| entryType == PumpHistoryEntryType.UnabsorbedInsulin512) {
|| entryType == PumpHistoryEntryType.UnabsorbedInsulin512) {
int elements = dataClear.get(counter);
listRawData.add((byte) elements);
counter++;
@ -105,20 +106,20 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
int els = getUnsignedInt(elements);
for (int k = 0; k < (els - 2); k++) {
listRawData.add((byte) dataClear.get(counter));
listRawData.add(dataClear.get(counter));
counter++;
}
special = true;
} else {
for (int j = 0; j < (entryType.getTotalLength() - 1); j++) {
for (int j = 0; j < (entryType.getTotalLength(medtronicUtil.getMedtronicPumpModel()) - 1); j++) {
try {
listRawData.add(dataClear.get(counter));
counter++;
} catch (Exception ex) {
LOG.error("OpCode: " + ByteUtil.shortHexString((byte) opCode) + ", Invalid package: "
aapsLogger.error(LTag.PUMPBTCOMM, "OpCode: " + ByteUtil.shortHexString((byte) opCode) + ", Invalid package: "
+ ByteUtil.getHex(listRawData));
// throw ex;
incompletePacket = true;
@ -133,14 +134,14 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
}
if (entryType == PumpHistoryEntryType.None) {
LOG.error("Error in code. We should have not come into this branch.");
aapsLogger.error(LTag.PUMPBTCOMM, "Error in code. We should have not come into this branch.");
} else {
if (pe.getEntryType() == PumpHistoryEntryType.UnknownBasePacket) {
pe.setOpCode(opCode);
}
if (entryType.getHeadLength() == 0)
if (entryType.getHeadLength(medtronicUtil.getMedtronicPumpModel()) == 0)
special = true;
pe.setData(listRawData, special);
@ -150,7 +151,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
if ((decoded == RecordDecodeStatus.OK) || (decoded == RecordDecodeStatus.Ignored)) {
//Log.i(TAG, "#" + record + " " + decoded.getDescription() + " " + pe);
} else {
Log.w(TAG, "#" + record + " " + decoded.getDescription() + " " + pe);
aapsLogger.warn(LTag.PUMPBTCOMM, "#" + record + " " + decoded.getDescription() + " " + pe);
}
addToStatistics(pe, decoded, null);
@ -173,13 +174,13 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
try {
return decodeRecord(record, false);
} catch (Exception ex) {
LOG.error(" Error decoding: type={}, ex={}", record.getEntryType().name(), ex.getMessage(), ex);
aapsLogger.error(LTag.PUMPBTCOMM, " Error decoding: type={}, ex={}", record.getEntryType().name(), ex.getMessage(), ex);
return RecordDecodeStatus.Error;
}
}
public RecordDecodeStatus decodeRecord(PumpHistoryEntry entry, boolean x) {
private RecordDecodeStatus decodeRecord(PumpHistoryEntry entry, boolean x) {
if (entry.getDateTimeLength() > 0) {
decodeDateTime(entry);
@ -260,7 +261,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
case EventUnknown_0x4d:
case EventUnknown_MM522_0x25:
case EventUnknown_MM522_0x05:
LOG.debug(" -- ignored Unknown Pump Entry: " + entry);
aapsLogger.debug(LTag.PUMPBTCOMM, " -- ignored Unknown Pump Entry: " + entry);
return RecordDecodeStatus.Ignored;
case UnabsorbedInsulin:
@ -340,7 +341,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
return RecordDecodeStatus.Error;
default: {
LOG.debug("Not supported: " + entry.getEntryType());
aapsLogger.debug(LTag.PUMPBTCOMM, "Not supported: " + entry.getEntryType());
return RecordDecodeStatus.NotSupported;
}
@ -396,7 +397,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
}
public static String getFormattedValue(float value, int decimals) {
private static String getFormattedValue(float value, int decimals) {
return String.format(Locale.ENGLISH, "%." + decimals + "f", value);
}
@ -408,16 +409,14 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
Float rate = null;
int index = entry.getHead()[0];
if (MedtronicDeviceType.isSameDevice(MedtronicUtil.getInstance().getMedtronicPumpModel(),
MedtronicDeviceType.Medtronic_523andHigher)) {
if (MedtronicDeviceType.isSameDevice(medtronicUtil.getMedtronicPumpModel(), MedtronicDeviceType.Medtronic_523andHigher)) {
rate = body[1] * 0.025f;
}
//LOG.info("Basal Profile Start: offset={}, rate={}, index={}, body_raw={}", offset, rate, index, body);
if (rate == null) {
LOG.warn("Basal Profile Start (ERROR): offset={}, rate={}, index={}, body_raw={}", offset, rate, index,
body);
aapsLogger.warn(LTag.PUMPBTCOMM, "Basal Profile Start (ERROR): offset={}, rate={}, index={}, body_raw={}", offset, rate, index, body);
return RecordDecodeStatus.Error;
} else {
entry.addDecodedData("Value", getFormattedFloat(rate, 3));
@ -435,8 +434,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
float bolusStrokes = 10.0f;
if (MedtronicDeviceType.isSameDevice(MedtronicUtil.getInstance().getMedtronicPumpModel(),
MedtronicDeviceType.Medtronic_523andHigher)) {
if (MedtronicDeviceType.isSameDevice(medtronicUtil.getMedtronicPumpModel(), MedtronicDeviceType.Medtronic_523andHigher)) {
// https://github.com/ps2/minimed_rf/blob/master/lib/minimed_rf/log_entries/bolus_wizard.rb#L102
bolusStrokes = 40.0f;
@ -447,19 +445,19 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
// carb_ratio (?) = (((self.body[2] & 0x07) << 8) + self.body[3]) /
// 10.0s
dto.insulinSensitivity = new Float(body[4]);
dto.bgTargetLow = (int)body[5];
dto.bgTargetHigh = (int)body[14];
dto.bgTargetLow = (int) body[5];
dto.bgTargetHigh = (int) body[14];
dto.correctionEstimate = (((body[9] & 0x38) << 5) + body[6]) / bolusStrokes;
dto.foodEstimate = ((body[7] << 8) + body[8]) / bolusStrokes;
dto.unabsorbedInsulin = ((body[10] << 8) + body[11]) / bolusStrokes;
dto.bolusTotal = ((body[12] << 8) + body[13]) / bolusStrokes;
} else {
dto.bloodGlucose = (((body[1] & 0x0F) << 8) | entry.getHead()[0]);
dto.carbs = (int)body[0];
dto.carbs = (int) body[0];
dto.carbRatio = Float.valueOf(body[2]);
dto.insulinSensitivity = new Float(body[3]);
dto.bgTargetLow = (int)body[4];
dto.bgTargetHigh = (int)body[12];
dto.bgTargetLow = (int) body[4];
dto.bgTargetHigh = (int) body[12];
dto.bolusTotal = body[11] / bolusStrokes;
dto.foodEstimate = body[6] / bolusStrokes;
dto.unabsorbedInsulin = body[9] / bolusStrokes;
@ -490,7 +488,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
dto.carbs = (body[1] & 0xC) << 6 | body[0]; // (int)body[0];
dto.carbRatio = Float.valueOf(body[2]);
dto.insulinSensitivity = new Float(body[3]);
dto.bgTargetLow = (int)body[4];
dto.bgTargetLow = (int) body[4];
dto.foodEstimate = body[6] / 10.0f;
dto.correctionEstimate = (body[7] + (body[5] & 0x0F)) / bolusStrokes;
dto.unabsorbedInsulin = body[9] / bolusStrokes;
@ -570,8 +568,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
byte[] data = entry.getHead();
if (MedtronicDeviceType.isSameDevice(MedtronicUtil.getInstance().getMedtronicPumpModel(),
MedtronicDeviceType.Medtronic_523andHigher)) {
if (MedtronicDeviceType.isSameDevice(medtronicUtil.getMedtronicPumpModel(), MedtronicDeviceType.Medtronic_523andHigher)) {
bolus.setRequestedAmount(ByteUtil.toInt(data[0], data[1]) / 40.0d);
bolus.setDeliveredAmount(ByteUtil.toInt(data[2], data[3]) / 40.0d);
bolus.setInsulinOnBoard(ByteUtil.toInt(data[4], data[5]) / 40.0d);
@ -639,7 +636,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
byte[] dt = entry.getDatetime();
if (dt == null) {
LOG.warn("DateTime not set.");
aapsLogger.warn(LTag.PUMPBTCOMM, "DateTime not set.");
}
if (entry.getDateTimeLength() == 5) {
@ -673,7 +670,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
//LOG.debug("DT: {} {} {}", year, month, dayOfMonth);
if (dayOfMonth == 32) {
LOG.warn("Entry: Day 32 {} = [{}] {}", entry.getEntryType().name(),
aapsLogger.warn(LTag.PUMPBTCOMM, "Entry: Day 32 {} = [{}] {}", entry.getEntryType().name(),
ByteUtil.getHex(entry.getRawData()), entry);
}
@ -686,7 +683,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
entry.setAtechDateTime(DateTimeUtil.toATechDate(year, month, dayOfMonth, hour, minutes, seconds));
} else {
LOG.warn("Unknown datetime format: " + entry.getDateTimeLength());
aapsLogger.warn(LTag.PUMPBTCOMM, "Unknown datetime format: " + entry.getDateTimeLength());
}
}

View file

@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
import com.google.gson.annotations.Expose;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Objects;
@ -11,6 +10,7 @@ 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;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
/**
* This file was taken from GGC - GNU Gluco Control (ggc.sourceforge.net), application for diabetes
@ -35,12 +35,12 @@ public class PumpHistoryEntry extends MedtronicHistoryEntry {
}
public void setEntryType(PumpHistoryEntryType entryType) {
public void setEntryType(MedtronicDeviceType medtronicDeviceType, PumpHistoryEntryType entryType) {
this.entryType = entryType;
this.sizes[0] = entryType.getHeadLength();
this.sizes[0] = entryType.getHeadLength(medtronicDeviceType);
this.sizes[1] = entryType.getDateLength();
this.sizes[2] = entryType.getBodyLength();
this.sizes[2] = entryType.getBodyLength(medtronicDeviceType);
if (this.entryType != null && this.atechDateTime != null)
setPumpId();

View file

@ -7,12 +7,11 @@ import java.util.Map;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
/**
* This file was taken from GGC - GNU Gluco Control (ggc.sourceforge.net), application for diabetes
* management and modified/extended for AAPS.
*
* <p>
* Author: Andy {andy.rozman@gmail.com}
*/
@ -289,9 +288,9 @@ public enum PumpHistoryEntryType // implements CodeEnum
}
public int getTotalLength() {
public int getTotalLength(MedtronicDeviceType medtronicDeviceType) {
if (hasSpecialRules()) {
return getHeadLength() + getBodyLength() + getDateLength();
return getHeadLength(medtronicDeviceType) + getBodyLength(medtronicDeviceType) + getDateLength();
} else {
return totalLength;
}
@ -305,7 +304,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
void addSpecialRuleHead(SpecialRule rule) {
if (isEmpty(specialRulesHead)) {
specialRulesHead = new ArrayList<SpecialRule>();
specialRulesHead = new ArrayList<>();
}
specialRulesHead.add(rule);
@ -315,7 +314,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
void addSpecialRuleBody(SpecialRule rule) {
if (isEmpty(specialRulesBody)) {
specialRulesBody = new ArrayList<SpecialRule>();
specialRulesBody = new ArrayList<>();
}
specialRulesBody.add(rule);
@ -333,10 +332,10 @@ public enum PumpHistoryEntryType // implements CodeEnum
}
public int getHeadLength() {
public int getHeadLength(MedtronicDeviceType medtronicDeviceType) {
if (hasSpecialRules) {
if (isNotEmpty(specialRulesHead)) {
return determineSizeByRule(headLength, specialRulesHead);
return determineSizeByRule(medtronicDeviceType, headLength, specialRulesHead);
} else {
return headLength;
}
@ -351,10 +350,10 @@ public enum PumpHistoryEntryType // implements CodeEnum
}
public int getBodyLength() {
public int getBodyLength(MedtronicDeviceType medtronicDeviceType) {
if (hasSpecialRules) {
if (isNotEmpty(specialRulesBody)) {
return determineSizeByRule(bodyLength, specialRulesBody);
return determineSizeByRule(medtronicDeviceType, bodyLength, specialRulesBody);
} else {
return bodyLength;
}
@ -376,11 +375,11 @@ public enum PumpHistoryEntryType // implements CodeEnum
// byte[] dh = { 2, 3 };
private int determineSizeByRule(int defaultValue, List<SpecialRule> rules) {
private int determineSizeByRule(MedtronicDeviceType medtronicDeviceType, int defaultValue, List<SpecialRule> rules) {
int size = defaultValue;
for (SpecialRule rule : rules) {
if (MedtronicDeviceType.isSameDevice(MedtronicUtil.getInstance().getMedtronicPumpModel(), rule.deviceType)) {
if (MedtronicDeviceType.isSameDevice(medtronicDeviceType, rule.deviceType)) {
size = rule.size;
break;
}
@ -395,29 +394,6 @@ public enum PumpHistoryEntryType // implements CodeEnum
return group;
}
enum DateFormat {
None(0), //
LongDate(5), //
ShortDate(2);
private int length;
DateFormat(int length) {
this.length = length;
}
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
}
public static class SpecialRule {
MedtronicDeviceType deviceType;

View file

@ -18,10 +18,12 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.DbObjectBase;
import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.Source;
@ -68,11 +70,13 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
// All things marked with "TODO: Fix db code" needs to be updated in new 2.5 database code
@Singleton
public class MedtronicHistoryData {
private AAPSLogger aapsLogger;
private SP sp;
private ActivePluginProvider activePlugin;
private final AAPSLogger aapsLogger;
private final SP sp;
private final ActivePluginProvider activePlugin;
private final MedtronicUtil medtronicUtil;
private List<PumpHistoryEntry> allHistory = null;
private List<PumpHistoryEntry> newHistory = null;
@ -80,10 +84,9 @@ public class MedtronicHistoryData {
private Long lastHistoryRecordTime;
private boolean isInit = false;
private Gson gson;
private Gson gsonCore;
private Gson gson; // cannot be initialized in constructor because of injection
private Gson gsonCore; // cannot be initialized in constructor because of injection
private DatabaseHelper databaseHelper = MainApp.getDbHelper();
private ClockDTO pumpTime;
private long lastIdUsed = 0;
@ -95,17 +98,30 @@ public class MedtronicHistoryData {
*/
public static boolean doubleBolusDebug = false;
public MedtronicHistoryData(AAPSLogger aapsLogger, SP sp, ActivePluginProvider activePlugin) {
@Inject
public MedtronicHistoryData(
AAPSLogger aapsLogger,
SP sp,
ActivePluginProvider activePlugin,
MedtronicUtil medtronicUtil
) {
this.allHistory = new ArrayList<>();
this.gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
this.gsonCore = new GsonBuilder().create();
this.aapsLogger = aapsLogger;
this.sp = sp;
this.activePlugin = activePlugin;
this.medtronicUtil = medtronicUtil;
}
private Gson gson() {
if (gson == null) gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
return gson;
}
private Gson gsonCore() {
if (gsonCore == null) gsonCore = new GsonBuilder().create();
return gsonCore;
}
/**
* Add New History entries
@ -127,7 +143,7 @@ public class MedtronicHistoryData {
this.newHistory = newEntries;
showLogs("List of history (before filtering): [" + this.newHistory.size() + "]", gson.toJson(this.newHistory));
showLogs("List of history (before filtering): [" + this.newHistory.size() + "]", gson().toJson(this.newHistory));
}
@ -201,7 +217,7 @@ public class MedtronicHistoryData {
aapsLogger.debug(LTag.PUMP, "New History entries found: {}", this.newHistory.size());
showLogs("List of history (after filtering): [" + this.newHistory.size() + "]", gson.toJson(this.newHistory));
showLogs("List of history (after filtering): [" + this.newHistory.size() + "]", gson().toJson(this.newHistory));
}
@ -314,7 +330,7 @@ public class MedtronicHistoryData {
List<PumpHistoryEntry> items = getDataForPumpSuspends();
showLogs("isPumpSuspended: ", gson.toJson(items));
showLogs("isPumpSuspended: ", gson().toJson(items));
if (isCollectionNotEmpty(items)) {
@ -400,7 +416,7 @@ public class MedtronicHistoryData {
// Prime (for reseting autosense)
List<PumpHistoryEntry> primeRecords = getFilteredItems(PumpHistoryEntryType.Prime);
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: Prime [count={}, items={}]", primeRecords.size(), gson.toJson(primeRecords));
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: Prime [count={}, items={}]", primeRecords.size(), gson().toJson(primeRecords));
if (isCollectionNotEmpty(primeRecords)) {
try {
@ -414,7 +430,7 @@ public class MedtronicHistoryData {
// TDD
List<PumpHistoryEntry> tdds = getFilteredItems(PumpHistoryEntryType.EndResultTotals, getTDDType());
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: TDD [count={}, items={}]", tdds.size(), gson.toJson(tdds));
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: TDD [count={}, items={}]", tdds.size(), gson().toJson(tdds));
if (isCollectionNotEmpty(tdds)) {
try {
@ -430,7 +446,7 @@ public class MedtronicHistoryData {
// Bolus
List<PumpHistoryEntry> treatments = getFilteredItems(PumpHistoryEntryType.Bolus);
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: Bolus [count={}, items={}]", treatments.size(), gson.toJson(treatments));
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: Bolus [count={}, items={}]", treatments.size(), gson().toJson(treatments));
if (treatments.size() > 0) {
try {
@ -444,7 +460,7 @@ public class MedtronicHistoryData {
// TBR
List<PumpHistoryEntry> tbrs = getFilteredItems(PumpHistoryEntryType.TempBasalCombined);
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: TBRs Processed [count={}, items={}]", tbrs.size(), gson.toJson(tbrs));
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: TBRs Processed [count={}, items={}]", tbrs.size(), gson().toJson(tbrs));
if (tbrs.size() > 0) {
try {
@ -466,7 +482,7 @@ public class MedtronicHistoryData {
}
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: 'Delivery Suspend' Processed [count={}, items={}]", suspends.size(),
gson.toJson(suspends));
gson().toJson(suspends));
if (isCollectionNotEmpty(suspends)) {
try {
@ -532,9 +548,9 @@ public class MedtronicHistoryData {
List<PumpHistoryEntry> tdds = filterTDDs(tddsIn);
aapsLogger.debug(LTag.PUMP, getLogPrefix() + "TDDs found: {}.\n{}", tdds.size(), gson.toJson(tdds));
aapsLogger.debug(LTag.PUMP, getLogPrefix() + "TDDs found: {}.\n{}", tdds.size(), gson().toJson(tdds));
List<TDD> tddsDb = databaseHelper.getTDDsForLastXDays(3);
List<TDD> tddsDb = MainApp.getDbHelper().getTDDsForLastXDays(3);
for (PumpHistoryEntry tdd : tdds) {
@ -550,7 +566,7 @@ public class MedtronicHistoryData {
aapsLogger.debug(LTag.PUMP, "TDD Add: {}", tddNew);
databaseHelper.createOrUpdateTDD(tddNew);
MainApp.getDbHelper().createOrUpdateTDD(tddNew);
} else {
@ -559,7 +575,7 @@ public class MedtronicHistoryData {
aapsLogger.debug(LTag.PUMP, "TDD Edit: {}", tddDbEntry);
databaseHelper.createOrUpdateTDD(tddDbEntry);
MainApp.getDbHelper().createOrUpdateTDD(tddDbEntry);
}
}
}
@ -591,8 +607,8 @@ public class MedtronicHistoryData {
List<? extends DbObjectBase> entriesFromHistory = getDatabaseEntriesByLastTimestamp(oldestTimestamp, ProcessHistoryRecord.Bolus);
if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: List (before filter): {}, FromDb={}", gson.toJson(entryList),
gsonCore.toJson(entriesFromHistory));
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: List (before filter): {}, FromDb={}", gson().toJson(entryList),
gsonCore().toJson(entriesFromHistory));
filterOutAlreadyAddedEntries(entryList, entriesFromHistory);
@ -605,8 +621,8 @@ public class MedtronicHistoryData {
filterOutNonInsulinEntries(entriesFromHistory);
if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: List (after filter): {}, FromDb={}", gson.toJson(entryList),
gsonCore.toJson(entriesFromHistory));
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: List (after filter): {}, FromDb={}", gson().toJson(entryList),
gsonCore().toJson(entriesFromHistory));
if (isCollectionEmpty(entriesFromHistory)) {
for (PumpHistoryEntry treatment : entryList) {
@ -669,8 +685,8 @@ public class MedtronicHistoryData {
List<? extends DbObjectBase> entriesFromHistory = getDatabaseEntriesByLastTimestamp(oldestTimestamp, ProcessHistoryRecord.TBR);
aapsLogger.debug(LTag.PUMP, ProcessHistoryRecord.TBR.getDescription() + " List (before filter): {}, FromDb={}", gson.toJson(entryList),
gson.toJson(entriesFromHistory));
aapsLogger.debug(LTag.PUMP, ProcessHistoryRecord.TBR.getDescription() + " List (before filter): {}, FromDb={}", gson().toJson(entryList),
gson().toJson(entriesFromHistory));
TempBasalProcessDTO processDTO = null;
@ -720,7 +736,7 @@ public class MedtronicHistoryData {
tempBasal.durationInMinutes = tempBasalProcessDTO.getDuration();
databaseHelper.createOrUpdate(tempBasal);
MainApp.getDbHelper().createOrUpdate(tempBasal);
aapsLogger.debug(LTag.PUMP, "Edit " + ProcessHistoryRecord.TBR.getDescription() + " - (entryFromDb={}) ", tempBasal);
} else {
@ -768,7 +784,7 @@ public class MedtronicHistoryData {
}
}
TemporaryBasal tempBasal = databaseHelper.findTempBasalByPumpId(pumpId);
TemporaryBasal tempBasal = MainApp.getDbHelper().findTempBasalByPumpId(pumpId);
return tempBasal;
}
@ -789,7 +805,7 @@ public class MedtronicHistoryData {
//proposedTime += (this.pumpTime.timeDifference * 1000);
if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry Treatment={}, FromDb={}", treatment, gson.toJson(entriesFromHistory));
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry Treatment={}, FromDb={}", treatment, gson().toJson(entriesFromHistory));
if (entriesFromHistory.size() == 0) {
if (doubleBolusDebug)
@ -843,10 +859,10 @@ public class MedtronicHistoryData {
if (min == 0 && sec == 10 && outList.size() > 1) {
aapsLogger.error("Too many entries (with too small diff): (timeDiff=[min={},sec={}],count={},list={})",
min, sec, outList.size(), gson.toJson(outList));
min, sec, outList.size(), gson().toJson(outList));
if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry Error - Too many entries (with too small diff): (timeDiff=[min={},sec={}],count={},list={})",
min, sec, outList.size(), gson.toJson(outList));
min, sec, outList.size(), gson().toJson(outList));
}
}
}
@ -859,7 +875,7 @@ public class MedtronicHistoryData {
if (processHistoryRecord == ProcessHistoryRecord.Bolus) {
return activePlugin.getActiveTreatments().getTreatmentsFromHistoryAfterTimestamp(startTimestamp);
} else {
return databaseHelper.getTemporaryBasalsDataFromTime(startTimestamp, true);
return MainApp.getDbHelper().getTemporaryBasalsDataFromTime(startTimestamp, true);
}
}
@ -896,8 +912,8 @@ public class MedtronicHistoryData {
if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: filterOutAlreadyAddedEntries: PumpHistory={}, Treatments={}",
gson.toJson(removeTreatmentsFromPH),
gsonCore.toJson(removeTreatmentsFromHistory));
gson().toJson(removeTreatmentsFromPH),
gsonCore().toJson(removeTreatmentsFromHistory));
treatmentsFromHistory.removeAll(removeTreatmentsFromHistory);
}
@ -1017,7 +1033,7 @@ public class MedtronicHistoryData {
treatment.setLinkedObject(temporaryBasalDb);
databaseHelper.createOrUpdate(temporaryBasalDb);
MainApp.getDbHelper().createOrUpdate(temporaryBasalDb);
aapsLogger.debug(LTag.PUMP, operation + " - [date={},pumpId={}, rate={} {}, duration={}]", //
temporaryBasalDb.date, //
@ -1033,7 +1049,7 @@ public class MedtronicHistoryData {
for (TempBasalProcessDTO tempBasalProcess : tempBasalProcessList) {
TemporaryBasal tempBasal = databaseHelper.findTempBasalByPumpId(tempBasalProcess.itemOne.getPumpId());
TemporaryBasal tempBasal = MainApp.getDbHelper().findTempBasalByPumpId(tempBasalProcess.itemOne.getPumpId());
if (tempBasal == null) {
// add
@ -1049,7 +1065,7 @@ public class MedtronicHistoryData {
tempBasalProcess.itemOne.setLinkedObject(tempBasal);
tempBasalProcess.itemTwo.setLinkedObject(tempBasal);
databaseHelper.createOrUpdate(tempBasal);
MainApp.getDbHelper().createOrUpdate(tempBasal);
}
}
@ -1196,11 +1212,11 @@ public class MedtronicHistoryData {
if (!finishedItems) {
showLogs("NoDeliveryRewindPrimeRecords: Not finished Items: ", gson.toJson(tempData));
showLogs("NoDeliveryRewindPrimeRecords: Not finished Items: ", gson().toJson(tempData));
return outList;
}
showLogs("NoDeliveryRewindPrimeRecords: Records to evaluate: ", gson.toJson(tempData));
showLogs("NoDeliveryRewindPrimeRecords: Records to evaluate: ", gson().toJson(tempData));
List<PumpHistoryEntry> items = getFilteredItems(tempData, //
PumpHistoryEntryType.Prime
@ -1392,7 +1408,7 @@ public class MedtronicHistoryData {
List<PumpHistoryEntry> filteredItems = getFilteredItems(PumpHistoryEntryType.ChangeBasalProfile_NewProfile);
aapsLogger.debug(LTag.PUMP, "hasBasalProfileChanged. Items: " + gson.toJson(filteredItems));
aapsLogger.debug(LTag.PUMP, "hasBasalProfileChanged. Items: " + gson().toJson(filteredItems));
return (filteredItems.size() > 0);
}
@ -1462,7 +1478,7 @@ public class MedtronicHistoryData {
for (PumpHistoryEntry pumpHistoryEntry : TBRs_Input) {
if (map.containsKey(pumpHistoryEntry.DT)) {
MedtronicPumpHistoryDecoder.decodeTempBasal(map.get(pumpHistoryEntry.DT), pumpHistoryEntry);
pumpHistoryEntry.setEntryType(PumpHistoryEntryType.TempBasalCombined);
pumpHistoryEntry.setEntryType(medtronicUtil.getMedtronicPumpModel(), PumpHistoryEntryType.TempBasalCombined);
TBRs.add(pumpHistoryEntry);
map.remove(pumpHistoryEntry.DT);
} else {

View file

@ -23,11 +23,13 @@ import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup;
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData;
public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
@Inject MedtronicHistoryData medtronicHistoryData;
Spinner historyTypeSpinner;
TextView statusView;
@ -49,7 +51,7 @@ public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
this.filteredHistoryList.clear();
List<PumpHistoryEntry> list = new ArrayList<>();
list.addAll(medtronicPumpPlugin.getMedtronicHistoryData().getAllHistory());
list.addAll(medtronicHistoryData.getAllHistory());
//LOG.debug("Items on full list: {}", list.size());

View file

@ -41,7 +41,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
public class MedtronicUtil {
private int ENVELOPE_SIZE = 4; // 0xA7 S1 S2 S3 CMD PARAM_COUNT [PARAMS]
private boolean lowLevelDebug = true;
private static boolean lowLevelDebug = true;
private PumpDeviceState pumpDeviceState;
private MedtronicDeviceType medtronicPumpModel;
private MedtronicCommandType currentCommand;
@ -396,16 +396,10 @@ public class MedtronicUtil {
}
public boolean isLowLevelDebug() {
public static boolean isLowLevelDebug() {
return lowLevelDebug;
}
public void setLowLevelDebug(boolean lowLevelDebug) {
this.lowLevelDebug = lowLevelDebug;
}
public PumpDeviceState getPumpDeviceState() {
return pumpDeviceState;
}

View file

@ -21,7 +21,7 @@ import static org.mockito.Mockito.when;
* Created by andy on 3/10/19.
*/
public class MedtronicHistoryDataUTest {
/*
//TestLogger LOGGER = TestLoggerFactory.getTestLogger(MedtronicHistoryDataUTest.class);
byte[] historyPageData = ByteUtil
@ -123,5 +123,5 @@ public class MedtronicHistoryDataUTest {
}
}
*/
}