Merge pull request #2614 from miyeongkim/dev

Added changes from 3.53 version above
This commit is contained in:
Milos Kozak 2023-07-11 12:04:21 +02:00 committed by GitHub
commit 047ed9d3ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 138 additions and 37 deletions

View file

@ -21,13 +21,14 @@ class DiaconnG8Pump @Inject constructor(
) { ) {
var isPumpLogUploadFailed: Boolean = false 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
var maxBolusePerDay: Double = 0.0 var maxBolusePerDay: Double = 0.0
var pumpIncarnationNum: Int = 65536 var pumpIncarnationNum: Int = 65536
var isPumpVersionGe2_63: Boolean = false // is pumpVersion higher then 2.63 var isPumpVersionGe2_63: Boolean = false // is pumpVersion higher then 2.63
var isPumpVersionGe3_53: Boolean = false // is pumpVersion higher then 3.42
var insulinWarningGrade: Int =0 var insulinWarningGrade: Int =0
var insulinWarningProcess: Int =0 var insulinWarningProcess: Int =0
var insulinWarningRemain: Int =0 var insulinWarningRemain: Int =0
@ -363,6 +364,11 @@ class DiaconnG8Pump @Inject constructor(
var otpNumber = 0 var otpNumber = 0
var bolusingSetAmount = 0.0
var bolusingInjAmount = 0.0
var bolusingSpeed = 0
var bolusingInjProgress = 0
companion object { companion object {
// User settings // User settings
const val ALARM = 0 const val ALARM = 0

View file

@ -43,6 +43,7 @@ import info.nightscout.pump.diaconn.packet.InjectionCancelSettingResponsePacket
import info.nightscout.pump.diaconn.packet.InjectionExtendedBolusResultReportPacket import info.nightscout.pump.diaconn.packet.InjectionExtendedBolusResultReportPacket
import info.nightscout.pump.diaconn.packet.InjectionExtendedBolusSettingPacket import info.nightscout.pump.diaconn.packet.InjectionExtendedBolusSettingPacket
import info.nightscout.pump.diaconn.packet.InjectionExtendedBolusSettingResponsePacket import info.nightscout.pump.diaconn.packet.InjectionExtendedBolusSettingResponsePacket
import info.nightscout.pump.diaconn.packet.InjectionProgressReportPacket
import info.nightscout.pump.diaconn.packet.InjectionSnackInquirePacket import info.nightscout.pump.diaconn.packet.InjectionSnackInquirePacket
import info.nightscout.pump.diaconn.packet.InjectionSnackInquireResponsePacket import info.nightscout.pump.diaconn.packet.InjectionSnackInquireResponsePacket
import info.nightscout.pump.diaconn.packet.InjectionSnackResultReportPacket import info.nightscout.pump.diaconn.packet.InjectionSnackResultReportPacket
@ -150,6 +151,7 @@ abstract class DiaconnG8PacketModule {
@ContributesAndroidInjector abstract fun contributesBigAPSMainInfoInquireResponsePacket(): BigAPSMainInfoInquireResponsePacket @ContributesAndroidInjector abstract fun contributesBigAPSMainInfoInquireResponsePacket(): BigAPSMainInfoInquireResponsePacket
@ContributesAndroidInjector abstract fun contributesSerialNumInquirePacket(): SerialNumInquirePacket @ContributesAndroidInjector abstract fun contributesSerialNumInquirePacket(): SerialNumInquirePacket
@ContributesAndroidInjector abstract fun contributesSerialNumInquireResponsePacket(): SerialNumInquireResponsePacket @ContributesAndroidInjector abstract fun contributesSerialNumInquireResponsePacket(): SerialNumInquireResponsePacket
@ContributesAndroidInjector abstract fun contributesInjectionProgressReportPacket(): InjectionProgressReportPacket
} }

View file

@ -215,6 +215,7 @@ class BigAPSMainInfoInquireResponsePacket(
//incarnation no 처리 //incarnation no 처리
diaconnG8Pump.isPumpVersionGe2_63 = PumpLogUtil.isPumpVersionGe(sp.getString(rh.gs(R.string.pumpversion), ""), 2, 63) diaconnG8Pump.isPumpVersionGe2_63 = PumpLogUtil.isPumpVersionGe(sp.getString(rh.gs(R.string.pumpversion), ""), 2, 63)
diaconnG8Pump.isPumpVersionGe3_53 = PumpLogUtil.isPumpVersionGe(sp.getString(rh.gs(R.string.pumpversion), ""), 3, 53)
aapsLogger.debug(LTag.PUMPCOMM, "result > " + diaconnG8Pump.result) aapsLogger.debug(LTag.PUMPCOMM, "result > " + diaconnG8Pump.result)
aapsLogger.debug(LTag.PUMPCOMM, "systemRemainInsulin > " + diaconnG8Pump.systemRemainInsulin) aapsLogger.debug(LTag.PUMPCOMM, "systemRemainInsulin > " + diaconnG8Pump.systemRemainInsulin)

View file

@ -214,6 +214,7 @@ class BigMainInfoInquireResponsePacket(
//incarnation no 처리 //incarnation no 처리
diaconnG8Pump.isPumpVersionGe2_63 = PumpLogUtil.isPumpVersionGe(sp.getString(rh.gs(R.string.pumpversion), ""), 2, 63) diaconnG8Pump.isPumpVersionGe2_63 = PumpLogUtil.isPumpVersionGe(sp.getString(rh.gs(R.string.pumpversion), ""), 2, 63)
diaconnG8Pump.isPumpVersionGe3_53 = PumpLogUtil.isPumpVersionGe(sp.getString(rh.gs(R.string.pumpversion), ""), 3, 53)
aapsLogger.debug(LTag.PUMPCOMM, "result > " + diaconnG8Pump.result) aapsLogger.debug(LTag.PUMPCOMM, "result > " + diaconnG8Pump.result)
aapsLogger.debug(LTag.PUMPCOMM, "systemRemainInsulin > " + diaconnG8Pump.systemRemainInsulin) aapsLogger.debug(LTag.PUMPCOMM, "systemRemainInsulin > " + diaconnG8Pump.systemRemainInsulin)

View file

@ -48,5 +48,6 @@ class DiaconnG8ResponseMessageHashTable @Inject constructor(val injector: HasAnd
put(BatteryWarningReportPacket(injector)) put(BatteryWarningReportPacket(injector))
put(InjectionBlockReportPacket(injector)) put(InjectionBlockReportPacket(injector))
put(BolusSpeedSettingReportPacket(injector)) put(BolusSpeedSettingReportPacket(injector))
put(InjectionProgressReportPacket(injector))
} }
} }

View file

@ -0,0 +1,53 @@
package info.nightscout.pump.diaconn.packet
import dagger.android.HasAndroidInjector
import info.nightscout.pump.diaconn.DiaconnG8Pump
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper
import javax.inject.Inject
/**
* InjectionProgressReportPacket
*/
class InjectionProgressReportPacket(injector: HasAndroidInjector) : DiaconnG8Packet(injector ) {
@Inject lateinit var diaconnG8Pump: DiaconnG8Pump
@Inject lateinit var rxBus: RxBus
@Inject lateinit var rh: ResourceHelper
init {
msgType = 0xEA.toByte()
aapsLogger.debug(LTag.PUMPCOMM, "InjectionProgressReportPacket init ")
}
override fun handleMessage(data: ByteArray?) {
val defectCheck = defect(data)
if (defectCheck != 0) {
aapsLogger.debug(LTag.PUMPCOMM, "InjectionProgressReportPacket Got some Error")
failed = true
return
} else failed = false
val bufferData = prefixDecode(data)
val setAmount = getShortToInt(bufferData) /100.0
val injAmount = getShortToInt(bufferData)/100.0
val speed = getByteToInt(bufferData);
val injProgress = getByteToInt(bufferData)
diaconnG8Pump.bolusingSetAmount = setAmount
diaconnG8Pump.bolusingInjAmount = injAmount
diaconnG8Pump.bolusingSpeed = speed
diaconnG8Pump.bolusingInjProgress = injProgress
aapsLogger.debug(LTag.PUMPCOMM, "bolusingSetAmount --> ${diaconnG8Pump.bolusingSetAmount}")
aapsLogger.debug(LTag.PUMPCOMM, "bolusingInjAmount --> ${diaconnG8Pump.bolusingInjAmount}")
aapsLogger.debug(LTag.PUMPCOMM, "bolusingSpeed --> ${diaconnG8Pump.bolusingSpeed}")
aapsLogger.debug(LTag.PUMPCOMM, "bolusingInjProgress --> ${diaconnG8Pump.bolusingInjProgress}")
}
override fun getFriendlyName(): String {
return "PUMP_INJECTION_PROGRESS_REPORT"
}
}

View file

@ -322,6 +322,7 @@ class DiaconnG8Service : DaggerService() {
for (i in 0 until loopSize) { for (i in 0 until loopSize) {
val startLogNo: Int = start + i * pumpLogPageSize val startLogNo: Int = start + i * pumpLogPageSize
val endLogNo: Int = startLogNo + min(end - startLogNo, pumpLogPageSize) val endLogNo: Int = startLogNo + min(end - startLogNo, pumpLogPageSize)
aapsLogger.debug(LTag.PUMPCOMM, "pumplog request : $startLogNo ~ $endLogNo")
val msg = BigLogInquirePacket(injector, startLogNo, endLogNo, 100) val msg = BigLogInquirePacket(injector, startLogNo, endLogNo, 100)
sendMessage(msg, 500) sendMessage(msg, 500)
} }
@ -500,15 +501,27 @@ class DiaconnG8Service : DaggerService() {
val bolusDurationInMSec = (insulin * speed * 1000).toLong() val bolusDurationInMSec = (insulin * speed * 1000).toLong()
val expectedEnd = bolusStart + bolusDurationInMSec + 3500L val expectedEnd = bolusStart + bolusDurationInMSec + 3500L
val totalwaitTime = (expectedEnd - System.currentTimeMillis()) / 1000 val totalwaitTime = (expectedEnd - System.currentTimeMillis()) / 1000
// reset bolus progress history
diaconnG8Pump.bolusingInjProgress = 0
diaconnG8Pump.bolusingSetAmount = 0.0
diaconnG8Pump.bolusingInjAmount = 0.0
if (diaconnG8Pump.isReadyToBolus) { if (diaconnG8Pump.isReadyToBolus) {
var progressPecent = 0
while (!diaconnG8Pump.bolusDone) { while (!diaconnG8Pump.bolusDone) {
val waitTime = (expectedEnd - System.currentTimeMillis()) / 1000 if(diaconnG8Pump.isPumpVersionGe3_53) {
bolusingEvent.status = String.format(rh.gs(R.string.waitingforestimatedbolusend), if (waitTime < 0) 0 else waitTime) progressPecent = diaconnG8Pump.bolusingInjProgress
var progressPecent = 0 //bolusingEvent.status = String.format(rh.gs(R.string.waitingforestimatedbolusend), progressPecent)
if (totalwaitTime > waitTime && totalwaitTime > 0) { bolusingEvent.status = "볼러스 주입중 ${diaconnG8Pump.bolusingInjAmount}U / ${diaconnG8Pump.bolusingSetAmount}U (${progressPecent}%)"
progressPecent = ((totalwaitTime - waitTime) * 100 / totalwaitTime).toInt() bolusingEvent.percent = min(progressPecent, 100)
} else {
val waitTime = (expectedEnd - System.currentTimeMillis()) / 1000
bolusingEvent.status = String.format(rh.gs(R.string.waitingforestimatedbolusend), if (waitTime < 0) 0 else waitTime)
if (totalwaitTime > waitTime && totalwaitTime > 0) {
progressPecent = ((totalwaitTime - waitTime) * 100 / totalwaitTime).toInt()
}
bolusingEvent.percent = min(progressPecent, 100)
} }
bolusingEvent.percent = min(progressPecent, 100)
rxBus.send(bolusingEvent) rxBus.send(bolusingEvent)
SystemClock.sleep(200) SystemClock.sleep(200)
} }
@ -522,7 +535,9 @@ class DiaconnG8Service : DaggerService() {
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingbolusstatus))) rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingbolusstatus)))
sendMessage(InjectionSnackInquirePacket(injector), 2000) // last bolus sendMessage(InjectionSnackInquirePacket(injector), 2000) // last bolus
// 볼러스 결과 보고패킷에서 처리함. // 볼러스 결과 보고패킷에서 처리함.
bolusingEvent.percent = 100 if(!diaconnG8Pump.isPumpVersionGe3_53) {
bolusingEvent.percent = 100
}
rxBus.send(EventPumpStatusChanged(rh.gs(info.nightscout.shared.R.string.disconnecting))) rxBus.send(EventPumpStatusChanged(rh.gs(info.nightscout.shared.R.string.disconnecting)))
} }
}) })
@ -549,29 +564,39 @@ class DiaconnG8Service : DaggerService() {
// temp state check // temp state check
sendMessage(TempBasalInquirePacket(injector)) sendMessage(TempBasalInquirePacket(injector))
val result : DiaconnG8Packet
if(diaconnG8Pump.isPumpVersionGe3_53) {
val tbrPacket = TempBasalSettingPacket(injector, 3, ((durationInHours * 60) / 15).toInt(), ((absoluteRate * 100) + 1000).toInt())
sendMessage(tbrPacket, 100)
result = tbrPacket
if (!processConfirm(tbrPacket.msgType)) return false
} else {
if (diaconnG8Pump.tbStatus == 1) { if (diaconnG8Pump.tbStatus == 1) {
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.stoppingtempbasal))) rxBus.send(EventPumpStatusChanged(rh.gs(R.string.stoppingtempbasal)))
val msgPacket = TempBasalSettingPacket(injector, 2, diaconnG8Pump.tbTime, diaconnG8Pump.tbInjectRateRatio) val tbrPacket = TempBasalSettingPacket(injector, 2, diaconnG8Pump.tbTime, diaconnG8Pump.tbInjectRateRatio)
// tempbasal stop // tempbasal stop
sendMessage(msgPacket, 100) sendMessage(tbrPacket, 100)
// otp process
if (!processConfirm(tbrPacket.msgType)) return false
diaconnG8Pump.tempBasalStart = dateUtil.now()
}
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.settingtempbasal)))
val tbInjectRate = ((absoluteRate * 100) + 1000).toInt()
val tbrPacket = TempBasalSettingPacket(injector, 1, ((durationInHours * 60) / 15).toInt(), tbInjectRate)
sendMessage(tbrPacket, 100)
result = tbrPacket
// otp process // otp process
if (!processConfirm(msgPacket.msgType)) return false if (!processConfirm(tbrPacket.msgType)) return false
diaconnG8Pump.tempBasalStart = dateUtil.now() // pump tempbasal status inquire
} }
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.settingtempbasal)))
val tbInjectRate = ((absoluteRate * 100) + 1000).toInt()
val msgTBR = TempBasalSettingPacket(injector, 1, ((durationInHours * 60) / 15).toInt(), tbInjectRate)
sendMessage(msgTBR, 100)
// otp process
if (!processConfirm(msgTBR.msgType)) return false
// pump tempbasal status inquire
sendMessage(TempBasalInquirePacket(injector)) sendMessage(TempBasalInquirePacket(injector))
loadHistory() loadHistory()
val tbr = pumpSync.expectedPumpState().temporaryBasal val tbr = pumpSync.expectedPumpState().temporaryBasal
diaconnG8Pump.fromTemporaryBasal(tbr) diaconnG8Pump.fromTemporaryBasal(tbr)
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING))
return msgTBR.success() return result.success()
} }
fun tempBasalShortDuration(absoluteRate: Double, durationInMinutes: Int): Boolean { fun tempBasalShortDuration(absoluteRate: Double, durationInMinutes: Int): Boolean {
@ -581,28 +606,40 @@ class DiaconnG8Service : DaggerService() {
} }
// temp state check // temp state check
val result:DiaconnG8Packet
sendMessage(TempBasalInquirePacket(injector)) sendMessage(TempBasalInquirePacket(injector))
if (diaconnG8Pump.tbStatus == 1) { if(diaconnG8Pump.isPumpVersionGe3_53) {
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.stoppingtempbasal))) rxBus.send(EventPumpStatusChanged(rh.gs(R.string.settingtempbasal)))
val msgPacket = TempBasalSettingPacket(injector, 2, diaconnG8Pump.tbTime, diaconnG8Pump.tbInjectRateRatio) val tbrSettingPacket = TempBasalSettingPacket(injector, 3, 2, ((absoluteRate * 100) + 1000).toInt())
// tempbasal stop sendMessage(tbrSettingPacket, 100)
sendMessage(msgPacket, 100) result=tbrSettingPacket
// otp process // otp process
if (!processConfirm(msgPacket.msgType)) return false if (!processConfirm(tbrSettingPacket.msgType)) return false
SystemClock.sleep(500) sendMessage(TempBasalInquirePacket(injector))
} else {
if (diaconnG8Pump.tbStatus == 1) {
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.stoppingtempbasal)))
val tbrPacket = TempBasalSettingPacket(injector, 2, diaconnG8Pump.tbTime, diaconnG8Pump.tbInjectRateRatio)
// tempbasal stop
sendMessage(tbrPacket, 100)
// otp process
if (!processConfirm(tbrPacket.msgType)) return false
SystemClock.sleep(500)
}
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.settingtempbasal)))
val tbInjectRate = absoluteRate * 100 + 1000
val msgTBR = TempBasalSettingPacket(injector, 1, 2, tbInjectRate.toInt())
sendMessage(msgTBR, 100)
result=msgTBR
// otp process
if (!processConfirm(msgTBR.msgType)) return false
} }
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.settingtempbasal)))
val tbInjectRate = absoluteRate * 100 + 1000
val msgTBR = TempBasalSettingPacket(injector, 1, 2, tbInjectRate.toInt())
sendMessage(msgTBR, 100)
// otp process
if (!processConfirm(msgTBR.msgType)) return false
sendMessage(TempBasalInquirePacket(injector)) sendMessage(TempBasalInquirePacket(injector))
loadHistory() loadHistory()
val tbr = pumpSync.expectedPumpState().temporaryBasal val tbr = pumpSync.expectedPumpState().temporaryBasal
diaconnG8Pump.fromTemporaryBasal(tbr) diaconnG8Pump.fromTemporaryBasal(tbr)
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING))
return msgTBR.success() return result.success()
} }
fun tempBasalStop(): Boolean { fun tempBasalStop(): Boolean {