Merge pull request #940 from miyeongkim/dev
code clean and some changes apply to AAPS
This commit is contained in:
commit
f8ed625ce5
|
@ -304,7 +304,7 @@ enum class PumpType {
|
||||||
specialBolusSize = null,
|
specialBolusSize = null,
|
||||||
extendedBolusSettings = DoseSettings(0.05, 10, 5 * 60, 0.05),
|
extendedBolusSettings = DoseSettings(0.05, 10, 5 * 60, 0.05),
|
||||||
pumpTempBasalType = PumpTempBasalType.Absolute,
|
pumpTempBasalType = PumpTempBasalType.Absolute,
|
||||||
tbrSettings = DoseSettings(0.01, 30, 24 * 60, 0.0, 6.0),
|
tbrSettings = DoseSettings(0.01, 30, 24 * 60, 0.0, 15.0),
|
||||||
specialBasalDurations = PumpCapability.BasalRate_Duration30minAllowed,
|
specialBasalDurations = PumpCapability.BasalRate_Duration30minAllowed,
|
||||||
baseBasalMinValue = 0.05,
|
baseBasalMinValue = 0.05,
|
||||||
baseBasalMaxValue = 3.0,
|
baseBasalMaxValue = 3.0,
|
||||||
|
|
|
@ -291,7 +291,7 @@ class DiaconnG8Plugin @Inject constructor(
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult {
|
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult {
|
||||||
val result = PumpEnactResult(injector)
|
val result = PumpEnactResult(injector)
|
||||||
var absoluteAfterConstrain = constraintChecker.applyBasalConstraints(Constraint(absoluteRate), profile).value()
|
val absoluteAfterConstrain = constraintChecker.applyBasalConstraints(Constraint(absoluteRate), profile).value()
|
||||||
val doTempOff = baseBasalRate - absoluteAfterConstrain == 0.0
|
val doTempOff = baseBasalRate - absoluteAfterConstrain == 0.0
|
||||||
val doLowTemp = absoluteAfterConstrain < baseBasalRate
|
val doLowTemp = absoluteAfterConstrain < baseBasalRate
|
||||||
val doHighTemp = absoluteAfterConstrain > baseBasalRate
|
val doHighTemp = absoluteAfterConstrain > baseBasalRate
|
||||||
|
@ -312,7 +312,7 @@ class DiaconnG8Plugin @Inject constructor(
|
||||||
|
|
||||||
if (doLowTemp || doHighTemp) {
|
if (doLowTemp || doHighTemp) {
|
||||||
// Check if some temp is already in progress
|
// Check if some temp is already in progress
|
||||||
if(absoluteAfterConstrain > 6.0) absoluteAfterConstrain = 6.0 // pumpLimit
|
//if(absoluteAfterConstrain > 6.0) absoluteAfterConstrain = 6.0 // pumpLimit
|
||||||
//val activeTemp = activePluginProvider.activeTreatments.getTempBasalFromHistory(System.currentTimeMillis())
|
//val activeTemp = activePluginProvider.activeTreatments.getTempBasalFromHistory(System.currentTimeMillis())
|
||||||
if (diaconnG8Pump.isTempBasalInProgress) {
|
if (diaconnG8Pump.isTempBasalInProgress) {
|
||||||
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: currently running")
|
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: currently running")
|
||||||
|
|
|
@ -21,7 +21,6 @@ class DiaconnG8Pump @Inject constructor(
|
||||||
private val dateUtil: DateUtil
|
private val dateUtil: DateUtil
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -37,6 +36,7 @@ class DiaconnG8Pump @Inject constructor(
|
||||||
var injectionBlockGrade: Int = 0
|
var injectionBlockGrade: Int = 0
|
||||||
var lastConnection: Long = 0
|
var lastConnection: Long = 0
|
||||||
var lastSettingsRead: Long = 0
|
var lastSettingsRead: Long = 0
|
||||||
|
var mealLimitTime: Int = 0
|
||||||
|
|
||||||
// time
|
// time
|
||||||
private var pumpTime: Long = 0
|
private var pumpTime: Long = 0
|
||||||
|
@ -259,9 +259,9 @@ class DiaconnG8Pump @Inject constructor(
|
||||||
// 7. Tempbasal status
|
// 7. Tempbasal status
|
||||||
var tbStatus = 0 // 임시기저 상태 (1 : running, 2:not running )
|
var tbStatus = 0 // 임시기저 상태 (1 : running, 2:not running )
|
||||||
var tbTime = 0 // 임시기저 시간
|
var tbTime = 0 // 임시기저 시간
|
||||||
var tbInjectRateRatio = 0 // 임시기저 주입량/률 1000(0.00U)~1600(6.00U), 50000(0%)~50200(200%), 50000이상이면 주입률로 판정
|
var tbInjectRateRatio = 0 // 임시기저 주입량/률 1000(0.00U)~1600(6.00U), 50000(0%)~50250(250%), 50000이상이면 주입률로 판정
|
||||||
var tbElapsedTime = 0 // 임시기저 경과 시간(0~1425분)
|
var tbElapsedTime = 0 // 임시기저 경과 시간(0~1425분)
|
||||||
var tbInjectAbsoluteValue = 0.0 // 임시기저 주입량/률 1000(0.00U)~1600(6.00U)
|
var tbInjectAbsoluteValue = 0.0 // 임시기저 주입량/률 1000(0.00U)~2500(15.00U)
|
||||||
|
|
||||||
// 8. Basal status
|
// 8. Basal status
|
||||||
var baseStatus = 0 // 주입상태
|
var baseStatus = 0 // 주입상태
|
||||||
|
|
|
@ -2,7 +2,12 @@ package info.nightscout.androidaps.diaconn.packet
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.diaconn.DiaconnG8Pump
|
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.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
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,6 +16,8 @@ import javax.inject.Inject
|
||||||
class BasalLimitInquireResponsePacket(injector: HasAndroidInjector) : DiaconnG8Packet(injector ) {
|
class BasalLimitInquireResponsePacket(injector: HasAndroidInjector) : DiaconnG8Packet(injector ) {
|
||||||
|
|
||||||
@Inject lateinit var diaconnG8Pump: DiaconnG8Pump
|
@Inject lateinit var diaconnG8Pump: DiaconnG8Pump
|
||||||
|
@Inject lateinit var sp: SP
|
||||||
|
@Inject lateinit var rh: ResourceHelper
|
||||||
|
|
||||||
init {
|
init {
|
||||||
msgType = 0x92.toByte()
|
msgType = 0x92.toByte()
|
||||||
|
@ -32,7 +39,12 @@ class BasalLimitInquireResponsePacket(injector: HasAndroidInjector) : DiaconnG8P
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
diaconnG8Pump.maxBasalPerHours = getShortToInt(bufferData).toDouble() / 100.0 // not include tempbasal limit
|
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, "Result --> ${diaconnG8Pump.result}")
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "maxBasal --> ${diaconnG8Pump.maxBasal}")
|
aapsLogger.debug(LTag.PUMPCOMM, "maxBasal --> ${diaconnG8Pump.maxBasal}")
|
||||||
|
|
|
@ -4,9 +4,7 @@ import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.diaconn.DiaconnG8Pump
|
import info.nightscout.androidaps.diaconn.DiaconnG8Pump
|
||||||
import info.nightscout.androidaps.diaconn.R
|
import info.nightscout.androidaps.diaconn.R
|
||||||
import info.nightscout.androidaps.diaconn.pumplog.PumplogUtil
|
import info.nightscout.androidaps.diaconn.pumplog.PumplogUtil
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription
|
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
|
@ -23,7 +21,6 @@ class BigAPSMainInfoInquireResponsePacket(
|
||||||
@Inject lateinit var diaconnG8Pump: DiaconnG8Pump
|
@Inject lateinit var diaconnG8Pump: DiaconnG8Pump
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var rh: ResourceHelper
|
@Inject lateinit var rh: ResourceHelper
|
||||||
private var pumpDesc = PumpDescription(PumpType.DIACONN_G8)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
msgType = 0x94.toByte()
|
msgType = 0x94.toByte()
|
||||||
|
@ -167,9 +164,10 @@ class BigAPSMainInfoInquireResponsePacket(
|
||||||
|
|
||||||
// 16. 1hour basal limit
|
// 16. 1hour basal limit
|
||||||
diaconnG8Pump.maxBasalPerHours = getShortToInt(bufferData).toDouble() / 100.0 // not include tempbasal 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
|
// 17. snack limit
|
||||||
|
diaconnG8Pump.mealLimitTime = getByteToInt(bufferData) // mealLimittime
|
||||||
diaconnG8Pump.maxBolus = getShortToInt(bufferData).toDouble() / 100
|
diaconnG8Pump.maxBolus = getShortToInt(bufferData).toDouble() / 100
|
||||||
diaconnG8Pump.maxBolusePerDay = getShortToInt(bufferData).toDouble() / 100
|
diaconnG8Pump.maxBolusePerDay = getShortToInt(bufferData).toDouble() / 100
|
||||||
|
|
||||||
|
@ -323,6 +321,7 @@ class BigAPSMainInfoInquireResponsePacket(
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "maxBasal > " + diaconnG8Pump.maxBasal)
|
aapsLogger.debug(LTag.PUMPCOMM, "maxBasal > " + diaconnG8Pump.maxBasal)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "maxBolus > " + diaconnG8Pump.maxBolus)
|
aapsLogger.debug(LTag.PUMPCOMM, "maxBolus > " + diaconnG8Pump.maxBolus)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "maxBolusePerDay > " + diaconnG8Pump.maxBolusePerDay)
|
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, "beepAndAlarm > " + diaconnG8Pump.beepAndAlarm)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "alarmIntesity > " + diaconnG8Pump.alarmIntesity)
|
aapsLogger.debug(LTag.PUMPCOMM, "alarmIntesity > " + diaconnG8Pump.alarmIntesity)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "lcdOnTimeSec > " + diaconnG8Pump.lcdOnTimeSec)
|
aapsLogger.debug(LTag.PUMPCOMM, "lcdOnTimeSec > " + diaconnG8Pump.lcdOnTimeSec)
|
||||||
|
|
|
@ -569,7 +569,7 @@ class BigLogInquireResponsePacket(
|
||||||
absoluteRate = pumpDesc.pumpType.determineCorrectBasalSize(diaconnG8Pump.baseAmount * (tempBasalPercent / 100.0))
|
absoluteRate = pumpDesc.pumpType.determineCorrectBasalSize(diaconnG8Pump.baseAmount * (tempBasalPercent / 100.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logItem.getTbInjectRateRatio() in 1000..1600) {
|
if (logItem.getTbInjectRateRatio() in 1000..2500) {
|
||||||
absoluteRate = (logItem.getTbInjectRateRatio() - 1000) / 100.0
|
absoluteRate = (logItem.getTbInjectRateRatio() - 1000) / 100.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,7 +604,7 @@ class BigLogInquireResponsePacket(
|
||||||
val tempBasalPercent = logItem.getTbInjectRateRatio() - 50000
|
val tempBasalPercent = logItem.getTbInjectRateRatio() - 50000
|
||||||
absoluteRate = diaconnG8Pump.baseAmount * (tempBasalPercent / 100.0)
|
absoluteRate = diaconnG8Pump.baseAmount * (tempBasalPercent / 100.0)
|
||||||
}
|
}
|
||||||
if (logItem.getTbInjectRateRatio() in 1000..1600) {
|
if (logItem.getTbInjectRateRatio() in 1000..2500) {
|
||||||
absoluteRate = (logItem.getTbInjectRateRatio() - 1000) / 100.0
|
absoluteRate = (logItem.getTbInjectRateRatio() - 1000) / 100.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -246,8 +246,8 @@ class DiaconnG8Service : DaggerService() {
|
||||||
val apsIncarnationNum = sp.getInt(rh.gs(R.string.apsIncarnationNo), 65536)
|
val apsIncarnationNum = sp.getInt(rh.gs(R.string.apsIncarnationNo), 65536)
|
||||||
// aps last log num
|
// aps last log num
|
||||||
val pumpSerialNo = sp.getInt(rh.gs(R.string.pumpserialno), 0)
|
val pumpSerialNo = sp.getInt(rh.gs(R.string.pumpserialno), 0)
|
||||||
val apsWrappingCount = sp.getInt(rh.gs(R.string.apsWrappingCount), 0)
|
var apsWrappingCount = sp.getInt(rh.gs(R.string.apsWrappingCount), 0)
|
||||||
val apsLastLogNum = sp.getInt(rh.gs(R.string.apslastLogNum), 0)
|
var apsLastLogNum = sp.getInt(rh.gs(R.string.apslastLogNum), 0)
|
||||||
|
|
||||||
// if first install app
|
// if first install app
|
||||||
if(apsWrappingCount == 0 && apsLastLogNum == 0 ) {
|
if(apsWrappingCount == 0 && apsLastLogNum == 0 ) {
|
||||||
|
@ -266,6 +266,9 @@ class DiaconnG8Service : DaggerService() {
|
||||||
sp.putInt(rh.gs(R.string.pumpserialno), diaconnG8Pump.serialNo)
|
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
|
val apsLastNum = apsWrappingCount * 10000 + apsLastLogNum
|
||||||
if((pumpWrappingCount * 10000 + pumpLastNum) < apsLastLogNum ) {
|
if((pumpWrappingCount * 10000 + pumpLastNum) < apsLastLogNum ) {
|
||||||
pumpLogDefaultSetting()
|
pumpLogDefaultSetting()
|
||||||
|
|
Loading…
Reference in a new issue