commit
273b09b2c0
|
@ -19,6 +19,9 @@ class DiaconnG8Pump @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger,
|
private val aapsLogger: AAPSLogger,
|
||||||
private val dateUtil: DateUtil
|
private val dateUtil: DateUtil
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
var isPumplogUploadFailed: Boolean = false
|
||||||
|
|
||||||
//var bleResultInfo: Pair<Int?, Boolean> = Pair(null, false)
|
//var bleResultInfo: Pair<Int?, Boolean> = Pair(null, false)
|
||||||
var bolusConfirmMessage: Byte = 0
|
var bolusConfirmMessage: Byte = 0
|
||||||
var isReadyToBolus: Boolean = false
|
var isReadyToBolus: Boolean = false
|
||||||
|
|
|
@ -846,6 +846,8 @@ class BigLogInquireResponsePacket(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
override fun onFailure(call: Call<ApiResponse>, t: Throwable) {
|
override fun onFailure(call: Call<ApiResponse>, t: Throwable) {
|
||||||
|
aapsLogger.error(LTag.PUMPCOMM, "api uploadPumplogs failed")
|
||||||
|
diaconnG8Pump.isPumplogUploadFailed = true
|
||||||
t.printStackTrace()
|
t.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,6 +270,11 @@ class BLECommonService @Inject internal constructor(
|
||||||
val bytes = message.encode(sequence)
|
val bytes = message.encode(sequence)
|
||||||
processedMessageByte = bytes
|
processedMessageByte = bytes
|
||||||
|
|
||||||
|
if (bluetoothGatt == null) {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> IGNORING (NOT CONNECTED) " + message.friendlyName )
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "sendMessage() before mSendQueue.size :: ${mSendQueue.size}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "sendMessage() before mSendQueue.size :: ${mSendQueue.size}")
|
||||||
// 펌프에 요청 보내기.
|
// 펌프에 요청 보내기.
|
||||||
writeCharacteristicNoResponse(uartWriteBTGattChar, bytes)
|
writeCharacteristicNoResponse(uartWriteBTGattChar, bytes)
|
||||||
|
|
|
@ -293,7 +293,7 @@ class DiaconnG8Service : DaggerService() {
|
||||||
|
|
||||||
// pump log loop size
|
// pump log loop size
|
||||||
val pumpLogPageSize = 11
|
val pumpLogPageSize = 11
|
||||||
val (start, end, loopSize) = getLogLoopCount(apsLastLogNum, apsWrappingCount, pumpLastNum, pumpWrappingCount, false)
|
val (start, end, loopSize) = getLogLoopCount(apsLastLogNum, apsWrappingCount, pumpLastNum, pumpWrappingCount)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "loopinfo start : $start, end : $end, loopSize : $loopSize")
|
aapsLogger.debug(LTag.PUMPCOMM, "loopinfo start : $start, end : $end, loopSize : $loopSize")
|
||||||
// log sync start!
|
// log sync start!
|
||||||
if (loopSize > 0) {
|
if (loopSize > 0) {
|
||||||
|
@ -326,10 +326,13 @@ class DiaconnG8Service : DaggerService() {
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "platformLogNo: $platformLogNo, platformWrappingCount: $platformWrappingCount")
|
aapsLogger.debug(LTag.PUMPCOMM, "platformLogNo: $platformLogNo, platformWrappingCount: $platformWrappingCount")
|
||||||
|
|
||||||
// 페이지 사이즈로 처리할 때 루핑 횟수 계산
|
// 페이지 사이즈로 처리할 때 루핑 횟수 계산
|
||||||
val (platformStart, platformEnd, platformLoopSize) = getLogLoopCount(platformLogNo, platformWrappingCount, pumpLastNum, pumpWrappingCount, true)
|
val (platformStart, platformEnd, platformLoopSize) = getCloudLogLoopCount(platformLastNo.toInt(), platformLogNo, platformWrappingCount, pumpLastNum, pumpWrappingCount)
|
||||||
if(platformLoopSize > 0) {
|
if(platformLoopSize > 0) {
|
||||||
diaconnG8Pump.isPlatformUploadStarted = true
|
diaconnG8Pump.isPlatformUploadStarted = true
|
||||||
for (i in 0 until platformLoopSize) {
|
for (i in 0 until platformLoopSize) {
|
||||||
|
if(diaconnG8Pump.isPumplogUploadFailed) {
|
||||||
|
break
|
||||||
|
}
|
||||||
rxBus.send(EventPumpStatusChanged("클라우드동기화 진행 중 : $i / $platformLoopSize"))
|
rxBus.send(EventPumpStatusChanged("클라우드동기화 진행 중 : $i / $platformLoopSize"))
|
||||||
val startLogNo: Int = platformStart + i * pumpLogPageSize
|
val startLogNo: Int = platformStart + i * pumpLogPageSize
|
||||||
val endLogNo: Int = startLogNo + min(platformEnd - startLogNo, pumpLogPageSize)
|
val endLogNo: Int = startLogNo + min(platformEnd - startLogNo, pumpLogPageSize)
|
||||||
|
@ -338,6 +341,7 @@ class DiaconnG8Service : DaggerService() {
|
||||||
}
|
}
|
||||||
SystemClock.sleep(1000)
|
SystemClock.sleep(1000)
|
||||||
diaconnG8Pump.isPlatformUploadStarted = false
|
diaconnG8Pump.isPlatformUploadStarted = false
|
||||||
|
diaconnG8Pump.isPumplogUploadFailed = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e:Exception) {
|
} catch (e:Exception) {
|
||||||
|
@ -347,22 +351,39 @@ class DiaconnG8Service : DaggerService() {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getLogLoopCount(lastLogNum: Int, wrappingCount: Int, pumpLastNum: Int, pumpWrappingCount: Int, isPlatform: Boolean): Triple<Int, Int, Int> {
|
private fun getLogLoopCount(lastLogNum: Int, wrappingCount: Int, pumpLastNum: Int, pumpWrappingCount: Int): Triple<Int, Int, Int> {
|
||||||
val start: Int// log sync start number
|
val start: Int// log sync start number
|
||||||
val end: Int // log sync end number1311
|
val end: Int // log sync end number1311
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "lastLogNum : $lastLogNum, wrappingCount : $wrappingCount , pumpLastNum: $pumpLastNum, pumpWrappingCount : $pumpWrappingCount")
|
aapsLogger.debug(LTag.PUMPCOMM, "lastLogNum : $lastLogNum, wrappingCount : $wrappingCount , pumpLastNum: $pumpLastNum, pumpWrappingCount : $pumpWrappingCount")
|
||||||
|
|
||||||
if ((pumpWrappingCount * 10000 + pumpLastNum - lastLogNum > 10000 && isPlatform)) {
|
if (pumpWrappingCount > wrappingCount && lastLogNum < 9999) {
|
||||||
start = pumpLastNum
|
|
||||||
end = 10000
|
|
||||||
} else if (pumpWrappingCount > wrappingCount && lastLogNum < 9999) {
|
|
||||||
start = (lastLogNum + 1)
|
start = (lastLogNum + 1)
|
||||||
end = 10000
|
end = 10000
|
||||||
} else if (pumpWrappingCount > wrappingCount && lastLogNum >= 9999 && isPlatform) {
|
} else {
|
||||||
|
start = (lastLogNum + 1)
|
||||||
|
end = pumpLastNum
|
||||||
|
}
|
||||||
|
val size = ceil((end - start) / 11.0).toInt()
|
||||||
|
//
|
||||||
|
return Triple(start, end, size)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getCloudLogLoopCount(platformLastNo:Int, PlatformPumpLogNum: Int, wrappingCount: Int, pumpLastNum: Int, pumpWrappingCount: Int): Triple<Int, Int, Int> {
|
||||||
|
val start: Int// log sync start number
|
||||||
|
val end: Int // log sync end number1311
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "platformLastNo: $platformLastNo, PlatformPumpLogNum : $PlatformPumpLogNum, wrappingCount : $wrappingCount , pumpLastNum: $pumpLastNum, pumpWrappingCount :$pumpWrappingCount")
|
||||||
|
|
||||||
|
if ((pumpWrappingCount * 10000 + pumpLastNum - platformLastNo > 10000 )) {
|
||||||
|
start = pumpLastNum
|
||||||
|
end = 10000
|
||||||
|
} else if (pumpWrappingCount > wrappingCount && PlatformPumpLogNum < 9999) {
|
||||||
|
start = (PlatformPumpLogNum + 1)
|
||||||
|
end = 10000
|
||||||
|
} else if (pumpWrappingCount > wrappingCount && PlatformPumpLogNum >= 9999 ) {
|
||||||
start = 0 // 처음부터 시작
|
start = 0 // 처음부터 시작
|
||||||
end = pumpLastNum
|
end = pumpLastNum
|
||||||
} else {
|
} else {
|
||||||
start = (lastLogNum + 1)
|
start = (PlatformPumpLogNum + 1)
|
||||||
end = pumpLastNum
|
end = pumpLastNum
|
||||||
}
|
}
|
||||||
val size = ceil((end - start) / 11.0).toInt()
|
val size = ceil((end - start) / 11.0).toInt()
|
||||||
|
|
Loading…
Reference in a new issue