- kotlinlize: info/nightscout/androidaps/plugins/pump/medtronic/comm/message
This commit is contained in:
parent
769ab218d4
commit
05a07c1904
|
@ -1223,7 +1223,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
return;
|
||||
|
||||
this.lastPumpHistoryEntry = latestEntry;
|
||||
sp.putLong(MedtronicConst.Statistics.LastPumpHistoryEntry, latestEntry.atechDateTime);
|
||||
sp.putLong(MedtronicConst.Statistics.LastPumpHistoryEntry, latestEntry.getAtechDateTime());
|
||||
|
||||
if (debugHistory)
|
||||
aapsLogger.debug(LTag.PUMP, "HST: History: valid=" + historyResult.validEntries.size() + ", unprocessed=" + historyResult.unprocessedEntries.size());
|
||||
|
|
|
@ -237,10 +237,10 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
aapsLogger.debug(LTag.PUMPCOMM, "Run command with Args: ");
|
||||
|
||||
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
|
||||
PumpMessage shortResponse = sendAndListen(shortMessage);
|
||||
if (shortResponse.commandType == MedtronicCommandType.CommandACK) {
|
||||
if (shortResponse.getCommandType() == MedtronicCommandType.CommandACK) {
|
||||
if (debugSetCommands)
|
||||
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
|
||||
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");
|
||||
|
||||
return new PumpMessage(aapsLogger, "No ACK after start message.");
|
||||
|
@ -288,7 +288,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
|
||||
// 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, 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()));
|
||||
|
||||
PumpMessage ackMsg = makePumpMessage(MedtronicCommandType.CommandACK, new PumpAckMessageBody());
|
||||
GetHistoryPageCarelinkMessageBody currentResponse = new GetHistoryPageCarelinkMessageBody(firstResponse
|
||||
.getMessageBody().getTxData());
|
||||
GetHistoryPageCarelinkMessageBody currentResponse = new GetHistoryPageCarelinkMessageBody(firstResponse.getMessageBody().getTxData());
|
||||
int expectedFrameNum = 1;
|
||||
boolean done = false;
|
||||
// while (expectedFrameNum == currentResponse.getFrameNumber()) {
|
||||
|
@ -861,7 +860,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
if (debugSetCommands)
|
||||
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;
|
||||
} else {
|
||||
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,
|
||||
basalProfileFrames);
|
||||
|
||||
if (responseMessage.commandType == MedtronicCommandType.CommandACK)
|
||||
if (responseMessage.getCommandType() == MedtronicCommandType.CommandACK)
|
||||
return true;
|
||||
|
||||
} catch (RileyLinkCommunicationException e) {
|
||||
|
@ -908,7 +907,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
}
|
||||
|
||||
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
|
||||
aapsLogger.warn(LTag.PUMPCOMM, "Set Basal Profile: Null response.");
|
||||
}
|
||||
|
|
|
@ -19,16 +19,13 @@ import kotlin.jvm.Throws
|
|||
*/
|
||||
abstract class MedtronicHistoryDecoder<T : MedtronicHistoryEntry?> : MedtronicHistoryDecoderInterface<T> {
|
||||
|
||||
@JvmField @Inject
|
||||
var aapsLogger: AAPSLogger? = null
|
||||
|
||||
@JvmField @Inject
|
||||
var medtronicUtil: MedtronicUtil? = null
|
||||
protected var bitUtils: ByteUtil? = null
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var medtronicUtil: MedtronicUtil
|
||||
@Inject lateinit var bitUtils: ByteUtil
|
||||
|
||||
// STATISTICS (remove at later time or not)
|
||||
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
|
||||
|
||||
// public abstract <E extends MedtronicHistoryEntry> Class<E> getHistoryEntryClass();
|
||||
|
|
|
@ -16,30 +16,41 @@ import java.util.*
|
|||
*/
|
||||
abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
|
||||
|
||||
@JvmField var rawData: List<Byte>? = null
|
||||
@JvmField protected var sizes = IntArray(3)
|
||||
var rawData: List<Byte>? = null
|
||||
get() = field
|
||||
|
||||
protected var sizes = IntArray(3)
|
||||
get() = field
|
||||
|
||||
var head: ByteArray? = null
|
||||
get() = field
|
||||
|
||||
var datetime: ByteArray? = null
|
||||
var body: ByteArray? = null
|
||||
|
||||
// protected LocalDateTime dateTime;
|
||||
@JvmField var id: Long = 0
|
||||
|
||||
@JvmField @Expose
|
||||
var DT: String? = null
|
||||
|
||||
@JvmField @Expose
|
||||
var atechDateTime: Long? = null
|
||||
var id: Long = 0
|
||||
set(value) {
|
||||
field = value
|
||||
}
|
||||
|
||||
@Expose
|
||||
protected var decodedData: MutableMap<String, Any?>? = null
|
||||
var phoneDateTime // time on phone
|
||||
: Long = 0
|
||||
var DT: String? = null
|
||||
get() = field
|
||||
|
||||
@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)
|
||||
*/
|
||||
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
|
||||
|
@ -52,7 +63,7 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
|
|||
* Linked object, see linked
|
||||
*/
|
||||
var linkedObject: Any? = null
|
||||
get() = field //= linkedObject
|
||||
get() = field
|
||||
set(value) {
|
||||
linked = true
|
||||
field = value
|
||||
|
@ -63,7 +74,7 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
|
|||
// this.linkedObject = linkedObject
|
||||
// }
|
||||
|
||||
override fun setData(listRawData: List<Byte>?, doNotProcess: Boolean) {
|
||||
override fun setData(listRawData: List<Byte>, doNotProcess: Boolean) {
|
||||
rawData = listRawData
|
||||
|
||||
// System.out.println("Head: " + sizes[0] + ", dates: " + sizes[1] +
|
||||
|
@ -78,7 +89,7 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
|
|||
var i = headLength
|
||||
var j = 0
|
||||
while (j < dateTimeLength) {
|
||||
datetime!![j] = listRawData!![i]!!
|
||||
datetime!![j] = listRawData[i]
|
||||
i++
|
||||
j++
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm.history
|
|||
interface MedtronicHistoryEntryInterface {
|
||||
|
||||
val entryTypeName: String?
|
||||
fun setData(listRawData: List<Byte>?, doNotProcess: Boolean)
|
||||
fun setData(listRawData: List<Byte>, doNotProcess: Boolean)
|
||||
val dateLength: Int
|
||||
}
|
|
@ -30,7 +30,7 @@ class CGMSHistoryEntry : MedtronicHistoryEntry() {
|
|||
override val entryTypeName: String
|
||||
get() = entryType!!.name
|
||||
|
||||
override fun setData(listRawData: List<Byte>?, doNotProcess: Boolean) {
|
||||
override fun setData(listRawData: List<Byte>, doNotProcess: Boolean) {
|
||||
if (entryType!!.schemaSet) {
|
||||
super.setData(listRawData, doNotProcess)
|
||||
} else {
|
||||
|
|
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil
|
|||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import kotlin.experimental.and
|
||||
|
||||
/**
|
||||
* This file was taken from GGC - GNU Gluco Control (ggc.sourceforge.net), application for diabetes
|
||||
|
@ -29,12 +30,13 @@ import javax.inject.Singleton
|
|||
*/
|
||||
@Singleton
|
||||
class MedtronicPumpHistoryDecoder @Inject constructor(
|
||||
aapsLogger: AAPSLogger?,
|
||||
medtronicUtil: MedtronicUtil?
|
||||
aapsLogger: AAPSLogger,
|
||||
medtronicUtil: MedtronicUtil
|
||||
) : MedtronicHistoryDecoder<PumpHistoryEntry>() {
|
||||
|
||||
private var tbrPreviousRecord: PumpHistoryEntry? = null
|
||||
private var changeTimeRecord: PumpHistoryEntry? = null
|
||||
|
||||
override fun createRecords(dataClear: List<Byte>): List<PumpHistoryEntry> {
|
||||
prepareStatistics()
|
||||
var counter = 0
|
||||
|
@ -42,8 +44,8 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
var incompletePacket: Boolean
|
||||
val outList: MutableList<PumpHistoryEntry> = ArrayList()
|
||||
var skipped: String? = null
|
||||
if (dataClear!!.size == 0) {
|
||||
aapsLogger!!.error(LTag.PUMPBTCOMM, "Empty page.")
|
||||
if (dataClear.size == 0) {
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "Empty page.")
|
||||
return outList
|
||||
}
|
||||
do {
|
||||
|
@ -57,13 +59,13 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
continue
|
||||
} else {
|
||||
if (skipped != null) {
|
||||
aapsLogger!!.warn(LTag.PUMPBTCOMM, " ... Skipped $skipped")
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, " ... Skipped $skipped")
|
||||
skipped = null
|
||||
skippedRecords = true
|
||||
}
|
||||
}
|
||||
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 pe = PumpHistoryEntry()
|
||||
|
@ -89,12 +91,12 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
}
|
||||
special = true
|
||||
} else {
|
||||
for (j in 0 until entryType.getTotalLength(medtronicUtil!!.medtronicPumpModel) - 1) {
|
||||
for (j in 0 until entryType.getTotalLength(medtronicUtil.medtronicPumpModel) - 1) {
|
||||
try {
|
||||
listRawData.add(dataClear[counter])
|
||||
counter++
|
||||
} 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))
|
||||
// throw ex;
|
||||
incompletePacket = true
|
||||
|
@ -115,7 +117,7 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
if (decoded === RecordDecodeStatus.OK || decoded === RecordDecodeStatus.Ignored) {
|
||||
//Log.i(TAG, "#" + record + " " + decoded.getDescription() + " " + pe);
|
||||
} else {
|
||||
aapsLogger!!.warn(LTag.PUMPBTCOMM, "#" + record + " " + decoded!!.description + " " + pe)
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "#" + record + " " + decoded!!.description + " " + pe)
|
||||
}
|
||||
addToStatistics(pe, decoded, null)
|
||||
record++
|
||||
|
@ -132,7 +134,8 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
return try {
|
||||
decodeRecord(record, false)
|
||||
} 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
|
||||
}
|
||||
}
|
||||
|
@ -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.Sensor_0x54, PumpHistoryEntryType.Sensor_0x55, PumpHistoryEntryType.Sensor_0x51, PumpHistoryEntryType.Sensor_0x52, PumpHistoryEntryType.EventUnknown_MM512_0x2e -> {
|
||||
// case EventUnknown_MM512_0x37:
|
||||
// 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")
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, " -- ignored Unknown Pump Entry: $entry")
|
||||
RecordDecodeStatus.Ignored
|
||||
}
|
||||
|
||||
|
@ -207,12 +200,10 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
PumpHistoryEntryType.None, PumpHistoryEntryType.UnknownBasePacket -> RecordDecodeStatus.Error
|
||||
|
||||
else -> {
|
||||
aapsLogger!!.debug(LTag.PUMPBTCOMM, "Not supported: " + entry.entryType)
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Not supported: " + entry.entryType)
|
||||
RecordDecodeStatus.NotSupported
|
||||
}
|
||||
}
|
||||
|
||||
// return RecordDecodeStatus.Error;
|
||||
}
|
||||
|
||||
private fun decodeDailyTotals(entry: PumpHistoryEntry): RecordDecodeStatus {
|
||||
|
@ -223,12 +214,8 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
}
|
||||
|
||||
private fun decodeBasalProfile(entry: PumpHistoryEntry): RecordDecodeStatus {
|
||||
|
||||
// LOG.debug("decodeBasalProfile: {}", entry);
|
||||
val basalProfile = BasalProfile(aapsLogger)
|
||||
basalProfile.setRawDataFromHistory(entry.body)
|
||||
|
||||
// LOG.debug("decodeBasalProfile BasalProfile: {}", basalProfile);
|
||||
entry.addDecodedData("Object", basalProfile)
|
||||
return RecordDecodeStatus.OK
|
||||
}
|
||||
|
@ -240,24 +227,21 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
}
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
private fun decodeBasalProfileStart(entry: PumpHistoryEntry): RecordDecodeStatus {
|
||||
val body = entry.body
|
||||
// int bodyOffset = headerSize + timestampSize;
|
||||
val offset = body!![0] * 1000 * 30 * 60
|
||||
var rate: Float? = null
|
||||
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
|
||||
}
|
||||
|
||||
//LOG.info("Basal Profile Start: offset={}, rate={}, index={}, body_raw={}", offset, rate, index, body);
|
||||
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
|
||||
} else {
|
||||
entry.addDecodedData("Value", getFormattedFloat(rate, 3))
|
||||
|
@ -267,26 +251,26 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
}
|
||||
|
||||
private fun decodeBolusWizard(entry: PumpHistoryEntry): RecordDecodeStatus {
|
||||
val body = entry.body as IntArray
|
||||
val body = entry.body!!
|
||||
val dto = BolusWizardDTO()
|
||||
var bolusStrokes = 10.0f
|
||||
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
|
||||
bolusStrokes = 40.0f
|
||||
dto.carbs = (body[1] and 0x0c shl 6) + body[0]
|
||||
dto.bloodGlucose = (body[1] and 0x03 shl 8) + entry.head!![0]
|
||||
dto.carbs = ((body[1] and 0x0c.toByte()).toInt() shl 6) + body[0]
|
||||
dto.bloodGlucose = ((body[1] and 0x03).toInt() shl 8) + entry.head!![0]
|
||||
dto.carbRatio = body[1] / 10.0f
|
||||
// carb_ratio (?) = (((self.body[2] & 0x07) << 8) + self.body[3]) /
|
||||
// 10.0s
|
||||
dto.insulinSensitivity = body[4].toFloat()
|
||||
dto.bgTargetLow = body[5] as Int
|
||||
dto.bgTargetHigh = body[14] as Int
|
||||
dto.correctionEstimate = ((body[9] and 0x38 shl 5) + body[6]) / bolusStrokes
|
||||
dto.foodEstimate = ((body[7] shl 8) + body[8]) / bolusStrokes
|
||||
dto.unabsorbedInsulin = ((body[10] shl 8) + body[11]) / bolusStrokes
|
||||
dto.bolusTotal = ((body[12] shl 8) + body[13]) / bolusStrokes
|
||||
dto.correctionEstimate = (((body[9] and 0x38).toInt() shl 5) + body[6]) / bolusStrokes
|
||||
dto.foodEstimate = ((body[7].toInt() shl 8) + body[8]) / bolusStrokes
|
||||
dto.unabsorbedInsulin = ((body[10].toInt() shl 8) + body[11]) / bolusStrokes
|
||||
dto.bolusTotal = ((body[12].toInt() shl 8) + body[13]) / bolusStrokes
|
||||
} 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.carbRatio = body.get(2).toFloat()
|
||||
dto.insulinSensitivity = body.get(3).toFloat()
|
||||
|
@ -308,14 +292,14 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
}
|
||||
|
||||
private fun decodeBolusWizard512(entry: PumpHistoryEntry): RecordDecodeStatus {
|
||||
val body = entry.body as IntArray
|
||||
val body = entry.body!!
|
||||
val dto = BolusWizardDTO()
|
||||
val bolusStrokes = 10.0f
|
||||
dto.bloodGlucose = body.get(1) and 0x03 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.carbRatio = body!!.get(2).toFloat()
|
||||
dto.insulinSensitivity = body!!.get(3).toFloat()
|
||||
dto.bgTargetLow = body.get(4)
|
||||
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.carbRatio = body.get(2).toFloat()
|
||||
dto.insulinSensitivity = body.get(3).toFloat()
|
||||
dto.bgTargetLow = body.get(4).toInt()
|
||||
dto.foodEstimate = body.get(6) / 10.0f
|
||||
dto.correctionEstimate = (body.get(7) + (body.get(5) and 0x0F)) / bolusStrokes
|
||||
dto.unabsorbedInsulin = body.get(9) / bolusStrokes
|
||||
|
@ -374,8 +358,8 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
|
||||
private fun decodeBolus(entry: PumpHistoryEntry) {
|
||||
val bolus = BolusDTO()
|
||||
val data = entry.head as IntArray
|
||||
if (MedtronicDeviceType.isSameDevice(medtronicUtil!!.getMedtronicPumpModel(), MedtronicDeviceType.Medtronic_523andHigher)) {
|
||||
val data = entry.head!!
|
||||
if (MedtronicDeviceType.isSameDevice(medtronicUtil.getMedtronicPumpModel(), MedtronicDeviceType.Medtronic_523andHigher)) {
|
||||
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.insulinOnBoard = ByteUtil.toInt(data.get(4), data.get(5)) / 40.0
|
||||
|
@ -433,18 +417,18 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
}
|
||||
|
||||
private fun decodeDateTime(entry: PumpHistoryEntry) {
|
||||
val dt = entry.datetime as IntArray
|
||||
if (dt == null) {
|
||||
aapsLogger!!.warn(LTag.PUMPBTCOMM, "DateTime not set.")
|
||||
if (entry.datetime==null) {
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "DateTime not set.")
|
||||
}
|
||||
val dt = entry.datetime!!
|
||||
if (entry.dateTimeLength == 5) {
|
||||
val seconds: Int = (dt!!.get(0) and 0x3F).toInt()
|
||||
val minutes: Int = (dt!!.get(1) and 0x3F).toInt()
|
||||
val seconds: Int = (dt.get(0) and 0x3F.toByte()).toInt()
|
||||
val minutes: Int = (dt.get(1) and 0x3F.toByte()).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);
|
||||
val dayOfMonth: Int = dt.get(3) and 0x1F
|
||||
val year = fix2DigitYear(dt.get(4) and 0x3F) // Assuming this is correct, need to verify. Otherwise this will be
|
||||
val dayOfMonth: Int = (dt.get(3) and 0x1F).toInt()
|
||||
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.
|
||||
entry.setAtechDateTime(DateTimeUtil.toATechDate(year, month, dayOfMonth, hour, minutes, seconds))
|
||||
} 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 month = mhigh + mlow
|
||||
// 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)
|
||||
var hour = 0
|
||||
var minutes = 0
|
||||
|
@ -461,7 +445,7 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
|
||||
//LOG.debug("DT: {} {} {}", year, month, dayOfMonth);
|
||||
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))
|
||||
}
|
||||
if (isEndResults(entry.entryType)) {
|
||||
|
@ -471,7 +455,7 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
}
|
||||
entry.setAtechDateTime(DateTimeUtil.toATechDate(year, month, dayOfMonth, hour, minutes, seconds))
|
||||
} else {
|
||||
aapsLogger!!.warn(LTag.PUMPBTCOMM, "Unknown datetime format: " + entry.dateTimeLength)
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Unknown datetime format: " + entry.dateTimeLength)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,8 @@ import java.util.*
|
|||
*/
|
||||
class PumpHistoryEntry : MedtronicHistoryEntry() {
|
||||
|
||||
@Expose var entryType: PumpHistoryEntryType? = null
|
||||
@Expose
|
||||
var entryType: PumpHistoryEntryType? = null
|
||||
private set
|
||||
|
||||
override var opCode: Byte? = null
|
||||
|
@ -27,16 +28,12 @@ class PumpHistoryEntry : MedtronicHistoryEntry() {
|
|||
field = value
|
||||
}
|
||||
|
||||
// // override fun getOpCode(): Int {
|
||||
// // return
|
||||
// // }
|
||||
//
|
||||
// fun setOpCode(opCode: Int?) {
|
||||
// this.opCode = opCode
|
||||
// }
|
||||
|
||||
var offset = 0
|
||||
var displayableValue = ""
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
}
|
||||
|
||||
fun setEntryType(medtronicDeviceType: MedtronicDeviceType?, entryType: PumpHistoryEntryType) {
|
||||
this.entryType = entryType
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.*
|
|||
* Author: Andy {andy.rozman@gmail.com}
|
||||
*/
|
||||
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
|
||||
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), //
|
||||
ChangeChildBlockEnable(0x23, "Change Child Block Enable", PumpHistoryEntryGroup.Configuration), //
|
||||
ChangeMaxBolus(0x24, "Change Max Bolus", PumpHistoryEntryGroup.Configuration), //
|
||||
|
||||
// /**/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
|
||||
ChangeRemoteId(0x27, "Change Remote ID", PumpHistoryEntryGroup.Configuration), // ??
|
||||
ChangeMaxBasal(0x2c, "Change Max Basal", PumpHistoryEntryGroup.Configuration), //
|
||||
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), //
|
||||
UnabsorbedInsulin512(0x30, "Unabsorbed Insulin (512)", PumpHistoryEntryGroup.Statistic, 5, 0, 0), // FIXME
|
||||
ChangeBGReminderOffset(0x31, "Change BG Reminder Offset", PumpHistoryEntryGroup.Configuration), //
|
||||
|
@ -57,13 +54,10 @@ enum class PumpHistoryEntryType // implements CodeEnum
|
|||
LowReservoir(0x34, "Low Reservoir", PumpHistoryEntryGroup.Notification), //
|
||||
ChangeAlarmClock(0x35, "Change Alarm Clock", PumpHistoryEntryGroup.Configuration), //
|
||||
ChangeMeterId(0x36, "Change Meter ID", PumpHistoryEntryGroup.Configuration), //
|
||||
|
||||
// /**/EventUnknown_MM512_0x37(0x37, "Unknown Event 0x37", PumpHistoryEntryGroup.Unknown), // V:MM512
|
||||
// /**/EventUnknown_MM512_0x38(0x38, "Unknown Event 0x38", PumpHistoryEntryGroup.Unknown), //
|
||||
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), //
|
||||
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
|
||||
JournalEntryExerciseMarker(0x41, "Exercise Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 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), //
|
||||
|
||||
// /**/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_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), //
|
||||
ChangeSensorSetup2(0x50, "Sensor Setup2", PumpHistoryEntryGroup.Configuration, 2, 5, 30), // Ian50
|
||||
|
||||
/* TODO */
|
||||
Sensor_0x51(0x51, "Unknown Event 0x51", PumpHistoryEntryGroup.Unknown), //
|
||||
|
||||
/* TODO */
|
||||
Sensor_0x52(0x52, "Unknown Event 0x52", PumpHistoryEntryGroup.Unknown), //
|
||||
/* TODO */ Sensor_0x51(0x51, "Unknown Event 0x51", PumpHistoryEntryGroup.Unknown), //
|
||||
/* TODO */ Sensor_0x52(0x52, "Unknown Event 0x52", PumpHistoryEntryGroup.Unknown), //
|
||||
ChangeSensorAlarmSilenceConfig(0x53, "Sensor Alarm Silence Config", PumpHistoryEntryGroup.Configuration, 2, 5, 1), // 8
|
||||
|
||||
/* TODO */
|
||||
Sensor_0x54(0x54, "Unknown Event 0x54", PumpHistoryEntryGroup.Unknown), // Ian54
|
||||
|
||||
/* TODO */
|
||||
Sensor_0x55(0x55, "Unknown Event 0x55", PumpHistoryEntryGroup.Unknown), //
|
||||
/* TODO */ 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
|
||||
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]
|
||||
|
@ -124,7 +110,6 @@ enum class PumpHistoryEntryType // implements CodeEnum
|
|||
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
|
||||
ChangeCarbUnits(0x6f.toByte(), "Change Carb Units", PumpHistoryEntryGroup.Configuration), //
|
||||
|
||||
// /**/EventUnknown_MM522_0x70((byte) 0x70, "Unknown Event 0x70", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
||||
BasalProfileStart(0x7b, "Basal Profile Start", PumpHistoryEntryGroup.Basal, 2, 5, 3), // // 722
|
||||
ChangeWatchdogEnable(0x7c, "Change Watchdog Enable", PumpHistoryEntryGroup.Configuration), //
|
||||
|
@ -158,7 +143,7 @@ enum class PumpHistoryEntryType // implements CodeEnum
|
|||
ChangeSensorSetup2.addSpecialRuleBody(SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 34))
|
||||
}
|
||||
|
||||
@JvmStatic fun getByCode(opCode: Byte): PumpHistoryEntryType? {
|
||||
fun getByCode(opCode: Byte): PumpHistoryEntryType? {
|
||||
return if (opCodeMap.containsKey(opCode)) {
|
||||
opCodeMap[opCode]
|
||||
} 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 {
|
||||
return entryType == Bolus || // Treatments
|
||||
entryType == TempBasalRate || //
|
||||
|
@ -215,8 +188,11 @@ enum class PumpHistoryEntryType // implements CodeEnum
|
|||
}
|
||||
|
||||
val code: Byte
|
||||
private val description: String?
|
||||
private val headLength: Int
|
||||
|
||||
val description: String?
|
||||
get() = field
|
||||
|
||||
val headLength: Int
|
||||
val dateLength: Int
|
||||
|
||||
// private MinimedDeviceType deviceType;
|
||||
|
@ -228,22 +204,25 @@ enum class PumpHistoryEntryType // implements CodeEnum
|
|||
private var specialRulesHead: MutableList<SpecialRule>? = null
|
||||
private var specialRulesBody: MutableList<SpecialRule>? = null
|
||||
private var hasSpecialRules = false
|
||||
get() = field
|
||||
|
||||
val group: PumpHistoryEntryGroup
|
||||
get() = field
|
||||
|
||||
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) {}
|
||||
|
||||
fun getTotalLength(medtronicDeviceType: MedtronicDeviceType?): Int {
|
||||
return if (hasSpecialRules()) {
|
||||
return if (hasSpecialRules) {
|
||||
getHeadLength(medtronicDeviceType) + getBodyLength(medtronicDeviceType) + dateLength
|
||||
} else {
|
||||
totalLength
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasSpecialRules(): Boolean {
|
||||
return hasSpecialRules
|
||||
}
|
||||
// private fun hasSpecialRules(): Boolean {
|
||||
// return hasSpecialRules
|
||||
// }
|
||||
|
||||
fun addSpecialRuleHead(rule: SpecialRule) {
|
||||
if (isEmpty(specialRulesHead)) {
|
||||
|
@ -261,9 +240,9 @@ enum class PumpHistoryEntryType // implements CodeEnum
|
|||
hasSpecialRules = true
|
||||
}
|
||||
|
||||
fun getDescription(): String {
|
||||
return description ?: name
|
||||
}
|
||||
// fun getDescription(): String {
|
||||
// return description ?: name
|
||||
// }
|
||||
|
||||
fun getHeadLength(medtronicDeviceType: MedtronicDeviceType?): Int {
|
||||
return if (hasSpecialRules) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
// }
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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)
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
|
@ -204,7 +204,7 @@ public class MedtronicHistoryData {
|
|||
} else {
|
||||
|
||||
if (type == PumpHistoryEntryType.EndResultTotals) {
|
||||
if (!DateTimeUtil.isSameDay(atechDate, pumpHistoryEntry.atechDateTime)) {
|
||||
if (!DateTimeUtil.isSameDay(atechDate, pumpHistoryEntry.getAtechDateTime())) {
|
||||
newHistory2.add(pumpHistoryEntry);
|
||||
}
|
||||
} else {
|
||||
|
@ -239,7 +239,7 @@ public class MedtronicHistoryData {
|
|||
|
||||
for (PumpHistoryEntry bolusEstimate : bolusEstimates) {
|
||||
for (PumpHistoryEntry bolus : boluses) {
|
||||
if (bolusEstimate.atechDateTime.equals(bolus.atechDateTime)) {
|
||||
if (bolusEstimate.getAtechDateTime().equals(bolus.getAtechDateTime())) {
|
||||
bolus.addDecodedData("Estimate", bolusEstimate.getDecodedData().get("Object"));
|
||||
}
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ public class MedtronicHistoryData {
|
|||
|
||||
// find last entry
|
||||
for (PumpHistoryEntry pumpHistoryEntry : newHistory) {
|
||||
if (pumpHistoryEntry.atechDateTime != null && pumpHistoryEntry.isAfter(pheLast.atechDateTime)) {
|
||||
if (pumpHistoryEntry.getAtechDateTime() != null && pumpHistoryEntry.isAfter(pheLast.getAtechDateTime())) {
|
||||
pheLast = pumpHistoryEntry;
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ public class MedtronicHistoryData {
|
|||
|
||||
if (!this.allHistory.contains(pumpHistoryEntry)) {
|
||||
lastIdUsed++;
|
||||
pumpHistoryEntry.id = lastIdUsed;
|
||||
pumpHistoryEntry.setId(lastIdUsed);
|
||||
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
|
||||
return;
|
||||
|
||||
this.setLastHistoryRecordTime(pheLast.atechDateTime);
|
||||
sp.putLong(MedtronicConst.Statistics.LastPumpHistoryEntry, pheLast.atechDateTime);
|
||||
this.setLastHistoryRecordTime(pheLast.getAtechDateTime());
|
||||
sp.putLong(MedtronicConst.Statistics.LastPumpHistoryEntry, pheLast.getAtechDateTime());
|
||||
|
||||
LocalDateTime dt = null;
|
||||
|
||||
try {
|
||||
dt = DateTimeUtil.toLocalDateTime(pheLast.atechDateTime);
|
||||
dt = DateTimeUtil.toLocalDateTime(pheLast.getAtechDateTime());
|
||||
} catch (Exception ex) {
|
||||
aapsLogger.error("Problem decoding date from last record: " + pheLast);
|
||||
}
|
||||
|
@ -537,9 +537,9 @@ public class MedtronicHistoryData {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (primeRecord.atechDateTime > maxAllowedTimeInPast) {
|
||||
if (lastPrimeRecord < primeRecord.atechDateTime) {
|
||||
lastPrimeRecord = primeRecord.atechDateTime;
|
||||
if (primeRecord.getAtechDateTime() > maxAllowedTimeInPast) {
|
||||
if (lastPrimeRecord < primeRecord.getAtechDateTime()) {
|
||||
lastPrimeRecord = primeRecord.getAtechDateTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -560,9 +560,9 @@ public class MedtronicHistoryData {
|
|||
long lastRewindRecord = 0L;
|
||||
|
||||
for (PumpHistoryEntry rewindRecord : rewindRecords) {
|
||||
if (rewindRecord.atechDateTime > maxAllowedTimeInPast) {
|
||||
if (lastRewindRecord < rewindRecord.atechDateTime) {
|
||||
lastRewindRecord = rewindRecord.atechDateTime;
|
||||
if (rewindRecord.getAtechDateTime() > maxAllowedTimeInPast) {
|
||||
if (lastRewindRecord < rewindRecord.getAtechDateTime()) {
|
||||
lastRewindRecord = rewindRecord.getAtechDateTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -593,7 +593,7 @@ public class MedtronicHistoryData {
|
|||
|
||||
for (PumpHistoryEntry tdd : tdds) {
|
||||
|
||||
TDD tddDbEntry = findTDD(tdd.atechDateTime, tddsDb);
|
||||
TDD tddDbEntry = findTDD(tdd.getAtechDateTime(), tddsDb);
|
||||
|
||||
DailyTotalsDTO totalsDTO = (DailyTotalsDTO) tdd.getDecodedData().get("Object");
|
||||
|
||||
|
@ -839,7 +839,7 @@ public class MedtronicHistoryData {
|
|||
*/
|
||||
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);
|
||||
|
||||
|
@ -856,10 +856,10 @@ public class MedtronicHistoryData {
|
|||
|
||||
// TODO: Fix db code
|
||||
// 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)
|
||||
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 (doubleBolusDebug)
|
||||
|
@ -970,7 +970,7 @@ public class MedtronicHistoryData {
|
|||
case Normal: {
|
||||
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.setPumpSerial(medtronicPumpStatus.serialNumber);
|
||||
detailedBolusInfo.setBolusPumpId(bolus.getPumpId());
|
||||
|
@ -993,7 +993,7 @@ public class MedtronicHistoryData {
|
|||
case Audio:
|
||||
case Extended: {
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus(injector);
|
||||
extendedBolus.date = tryToGetByLocalTime(bolus.atechDateTime);
|
||||
extendedBolus.date = tryToGetByLocalTime(bolus.getAtechDateTime());
|
||||
extendedBolus.source = Source.PUMP;
|
||||
extendedBolus.insulin = bolusDTO.getDeliveredAmount();
|
||||
extendedBolus.pumpId = bolus.getPumpId();
|
||||
|
@ -1060,7 +1060,7 @@ public class MedtronicHistoryData {
|
|||
|
||||
if (temporaryBasalDb == null) {
|
||||
temporaryBasalDb = new TemporaryBasal(injector);
|
||||
temporaryBasalDb.date = tryToGetByLocalTime(treatment.atechDateTime);
|
||||
temporaryBasalDb.date = tryToGetByLocalTime(treatment.getAtechDateTime());
|
||||
|
||||
operation = "addTBR";
|
||||
}
|
||||
|
@ -1094,7 +1094,7 @@ public class MedtronicHistoryData {
|
|||
if (tempBasal == null) {
|
||||
// add
|
||||
tempBasal = new TemporaryBasal(injector);
|
||||
tempBasal.date = tryToGetByLocalTime(tempBasalProcess.itemOne.atechDateTime);
|
||||
tempBasal.date = tryToGetByLocalTime(tempBasalProcess.itemOne.getAtechDateTime());
|
||||
|
||||
tempBasal.source = Source.PUMP;
|
||||
tempBasal.pumpId = tempBasalProcess.itemOne.getPumpId();
|
||||
|
@ -1346,8 +1346,8 @@ public class MedtronicHistoryData {
|
|||
|
||||
for (PumpHistoryEntry treatment : treatments) {
|
||||
|
||||
if (treatment.atechDateTime < dt) {
|
||||
dt = treatment.atechDateTime;
|
||||
if (treatment.getAtechDateTime() < dt) {
|
||||
dt = treatment.getAtechDateTime();
|
||||
currentTreatment = treatment;
|
||||
}
|
||||
}
|
||||
|
@ -1386,8 +1386,8 @@ public class MedtronicHistoryData {
|
|||
|
||||
for (PumpHistoryEntry treatment : treatments) {
|
||||
|
||||
if (treatment.atechDateTime < dt) {
|
||||
dt = treatment.atechDateTime;
|
||||
if (treatment.getAtechDateTime() < dt) {
|
||||
dt = treatment.getAtechDateTime();
|
||||
currentTreatment = treatment;
|
||||
}
|
||||
}
|
||||
|
@ -1469,9 +1469,9 @@ public class MedtronicHistoryData {
|
|||
|
||||
for (PumpHistoryEntry filteredItem : filteredItems) {
|
||||
|
||||
if (lastDate == null || lastDate < filteredItem.atechDateTime) {
|
||||
if (lastDate == null || lastDate < filteredItem.getAtechDateTime()) {
|
||||
newProfile = filteredItem;
|
||||
lastDate = newProfile.atechDateTime;
|
||||
lastDate = newProfile.getAtechDateTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1517,13 +1517,13 @@ public class MedtronicHistoryData {
|
|||
Map<String, PumpHistoryEntry> map = new HashMap<>();
|
||||
|
||||
for (PumpHistoryEntry pumpHistoryEntry : TBRs_Input) {
|
||||
if (map.containsKey(pumpHistoryEntry.DT)) {
|
||||
medtronicPumpHistoryDecoder.decodeTempBasal(map.get(pumpHistoryEntry.DT), pumpHistoryEntry);
|
||||
if (map.containsKey(pumpHistoryEntry.getDT())) {
|
||||
medtronicPumpHistoryDecoder.decodeTempBasal(map.get(pumpHistoryEntry.getDT()), pumpHistoryEntry);
|
||||
pumpHistoryEntry.setEntryType(medtronicUtil.getMedtronicPumpModel(), PumpHistoryEntryType.TempBasalCombined);
|
||||
TBRs.add(pumpHistoryEntry);
|
||||
map.remove(pumpHistoryEntry.DT);
|
||||
map.remove(pumpHistoryEntry.getDT());
|
||||
} else {
|
||||
map.put(pumpHistoryEntry.DT, pumpHistoryEntry);
|
||||
map.put(pumpHistoryEntry.getDT(), pumpHistoryEntry);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,15 +74,15 @@ public class DailyTotalsDTO {
|
|||
break;
|
||||
|
||||
case DailyTotals515:
|
||||
decodeDailyTotals515(entry.body);
|
||||
decodeDailyTotals515(entry.getBody());
|
||||
break;
|
||||
|
||||
case DailyTotals522:
|
||||
decodeDailyTotals522(entry.body);
|
||||
decodeDailyTotals522(entry.getBody());
|
||||
break;
|
||||
|
||||
case DailyTotals523:
|
||||
decodeDailyTotals523(entry.body);
|
||||
decodeDailyTotals523(entry.getBody());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -96,18 +96,18 @@ public class DailyTotalsDTO {
|
|||
private void setDisplayable() {
|
||||
|
||||
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 {
|
||||
this.entry.displayableValue = "Basal Insulin: " + StringUtil.getFormatedValueUS(this.insulinBasal, 2)
|
||||
+ ", Total Insulin: " + StringUtil.getFormatedValueUS(this.insulinTotal, 2);
|
||||
this.entry.setDisplayableValue("Basal Insulin: " + StringUtil.getFormatedValueUS(this.insulinBasal, 2)
|
||||
+ ", Total Insulin: " + StringUtil.getFormatedValueUS(this.insulinTotal, 2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void decodeEndResultsTotals(PumpHistoryEntry entry) {
|
||||
double totals = ByteUtil.toInt((int) entry.head[0], (int) entry.head[1], (int) entry.head[2],
|
||||
(int) entry.head[3], ByteUtil.BitConversion.BIG_ENDIAN) * 0.025d;
|
||||
double totals = ByteUtil.toInt((int) entry.getHead()[0], (int) entry.getHead()[1], (int) entry.getHead()[2],
|
||||
(int) entry.getHead()[3], ByteUtil.BitConversion.BIG_ENDIAN) * 0.025d;
|
||||
|
||||
this.insulinTotal = totals;
|
||||
|
||||
|
@ -241,7 +241,7 @@ public class DailyTotalsDTO {
|
|||
}
|
||||
|
||||
public void setTDD(TDD tdd) {
|
||||
tdd.date = DateTimeUtil.toMillisFromATD(this.entry.atechDateTime);
|
||||
tdd.date = DateTimeUtil.toMillisFromATD(this.entry.getAtechDateTime());
|
||||
tdd.basal = insulinBasal;
|
||||
tdd.bolus = insulinBolus;
|
||||
tdd.total = insulinTotal;
|
||||
|
|
|
@ -15,7 +15,7 @@ public class TempBasalProcessDTO {
|
|||
TempBasalPair tbr = (TempBasalPair) itemOne.getDecodedDataEntry("Object");
|
||||
return tbr.getDurationMinutes();
|
||||
} else {
|
||||
int difference = DateTimeUtil.getATechDateDiferenceAsMinutes(itemOne.atechDateTime, itemTwo.atechDateTime);
|
||||
int difference = DateTimeUtil.getATechDateDiferenceAsMinutes(itemOne.getAtechDateTime(), itemTwo.getAtechDateTime());
|
||||
return difference;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.di
|
||||
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
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.comm.MedtronicCommunicationManager
|
||||
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 medtronicUITaskProvider(): MedtronicUITask
|
||||
@ContributesAndroidInjector abstract fun contributesRileyLinkStatusDeviceMedtronic(): RileyLinkStatusDeviceMedtronic
|
||||
|
||||
companion object {
|
||||
@Provides
|
||||
fun byteUtilProvider(): ByteUtil = ByteUtil();
|
||||
}
|
||||
}
|
|
@ -59,7 +59,7 @@ public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
|
|||
this.filteredHistoryList.addAll(list);
|
||||
} else {
|
||||
for (PumpHistoryEntry pumpHistoryEntry : list) {
|
||||
if (pumpHistoryEntry.getEntryType().group == group) {
|
||||
if (pumpHistoryEntry.getEntryType().getGroup() == group) {
|
||||
this.filteredHistoryList.add(pumpHistoryEntry);
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
|
|||
if (record != null) {
|
||||
holder.timeView.setText(record.getDateTimeString());
|
||||
holder.typeView.setText(record.getEntryType().getDescription());
|
||||
holder.valueView.setText(record.displayableValue);
|
||||
holder.valueView.setText(record.getDisplayableValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public class PumpHistoryEntryUTest {
|
|||
long queryObject = 20191009000000L;
|
||||
|
||||
PumpHistoryEntry phe = new PumpHistoryEntry();
|
||||
phe.atechDateTime = dateObject;
|
||||
phe.setAtechDateTime(dateObject);
|
||||
|
||||
Assert.assertTrue(phe.isAfter(queryObject));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue