- kotlinlize: info/nightscout/androidaps/plugins/pump/medtronic/comm/message

This commit is contained in:
Andy Rozman 2021-04-16 21:40:25 +01:00
parent 769ab218d4
commit 05a07c1904
31 changed files with 575 additions and 713 deletions

View file

@ -1223,7 +1223,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
return; return;
this.lastPumpHistoryEntry = latestEntry; this.lastPumpHistoryEntry = latestEntry;
sp.putLong(MedtronicConst.Statistics.LastPumpHistoryEntry, latestEntry.atechDateTime); sp.putLong(MedtronicConst.Statistics.LastPumpHistoryEntry, latestEntry.getAtechDateTime());
if (debugHistory) if (debugHistory)
aapsLogger.debug(LTag.PUMP, "HST: History: valid=" + historyResult.validEntries.size() + ", unprocessed=" + historyResult.unprocessedEntries.size()); aapsLogger.debug(LTag.PUMP, "HST: History: valid=" + historyResult.validEntries.size() + ", unprocessed=" + historyResult.unprocessedEntries.size());

View file

@ -237,10 +237,10 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
aapsLogger.debug(LTag.PUMPCOMM, "Run command with Args: "); aapsLogger.debug(LTag.PUMPCOMM, "Run command with Args: ");
PumpMessage rval; PumpMessage rval;
PumpMessage shortMessage = makePumpMessage(msg.commandType, new CarelinkShortMessageBody(new byte[]{0})); PumpMessage shortMessage = makePumpMessage(msg.getCommandType(), new CarelinkShortMessageBody(new byte[]{0}));
// look for ack from short message // look for ack from short message
PumpMessage shortResponse = sendAndListen(shortMessage); PumpMessage shortResponse = sendAndListen(shortMessage);
if (shortResponse.commandType == MedtronicCommandType.CommandACK) { if (shortResponse.getCommandType() == MedtronicCommandType.CommandACK) {
if (debugSetCommands) if (debugSetCommands)
aapsLogger.debug(LTag.PUMPCOMM, "Run command with Args: Got ACK response"); aapsLogger.debug(LTag.PUMPCOMM, "Run command with Args: Got ACK response");
@ -266,7 +266,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// look for ack from short message // look for ack from short message
PumpMessage shortResponse = sendAndListen(shortMessage); PumpMessage shortResponse = sendAndListen(shortMessage);
if (shortResponse.commandType != MedtronicCommandType.CommandACK) { if (shortResponse.getCommandType() != MedtronicCommandType.CommandACK) {
aapsLogger.error(LTag.PUMPCOMM, "runCommandWithFrames: Pump did not ack Attention packet"); aapsLogger.error(LTag.PUMPCOMM, "runCommandWithFrames: Pump did not ack Attention packet");
return new PumpMessage(aapsLogger, "No ACK after start message."); return new PumpMessage(aapsLogger, "No ACK after start message.");
@ -288,7 +288,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// aapsLogger.debug(LTag.PUMPCOMM,"PumpResponse: " + rval); // aapsLogger.debug(LTag.PUMPCOMM,"PumpResponse: " + rval);
if (rval.commandType != MedtronicCommandType.CommandACK) { if (rval.getCommandType() != MedtronicCommandType.CommandACK) {
aapsLogger.error(LTag.PUMPCOMM, "runCommandWithFrames: Pump did not ACK frame #" + frameNr); aapsLogger.error(LTag.PUMPCOMM, "runCommandWithFrames: Pump did not ACK frame #" + frameNr);
aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Run command with Frames FAILED (command=%s, response=%s)", commandType.name(), aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Run command with Frames FAILED (command=%s, response=%s)", commandType.name(),
@ -356,8 +356,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// aapsLogger.info(LTag.PUMPCOMM,"getPumpHistoryPage("+pageNumber+"): " + ByteUtil.shortHexString(firstResponse.getContents())); // aapsLogger.info(LTag.PUMPCOMM,"getPumpHistoryPage("+pageNumber+"): " + ByteUtil.shortHexString(firstResponse.getContents()));
PumpMessage ackMsg = makePumpMessage(MedtronicCommandType.CommandACK, new PumpAckMessageBody()); PumpMessage ackMsg = makePumpMessage(MedtronicCommandType.CommandACK, new PumpAckMessageBody());
GetHistoryPageCarelinkMessageBody currentResponse = new GetHistoryPageCarelinkMessageBody(firstResponse GetHistoryPageCarelinkMessageBody currentResponse = new GetHistoryPageCarelinkMessageBody(firstResponse.getMessageBody().getTxData());
.getMessageBody().getTxData());
int expectedFrameNum = 1; int expectedFrameNum = 1;
boolean done = false; boolean done = false;
// while (expectedFrameNum == currentResponse.getFrameNumber()) { // while (expectedFrameNum == currentResponse.getFrameNumber()) {
@ -861,7 +860,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
if (debugSetCommands) if (debugSetCommands)
aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "%s: %s", commandType.getCommandDescription(), pumpMessage.getResponseContent())); aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "%s: %s", commandType.getCommandDescription(), pumpMessage.getResponseContent()));
if (pumpMessage.commandType == MedtronicCommandType.CommandACK) { if (pumpMessage.getCommandType() == MedtronicCommandType.CommandACK) {
return true; return true;
} else { } else {
aapsLogger.warn(LTag.PUMPCOMM, "We received non-ACK response from pump: " + pumpMessage.getResponseContent()); aapsLogger.warn(LTag.PUMPCOMM, "We received non-ACK response from pump: " + pumpMessage.getResponseContent());
@ -900,7 +899,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
responseMessage = runCommandWithFrames(MedtronicCommandType.SetBasalProfileSTD, responseMessage = runCommandWithFrames(MedtronicCommandType.SetBasalProfileSTD,
basalProfileFrames); basalProfileFrames);
if (responseMessage.commandType == MedtronicCommandType.CommandACK) if (responseMessage.getCommandType() == MedtronicCommandType.CommandACK)
return true; return true;
} catch (RileyLinkCommunicationException e) { } catch (RileyLinkCommunicationException e) {
@ -908,7 +907,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
} }
if (responseMessage != null) if (responseMessage != null)
aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Set Basal Profile: Invalid response: commandType=%s,rawData=%s", responseMessage.commandType, ByteUtil.shortHexString(responseMessage.getRawContent()))); aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Set Basal Profile: Invalid response: commandType=%s,rawData=%s", responseMessage.getCommandType(), ByteUtil.shortHexString(responseMessage.getRawContent())));
else else
aapsLogger.warn(LTag.PUMPCOMM, "Set Basal Profile: Null response."); aapsLogger.warn(LTag.PUMPCOMM, "Set Basal Profile: Null response.");
} }

View file

