do not use last record in DetailedBolusInfoStorage
This commit is contained in:
parent
bee6d289c0
commit
5ef92462a7
2 changed files with 15 additions and 12 deletions
|
@ -29,7 +29,7 @@ class DetailedBolusInfoStorage @Inject constructor(
|
||||||
val d = store[i]
|
val d = store[i]
|
||||||
//aapsLogger.debug(LTag.PUMP, "Existing bolus info: " + store[i])
|
//aapsLogger.debug(LTag.PUMP, "Existing bolus info: " + store[i])
|
||||||
if (bolusTime > d.timestamp - T.mins(1).msecs() && bolusTime < d.timestamp + T.mins(1).msecs() && abs(store[i].insulin - bolus) < 0.01) {
|
if (bolusTime > d.timestamp - T.mins(1).msecs() && bolusTime < d.timestamp + T.mins(1).msecs() && abs(store[i].insulin - bolus) < 0.01) {
|
||||||
aapsLogger.debug(LTag.PUMP, "Using & removing bolus info: ${store[i]}")
|
aapsLogger.debug(LTag.PUMP, "Using & removing bolus info for time $bolusTime: ${store[i]}")
|
||||||
store.removeAt(i)
|
store.removeAt(i)
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
@ -38,22 +38,22 @@ class DetailedBolusInfoStorage @Inject constructor(
|
||||||
for (i in store.indices) {
|
for (i in store.indices) {
|
||||||
val d = store[i]
|
val d = store[i]
|
||||||
if (bolusTime > d.timestamp - T.mins(1).msecs() && bolusTime < d.timestamp + T.mins(1).msecs() && bolus <= store[i].insulin + 0.01) {
|
if (bolusTime > d.timestamp - T.mins(1).msecs() && bolusTime < d.timestamp + T.mins(1).msecs() && bolus <= store[i].insulin + 0.01) {
|
||||||
aapsLogger.debug(LTag.PUMP, "Using TIME-ONLY & removing bolus info: ${store[i]}")
|
aapsLogger.debug(LTag.PUMP, "Using TIME-ONLY & removing bolus info for time $bolusTime: ${store[i]}")
|
||||||
store.removeAt(i)
|
store.removeAt(i)
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If not found, use last record if amount is the same
|
// If not found, use last record if amount is the same
|
||||||
if (store.size > 0) {
|
// if (store.size > 0) {
|
||||||
val d = store[store.size - 1]
|
// val d = store[store.size - 1]
|
||||||
if (abs(d.insulin - bolus) < 0.01) {
|
// if (abs(d.insulin - bolus) < 0.01) {
|
||||||
aapsLogger.debug(LTag.PUMP, "Using LAST & removing bolus info: $d")
|
// aapsLogger.debug(LTag.PUMP, "Using LAST & removing bolus info for time $bolusTime: $d")
|
||||||
store.removeAt(store.size - 1)
|
// store.removeAt(store.size - 1)
|
||||||
return d
|
// return d
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
//Not found
|
//Not found
|
||||||
//aapsLogger.debug(LTag.PUMP, "Bolus info not found")
|
aapsLogger.debug(LTag.PUMP, "Bolus info not found for time $bolusTime")
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -323,13 +323,16 @@ class BLEComm @Inject internal constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private val readBuffer = ByteArray(1024)
|
private val readBuffer = ByteArray(1024)
|
||||||
private var bufferLength = 0
|
@Volatile private var bufferLength = 0
|
||||||
|
|
||||||
private fun addToReadBuffer(buffer: ByteArray) {
|
private fun addToReadBuffer(buffer: ByteArray) {
|
||||||
//log.debug("addToReadBuffer " + DanaRS_Packet.toHexString(buffer));
|
//log.debug("addToReadBuffer " + DanaRS_Packet.toHexString(buffer));
|
||||||
if (buffer.isEmpty()) {
|
if (buffer.isEmpty()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (bufferLength == 1024) {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "1024 XXXXXXXXXXXXXX")
|
||||||
|
}
|
||||||
synchronized(readBuffer) {
|
synchronized(readBuffer) {
|
||||||
// Append incoming data to input buffer
|
// Append incoming data to input buffer
|
||||||
System.arraycopy(buffer, 0, readBuffer, bufferLength, buffer.size)
|
System.arraycopy(buffer, 0, readBuffer, bufferLength, buffer.size)
|
||||||
|
|
Loading…
Reference in a new issue