- Fixed bugs for pump firmware 3.0

- Changing basal limit values for each pump firmware version.
- Pump log DB processing modification.
This commit is contained in:
miyeongkim 2021-11-15 16:44:04 +09:00
parent 7ad425ae1d
commit 7b4b9fd0dc
4 changed files with 23 additions and 5 deletions

View file

@ -21,7 +21,6 @@ class DiaconnG8Pump @Inject constructor(
private val dateUtil: DateUtil
) {
var maxBolusePerDay: Double = 0.0
var pumpIncarnationNum: Int = 65536
var isPumpVersionGe2_63: Boolean = false // is pumpVersion higher then 2.63
@ -37,6 +36,7 @@ class DiaconnG8Pump @Inject constructor(
var injectionBlockGrade: Int = 0
var lastConnection: Long = 0
var lastSettingsRead: Long = 0
var mealLimitTime: Int = 0
// time
private var pumpTime: Long = 0

View file

@ -2,7 +2,12 @@ package info.nightscout.androidaps.diaconn.packet
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.diaconn.DiaconnG8Pump
import info.nightscout.androidaps.diaconn.R
import info.nightscout.androidaps.diaconn.pumplog.PumplogUtil
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.utils.StringUtils
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import javax.inject.Inject
/**
@ -11,6 +16,8 @@ import javax.inject.Inject
class BasalLimitInquireResponsePacket(injector: HasAndroidInjector) : DiaconnG8Packet(injector ) {
@Inject lateinit var diaconnG8Pump: DiaconnG8Pump
@Inject lateinit var sp: SP
@Inject lateinit var rh: ResourceHelper
init {
msgType = 0x92.toByte()
@ -32,7 +39,12 @@ class BasalLimitInquireResponsePacket(injector: HasAndroidInjector) : DiaconnG8P
return
}
diaconnG8Pump.maxBasalPerHours = getShortToInt(bufferData).toDouble() / 100.0 // not include tempbasal limit
diaconnG8Pump.maxBasal = diaconnG8Pump.maxBasalPerHours * 2 // include tempbasal
val pumpFirmwareVersion = sp.getString(rh.gs(R.string.pumpversion), "")
if(!StringUtils.emptyString(pumpFirmwareVersion) && PumplogUtil.isPumpVersionGe(pumpFirmwareVersion, 3, 0)) {
diaconnG8Pump.maxBasal = diaconnG8Pump.maxBasalPerHours * 2.5 // include tempbasal
} else {
diaconnG8Pump.maxBasal = diaconnG8Pump.maxBasalPerHours * 2.0 // include tempbasal
}
aapsLogger.debug(LTag.PUMPCOMM, "Result --> ${diaconnG8Pump.result}")
aapsLogger.debug(LTag.PUMPCOMM, "maxBasal --> ${diaconnG8Pump.maxBasal}")

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.diaconn.packet
import android.util.Log
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.diaconn.DiaconnG8Pump
import info.nightscout.androidaps.diaconn.R
@ -167,9 +168,10 @@ class BigAPSMainInfoInquireResponsePacket(
// 16. 1hour basal limit
diaconnG8Pump.maxBasalPerHours = getShortToInt(bufferData).toDouble() / 100.0 // not include tempbasal limit
diaconnG8Pump.maxBasal = diaconnG8Pump.maxBasalPerHours * 2 // include tempbasal
diaconnG8Pump.maxBasal = diaconnG8Pump.maxBasalPerHours * 2.5 // include tempbasal
// 17. snack limit
diaconnG8Pump.mealLimitTime = getByteToInt(bufferData) // mealLimittime
diaconnG8Pump.maxBolus = getShortToInt(bufferData).toDouble() / 100
diaconnG8Pump.maxBolusePerDay = getShortToInt(bufferData).toDouble() / 100
@ -323,6 +325,7 @@ class BigAPSMainInfoInquireResponsePacket(
aapsLogger.debug(LTag.PUMPCOMM, "maxBasal > " + diaconnG8Pump.maxBasal)
aapsLogger.debug(LTag.PUMPCOMM, "maxBolus > " + diaconnG8Pump.maxBolus)
aapsLogger.debug(LTag.PUMPCOMM, "maxBolusePerDay > " + diaconnG8Pump.maxBolusePerDay)
aapsLogger.debug(LTag.PUMPCOMM, "mealLimitTime > " + diaconnG8Pump.mealLimitTime)
aapsLogger.debug(LTag.PUMPCOMM, "beepAndAlarm > " + diaconnG8Pump.beepAndAlarm)
aapsLogger.debug(LTag.PUMPCOMM, "alarmIntesity > " + diaconnG8Pump.alarmIntesity)
aapsLogger.debug(LTag.PUMPCOMM, "lcdOnTimeSec > " + diaconnG8Pump.lcdOnTimeSec)

View file

@ -246,8 +246,8 @@ class DiaconnG8Service : DaggerService() {
val apsIncarnationNum = sp.getInt(rh.gs(R.string.apsIncarnationNo), 65536)
// aps last log num
val pumpSerialNo = sp.getInt(rh.gs(R.string.pumpserialno), 0)
val apsWrappingCount = sp.getInt(rh.gs(R.string.apsWrappingCount), 0)
val apsLastLogNum = sp.getInt(rh.gs(R.string.apslastLogNum), 0)
var apsWrappingCount = sp.getInt(rh.gs(R.string.apsWrappingCount), 0)
var apsLastLogNum = sp.getInt(rh.gs(R.string.apslastLogNum), 0)
// if first install app
if(apsWrappingCount == 0 && apsLastLogNum == 0 ) {
@ -266,6 +266,9 @@ class DiaconnG8Service : DaggerService() {
sp.putInt(rh.gs(R.string.pumpserialno), diaconnG8Pump.serialNo)
}
apsWrappingCount = sp.getInt(rh.gs(R.string.apsWrappingCount), 0)
apsLastLogNum = sp.getInt(rh.gs(R.string.apslastLogNum), 0)
val apsLastNum = apsWrappingCount * 10000 + apsLastLogNum
if((pumpWrappingCount * 10000 + pumpLastNum) < apsLastLogNum ) {
pumpLogDefaultSetting()