@ -19,16 +19,13 @@ import kotlin.jvm.Throws
*/ */
abstract class MedtronicHistoryDecoder<T : MedtronicHistoryEntry?> : MedtronicHistoryDecoderInterface<T> { abstract class MedtronicHistoryDecoder<T : MedtronicHistoryEntry?> : MedtronicHistoryDecoderInterface<T> {
@JvmField @Inject @Inject lateinit var aapsLogger: AAPSLogger
var aapsLogger: AAPSLogger? = null @Inject lateinit var medtronicUtil: MedtronicUtil
@Inject lateinit var bitUtils: ByteUtil
@JvmField @Inject
var medtronicUtil: MedtronicUtil? = null
protected var bitUtils: ByteUtil? = null
// STATISTICS (remove at later time or not) // STATISTICS (remove at later time or not)
protected var statisticsEnabled = true protected var statisticsEnabled = true
@JvmField protected var unknownOpCodes: MutableMap<Int, Int?>? = null protected var unknownOpCodes: MutableMap<Int, Int?>? = null
protected var mapStatistics: MutableMap<RecordDecodeStatus, MutableMap<String, String>>? = null protected var mapStatistics: MutableMap<RecordDecodeStatus, MutableMap<String, String>>? = null
// public abstract <E extends MedtronicHistoryEntry> Class<E> getHistoryEntryClass(); // public abstract <E extends MedtronicHistoryEntry> Class<E> getHistoryEntryClass();

View file

@ -16,30 +16,41 @@ import java.util.*
*/ */
abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface { abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
@JvmField var rawData: List<Byte>? = null var rawData: List<Byte>? = null
@JvmField protected var sizes = IntArray(3) get() = field
protected var sizes = IntArray(3)
get() = field
var head: ByteArray? = null var head: ByteArray? = null
get() = field
var datetime: ByteArray? = null var datetime: ByteArray? = null
var body: ByteArray? = null var body: ByteArray? = null
var id: Long = 0
// protected LocalDateTime dateTime; set(value) {
@JvmField var id: Long = 0 field = value
}
@JvmField @Expose
var DT: String? = null
@JvmField @Expose
var atechDateTime: Long? = null
@Expose @Expose
protected var decodedData: MutableMap<String, Any?>? = null var DT: String? = null
var phoneDateTime // time on phone get() = field
: Long = 0
@Expose
var atechDateTime: Long? = null
get() = field
set(value) {
field = value
}
@Expose
var decodedData: MutableMap<String, Any?>? = null
get() = field
/** /**
* Pump id that will be used with AAPS object (time * 1000 + historyType (max is FF = 255) * Pump id that will be used with AAPS object (time * 1000 + historyType (max is FF = 255)
*/ */
protected open var pumpId: Long? = null open var pumpId: Long? = null
/** /**
* if history object is already linked to AAPS object (either Treatment, TempBasal or TDD (tdd's * if history object is already linked to AAPS object (either Treatment, TempBasal or TDD (tdd's
@ -52,7 +63,7 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
* Linked object, see linked * Linked object, see linked
*/ */
var linkedObject: Any? = null var linkedObject: Any? = null
get() = field //= linkedObject get() = field
set(value) { set(value) {
linked = true linked = true
field = value field = value
@ -63,7 +74,7 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
// this.linkedObject = linkedObject // this.linkedObject = linkedObject
// } // }
override fun setData(listRawData: List<Byte>?, doNotProcess: Boolean) { override fun setData(listRawData: List<Byte>, doNotProcess: Boolean) {
rawData = listRawData rawData = listRawData
// System.out.println("Head: " + sizes[0] + ", dates: " + sizes[1] + // System.out.println("Head: " + sizes[0] + ", dates: " + sizes[1] +
@ -78,7 +89,7 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
var i = headLength var i = headLength
var j = 0 var j = 0
while (j < dateTimeLength) { while (j < dateTimeLength) {
datetime!![j] = listRawData!![i]!! datetime!![j] = listRawData[i]
i++ i++
j++ j++
} }

View file

@ -6,6 +6,6 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm.history
interface MedtronicHistoryEntryInterface { interface MedtronicHistoryEntryInterface {
val entryTypeName: String? val entryTypeName: String?
fun setData(listRawData: List<Byte>?, doNotProcess: Boolean) fun setData(listRawData: List<Byte>, doNotProcess: Boolean)
val dateLength: Int val dateLength: Int
} }

View file

@ -30,7 +30,7 @@ class CGMSHistoryEntry : MedtronicHistoryEntry() {
override val entryTypeName: String override val entryTypeName: String
get() = entryType!!.name get() = entryType!!.name
override fun setData(listRawData: List<Byte>?, doNotProcess: Boolean) { override fun setData(listRawData: List<Byte>, doNotProcess: Boolean) {
if (entryType!!.schemaSet) { if (entryType!!.schemaSet) {
super.setData(listRawData, doNotProcess) super.setData(listRawData, doNotProcess)
} else { } else {

View file

@ -19,6 +19,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.experimental.and
/** /**
* This file was taken from GGC - GNU Gluco Control (ggc.sourceforge.net), application for diabetes * This file was taken from GGC - GNU Gluco Control (ggc.sourceforge.net), application for diabetes
@ -29,12 +30,13 @@ import javax.inject.Singleton
*/ */
@Singleton @Singleton
class MedtronicPumpHistoryDecoder @Inject constructor( class MedtronicPumpHistoryDecoder @Inject constructor(
aapsLogger: AAPSLogger?, aapsLogger: AAPSLogger,
medtronicUtil: MedtronicUtil? medtronicUtil: MedtronicUtil
) : MedtronicHistoryDecoder<PumpHistoryEntry>() { ) : MedtronicHistoryDecoder<PumpHistoryEntry>() {
private var tbrPreviousRecord: PumpHistoryEntry? = null private var tbrPreviousRecord: PumpHistoryEntry? = null
private var changeTimeRecord: PumpHistoryEntry? = null private var changeTimeRecord: PumpHistoryEntry? = null
override fun createRecords(dataClear: List<Byte>): List<PumpHistoryEntry> { override fun createRecords(dataClear: List<Byte>): List<PumpHistoryEntry> {
prepareStatistics() prepareStatistics()
var counter = 0 var counter = 0
@ -42,8 +44,8 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
var incompletePacket: Boolean var incompletePacket: Boolean
val outList: MutableList<PumpHistoryEntry> = ArrayList() val outList: MutableList<PumpHistoryEntry> = ArrayList()
var skipped: String? = null var skipped: String? = null
if (dataClear!!.size == 0) { if (dataClear.size == 0) {
aapsLogger!!.error(LTag.PUMPBTCOMM, "Empty page.") aapsLogger.error(LTag.PUMPBTCOMM, "Empty page.")
return outList return outList
} }
do { do {
@ -57,13 +59,13 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
continue continue
} else { } else {
if (skipped != null) { if (skipped != null) {
aapsLogger!!.warn(LTag.PUMPBTCOMM, " ... Skipped $skipped") aapsLogger.warn(LTag.PUMPBTCOMM, " ... Skipped $skipped")
skipped = null skipped = null
skippedRecords = true skippedRecords = true
} }
} }
if (skippedRecords) { if (skippedRecords) {
aapsLogger!!.error(LTag.PUMPBTCOMM, "We had some skipped bytes, which might indicate error in pump history. Please report this problem.") aapsLogger.error(LTag.PUMPBTCOMM, "We had some skipped bytes, which might indicate error in pump history. Please report this problem.")
} }
val entryType = getByCode(opCode.toByte()) val entryType = getByCode(opCode.toByte())
val pe = PumpHistoryEntry() val pe = PumpHistoryEntry()
@ -89,12 +91,12 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
} }
special = true special = true
} else { } else {
for (j in 0 until entryType.getTotalLength(medtronicUtil!!.medtronicPumpModel) - 1) { for (j in 0 until entryType.getTotalLength(medtronicUtil.medtronicPumpModel) - 1) {
try { try {
listRawData.add(dataClear[counter]) listRawData.add(dataClear[counter])
counter++ counter++
} catch (ex: Exception) { } catch (ex: Exception) {
aapsLogger!!.error(LTag.PUMPBTCOMM, "OpCode: " + ByteUtil.shortHexString(opCode.toByte()) + ", Invalid package: " aapsLogger.error(LTag.PUMPBTCOMM, "OpCode: " + ByteUtil.shortHexString(opCode.toByte()) + ", Invalid package: "
+ ByteUtil.getHex(listRawData)) + ByteUtil.getHex(listRawData))
// throw ex; // throw ex;
incompletePacket = true incompletePacket = true
@ -115,7 +117,7 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
if (decoded === RecordDecodeStatus.OK || decoded === RecordDecodeStatus.Ignored) { if (decoded === RecordDecodeStatus.OK || decoded === RecordDecodeStatus.Ignored) {
//Log.i(TAG, "#" + record + " " + decoded.getDescription() + " " + pe); //Log.i(TAG, "#" + record + " " + decoded.getDescription() + " " + pe);
} else { } else {
aapsLogger!!.warn(LTag.PUMPBTCOMM, "#" + record + " " + decoded!!.description + " " + pe) aapsLogger.warn(LTag.PUMPBTCOMM, "#" + record + " " + decoded!!.description + " " + pe)
} }
addToStatistics(pe, decoded, null) addToStatistics(pe, decoded, null)
record++ record++
@ -132,7 +134,8 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
return try { return try {
decodeRecord(record, false) decodeRecord(record, false)
} catch (ex: Exception) { } catch (ex: Exception) {
aapsLogger!!.error(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, " Error decoding: type=%s, ex=%s", record.entryType!!.name, ex.message, ex)) aapsLogger.error(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, " Error decoding: type=%s, ex=%s", record.entryType!!.name, ex.message, ex))
//ex.printStackTrace()
RecordDecodeStatus.Error RecordDecodeStatus.Error
} }
} }
@ -145,17 +148,7 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
PumpHistoryEntryType.ChangeBasalPattern, PumpHistoryEntryType.CalBGForPH, PumpHistoryEntryType.ChangeRemoteId, PumpHistoryEntryType.ClearAlarm, PumpHistoryEntryType.ChangeAlarmNotifyMode, PumpHistoryEntryType.EnableDisableRemote, PumpHistoryEntryType.BGReceived, PumpHistoryEntryType.SensorAlert, PumpHistoryEntryType.ChangeTimeFormat, PumpHistoryEntryType.ChangeReservoirWarningTime, PumpHistoryEntryType.ChangeBolusReminderEnable, PumpHistoryEntryType.SetBolusReminderTime, PumpHistoryEntryType.ChangeChildBlockEnable, PumpHistoryEntryType.BolusWizardEnabled, PumpHistoryEntryType.ChangeBGReminderOffset, PumpHistoryEntryType.ChangeAlarmClockTime, PumpHistoryEntryType.ChangeMeterId, PumpHistoryEntryType.ChangeParadigmID, PumpHistoryEntryType.JournalEntryMealMarker, PumpHistoryEntryType.JournalEntryExerciseMarker, PumpHistoryEntryType.DeleteBolusReminderTime, PumpHistoryEntryType.SetAutoOff, PumpHistoryEntryType.SelfTest, PumpHistoryEntryType.JournalEntryInsulinMarker, PumpHistoryEntryType.JournalEntryOtherMarker, PumpHistoryEntryType.BolusWizardSetup512, PumpHistoryEntryType.ChangeSensorSetup2, PumpHistoryEntryType.ChangeSensorAlarmSilenceConfig, PumpHistoryEntryType.ChangeSensorRateOfChangeAlertSetup, PumpHistoryEntryType.ChangeBolusScrollStepSize, PumpHistoryEntryType.BolusWizardSetup, PumpHistoryEntryType.ChangeVariableBolus, PumpHistoryEntryType.ChangeAudioBolus, PumpHistoryEntryType.ChangeBGReminderEnable, PumpHistoryEntryType.ChangeAlarmClockEnable, PumpHistoryEntryType.BolusReminder, PumpHistoryEntryType.DeleteAlarmClockTime, PumpHistoryEntryType.ChangeCarbUnits, PumpHistoryEntryType.ChangeWatchdogEnable, PumpHistoryEntryType.ChangeOtherDeviceID, PumpHistoryEntryType.ReadOtherDevicesIDs, PumpHistoryEntryType.BGReceived512, PumpHistoryEntryType.SensorStatus, PumpHistoryEntryType.ReadCaptureEventEnabled, PumpHistoryEntryType.ChangeCaptureEventEnable, PumpHistoryEntryType.ReadOtherDevicesStatus -> RecordDecodeStatus.OK PumpHistoryEntryType.ChangeBasalPattern, PumpHistoryEntryType.CalBGForPH, PumpHistoryEntryType.ChangeRemoteId, PumpHistoryEntryType.ClearAlarm, PumpHistoryEntryType.ChangeAlarmNotifyMode, PumpHistoryEntryType.EnableDisableRemote, PumpHistoryEntryType.BGReceived, PumpHistoryEntryType.SensorAlert, PumpHistoryEntryType.ChangeTimeFormat, PumpHistoryEntryType.ChangeReservoirWarningTime, PumpHistoryEntryType.ChangeBolusReminderEnable, PumpHistoryEntryType.SetBolusReminderTime, PumpHistoryEntryType.ChangeChildBlockEnable, PumpHistoryEntryType.BolusWizardEnabled, PumpHistoryEntryType.ChangeBGReminderOffset, PumpHistoryEntryType.ChangeAlarmClockTime, PumpHistoryEntryType.ChangeMeterId, PumpHistoryEntryType.ChangeParadigmID, PumpHistoryEntryType.JournalEntryMealMarker, PumpHistoryEntryType.JournalEntryExerciseMarker, PumpHistoryEntryType.DeleteBolusReminderTime, PumpHistoryEntryType.SetAutoOff, PumpHistoryEntryType.SelfTest, PumpHistoryEntryType.JournalEntryInsulinMarker, PumpHistoryEntryType.JournalEntryOtherMarker, PumpHistoryEntryType.BolusWizardSetup512, PumpHistoryEntryType.ChangeSensorSetup2, PumpHistoryEntryType.ChangeSensorAlarmSilenceConfig, PumpHistoryEntryType.ChangeSensorRateOfChangeAlertSetup, PumpHistoryEntryType.ChangeBolusScrollStepSize, PumpHistoryEntryType.BolusWizardSetup, PumpHistoryEntryType.ChangeVariableBolus, PumpHistoryEntryType.ChangeAudioBolus, PumpHistoryEntryType.ChangeBGReminderEnable, PumpHistoryEntryType.ChangeAlarmClockEnable, PumpHistoryEntryType.BolusReminder, PumpHistoryEntryType.DeleteAlarmClockTime, PumpHistoryEntryType.ChangeCarbUnits, PumpHistoryEntryType.ChangeWatchdogEnable, PumpHistoryEntryType.ChangeOtherDeviceID, PumpHistoryEntryType.ReadOtherDevicesIDs, PumpHistoryEntryType.BGReceived512, PumpHistoryEntryType.SensorStatus, PumpHistoryEntryType.ReadCaptureEventEnabled, PumpHistoryEntryType.ChangeCaptureEventEnable, PumpHistoryEntryType.ReadOtherDevicesStatus -> RecordDecodeStatus.OK
PumpHistoryEntryType.Sensor_0x54, PumpHistoryEntryType.Sensor_0x55, PumpHistoryEntryType.Sensor_0x51, PumpHistoryEntryType.Sensor_0x52, PumpHistoryEntryType.EventUnknown_MM512_0x2e -> { PumpHistoryEntryType.Sensor_0x54, PumpHistoryEntryType.Sensor_0x55, PumpHistoryEntryType.Sensor_0x51, PumpHistoryEntryType.Sensor_0x52, PumpHistoryEntryType.EventUnknown_MM512_0x2e -> {
// case EventUnknown_MM512_0x37: aapsLogger.debug(LTag.PUMPBTCOMM, " -- ignored Unknown Pump Entry: $entry")
// case EventUnknown_MM512_0x38:
// case EventUnknown_MM512_0x4e:
// case EventUnknown_MM522_0x70:
// case EventUnknown_MM512_0x88:
// case EventUnknown_MM512_0x94:
// case EventUnknown_MM522_0xE8:
// case EventUnknown_0x4d:
// case EventUnknown_MM522_0x25:
// case EventUnknown_MM522_0x05:
aapsLogger!!.debug(LTag.PUMPBTCOMM, " -- ignored Unknown Pump Entry: $entry")
RecordDecodeStatus.Ignored RecordDecodeStatus.Ignored
} }
@ -207,12 +200,10 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
PumpHistoryEntryType.None, PumpHistoryEntryType.UnknownBasePacket -> RecordDecodeStatus.Error PumpHistoryEntryType.None, PumpHistoryEntryType.UnknownBasePacket -> RecordDecodeStatus.Error
else -> { else -> {
aapsLogger!!.debug(LTag.PUMPBTCOMM, "Not supported: " + entry.entryType) aapsLogger.debug(LTag.PUMPBTCOMM, "Not supported: " + entry.entryType)
RecordDecodeStatus.NotSupported RecordDecodeStatus.NotSupported
} }
} }
// return RecordDecodeStatus.Error;
} }
private fun decodeDailyTotals(entry: PumpHistoryEntry): RecordDecodeStatus { private fun decodeDailyTotals(entry: PumpHistoryEntry): RecordDecodeStatus {
@ -223,12 +214,8 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
} }
private fun decodeBasalProfile(entry: PumpHistoryEntry): RecordDecodeStatus { private fun decodeBasalProfile(entry: PumpHistoryEntry): RecordDecodeStatus {
// LOG.debug("decodeBasalProfile: {}", entry);
val basalProfile = BasalProfile(aapsLogger) val basalProfile = BasalProfile(aapsLogger)
basalProfile.setRawDataFromHistory(entry.body) basalProfile.setRawDataFromHistory(entry.body)
// LOG.debug("decodeBasalProfile BasalProfile: {}", basalProfile);
entry.addDecodedData("Object", basalProfile) entry.addDecodedData("Object", basalProfile)
return RecordDecodeStatus.OK return RecordDecodeStatus.OK
} }
@ -240,24 +227,21 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
} }
private fun decodeBatteryActivity(entry: PumpHistoryEntry) { private fun decodeBatteryActivity(entry: PumpHistoryEntry) {
// this.writeData(PumpBaseType.Event, entry.getHead()[0] == 0 ? PumpEventType.BatteryRemoved :
// PumpEventType.BatteryReplaced, entry.getATechDate());
entry.displayableValue = if (entry.head!![0] == 0.toByte()) "Battery Removed" else "Battery Replaced" entry.displayableValue = if (entry.head!![0] == 0.toByte()) "Battery Removed" else "Battery Replaced"
} }
private fun decodeBasalProfileStart(entry: PumpHistoryEntry): RecordDecodeStatus { private fun decodeBasalProfileStart(entry: PumpHistoryEntry): RecordDecodeStatus {
val body = entry.body val body = entry.body
// int bodyOffset = headerSize + timestampSize;
val offset = body!![0] * 1000 * 30 * 60 val offset = body!![0] * 1000 * 30 * 60
var rate: Float? = null var rate: Float? = null
val index = entry.head!![0].toInt() val index = entry.head!![0].toInt()
if (MedtronicDeviceType.isSameDevice(medtronicUtil!!.medtronicPumpModel, MedtronicDeviceType.Medtronic_523andHigher)) { if (MedtronicDeviceType.isSameDevice(medtronicUtil.medtronicPumpModel, MedtronicDeviceType.Medtronic_523andHigher)) {
rate = body[1] * 0.025f rate = body[1] * 0.025f
} }
//LOG.info("Basal Profile Start: offset={}, rate={}, index={}, body_raw={}", offset, rate, index, body); //LOG.info("Basal Profile Start: offset={}, rate={}, index={}, body_raw={}", offset, rate, index, body);
return if (rate == null) { return if (rate == null) {
aapsLogger!!.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Basal Profile Start (ERROR): offset=%d, rate=%.3f, index=%d, body_raw=%s", offset, rate, index, ByteUtil.getHex(body))) aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Basal Profile Start (ERROR): offset=%d, rate=%.3f, index=%d, body_raw=%s", offset, rate, index, ByteUtil.getHex(body)))
RecordDecodeStatus.Error RecordDecodeStatus.Error
} else { } else {
entry.addDecodedData("Value", getFormattedFloat(rate, 3)) entry.addDecodedData("Value", getFormattedFloat(rate, 3))
@ -267,26 +251,26 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
} }
private fun decodeBolusWizard(entry: PumpHistoryEntry): RecordDecodeStatus { private fun decodeBolusWizard(entry: PumpHistoryEntry): RecordDecodeStatus {
val body = entry.body as IntArray val body = entry.body!!
val dto = BolusWizardDTO() val dto = BolusWizardDTO()
var bolusStrokes = 10.0f var bolusStrokes = 10.0f
if (MedtronicDeviceType.isSameDevice(medtronicUtil!!.medtronicPumpModel, MedtronicDeviceType.Medtronic_523andHigher)) { if (MedtronicDeviceType.isSameDevice(medtronicUtil!!.medtronicPumpModel, MedtronicDeviceType.Medtronic_523andHigher)) {
// https://github.com/ps2/minimed_rf/blob/master/lib/minimed_rf/log_entries/bolus_wizard.rb#L102 // https://github.com/ps2/minimed_rf/blob/master/lib/minimed_rf/log_entries/bolus_wizard.rb#L102
bolusStrokes = 40.0f bolusStrokes = 40.0f
dto.carbs = (body[1] and 0x0c shl 6) + body[0] dto.carbs = ((body[1] and 0x0c.toByte()).toInt() shl 6) + body[0]
dto.bloodGlucose = (body[1] and 0x03 shl 8) + entry.head!![0] dto.bloodGlucose = ((body[1] and 0x03).toInt() shl 8) + entry.head!![0]
dto.carbRatio = body[1] / 10.0f dto.carbRatio = body[1] / 10.0f
// carb_ratio (?) = (((self.body[2] & 0x07) << 8) + self.body[3]) / // carb_ratio (?) = (((self.body[2] & 0x07) << 8) + self.body[3]) /
// 10.0s // 10.0s
dto.insulinSensitivity = body[4].toFloat() dto.insulinSensitivity = body[4].toFloat()
dto.bgTargetLow = body[5] as Int dto.bgTargetLow = body[5] as Int
dto.bgTargetHigh = body[14] as Int dto.bgTargetHigh = body[14] as Int
dto.correctionEstimate = ((body[9] and 0x38 shl 5) + body[6]) / bolusStrokes dto.correctionEstimate = (((body[9] and 0x38).toInt() shl 5) + body[6]) / bolusStrokes
dto.foodEstimate = ((body[7] shl 8) + body[8]) / bolusStrokes dto.foodEstimate = ((body[7].toInt() shl 8) + body[8]) / bolusStrokes
dto.unabsorbedInsulin = ((body[10] shl 8) + body[11]) / bolusStrokes dto.unabsorbedInsulin = ((body[10].toInt() shl 8) + body[11]) / bolusStrokes
dto.bolusTotal = ((body[12] shl 8) + body[13]) / bolusStrokes dto.bolusTotal = ((body[12].toInt() shl 8) + body[13]) / bolusStrokes
} else { } else {
dto.bloodGlucose = body.get(1) and 0x0F shl 8 or entry.head!!.get(0).toInt() dto.bloodGlucose = (body.get(1) and 0x0F).toInt() shl 8 or entry.head!!.get(0).toInt()
dto.carbs = body.get(0) as Int dto.carbs = body.get(0) as Int
dto.carbRatio = body.get(2).toFloat() dto.carbRatio = body.get(2).toFloat()
dto.insulinSensitivity = body.get(3).toFloat() dto.insulinSensitivity = body.get(3).toFloat()
@ -308,14 +292,14 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
} }
private fun decodeBolusWizard512(entry: PumpHistoryEntry): RecordDecodeStatus { private fun decodeBolusWizard512(entry: PumpHistoryEntry): RecordDecodeStatus {
val body = entry.body as IntArray val body = entry.body!!
val dto = BolusWizardDTO() val dto = BolusWizardDTO()
val bolusStrokes = 10.0f val bolusStrokes = 10.0f
dto.bloodGlucose = body.get(1) and 0x03 shl 8 or entry.head!!.get(0).toInt() dto.bloodGlucose = (body.get(1) and 0x03).toInt() shl 8 or entry.head!!.get(0).toInt()
dto.carbs = body!!.get(1).toInt() and 0xC shl 6 or body.get(0).toInt() // (int)body[0]; dto.carbs = body.get(1).toInt() and 0xC shl 6 or body.get(0).toInt() // (int)body[0];
dto.carbRatio = body!!.get(2).toFloat() dto.carbRatio = body.get(2).toFloat()
dto.insulinSensitivity = body!!.get(3).toFloat() dto.insulinSensitivity = body.get(3).toFloat()
dto.bgTargetLow = body.get(4) dto.bgTargetLow = body.get(4).toInt()
dto.foodEstimate = body.get(6) / 10.0f dto.foodEstimate = body.get(6) / 10.0f
dto.correctionEstimate = (body.get(7) + (body.get(5) and 0x0F)) / bolusStrokes dto.correctionEstimate = (body.get(7) + (body.get(5) and 0x0F)) / bolusStrokes
dto.unabsorbedInsulin = body.get(9) / bolusStrokes dto.unabsorbedInsulin = body.get(9) / bolusStrokes
@ -374,8 +358,8 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
private fun decodeBolus(entry: PumpHistoryEntry) { private fun decodeBolus(entry: PumpHistoryEntry) {
val bolus = BolusDTO() val bolus = BolusDTO()
val data = entry.head as IntArray val data = entry.head!!
if (MedtronicDeviceType.isSameDevice(medtronicUtil!!.getMedtronicPumpModel(), MedtronicDeviceType.Medtronic_523andHigher)) { if (MedtronicDeviceType.isSameDevice(medtronicUtil.getMedtronicPumpModel(), MedtronicDeviceType.Medtronic_523andHigher)) {
bolus.requestedAmount = ByteUtil.toInt(data.get(0), data.get(1)) / 40.0 bolus.requestedAmount = ByteUtil.toInt(data.get(0), data.get(1)) / 40.0
bolus.deliveredAmount = ByteUtil.toInt(data.get(2), data.get(3)) / 40.0 bolus.deliveredAmount = ByteUtil.toInt(data.get(2), data.get(3)) / 40.0
bolus.insulinOnBoard = ByteUtil.toInt(data.get(4), data.get(5)) / 40.0 bolus.insulinOnBoard = ByteUtil.toInt(data.get(4), data.get(5)) / 40.0
@ -433,18 +417,18 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
} }
private fun decodeDateTime(entry: PumpHistoryEntry) { private fun decodeDateTime(entry: PumpHistoryEntry) {
val dt = entry.datetime as IntArray if (entry.datetime==null) {
if (dt == null) { aapsLogger.warn(LTag.PUMPBTCOMM, "DateTime not set.")
aapsLogger!!.warn(LTag.PUMPBTCOMM, "DateTime not set.")
} }
val dt = entry.datetime!!
if (entry.dateTimeLength == 5) { if (entry.dateTimeLength == 5) {
val seconds: Int = (dt!!.get(0) and 0x3F).toInt() val seconds: Int = (dt.get(0) and 0x3F.toByte()).toInt()
val minutes: Int = (dt!!.get(1) and 0x3F).toInt() val minutes: Int = (dt.get(1) and 0x3F.toByte()).toInt()
val hour: Int = (dt.get(2) and 0x1F).toInt() val hour: Int = (dt.get(2) and 0x1F).toInt()
val month: Int = (dt.get(0) shr 4 and 0x0c) + (dt.get(1) shr 6 and 0x03) val month: Int = (dt.get(0).toInt() shr 4 and 0x0c) + (dt.get(1).toInt() shr 6 and 0x03)
// ((dt[0] & 0xC0) >> 6) | ((dt[1] & 0xC0) >> 4); // ((dt[0] & 0xC0) >> 6) | ((dt[1] & 0xC0) >> 4);
val dayOfMonth: Int = dt.get(3) and 0x1F val dayOfMonth: Int = (dt.get(3) and 0x1F).toInt()
val year = fix2DigitYear(dt.get(4) and 0x3F) // Assuming this is correct, need to verify. Otherwise this will be val year = fix2DigitYear((dt.get(4) and 0x3F.toByte()).toInt()) // Assuming this is correct, need to verify. Otherwise this will be
// a problem in 2016. // a problem in 2016.
entry.setAtechDateTime(DateTimeUtil.toATechDate(year, month, dayOfMonth, hour, minutes, seconds)) entry.setAtechDateTime(DateTimeUtil.toATechDate(year, month, dayOfMonth, hour, minutes, seconds))
} else if (entry.dateTimeLength == 2) { } else if (entry.dateTimeLength == 2) {
@ -453,7 +437,7 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
val mlow = ByteUtil.asUINT8(dt.get(1)) and 0x80 shr 7 val mlow = ByteUtil.asUINT8(dt.get(1)) and 0x80 shr 7
val month = mhigh + mlow val month = mhigh + mlow
// int dayOfMonth = low + 1; // int dayOfMonth = low + 1;
val dayOfMonth: Int = dt.get(0) and 0x1F val dayOfMonth: Int = (dt.get(0) and 0x1F).toInt()
val year = 2000 + (ByteUtil.asUINT8(dt.get(1)) and 0x7F) val year = 2000 + (ByteUtil.asUINT8(dt.get(1)) and 0x7F)
var hour = 0 var hour = 0
var minutes = 0 var minutes = 0
@ -461,7 +445,7 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
//LOG.debug("DT: {} {} {}", year, month, dayOfMonth); //LOG.debug("DT: {} {} {}", year, month, dayOfMonth);
if (dayOfMonth == 32) { if (dayOfMonth == 32) {
aapsLogger!!.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Entry: Day 32 %s = [%s] %s", entry.entryType!!.name, aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Entry: Day 32 %s = [%s] %s", entry.entryType!!.name,
ByteUtil.getHex(entry.rawData), entry)) ByteUtil.getHex(entry.rawData), entry))
} }
if (isEndResults(entry.entryType)) { if (isEndResults(entry.entryType)) {
@ -471,7 +455,7 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
} }
entry.setAtechDateTime(DateTimeUtil.toATechDate(year, month, dayOfMonth, hour, minutes, seconds)) entry.setAtechDateTime(DateTimeUtil.toATechDate(year, month, dayOfMonth, hour, minutes, seconds))
} else { } else {
aapsLogger!!.warn(LTag.PUMPBTCOMM, "Unknown datetime format: " + entry.dateTimeLength) aapsLogger.warn(LTag.PUMPBTCOMM, "Unknown datetime format: " + entry.dateTimeLength)
} }
} }

View file

@ -17,7 +17,8 @@ import java.util.*
*/ */
class PumpHistoryEntry : MedtronicHistoryEntry() { class PumpHistoryEntry : MedtronicHistoryEntry() {
@Expose var entryType: PumpHistoryEntryType? = null @Expose
var entryType: PumpHistoryEntryType? = null
private set private set
override var opCode: Byte? = null override var opCode: Byte? = null
@ -27,16 +28,12 @@ class PumpHistoryEntry : MedtronicHistoryEntry() {
field = value field = value
} }
// // override fun getOpCode(): Int {
// // return
// // }
//
// fun setOpCode(opCode: Int?) {
// this.opCode = opCode
// }
var offset = 0 var offset = 0
var displayableValue = "" var displayableValue = ""
get() = field
set(value) {
field = value
}
fun setEntryType(medtronicDeviceType: MedtronicDeviceType?, entryType: PumpHistoryEntryType) { fun setEntryType(medtronicDeviceType: MedtronicDeviceType?, entryType: PumpHistoryEntryType) {
this.entryType = entryType this.entryType = entryType

View file

@ -12,7 +12,7 @@ import java.util.*
* Author: Andy {andy.rozman@gmail.com} * Author: Andy {andy.rozman@gmail.com}
*/ */
enum class PumpHistoryEntryType // implements CodeEnum enum class PumpHistoryEntryType // implements CodeEnum
@JvmOverloads constructor(opCode: Byte, name: String?, group: PumpHistoryEntryGroup, head: Int = 2, date: Int = 5, body: Int = 0) { constructor(opCode: Byte, name: String?, group: PumpHistoryEntryGroup, head: Int = 2, date: Int = 5, body: Int = 0) {
// all commented out are probably not the real items // all commented out are probably not the real items
None(0, "None", PumpHistoryEntryGroup.Unknown, 1, 0, 0), Bolus(0x01, "Bolus", PumpHistoryEntryGroup.Bolus, 4, 5, 0), // 523+[H=8] 9/13 None(0, "None", PumpHistoryEntryGroup.Unknown, 1, 0, 0), Bolus(0x01, "Bolus", PumpHistoryEntryGroup.Bolus, 4, 5, 0), // 523+[H=8] 9/13
@ -40,15 +40,12 @@ enum class PumpHistoryEntryType // implements CodeEnum
ClearSettings(0x22, "Clear Settings", PumpHistoryEntryGroup.Configuration), // ClearSettings(0x22, "Clear Settings", PumpHistoryEntryGroup.Configuration), //
ChangeChildBlockEnable(0x23, "Change Child Block Enable", PumpHistoryEntryGroup.Configuration), // ChangeChildBlockEnable(0x23, "Change Child Block Enable", PumpHistoryEntryGroup.Configuration), //
ChangeMaxBolus(0x24, "Change Max Bolus", PumpHistoryEntryGroup.Configuration), // ChangeMaxBolus(0x24, "Change Max Bolus", PumpHistoryEntryGroup.Configuration), //
// /**/EventUnknown_MM522_0x25(0x25, "Unknown Event 0x25", PumpHistoryEntryGroup.Unknown), // 8? // /**/EventUnknown_MM522_0x25(0x25, "Unknown Event 0x25", PumpHistoryEntryGroup.Unknown), // 8?
EnableDisableRemote(0x26, "Enable/Disable Remote", PumpHistoryEntryGroup.Configuration, 2, 5, 14), // 2, 5, 14 V6:2,5,14 EnableDisableRemote(0x26, "Enable/Disable Remote", PumpHistoryEntryGroup.Configuration, 2, 5, 14), // 2, 5, 14 V6:2,5,14
ChangeRemoteId(0x27, "Change Remote ID", PumpHistoryEntryGroup.Configuration), // ?? ChangeRemoteId(0x27, "Change Remote ID", PumpHistoryEntryGroup.Configuration), // ??
ChangeMaxBasal(0x2c, "Change Max Basal", PumpHistoryEntryGroup.Configuration), // ChangeMaxBasal(0x2c, "Change Max Basal", PumpHistoryEntryGroup.Configuration), //
BolusWizardEnabled(0x2d, "Bolus Wizard Enabled", PumpHistoryEntryGroup.Configuration), // V3 ? BolusWizardEnabled(0x2d, "Bolus Wizard Enabled", PumpHistoryEntryGroup.Configuration), // V3 ?
/* TODO */ EventUnknown_MM512_0x2e(0x2e, "Unknown Event 0x2e", PumpHistoryEntryGroup.Unknown, 2, 5, 100), //
/* TODO */
EventUnknown_MM512_0x2e(0x2e, "Unknown Event 0x2e", PumpHistoryEntryGroup.Unknown, 2, 5, 100), //
BolusWizard512(0x2f, "Bolus Wizard (512)", PumpHistoryEntryGroup.Bolus, 2, 5, 12), // BolusWizard512(0x2f, "Bolus Wizard (512)", PumpHistoryEntryGroup.Bolus, 2, 5, 12), //
UnabsorbedInsulin512(0x30, "Unabsorbed Insulin (512)", PumpHistoryEntryGroup.Statistic, 5, 0, 0), // FIXME UnabsorbedInsulin512(0x30, "Unabsorbed Insulin (512)", PumpHistoryEntryGroup.Statistic, 5, 0, 0), // FIXME
ChangeBGReminderOffset(0x31, "Change BG Reminder Offset", PumpHistoryEntryGroup.Configuration), // ChangeBGReminderOffset(0x31, "Change BG Reminder Offset", PumpHistoryEntryGroup.Configuration), //
@ -57,13 +54,10 @@ enum class PumpHistoryEntryType // implements CodeEnum
LowReservoir(0x34, "Low Reservoir", PumpHistoryEntryGroup.Notification), // LowReservoir(0x34, "Low Reservoir", PumpHistoryEntryGroup.Notification), //
ChangeAlarmClock(0x35, "Change Alarm Clock", PumpHistoryEntryGroup.Configuration), // ChangeAlarmClock(0x35, "Change Alarm Clock", PumpHistoryEntryGroup.Configuration), //
ChangeMeterId(0x36, "Change Meter ID", PumpHistoryEntryGroup.Configuration), // ChangeMeterId(0x36, "Change Meter ID", PumpHistoryEntryGroup.Configuration), //
// /**/EventUnknown_MM512_0x37(0x37, "Unknown Event 0x37", PumpHistoryEntryGroup.Unknown), // V:MM512 // /**/EventUnknown_MM512_0x37(0x37, "Unknown Event 0x37", PumpHistoryEntryGroup.Unknown), // V:MM512
// /**/EventUnknown_MM512_0x38(0x38, "Unknown Event 0x38", PumpHistoryEntryGroup.Unknown), // // /**/EventUnknown_MM512_0x38(0x38, "Unknown Event 0x38", PumpHistoryEntryGroup.Unknown), //
BGReceived512(0x39, "BG Received (512)", PumpHistoryEntryGroup.Glucose, 2, 5, 3), // BGReceived512(0x39, "BG Received (512)", PumpHistoryEntryGroup.Glucose, 2, 5, 3), //
/* TODO */ ConfirmInsulinChange(0x3a, "Confirm Insulin Change", PumpHistoryEntryGroup.Unknown), //
/* TODO */
ConfirmInsulinChange(0x3a, "Confirm Insulin Change", PumpHistoryEntryGroup.Unknown), //
SensorStatus(0x3b, "Sensor Status", PumpHistoryEntryGroup.Glucose), // SensorStatus(0x3b, "Sensor Status", PumpHistoryEntryGroup.Glucose), //
ChangeParadigmID(0x3c, "Change Paradigm ID", PumpHistoryEntryGroup.Configuration, 2, 5, 14), // V3 ? V6: 2,5,14 ?? is it this length or just 7 ChangeParadigmID(0x3c, "Change Paradigm ID", PumpHistoryEntryGroup.Configuration, 2, 5, 14), // V3 ? V6: 2,5,14 ?? is it this length or just 7
@ -73,9 +67,8 @@ enum class PumpHistoryEntryType // implements CodeEnum
JournalEntryMealMarker(0x40, "Meal Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 2), // is size just 7??? V6 JournalEntryMealMarker(0x40, "Meal Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 2), // is size just 7??? V6
JournalEntryExerciseMarker(0x41, "Exercise Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 1), // ?? JournalEntryExerciseMarker(0x41, "Exercise Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 1), // ??
JournalEntryInsulinMarker(0x42, "Insulin Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 0), // V6 = body(0)/was=1 JournalEntryInsulinMarker(0x42, "Insulin Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 0), // V6 = body(0)/was=1
JournalEntryOtherMarker(0x43, "Other Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 1), // V6 = body(1)/was=0 JournalEntryOtherMarker(0x43, "Other Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 1), // V6 = body(1) was=0
EnableSensorAutoCal(0x44, "Enable Sensor AutoCal", PumpHistoryEntryGroup.Glucose), // EnableSensorAutoCal(0x44, "Enable Sensor AutoCal", PumpHistoryEntryGroup.Glucose), //
// /**/EventUnknown_MM522_0x45(0x45, "Unknown Event 0x45", PumpHistoryEntryGroup.Unknown, 2, 5, 1), // // /**/EventUnknown_MM522_0x45(0x45, "Unknown Event 0x45", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
// /**/EventUnknown_MM522_0x46(0x46, "Unknown Event 0x46", PumpHistoryEntryGroup.Unknown, 2, 5, 1), // // /**/EventUnknown_MM522_0x46(0x46, "Unknown Event 0x46", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
// /**/EventUnknown_MM522_0x47(0x47, "Unknown Event 0x47", PumpHistoryEntryGroup.Unknown, 2, 5, 1), // // /**/EventUnknown_MM522_0x47(0x47, "Unknown Event 0x47", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
@ -89,18 +82,11 @@ enum class PumpHistoryEntryType // implements CodeEnum
BolusWizardSetup512(0x4f, "Bolus Wizard Setup (512)", PumpHistoryEntryGroup.Configuration, 2, 5, 32), // BolusWizardSetup512(0x4f, "Bolus Wizard Setup (512)", PumpHistoryEntryGroup.Configuration, 2, 5, 32), //
ChangeSensorSetup2(0x50, "Sensor Setup2", PumpHistoryEntryGroup.Configuration, 2, 5, 30), // Ian50 ChangeSensorSetup2(0x50, "Sensor Setup2", PumpHistoryEntryGroup.Configuration, 2, 5, 30), // Ian50
/* TODO */ /* TODO */ Sensor_0x51(0x51, "Unknown Event 0x51", PumpHistoryEntryGroup.Unknown), //
Sensor_0x51(0x51, "Unknown Event 0x51", PumpHistoryEntryGroup.Unknown), // /* TODO */ Sensor_0x52(0x52, "Unknown Event 0x52", PumpHistoryEntryGroup.Unknown), //
/* TODO */
Sensor_0x52(0x52, "Unknown Event 0x52", PumpHistoryEntryGroup.Unknown), //
ChangeSensorAlarmSilenceConfig(0x53, "Sensor Alarm Silence Config", PumpHistoryEntryGroup.Configuration, 2, 5, 1), // 8 ChangeSensorAlarmSilenceConfig(0x53, "Sensor Alarm Silence Config", PumpHistoryEntryGroup.Configuration, 2, 5, 1), // 8
/* TODO */ Sensor_0x54(0x54, "Unknown Event 0x54", PumpHistoryEntryGroup.Unknown), // Ian54
/* TODO */ /* TODO */ Sensor_0x55(0x55, "Unknown Event 0x55", PumpHistoryEntryGroup.Unknown), //
Sensor_0x54(0x54, "Unknown Event 0x54", PumpHistoryEntryGroup.Unknown), // Ian54
/* TODO */
Sensor_0x55(0x55, "Unknown Event 0x55", PumpHistoryEntryGroup.Unknown), //
ChangeSensorRateOfChangeAlertSetup(0x56, "Sensor Rate Of Change Alert Setup", PumpHistoryEntryGroup.Configuration, 2, 5, 5), // 12 ChangeSensorRateOfChangeAlertSetup(0x56, "Sensor Rate Of Change Alert Setup", PumpHistoryEntryGroup.Configuration, 2, 5, 5), // 12
ChangeBolusScrollStepSize(0x57, "Change Bolus Scroll Step Size", PumpHistoryEntryGroup.Configuration), // ChangeBolusScrollStepSize(0x57, "Change Bolus Scroll Step Size", PumpHistoryEntryGroup.Configuration), //
BolusWizardSetup(0x5a, "Bolus Wizard Setup (522)", PumpHistoryEntryGroup.Configuration, 2, 5, 117), // V2: 522+[B=143]; V6: 124, v6: 137, v7: 117/137 [523] BolusWizardSetup(0x5a, "Bolus Wizard Setup (522)", PumpHistoryEntryGroup.Configuration, 2, 5, 117), // V2: 522+[B=143]; V6: 124, v6: 137, v7: 117/137 [523]
@ -124,7 +110,6 @@ enum class PumpHistoryEntryType // implements CodeEnum
DailyTotals522(0x6d, "Daily Totals (522)", PumpHistoryEntryGroup.Statistic, 1, 2, 41), // DailyTotals522(0x6d, "Daily Totals (522)", PumpHistoryEntryGroup.Statistic, 1, 2, 41), //
DailyTotals523(0x6e, "Daily Totals (523)", PumpHistoryEntryGroup.Statistic, 1, 2, 49), // 1102014-03-17T00:00:00 DailyTotals523(0x6e, "Daily Totals (523)", PumpHistoryEntryGroup.Statistic, 1, 2, 49), // 1102014-03-17T00:00:00
ChangeCarbUnits(0x6f.toByte(), "Change Carb Units", PumpHistoryEntryGroup.Configuration), // ChangeCarbUnits(0x6f.toByte(), "Change Carb Units", PumpHistoryEntryGroup.Configuration), //
// /**/EventUnknown_MM522_0x70((byte) 0x70, "Unknown Event 0x70", PumpHistoryEntryGroup.Unknown, 2, 5, 1), // // /**/EventUnknown_MM522_0x70((byte) 0x70, "Unknown Event 0x70", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
BasalProfileStart(0x7b, "Basal Profile Start", PumpHistoryEntryGroup.Basal, 2, 5, 3), // // 722 BasalProfileStart(0x7b, "Basal Profile Start", PumpHistoryEntryGroup.Basal, 2, 5, 3), // // 722
ChangeWatchdogEnable(0x7c, "Change Watchdog Enable", PumpHistoryEntryGroup.Configuration), // ChangeWatchdogEnable(0x7c, "Change Watchdog Enable", PumpHistoryEntryGroup.Configuration), //
@ -158,7 +143,7 @@ enum class PumpHistoryEntryType // implements CodeEnum
ChangeSensorSetup2.addSpecialRuleBody(SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 34)) ChangeSensorSetup2.addSpecialRuleBody(SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 34))
} }
@JvmStatic fun getByCode(opCode: Byte): PumpHistoryEntryType? { fun getByCode(opCode: Byte): PumpHistoryEntryType? {
return if (opCodeMap.containsKey(opCode)) { return if (opCodeMap.containsKey(opCode)) {
opCodeMap[opCode] opCodeMap[opCode]
} else { } else {
@ -166,18 +151,6 @@ enum class PumpHistoryEntryType // implements CodeEnum
} }
} }
//
// private PumpHistoryEntryType(int opCode, String name, int head, int date,
// int body)
// {
// this.opCode = (byte) opCode;
// this.description = name;
// this.headLength = head;
// this.dateLength = date;
// this.bodyLength = body;
// this.totalLength = (head + date + body);
// }
//
fun isAAPSRelevantEntry(entryType: PumpHistoryEntryType): Boolean { fun isAAPSRelevantEntry(entryType: PumpHistoryEntryType): Boolean {
return entryType == Bolus || // Treatments return entryType == Bolus || // Treatments
entryType == TempBasalRate || // entryType == TempBasalRate || //
@ -215,8 +188,11 @@ enum class PumpHistoryEntryType // implements CodeEnum
} }
val code: Byte val code: Byte
private val description: String?
private val headLength: Int val description: String?
get() = field
val headLength: Int
val dateLength: Int val dateLength: Int
// private MinimedDeviceType deviceType; // private MinimedDeviceType deviceType;
@ -228,22 +204,25 @@ enum class PumpHistoryEntryType // implements CodeEnum
private var specialRulesHead: MutableList<SpecialRule>? = null private var specialRulesHead: MutableList<SpecialRule>? = null
private var specialRulesBody: MutableList<SpecialRule>? = null private var specialRulesBody: MutableList<SpecialRule>? = null
private var hasSpecialRules = false private var hasSpecialRules = false
get() = field
val group: PumpHistoryEntryGroup val group: PumpHistoryEntryGroup
get() = field
private constructor(opCode: Byte, group: PumpHistoryEntryGroup) : this(opCode, null, group, 2, 5, 0) {} private constructor(opCode: Byte, group: PumpHistoryEntryGroup) : this(opCode, null, group, 2, 5, 0) {}
private constructor(opCode: Byte, group: PumpHistoryEntryGroup, head: Int, date: Int, body: Int) : this(opCode, null, group, head, date, body) {} private constructor(opCode: Byte, group: PumpHistoryEntryGroup, head: Int, date: Int, body: Int) : this(opCode, null, group, head, date, body) {}
fun getTotalLength(medtronicDeviceType: MedtronicDeviceType?): Int { fun getTotalLength(medtronicDeviceType: MedtronicDeviceType?): Int {
return if (hasSpecialRules()) { return if (hasSpecialRules) {
getHeadLength(medtronicDeviceType) + getBodyLength(medtronicDeviceType) + dateLength getHeadLength(medtronicDeviceType) + getBodyLength(medtronicDeviceType) + dateLength
} else { } else {
totalLength totalLength
} }
} }
private fun hasSpecialRules(): Boolean { // private fun hasSpecialRules(): Boolean {
return hasSpecialRules // return hasSpecialRules
} // }
fun addSpecialRuleHead(rule: SpecialRule) { fun addSpecialRuleHead(rule: SpecialRule) {
if (isEmpty(specialRulesHead)) { if (isEmpty(specialRulesHead)) {
@ -261,9 +240,9 @@ enum class PumpHistoryEntryType // implements CodeEnum
hasSpecialRules = true hasSpecialRules = true
} }
fun getDescription(): String { // fun getDescription(): String {
return description ?: name // return description ?: name
} // }
fun getHeadLength(medtronicDeviceType: MedtronicDeviceType?): Int { fun getHeadLength(medtronicDeviceType: MedtronicDeviceType?): Int {
return if (hasSpecialRules) { return if (hasSpecialRules) {

View file

@ -1,49 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message;
/**
* Created by geoff on 6/2/16.
*/
public class CarelinkLongMessageBody extends MessageBody {
private static final int LONG_MESSAGE_BODY_LENGTH = 65;
protected byte[] data;
CarelinkLongMessageBody() {
init(new byte[0]);
}
public CarelinkLongMessageBody(byte[] payload) {
init(payload);
}
@Override
public void init(byte[] rxData) {
if (rxData != null && rxData.length == LONG_MESSAGE_BODY_LENGTH) {
data = rxData;
} else {
data = new byte[LONG_MESSAGE_BODY_LENGTH];
if (rxData != null) {
int size = rxData.length < LONG_MESSAGE_BODY_LENGTH ? rxData.length : LONG_MESSAGE_BODY_LENGTH;
for (int i = 0; i < size; i++) {
data[i] = rxData[i];
}
}
}
}
@Override
public int getLength() {
return LONG_MESSAGE_BODY_LENGTH;
}
@Override
public byte[] getTxData() {
return data;
}
}

View file

@ -0,0 +1,46 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message
/**
* Created by geoff on 6/2/16.
*/
open class CarelinkLongMessageBody : MessageBody {
//protected var data: ByteArray? = null
internal constructor() {
init(ByteArray(0))
}
constructor(payload: ByteArray) {
init(payload)
}
override fun init(rxData: ByteArray?) {
if (rxData != null && rxData.size == LONG_MESSAGE_BODY_LENGTH) {
data = rxData
} else {
data = ByteArray(LONG_MESSAGE_BODY_LENGTH)
if (rxData != null) {
val size = if (rxData.size < LONG_MESSAGE_BODY_LENGTH) rxData.size else LONG_MESSAGE_BODY_LENGTH
for (i in 0 until size) {
data!![i] = rxData[i]
}
}
}
}
override val length: Int
get() = LONG_MESSAGE_BODY_LENGTH
// {
// return LONG_MESSAGE_BODY_LENGTH
// }
// override fun getTxData(): ByteArray {
// return data
// }
companion object {
private const val LONG_MESSAGE_BODY_LENGTH = 65
}
}

View file

@ -1,53 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message;
/**
* Created by geoff on 5/29/16.
*/
// Andy: See comments in message body
public class CarelinkShortMessageBody extends MessageBody {
byte[] body;
public CarelinkShortMessageBody() {
init(new byte[] { 0 });
}
public CarelinkShortMessageBody(byte[] data) {
init(data);
}
@Override
public int getLength() {
return body.length;
}
@Override
public void init(byte[] rxData) {
body = rxData;
}
public byte[] getRxData() {
return body;
}
public void setRxData(byte[] rxData) {
init(rxData);
}
@Override
public byte[] getTxData() {
return body;
}
public void setTxData(byte[] txData) {
init(txData);
}
}

View file

@ -0,0 +1,38 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message
/**
* Created by geoff on 5/29/16.
*/
// Andy: See comments in message body
open class CarelinkShortMessageBody : MessageBody {
//var body: ByteArray?
constructor() {
init(byteArrayOf(0))
}
constructor(data: ByteArray?) {
init(data)
}
override val length: Int
get() = data!!.size
override fun init(rxData: ByteArray?) {
data = rxData
}
var rxData: ByteArray?
get() = data
set(rxData) {
init(rxData)
}
// override var txData: ByteArray?
// get() = body
// set(txData) {
// init(txData)
// }
}

View file

@ -1,59 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
/**
* Created by geoff on 6/2/16.
*/
public class GetHistoryPageCarelinkMessageBody extends CarelinkLongMessageBody {
// public boolean wasLastFrame = false;
// public int frameNumber = 0;
// public byte[] frame = new byte[] {};
public GetHistoryPageCarelinkMessageBody(byte[] frameData) {
init(frameData);
}
public GetHistoryPageCarelinkMessageBody(int pageNum) {
init(pageNum);
}
@Override
public int getLength() {
return data.length;
}
@Override
public void init(byte[] rxData) {
super.init(rxData);
}
public void init(int pageNum) {
byte numArgs = 1;
super.init(new byte[] { numArgs, (byte)pageNum });
}
public int getFrameNumber() {
if (data.length > 0) {
return data[0] & 0x7f;
}
return 255;
}
public boolean wasLastFrame() {
return (data[0] & 0x80) != 0;
}
public byte[] getFrameData() {
return ByteUtil.substring(data, 1, data.length - 1);
}
}

View file

@ -0,0 +1,45 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil
import kotlin.experimental.and
/**
* Created by geoff on 6/2/16.
*/
class GetHistoryPageCarelinkMessageBody : CarelinkLongMessageBody {
// public boolean wasLastFrame = false;
// public int frameNumber = 0;
// public byte[] frame = new byte[] {};
constructor(frameData: ByteArray?) {
init(frameData)
}
constructor(pageNum: Int) {
init(pageNum)
}
override val length: Int
get() = data!!.size
override fun init(rxData: ByteArray?) {
super.init(rxData)
}
fun init(pageNum: Int) {
val numArgs: Byte = 1
super.init(byteArrayOf(numArgs, pageNum.toByte()))
}
val frameNumber: Int
get() = if (data!!.size > 0) {
(data!![0] and 0x7f.toByte()).toInt()
} else 255
fun wasLastFrame(): Boolean {
return (data!![0] and 0x80.toByte()).toInt() != 0
}
val frameData: ByteArray
get() = ByteUtil.substring(data!!, 1, data!!.size - 1)
}

View file

@ -1,34 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
/**
* Created by geoff on 5/29/16.
*/
public class MessageBody {
public int getLength() {
return 0;
}
public void init(byte[] rxData) {
}
public byte[] getTxData() {
return new byte[]{};
}
public String toString() {
StringBuilder sb = new StringBuilder(getClass().getSimpleName());
sb.append(" [txData=");
sb.append(ByteUtil.shortHexString(getTxData()));
sb.append("]");
return sb.toString();
}
}

View file

@ -0,0 +1,27 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil
/**
* Created by geoff on 5/29/16.
*/
open class MessageBody {
protected var data: ByteArray? = null
open val length: Int
get() = 0
open fun init(rxData: ByteArray?) {}
open val txData: ByteArray?
get() = if (data==null) byteArrayOf() else data
override fun toString(): String {
val sb = StringBuilder(javaClass.simpleName)
sb.append(" [txData=")
sb.append(ByteUtil.shortHexString(txData))
sb.append("]")
return sb.toString()
}
}

View file

@ -1,47 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message;
import java.util.HashMap;
import java.util.Map;
/**
* Created by geoff on 5/29/16.
* refactored into enum
*/
public enum PacketType {
Invalid(0x00), //
MySentry(0xa2), //
Meter(0xa5), //
Carelink(0xa7), //
Sensor(0xa8) //
;
public static Map<Byte, PacketType> mapByValue;
static {
mapByValue = new HashMap<>();
for (PacketType packetType : values()) {
mapByValue.put(packetType.value, packetType);
}
}
private final byte value;
PacketType(int value) {
this.value = (byte)value;
}
public static PacketType getByValue(short value) {
if (mapByValue.containsKey(value))
return mapByValue.get(value);
else
return PacketType.Invalid;
}
public byte getValue() {
return value;
}
}

View file

@ -0,0 +1,37 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message
import java.util.*
/**
* Created by geoff on 5/29/16.
* refactored into enum
*/
enum class PacketType(value: Int) {
Invalid(0x00), //
MySentry(0xa2), //
Meter(0xa5), //
Carelink(0xa7), //
Sensor(0xa8 //
);
companion object {
var mapByValue: MutableMap<Byte, PacketType> = HashMap()
fun getByValue(value: Short): PacketType? {
return if (mapByValue.containsKey(value.toByte())) mapByValue.get(value.toByte()) else Invalid
}
init {
for (packetType in values()) {
mapByValue[packetType.value] = packetType
}
}
}
val value: Byte
init {
this.value = value.toByte()
}
}

View file

@ -1,16 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message;
/**
* Created by geoff on 5/29/16.
*/
public class PumpAckMessageBody extends CarelinkShortMessageBody {
public PumpAckMessageBody() {
init(new byte[] { 0 });
}
public PumpAckMessageBody(byte[] bodyData) {
init(bodyData);
}
}

View file

@ -0,0 +1,15 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message
/**
* Created by geoff on 5/29/16.
*/
class PumpAckMessageBody : CarelinkShortMessageBody {
constructor() {
init(byteArrayOf(0))
}
constructor(bodyData: ByteArray?) {
init(bodyData)
}
}

View file

@ -1,214 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message;
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;
/**
* Created by geoff on 5/29/16.
*/
public class PumpMessage implements RLMessage {
private final AAPSLogger aapsLogger;
private PacketType packetType = PacketType.Carelink;
public byte[] address = new byte[]{0, 0, 0};
public MedtronicCommandType commandType;
public Byte invalidCommandType;
public MessageBody messageBody = new MessageBody();
public String error = null;
public static final int FRAME_DATA_LENGTH = 64;
public PumpMessage(AAPSLogger aapsLogger, String error) {
this.error = error;
this.aapsLogger = aapsLogger;
}
public PumpMessage(AAPSLogger aapsLogger, byte[] rxData) {
this.aapsLogger = aapsLogger;
init(rxData);
}
public PumpMessage(AAPSLogger aapsLogger) {
this.aapsLogger = aapsLogger;
}
public boolean isErrorResponse() {
return (this.error != null);
}
public void init(PacketType packetType, byte[] address, MedtronicCommandType commandType, MessageBody messageBody) {
this.packetType = packetType;
this.address = address;
this.commandType = commandType;
this.messageBody = messageBody;
}
public void init(byte[] rxData) {
if (rxData == null) {
return;
}
if (rxData.length > 0) {
this.packetType = PacketType.getByValue(rxData[0]);
}
if (rxData.length > 3) {
this.address = ByteUtil.substring(rxData, 1, 3);
}
if (rxData.length > 4) {
this.commandType = MedtronicCommandType.getByCode(rxData[4]);
if (this.commandType == MedtronicCommandType.InvalidCommand) {
aapsLogger.error(LTag.PUMPCOMM, "PumpMessage - Unknown commandType " + rxData[4]);
}
}
if (rxData.length > 5) {
this.messageBody = MedtronicCommandType.constructMessageBody(commandType,
ByteUtil.substring(rxData, 5, rxData.length - 5));
}
}
@Override
public byte[] getTxData() {
byte[] rval = ByteUtil.concat(new byte[]{packetType.getValue()}, address);
rval = ByteUtil.concat(rval, commandType.getCommandCode());
rval = ByteUtil.concat(rval, messageBody.getTxData());
return rval;
}
public byte[] getContents() {
return ByteUtil.concat(new byte[]{commandType.getCommandCode()}, messageBody.getTxData());
}
// rawContent = just response without code (contents-2, messageBody.txData-1);
public byte[] getRawContent() {
if ((messageBody == null) || (messageBody.getTxData() == null) || (messageBody.getTxData().length == 0))
return null;
byte[] data = messageBody.getTxData();
int length = ByteUtil.asUINT8(data[0]); // length is not always correct so, we check whole array if we have
// data, after length
int originalLength = length;
// check if displayed length is invalid
if (length > data.length - 1) {
return data;
}
// check Old Way
boolean oldWay = false;
for (int i = (length + 1); i < data.length; i++) {
if (data[i] != 0x00) {
oldWay = true;
}
}
if (oldWay) {
length = data.length - 1;
}
byte[] arrayOut = new byte[length];
System.arraycopy(messageBody.getTxData(), 1, arrayOut, 0, length);
// if (isLogEnabled())
// LOG.debug("PumpMessage - Length: " + length + ", Original Length: " + originalLength + ", CommandType: "
// + commandType);
return arrayOut;
}
public byte[] getRawContentOfFrame() {
byte[] raw = messageBody.getTxData();
if (raw==null || raw.length==0) {
return new byte[0];
} else {
return ByteUtil.substring(raw, 1, Math.min(FRAME_DATA_LENGTH, raw.length - 1));
}
}
public boolean isValid() {
if (packetType == null)
return false;
if (address == null)
return false;
if (commandType == null)
return false;
return messageBody != null;
}
public MessageBody getMessageBody() {
return messageBody;
}
public String getResponseContent() {
StringBuilder sb = new StringBuilder("PumpMessage [response=");
boolean showData = true;
if (commandType != null) {
if (commandType == MedtronicCommandType.CommandACK) {
sb.append("Acknowledged");
showData = false;
} else if (commandType == MedtronicCommandType.CommandNAK) {
sb.append("NOT Acknowledged");
showData = false;
} else {
sb.append(commandType.name());
}
} else {
sb.append("Unknown_Type");
sb.append(" (" + invalidCommandType + ")");
}
if (showData) {
sb.append(", rawResponse=");
sb.append(ByteUtil.shortHexString(getRawContent()));
}
sb.append("]");
return sb.toString();
}
public String toString() {
StringBuilder sb = new StringBuilder("PumpMessage [");
sb.append("packetType=");
sb.append(packetType == null ? "null" : packetType.name());
sb.append(", address=(");
sb.append(ByteUtil.shortHexString(this.address));
sb.append("), commandType=");
sb.append(commandType == null ? "null" : commandType.name());
if (invalidCommandType != null) {
sb.append(", invalidCommandType=");
sb.append(invalidCommandType);
}
sb.append(", messageBody=(");
sb.append(this.messageBody == null ? "null" : this.messageBody);
sb.append(")]");
return sb.toString();
}
}

View file

@ -0,0 +1,183 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message
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
/**
* Created by geoff on 5/29/16.
*/
class PumpMessage : RLMessage {
private val aapsLogger: AAPSLogger
private var packetType: PacketType? = PacketType.Carelink
var address: ByteArray? = byteArrayOf(0, 0, 0)
var commandType: MedtronicCommandType? = null
var invalidCommandType: Byte? = null
var messageBody: MessageBody? = MessageBody()
var error: String? = null
constructor(aapsLogger: AAPSLogger, error: String?) {
this.error = error
this.aapsLogger = aapsLogger
}
constructor(aapsLogger: AAPSLogger, rxData: ByteArray?) {
this.aapsLogger = aapsLogger
init(rxData)
}
constructor(aapsLogger: AAPSLogger) {
this.aapsLogger = aapsLogger
}
val isErrorResponse: Boolean
get() = error != null
fun init(packetType: PacketType?, address: ByteArray?, commandType: MedtronicCommandType?, messageBody: MessageBody?) {
this.packetType = packetType
this.address = address
this.commandType = commandType
this.messageBody = messageBody
}
fun init(rxData: ByteArray?) {
if (rxData == null) {
return
}
if (rxData.size > 0) {
packetType = PacketType.getByValue(rxData[0].toShort())
}
if (rxData.size > 3) {
address = ByteUtil.substring(rxData, 1, 3)
}
if (rxData.size > 4) {
commandType = MedtronicCommandType.getByCode(rxData[4])
if (commandType == MedtronicCommandType.InvalidCommand) {
aapsLogger.error(LTag.PUMPCOMM, "PumpMessage - Unknown commandType " + rxData[4])
}
}
if (rxData.size > 5) {
messageBody = MedtronicCommandType.constructMessageBody(commandType,
ByteUtil.substring(rxData, 5, rxData.size - 5))
}
}
override fun getTxData(): ByteArray {
var rval = ByteUtil.concat(byteArrayOf(packetType!!.value), address)
rval = ByteUtil.concat(rval, commandType!!.getCommandCode())
rval = ByteUtil.concat(rval, messageBody!!.txData)
return rval
}
val contents: ByteArray
get() = ByteUtil.concat(byteArrayOf(commandType!!.getCommandCode()), messageBody!!.txData)// length is not always correct so, we check whole array if we have
// data, after length
// check if displayed length is invalid
// check Old Way
// if (isLogEnabled())
// LOG.debug("PumpMessage - Length: " + length + ", Original Length: " + originalLength + ", CommandType: "
// + commandType);
// rawContent = just response without code (contents-2, messageBody.txData-1);
val rawContent: ByteArray?
get() {
if (messageBody == null || messageBody!!.txData == null || messageBody!!.txData!!.size == 0) return null
val data = messageBody!!.txData
var length = ByteUtil.asUINT8(data!![0]) // length is not always correct so, we check whole array if we have
// data, after length
val originalLength = length
// check if displayed length is invalid
if (length > data.size - 1) {
return data
}
// check Old Way
var oldWay = false
for (i in length + 1 until data.size) {
if (data[i] != 0x00.toByte()) {
oldWay = true
}
}
if (oldWay) {
length = data.size - 1
}
val arrayOut = ByteArray(length)
System.arraycopy(messageBody!!.txData, 1, arrayOut, 0, length)
// if (isLogEnabled())
// LOG.debug("PumpMessage - Length: " + length + ", Original Length: " + originalLength + ", CommandType: "
// + commandType);
return arrayOut
}
val rawContentOfFrame: ByteArray
get() {
val raw = messageBody!!.txData
return if (raw == null || raw.size == 0) {
ByteArray(0)
} else {
ByteUtil.substring(raw, 1, Math.min(FRAME_DATA_LENGTH, raw.size - 1))
}
}
override fun isValid(): Boolean {
if (packetType == null) return false
if (address == null) return false
return if (commandType == null) false else messageBody != null
}
val responseContent: String
get() {
val sb = StringBuilder("PumpMessage [response=")
var showData = true
if (commandType != null) {
if (commandType == MedtronicCommandType.CommandACK) {
sb.append("Acknowledged")
showData = false
} else if (commandType == MedtronicCommandType.CommandNAK) {
sb.append("NOT Acknowledged")
showData = false
} else {
sb.append(commandType!!.name)
}
} else {
sb.append("Unknown_Type")
sb.append(" ($invalidCommandType)")
}
if (showData) {
sb.append(", rawResponse=")
sb.append(ByteUtil.shortHexString(rawContent))
}
sb.append("]")
return sb.toString()
}
override fun toString(): String {
val sb = StringBuilder("PumpMessage [")
sb.append("packetType=")
sb.append(if (packetType == null) "null" else packetType!!.name)
sb.append(", address=(")
sb.append(ByteUtil.shortHexString(address))
sb.append("), commandType=")
sb.append(if (commandType == null) "null" else commandType!!.name)
if (invalidCommandType != null) {
sb.append(", invalidCommandType=")
sb.append(invalidCommandType)
}
sb.append(", messageBody=(")
sb.append(if (messageBody == null) "null" else messageBody)
sb.append(")]")
return sb.toString()
}
companion object {
const val FRAME_DATA_LENGTH = 64
}
}

View file

@ -1,46 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message;
/**
* Created by geoff on 5/29/16.
*/
public class UnknownMessageBody extends MessageBody {
public byte[] rxData;
public UnknownMessageBody(byte[] data) {
this.rxData = data;
}
@Override
public int getLength() {
return 0;
}
@Override
public void init(byte[] rxData) {
}
public byte[] getRxData() {
return rxData;
}
public void setRxData(byte[] rxData) {
this.rxData = rxData;
}
@Override
public byte[] getTxData() {
return rxData;
}
public void setTxData(byte[] txData) {
this.rxData = txData;
}
}

View file

@ -0,0 +1,15 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message
/**
* Created by geoff on 5/29/16.
*/
class UnknownMessageBody(override var txData: ByteArray) : MessageBody() {
override val length: Int
get() = 0
override fun init(rxData: ByteArray?) {
data = rxData
}
}

View file

@ -204,7 +204,7 @@ public class MedtronicHistoryData {
} else { } else {
if (type == PumpHistoryEntryType.EndResultTotals) { if (type == PumpHistoryEntryType.EndResultTotals) {
if (!DateTimeUtil.isSameDay(atechDate, pumpHistoryEntry.atechDateTime)) { if (!DateTimeUtil.isSameDay(atechDate, pumpHistoryEntry.getAtechDateTime())) {
newHistory2.add(pumpHistoryEntry); newHistory2.add(pumpHistoryEntry);
} }
} else { } else {
@ -239,7 +239,7 @@ public class MedtronicHistoryData {
for (PumpHistoryEntry bolusEstimate : bolusEstimates) { for (PumpHistoryEntry bolusEstimate : bolusEstimates) {
for (PumpHistoryEntry bolus : boluses) { for (PumpHistoryEntry bolus : boluses) {
if (bolusEstimate.atechDateTime.equals(bolus.atechDateTime)) { if (bolusEstimate.getAtechDateTime().equals(bolus.getAtechDateTime())) {
bolus.addDecodedData("Estimate", bolusEstimate.getDecodedData().get("Object")); bolus.addDecodedData("Estimate", bolusEstimate.getDecodedData().get("Object"));
} }
} }
@ -256,7 +256,7 @@ public class MedtronicHistoryData {
// find last entry // find last entry
for (PumpHistoryEntry pumpHistoryEntry : newHistory) { for (PumpHistoryEntry pumpHistoryEntry : newHistory) {
if (pumpHistoryEntry.atechDateTime != null && pumpHistoryEntry.isAfter(pheLast.atechDateTime)) { if (pumpHistoryEntry.getAtechDateTime() != null && pumpHistoryEntry.isAfter(pheLast.getAtechDateTime())) {
pheLast = pumpHistoryEntry; pheLast = pumpHistoryEntry;
} }
} }
@ -268,7 +268,7 @@ public class MedtronicHistoryData {
if (!this.allHistory.contains(pumpHistoryEntry)) { if (!this.allHistory.contains(pumpHistoryEntry)) {
lastIdUsed++; lastIdUsed++;
pumpHistoryEntry.id = lastIdUsed; pumpHistoryEntry.setId(lastIdUsed);
this.allHistory.add(pumpHistoryEntry); this.allHistory.add(pumpHistoryEntry);
} }
@ -278,13 +278,13 @@ public class MedtronicHistoryData {
if (pheLast == null) // if we don't have any valid record we don't do the filtering and setting if (pheLast == null) // if we don't have any valid record we don't do the filtering and setting
return; return;
this.setLastHistoryRecordTime(pheLast.atechDateTime); this.setLastHistoryRecordTime(pheLast.getAtechDateTime());
sp.putLong(MedtronicConst.Statistics.LastPumpHistoryEntry, pheLast.atechDateTime); sp.putLong(MedtronicConst.Statistics.LastPumpHistoryEntry, pheLast.getAtechDateTime());
LocalDateTime dt = null; LocalDateTime dt = null;
try { try {
dt = DateTimeUtil.toLocalDateTime(pheLast.atechDateTime); dt = DateTimeUtil.toLocalDateTime(pheLast.getAtechDateTime());
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.error("Problem decoding date from last record: " + pheLast); aapsLogger.error("Problem decoding date from last record: " + pheLast);
} }
@ -537,9 +537,9 @@ public class MedtronicHistoryData {
continue; continue;
} }
if (primeRecord.atechDateTime > maxAllowedTimeInPast) { if (primeRecord.getAtechDateTime() > maxAllowedTimeInPast) {
if (lastPrimeRecord < primeRecord.atechDateTime) { if (lastPrimeRecord < primeRecord.getAtechDateTime()) {
lastPrimeRecord = primeRecord.atechDateTime; lastPrimeRecord = primeRecord.getAtechDateTime();
} }
} }
} }
@ -560,9 +560,9 @@ public class MedtronicHistoryData {
long lastRewindRecord = 0L; long lastRewindRecord = 0L;
for (PumpHistoryEntry rewindRecord : rewindRecords) { for (PumpHistoryEntry rewindRecord : rewindRecords) {
if (rewindRecord.atechDateTime > maxAllowedTimeInPast) { if (rewindRecord.getAtechDateTime() > maxAllowedTimeInPast) {
if (lastRewindRecord < rewindRecord.atechDateTime) { if (lastRewindRecord < rewindRecord.getAtechDateTime()) {
lastRewindRecord = rewindRecord.atechDateTime; lastRewindRecord = rewindRecord.getAtechDateTime();
} }
} }
} }
@ -593,7 +593,7 @@ public class MedtronicHistoryData {
for (PumpHistoryEntry tdd : tdds) { for (PumpHistoryEntry tdd : tdds) {
TDD tddDbEntry = findTDD(tdd.atechDateTime, tddsDb); TDD tddDbEntry = findTDD(tdd.getAtechDateTime(), tddsDb);
DailyTotalsDTO totalsDTO = (DailyTotalsDTO) tdd.getDecodedData().get("Object"); DailyTotalsDTO totalsDTO = (DailyTotalsDTO) tdd.getDecodedData().get("Object");
@ -839,7 +839,7 @@ public class MedtronicHistoryData {
*/ */
private DbObjectBase findDbEntry(PumpHistoryEntry treatment, List<? extends DbObjectBase> entriesFromHistory) { private DbObjectBase findDbEntry(PumpHistoryEntry treatment, List<? extends DbObjectBase> entriesFromHistory) {
long proposedTime = DateTimeUtil.toMillisFromATD(treatment.atechDateTime); long proposedTime = DateTimeUtil.toMillisFromATD(treatment.getAtechDateTime());
//proposedTime += (this.pumpTime.timeDifference * 1000); //proposedTime += (this.pumpTime.timeDifference * 1000);
@ -856,10 +856,10 @@ public class MedtronicHistoryData {
// TODO: Fix db code // TODO: Fix db code
// if difference is bigger than 2 minutes we discard entry // if difference is bigger than 2 minutes we discard entry
long maxMillisAllowed = DateTimeUtil.getMillisFromATDWithAddedMinutes(treatment.atechDateTime, 2); long maxMillisAllowed = DateTimeUtil.getMillisFromATDWithAddedMinutes(treatment.getAtechDateTime(), 2);
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry maxMillisAllowed=%d, AtechDateTime=%d (add 2 minutes). ", maxMillisAllowed, treatment.atechDateTime)); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry maxMillisAllowed=%d, AtechDateTime=%d (add 2 minutes). ", maxMillisAllowed, treatment.getAtechDateTime()));
if (entriesFromHistory.get(0).getDate() > maxMillisAllowed) { if (entriesFromHistory.get(0).getDate() > maxMillisAllowed) {
if (doubleBolusDebug) if (doubleBolusDebug)
@ -970,7 +970,7 @@ public class MedtronicHistoryData {
case Normal: { case Normal: {
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo(); DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
detailedBolusInfo.setBolusTimestamp(tryToGetByLocalTime(bolus.atechDateTime)); detailedBolusInfo.setBolusTimestamp(tryToGetByLocalTime(bolus.getAtechDateTime()));
detailedBolusInfo.setPumpType(PumpType.MEDTRONIC_512_712); // TODO grab real model detailedBolusInfo.setPumpType(PumpType.MEDTRONIC_512_712); // TODO grab real model
detailedBolusInfo.setPumpSerial(medtronicPumpStatus.serialNumber); detailedBolusInfo.setPumpSerial(medtronicPumpStatus.serialNumber);
detailedBolusInfo.setBolusPumpId(bolus.getPumpId()); detailedBolusInfo.setBolusPumpId(bolus.getPumpId());
@ -993,7 +993,7 @@ public class MedtronicHistoryData {
case Audio: case Audio:
case Extended: { case Extended: {
ExtendedBolus extendedBolus = new ExtendedBolus(injector); ExtendedBolus extendedBolus = new ExtendedBolus(injector);
extendedBolus.date = tryToGetByLocalTime(bolus.atechDateTime); extendedBolus.date = tryToGetByLocalTime(bolus.getAtechDateTime());
extendedBolus.source = Source.PUMP; extendedBolus.source = Source.PUMP;
extendedBolus.insulin = bolusDTO.getDeliveredAmount(); extendedBolus.insulin = bolusDTO.getDeliveredAmount();
extendedBolus.pumpId = bolus.getPumpId(); extendedBolus.pumpId = bolus.getPumpId();
@ -1060,7 +1060,7 @@ public class MedtronicHistoryData {
if (temporaryBasalDb == null) { if (temporaryBasalDb == null) {
temporaryBasalDb = new TemporaryBasal(injector); temporaryBasalDb = new TemporaryBasal(injector);
temporaryBasalDb.date = tryToGetByLocalTime(treatment.atechDateTime); temporaryBasalDb.date = tryToGetByLocalTime(treatment.getAtechDateTime());
operation = "addTBR"; operation = "addTBR";
} }
@ -1094,7 +1094,7 @@ public class MedtronicHistoryData {
if (tempBasal == null) { if (tempBasal == null) {
// add // add
tempBasal = new TemporaryBasal(injector); tempBasal = new TemporaryBasal(injector);
tempBasal.date = tryToGetByLocalTime(tempBasalProcess.itemOne.atechDateTime); tempBasal.date = tryToGetByLocalTime(tempBasalProcess.itemOne.getAtechDateTime());
tempBasal.source = Source.PUMP; tempBasal.source = Source.PUMP;
tempBasal.pumpId = tempBasalProcess.itemOne.getPumpId(); tempBasal.pumpId = tempBasalProcess.itemOne.getPumpId();
@ -1346,8 +1346,8 @@ public class MedtronicHistoryData {
for (PumpHistoryEntry treatment : treatments) { for (PumpHistoryEntry treatment : treatments) {
if (treatment.atechDateTime < dt) { if (treatment.getAtechDateTime() < dt) {
dt = treatment.atechDateTime; dt = treatment.getAtechDateTime();
currentTreatment = treatment; currentTreatment = treatment;
} }
} }
@ -1386,8 +1386,8 @@ public class MedtronicHistoryData {
for (PumpHistoryEntry treatment : treatments) { for (PumpHistoryEntry treatment : treatments) {
if (treatment.atechDateTime < dt) { if (treatment.getAtechDateTime() < dt) {
dt = treatment.atechDateTime; dt = treatment.getAtechDateTime();
currentTreatment = treatment; currentTreatment = treatment;
} }
} }
@ -1469,9 +1469,9 @@ public class MedtronicHistoryData {
for (PumpHistoryEntry filteredItem : filteredItems) { for (PumpHistoryEntry filteredItem : filteredItems) {
if (lastDate == null || lastDate < filteredItem.atechDateTime) { if (lastDate == null || lastDate < filteredItem.getAtechDateTime()) {
newProfile = filteredItem; newProfile = filteredItem;
lastDate = newProfile.atechDateTime; lastDate = newProfile.getAtechDateTime();
} }
} }
} }
@ -1517,13 +1517,13 @@ public class MedtronicHistoryData {
Map<String, PumpHistoryEntry> map = new HashMap<>(); Map<String, PumpHistoryEntry> map = new HashMap<>();
for (PumpHistoryEntry pumpHistoryEntry : TBRs_Input) { for (PumpHistoryEntry pumpHistoryEntry : TBRs_Input) {
if (map.containsKey(pumpHistoryEntry.DT)) { if (map.containsKey(pumpHistoryEntry.getDT())) {
medtronicPumpHistoryDecoder.decodeTempBasal(map.get(pumpHistoryEntry.DT), pumpHistoryEntry); medtronicPumpHistoryDecoder.decodeTempBasal(map.get(pumpHistoryEntry.getDT()), pumpHistoryEntry);
pumpHistoryEntry.setEntryType(medtronicUtil.getMedtronicPumpModel(), PumpHistoryEntryType.TempBasalCombined); pumpHistoryEntry.setEntryType(medtronicUtil.getMedtronicPumpModel(), PumpHistoryEntryType.TempBasalCombined);
TBRs.add(pumpHistoryEntry); TBRs.add(pumpHistoryEntry);
map.remove(pumpHistoryEntry.DT); map.remove(pumpHistoryEntry.getDT());
} else { } else {
map.put(pumpHistoryEntry.DT, pumpHistoryEntry); map.put(pumpHistoryEntry.getDT(), pumpHistoryEntry);
} }
} }

View file

@ -74,15 +74,15 @@ public class DailyTotalsDTO {
break; break;
case DailyTotals515: case DailyTotals515:
decodeDailyTotals515(entry.body); decodeDailyTotals515(entry.getBody());
break; break;
case DailyTotals522: case DailyTotals522:
decodeDailyTotals522(entry.body); decodeDailyTotals522(entry.getBody());
break; break;
case DailyTotals523: case DailyTotals523:
decodeDailyTotals523(entry.body); decodeDailyTotals523(entry.getBody());
break; break;
default: default:
@ -96,18 +96,18 @@ public class DailyTotalsDTO {
private void setDisplayable() { private void setDisplayable() {
if (this.insulinBasal == null) { if (this.insulinBasal == null) {
this.entry.displayableValue = "Total Insulin: " + StringUtil.getFormatedValueUS(this.insulinTotal, 2); this.entry.setDisplayableValue("Total Insulin: " + StringUtil.getFormatedValueUS(this.insulinTotal, 2));
} else { } else {
this.entry.displayableValue = "Basal Insulin: " + StringUtil.getFormatedValueUS(this.insulinBasal, 2) this.entry.setDisplayableValue("Basal Insulin: " + StringUtil.getFormatedValueUS(this.insulinBasal, 2)
+ ", Total Insulin: " + StringUtil.getFormatedValueUS(this.insulinTotal, 2); + ", Total Insulin: " + StringUtil.getFormatedValueUS(this.insulinTotal, 2));
} }
} }
private void decodeEndResultsTotals(PumpHistoryEntry entry) { private void decodeEndResultsTotals(PumpHistoryEntry entry) {
double totals = ByteUtil.toInt((int) entry.head[0], (int) entry.head[1], (int) entry.head[2], double totals = ByteUtil.toInt((int) entry.getHead()[0], (int) entry.getHead()[1], (int) entry.getHead()[2],
(int) entry.head[3], ByteUtil.BitConversion.BIG_ENDIAN) * 0.025d; (int) entry.getHead()[3], ByteUtil.BitConversion.BIG_ENDIAN) * 0.025d;
this.insulinTotal = totals; this.insulinTotal = totals;
@ -241,7 +241,7 @@ public class DailyTotalsDTO {
} }
public void setTDD(TDD tdd) { public void setTDD(TDD tdd) {
tdd.date = DateTimeUtil.toMillisFromATD(this.entry.atechDateTime); tdd.date = DateTimeUtil.toMillisFromATD(this.entry.getAtechDateTime());
tdd.basal = insulinBasal; tdd.basal = insulinBasal;
tdd.bolus = insulinBolus; tdd.bolus = insulinBolus;
tdd.total = insulinTotal; tdd.total = insulinTotal;

View file

@ -15,7 +15,7 @@ public class TempBasalProcessDTO {
TempBasalPair tbr = (TempBasalPair) itemOne.getDecodedDataEntry("Object"); TempBasalPair tbr = (TempBasalPair) itemOne.getDecodedDataEntry("Object");
return tbr.getDurationMinutes(); return tbr.getDurationMinutes();
} else { } else {
int difference = DateTimeUtil.getATechDateDiferenceAsMinutes(itemOne.atechDateTime, itemTwo.atechDateTime); int difference = DateTimeUtil.getATechDateDiferenceAsMinutes(itemOne.getAtechDateTime(), itemTwo.getAtechDateTime());
return difference; return difference;
} }
} }

View file

@ -1,7 +1,9 @@
package info.nightscout.androidaps.plugins.pump.medtronic.di package info.nightscout.androidaps.plugins.pump.medtronic.di
import dagger.Module import dagger.Module
import dagger.Provides
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask
@ -20,4 +22,9 @@ abstract class MedtronicModule {
@ContributesAndroidInjector abstract fun medtronicCommunicationManagerProvider(): MedtronicCommunicationManager @ContributesAndroidInjector abstract fun medtronicCommunicationManagerProvider(): MedtronicCommunicationManager
@ContributesAndroidInjector abstract fun medtronicUITaskProvider(): MedtronicUITask @ContributesAndroidInjector abstract fun medtronicUITaskProvider(): MedtronicUITask
@ContributesAndroidInjector abstract fun contributesRileyLinkStatusDeviceMedtronic(): RileyLinkStatusDeviceMedtronic @ContributesAndroidInjector abstract fun contributesRileyLinkStatusDeviceMedtronic(): RileyLinkStatusDeviceMedtronic
companion object {
@Provides
fun byteUtilProvider(): ByteUtil = ByteUtil();
}
} }

View file

@ -59,7 +59,7 @@ public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
this.filteredHistoryList.addAll(list); this.filteredHistoryList.addAll(list);
} else { } else {
for (PumpHistoryEntry pumpHistoryEntry : list) { for (PumpHistoryEntry pumpHistoryEntry : list) {
if (pumpHistoryEntry.getEntryType().group == group) { if (pumpHistoryEntry.getEntryType().getGroup() == group) {
this.filteredHistoryList.add(pumpHistoryEntry); this.filteredHistoryList.add(pumpHistoryEntry);
} }
} }
@ -214,7 +214,7 @@ public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
if (record != null) { if (record != null) {
holder.timeView.setText(record.getDateTimeString()); holder.timeView.setText(record.getDateTimeString());
holder.typeView.setText(record.getEntryType().getDescription()); holder.typeView.setText(record.getEntryType().getDescription());
holder.valueView.setText(record.displayableValue); holder.valueView.setText(record.getDisplayableValue());
} }
} }

View file

@ -16,7 +16,7 @@ public class PumpHistoryEntryUTest {
long queryObject = 20191009000000L; long queryObject = 20191009000000L;
PumpHistoryEntry phe = new PumpHistoryEntry(); PumpHistoryEntry phe = new PumpHistoryEntry();
phe.atechDateTime = dateObject; phe.setAtechDateTime(dateObject);
Assert.assertTrue(phe.isAfter(queryObject)); Assert.assertTrue(phe.isAfter(queryObject));
} }