fix Dana history parsing
This commit is contained in:
parent
2845bc8714
commit
763c0bb766
1 changed files with 9 additions and 7 deletions
|
@ -86,7 +86,7 @@ open class DanaRS_Packet_APS_History_Events(
|
||||||
// but on pump is running
|
// but on pump is running
|
||||||
// at least on Model: 05 Protocol: 10 Code: 10
|
// at least on Model: 05 Protocol: 10 Code: 10
|
||||||
if (index > 0 && recordCode(message) == DanaPump.TEMPSTOP) {
|
if (index > 0 && recordCode(message) == DanaPump.TEMPSTOP) {
|
||||||
val previous = sorted[index-1]
|
val previous = sorted[index - 1]
|
||||||
if (recordCode(previous) == DanaPump.TEMPSTART && dateTime(message) == dateTime(previous)) {
|
if (recordCode(previous) == DanaPump.TEMPSTART && dateTime(message) == dateTime(previous)) {
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "SKIPPING EVENT TEMPSTOP (" + recordCode(message) + ") " + dateUtil.dateAndTimeString(dateTime(message)) + " (" + dateTime(message) + ")")
|
aapsLogger.debug(LTag.PUMPCOMM, "SKIPPING EVENT TEMPSTOP (" + recordCode(message) + ") " + dateUtil.dateAndTimeString(dateTime(message)) + " (" + dateTime(message) + ")")
|
||||||
continue
|
continue
|
||||||
|
@ -102,13 +102,16 @@ open class DanaRS_Packet_APS_History_Events(
|
||||||
if (!danaPump.usingUTC) dateTimeSecFromBuff(data, 1) // 6 bytes
|
if (!danaPump.usingUTC) dateTimeSecFromBuff(data, 1) // 6 bytes
|
||||||
else intFromBuffMsbLsb(data, 3, 4) * 1000L
|
else intFromBuffMsbLsb(data, 3, 4) * 1000L
|
||||||
|
|
||||||
fun recordCode(data: ByteArray): Int =
|
private fun recordCode(data: ByteArray): Int =
|
||||||
intFromBuff(data, 0, 1).toInt()
|
if (!danaPump.usingUTC)
|
||||||
|
intFromBuff(data, 0, 1)
|
||||||
|
else
|
||||||
|
intFromBuff(data, 2, 1)
|
||||||
|
|
||||||
fun processMessage(data: ByteArray) {
|
fun processMessage(data: ByteArray) {
|
||||||
var recordCode = intFromBuff(data, 0, 1).toByte()
|
val recordCode = recordCode(data)
|
||||||
// Last record
|
// Last record
|
||||||
if (recordCode == 0xFF.toByte()) {
|
if (recordCode == 0xFF) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val datetime: Long
|
val datetime: Long
|
||||||
|
@ -121,12 +124,11 @@ open class DanaRS_Packet_APS_History_Events(
|
||||||
pumpId = datetime
|
pumpId = datetime
|
||||||
} else {
|
} else {
|
||||||
datetime = intFromBuffMsbLsb(data, 3, 4) * 1000L
|
datetime = intFromBuffMsbLsb(data, 3, 4) * 1000L
|
||||||
recordCode = intFromBuff(data, 2, 1).toByte()
|
|
||||||
id = intFromBuffMsbLsb(data, 0, 2) // range only 1-2000
|
id = intFromBuffMsbLsb(data, 0, 2) // range only 1-2000
|
||||||
pumpId = datetime shl 16 + id
|
pumpId = datetime shl 16 + id
|
||||||
}
|
}
|
||||||
val status: String
|
val status: String
|
||||||
when (recordCode.toInt()) {
|
when (recordCode) {
|
||||||
DanaPump.TEMPSTART -> {
|
DanaPump.TEMPSTART -> {
|
||||||
val temporaryBasalInfo = temporaryBasalStorage.findTemporaryBasal(datetime, param1.toDouble())
|
val temporaryBasalInfo = temporaryBasalStorage.findTemporaryBasal(datetime, param1.toDouble())
|
||||||
val newRecord = pumpSync.syncTemporaryBasalWithPumpId(
|
val newRecord = pumpSync.syncTemporaryBasalWithPumpId(
|
||||||
|
|
Loading…
Reference in a new issue