1. new packet is added (BigAPSMainPacket)

2. Tempbasal time bug fixed
3. class warnning fixed
This commit is contained in:
miyeongkim 2021-06-14 17:36:06 +09:00
parent 8e466be92c
commit 3454252bcc
10 changed files with 454 additions and 19 deletions

View file

@ -332,11 +332,11 @@ class DiaconnG8Plugin @Inject constructor(
}
temporaryBasalStorage.add(PumpSync.PumpState.TemporaryBasal(dateUtil.now(), T.mins(durationInMinutes.toLong()).msecs(), absoluteRate, true, tbrType, 0L, 0L))
// Convert duration from minutes to hours
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Setting temp basal $absoluteAfterConstrain% for $durationInMinutes mins (doLowTemp || doHighTemp)")
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Setting temp basal $absoluteAfterConstrain U for $durationInMinutes mins (doLowTemp || doHighTemp)")
val connectionOK: Boolean = if (durationInMinutes == 15 || durationInMinutes == 30) {
diaconnG8Service?.tempBasalShortDuration(absoluteAfterConstrain, durationInMinutes) ?: false
} else {
val durationInHours = max(durationInMinutes / 60, 1)
val durationInHours = max(durationInMinutes / 60.0, 1.0)
diaconnG8Service?.tempBasal(absoluteAfterConstrain, durationInHours) ?: false
}
@ -377,7 +377,6 @@ class DiaconnG8Plugin @Inject constructor(
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult {
var insulinAfterConstraint = constraintChecker.applyExtendedBolusConstraints(Constraint(insulin)).value()
// needs to be rounded
//val durationInHalfHours = max(durationInMinutes / 30, 1)
insulinAfterConstraint = Round.roundTo(insulinAfterConstraint, pumpDescription.extendedBolusStep)
val result = PumpEnactResult(injector)

View file

@ -21,6 +21,7 @@ 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
@ -98,7 +99,16 @@ class DiaconnG8Pump @Inject constructor(
var extendedBolusStart: Long = 0
var extendedBolusDuration: Long = 0
var extendedBolusAmount = 0.0
var isExtendedInProgress:Boolean = false
var isExtendedInProgress: Boolean
get() = extendedBolusStart != 0L && dateUtil.now() in extendedBolusStart..extendedBolusStart + extendedBolusDuration
set(isRunning) {
if (isRunning) throw IllegalArgumentException("Use to cancel EB only")
else {
extendedBolusStart = 0L
extendedBolusDuration = 0L
extendedBolusAmount = 0.0
}
}
var extendedBolusPassedMinutes = 0
var extendedBolusRemainingMinutes = 0
var extendedBolusAbsoluteRate = 0.0
@ -149,6 +159,11 @@ class DiaconnG8Pump @Inject constructor(
var bolusStopForced = false // bolus forced to stop by user
var bolusDone = false // success end
// LGS Status
var lgsStatus: Int = 0 // LGS Status(1=LGS_ON, 2=LGS_OFF)
var lgsTime:Int = 0 // LGS Setting time (0~255 min)
var lgsElapsedTime:Int = 0 // LGS Passed Time (0~255 min)
fun buildDiaconnG8ProfileRecord(nsProfile: Profile): Array<Double> {
val record = Array(24) { 0.0 }
for (hour in 0..23) {

View file

@ -75,6 +75,8 @@ abstract class DiaconnG8PacketModule {
@ContributesAndroidInjector abstract fun contributesDisplayTimeInquireResponsePacket(): DisplayTimeInquireResponsePacket
@ContributesAndroidInjector abstract fun contributesLanguageInquirePacket(): LanguageInquirePacket
@ContributesAndroidInjector abstract fun contributesLanguageInquireResponsePacket(): LanguageInquireResponsePacket
@ContributesAndroidInjector abstract fun contributesBigAPSMainInfoInquirePacket(): BigAPSMainInfoInquirePacket
@ContributesAndroidInjector abstract fun contributesBigAPSMainInfoInquireResponsePacket(): BigAPSMainInfoInquireResponsePacket

View file

@ -0,0 +1,33 @@
package info.nightscout.androidaps.diaconn.packet
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.diaconn.DiaconnG8Pump
import info.nightscout.androidaps.logging.LTag
import javax.inject.Inject
/**
* BigAPSMainInfoInquirePacket
*/
class BigAPSMainInfoInquirePacket(
injector: HasAndroidInjector
) : DiaconnG8Packet(injector ) {
@Inject lateinit var diaconnG8Pump: DiaconnG8Pump
init {
msgType = 0x54
aapsLogger.debug(LTag.PUMPCOMM, "BigAPSMainInfoInquirePacket init")
}
override fun encode(msgSeq:Int): ByteArray {
val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
return suffixEncode(buffer)
}
override fun getFriendlyName(): String {
return "PUMP_BIG_APS_MAIN_INFO_INQUIRE"
}
}

View file

@ -0,0 +1,375 @@
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.interfaces.PumpDescription
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.sharedPreferences.SP
import org.joda.time.DateTime
import javax.inject.Inject
import kotlin.math.floor
/**
* BigAPSMainInfoInquireResponsePacket
*/
class BigAPSMainInfoInquireResponsePacket(
injector: HasAndroidInjector
) : DiaconnG8Packet(injector) {
@Inject lateinit var diaconnG8Pump: DiaconnG8Pump
@Inject lateinit var sp: SP
@Inject lateinit var resourceHelper: ResourceHelper
private var pumpDesc = PumpDescription(PumpType.DIACONN_G8)
init {
msgType = 0x94.toByte()
aapsLogger.debug(LTag.PUMPCOMM, "BigAPSMainInfoInquireResponsePacket init")
}
override fun handleMessage(data: ByteArray?) {
val result = defect(data)
if (result != 0) {
aapsLogger.debug(LTag.PUMPCOMM, "BigAPSMainInfoInquireResponsePacket Got some Error")
failed = true
return
} else failed = false
val bufferData = prefixDecode(data)
val result2 = getByteToInt(bufferData) // 결과비트 상위 4비트 제거
if(!isSuccInquireResponseResult(result2)) {
failed = true
return
}
// 1. pump system setting info
diaconnG8Pump.systemRemainInsulin = floor(getShortToInt(bufferData) / 100.0) // 인슐린 잔량
diaconnG8Pump.systemRemainBattery = getByteToInt(bufferData) // 베터리잔량(1~100%)
diaconnG8Pump.systemBasePattern = getByteToInt(bufferData) // 기저주입 패턴(0=없음, 1=기본, 2=생활1, 3=생활2, 4=생활3, 5=닥터1, 6=닥터2)
diaconnG8Pump.systemTbStatus = getByteToInt(bufferData) // 임시기저 상태(1=임시기저 중, 2=임시기저 해제)
diaconnG8Pump.systemInjectionMealStatus = getByteToInt(bufferData) // 식사주입 상태(1=주입중, 2=주입상태아님)
diaconnG8Pump.systemInjectionSnackStatus = getByteToInt(bufferData) // 일반간식 주입 상태(1=주입중, 2=주입상태아님)
diaconnG8Pump.systemInjectionSquareStatue = getByteToInt(bufferData) // 스퀘어회식 주입 상태(1=주입중, 2=주입상태아님)
diaconnG8Pump.systemInjectionDualStatus = getByteToInt(bufferData) // 더블회식 주입 상태(1=주입중, 2=주입상태아님)
// 2. basal injection suspend status (1:stop, 2:release)
diaconnG8Pump.basePauseStatus = getByteToInt(bufferData) // 상태(1=정지,2=해제)
// 3. Pump time
diaconnG8Pump.year = getByteToInt(bufferData) + 2000 // 년 (18~99)
diaconnG8Pump.month = getByteToInt(bufferData) // 월 (1~12)
diaconnG8Pump.day = getByteToInt(bufferData) // 일 (1~31)
diaconnG8Pump.hour = getByteToInt(bufferData) // 시 (0~23)
diaconnG8Pump.minute = getByteToInt(bufferData) // 분 (0~59)
diaconnG8Pump.second = getByteToInt(bufferData) // 초 (0~59)
//4. pump system info
diaconnG8Pump.country = getByteToInt(bufferData).toChar().toString().toInt() // ASCII
diaconnG8Pump.productType = getByteToInt(bufferData).toChar().toString().toInt() // ASCII
diaconnG8Pump.makeYear = getByteToInt(bufferData)
diaconnG8Pump.makeMonth = getByteToInt(bufferData)
diaconnG8Pump.makeDay = getByteToInt(bufferData)
diaconnG8Pump.lotNo = getByteToInt(bufferData)// LOT NO
diaconnG8Pump.serialNo = getShortToInt(bufferData)
diaconnG8Pump.majorVersion = getByteToInt(bufferData)
diaconnG8Pump.minorVersion = getByteToInt(bufferData)
// save current pump firmware version
sp.putString(resourceHelper.gs(R.string.pumpversion), diaconnG8Pump.majorVersion.toString() + "." + diaconnG8Pump.minorVersion.toString())
// 5. pump log status
diaconnG8Pump.pumpLastLogNum = getShortToInt(bufferData) // last saved log no
diaconnG8Pump.pumpWrappingCount = getByteToInt(bufferData) // wrapping count
// 6. bolus speed status.
diaconnG8Pump.speed = getByteToInt(bufferData) // bolus speed (1~8)
// 7. Tempbasal status
diaconnG8Pump.tbStatus = getByteToInt(bufferData) // tempbasal status
diaconnG8Pump.tbTime = getByteToInt(bufferData) // tempbasal durationn
diaconnG8Pump.tbInjectRateRatio = getShortToInt(bufferData) //rate/percent
diaconnG8Pump.tbElapsedTime = getShortToInt(bufferData) // tempbasal elapsed time(0~1425 min)
// 8. Basal status
diaconnG8Pump.baseStatus = getByteToInt(bufferData) // 기저주입 상태
diaconnG8Pump.baseHour = getByteToInt(bufferData) // 현재 주입시간
diaconnG8Pump.baseAmount = getShortToInt(bufferData) / 100.0 // 주입설정량
diaconnG8Pump.baseInjAmount = getShortToInt(bufferData) / 100.0 // 현재 주입량
// 9. snack bolus status
diaconnG8Pump.snackStatus = getByteToInt(bufferData) //주입상태
diaconnG8Pump.snackAmount = getShortToInt(bufferData) / 100.0 // 주입설정량
diaconnG8Pump.snackInjAmount = getShortToInt(bufferData) / 100.0 // 현재주입량
diaconnG8Pump.snackSpeed = getByteToInt(bufferData) //주입속도
// 10. square(extended) bolus status
diaconnG8Pump.squareStatus = getByteToInt(bufferData) // 주입상태
diaconnG8Pump.squareTime = getShortToInt(bufferData) // 설정 주입시간(10~300분)
diaconnG8Pump.squareInjTime = getShortToInt(bufferData) // 경과 주입시간(10~300분)
diaconnG8Pump.squareAmount = getShortToInt(bufferData) / 100.0 // 주입 설정량
diaconnG8Pump.squareInjAmount = getShortToInt(bufferData) / 100.0 // 현재 주입량
// 11. daul bolus status
diaconnG8Pump.dualStatus = getByteToInt(bufferData) // 주입상태
diaconnG8Pump.dualAmount = getShortToInt(bufferData) / 100.0 // 일반주입 설정량
diaconnG8Pump.dualInjAmount = getShortToInt(bufferData) / 100.0 // 일반주입량
diaconnG8Pump.dualSquareTime = getShortToInt(bufferData) // 스퀘어주입 설정시간(10~300분)
diaconnG8Pump.dualInjSquareTime = getShortToInt(bufferData) // 스퀘어주입 경과시간(10~300분)
diaconnG8Pump.dualSquareAmount = getShortToInt(bufferData) / 100.0 // 스퀘어주입 설정량
diaconnG8Pump.dualInjSquareAmount = getShortToInt(bufferData) / 100.0 // 스퀘어주입량
// 12. last injection status
diaconnG8Pump.recentKind1 = getByteToInt(bufferData) // 최근-1 주입 종류(1=식사, 2=일반간식, 3=스퀘어회식, 4=더블회식)
diaconnG8Pump.recentTime1 = getIntToInt(bufferData) // 최근-1 주입 시간
diaconnG8Pump.recentAmount1 = getShortToInt(bufferData) / 100.0 // 최근-1 주입량
diaconnG8Pump.recentKind2 = getByteToInt(bufferData) // 최근-2 주입 종류(1=식사, 2=일반간식, 3=스퀘어회식, 4=더블회식)
diaconnG8Pump.recentTime2 = getIntToInt(bufferData) // 최근-2 주입 시간
diaconnG8Pump.recentAmount2 = getShortToInt(bufferData) / 100.0 // 최근-2 주입량
// 13. daily injection status
diaconnG8Pump.todayBaseAmount = getShortToInt(bufferData) / 100.0 // 기저주입 총량
diaconnG8Pump.todayMealAmount = getShortToInt(bufferData) / 100.0 // 식사주입 총량
diaconnG8Pump.todaySnackAmount = getShortToInt(bufferData) / 100.0 // 회식주입 총량
// 14. basal injection status at this hour
diaconnG8Pump.currentBasePattern = getByteToInt(bufferData) // 패턴 종류 (1=기본, 2=생활1, 3=생활2, 4=생활3, 5=닥터1, 6=닥터2)
diaconnG8Pump.currentBaseHour = getByteToInt(bufferData) // 현재주입시간(0~23)
diaconnG8Pump.currentBaseTbBeforeAmount = getShortToInt(bufferData) / 100.0 // 해당시간의 임시기저 계산 전 기저주입량: 기저주입막힘 발생 시 기저주입 막힘량 제외, 기저정지로 인해 주입되지 않은 량 제외, 리셋으로 인해 주입되지 않은 량 제외(47.5=4750)
diaconnG8Pump.currentBaseTbAfterAmount = getShortToInt(bufferData)/ 100.0 // 해당시간의 임시기저 계산 후 기저주입량: 기저주입막힘 발생 시 기저주입 막힘량 제외, 기저정지로 인해 주입되지 않은 량 제외, 리셋으로 인해 주입되지 않은 량 제외(47.5=4750)
// 15. saved basal pattern status
diaconnG8Pump.baseAmount1 = getShortToInt(bufferData) / 100.0 // 주입량 1(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount2 = getShortToInt(bufferData) / 100.0 // 주입량 2(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount3 = getShortToInt(bufferData) / 100.0 // 주입량 3(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount4 = getShortToInt(bufferData) / 100.0 // 주입량 4(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount5 = getShortToInt(bufferData) / 100.0 // 주입량 5(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount6 = getShortToInt(bufferData) / 100.0 // 주입량 6(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount7 = getShortToInt(bufferData) / 100.0 // 주입량 7(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount8 = getShortToInt(bufferData) / 100.0 // 주입량 8(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount9 = getShortToInt(bufferData) / 100.0 // 주입량 9(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount10 = getShortToInt(bufferData) / 100.0 // 주입량 10(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount11 = getShortToInt(bufferData) / 100.0 // 주입량 11(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount12 = getShortToInt(bufferData) / 100.0 // 주입량 12(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount13 = getShortToInt(bufferData) / 100.0 // 주입량 13(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount14 = getShortToInt(bufferData) / 100.0 // 주입량 14(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount15 = getShortToInt(bufferData) / 100.0 // 주입량 15(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount16 = getShortToInt(bufferData) / 100.0 // 주입량 16(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount17 = getShortToInt(bufferData) / 100.0 // 주입량 17(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount18 = getShortToInt(bufferData) / 100.0 // 주입량 18(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount19 = getShortToInt(bufferData) / 100.0 // 주입량 19(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount20 = getShortToInt(bufferData) / 100.0 // 주입량 20(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount21 = getShortToInt(bufferData) / 100.0 // 주입량 21(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount22 = getShortToInt(bufferData) / 100.0 // 주입량 22(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount23 = getShortToInt(bufferData) / 100.0 // 주입량 23(량*100, 23.25->2325, 15.2->1520)
diaconnG8Pump.baseAmount24 = getShortToInt(bufferData) / 100.0 // 주입량 24(량*100, 23.25->2325, 15.2->1520)
// 16. 1hour basal limit
diaconnG8Pump.maxBasalPerHours = getShortToInt(bufferData).toDouble() / 100.0 // not include tempbasal limit
diaconnG8Pump.maxBasal = diaconnG8Pump.maxBasalPerHours * 2 // include tempbasal
// 17. snack limit
diaconnG8Pump.maxBolus = getShortToInt(bufferData).toDouble() / 100
diaconnG8Pump.maxBolusePerDay = getShortToInt(bufferData).toDouble() / 100
// 18. pump sound
diaconnG8Pump.beepAndAlarm = getByteToInt(bufferData) -1
diaconnG8Pump.alarmIntesity = getByteToInt(bufferData) -1
// 19. pump light time
diaconnG8Pump.lcdOnTimeSec = getByteToInt(bufferData) // kind (1=30 sec, 2=40 sec, 3=50 sec)
// 20. language
diaconnG8Pump.selectedLanguage = getByteToInt(bufferData) // language (1=Chiness, 2=Korean, 3=English)
// 21. pump LGS ( firmware above
diaconnG8Pump.lgsStatus = 0 // LGS 상태(1=LGS_ON, 2=LGS_OFF)
diaconnG8Pump.lgsTime = 0 // LGS 적용 시간 (0~255분)
diaconnG8Pump.lgsElapsedTime= 0 // LGS 경과 시간(0~255분)
// tempbasal setting status
diaconnG8Pump.isTempBasalInProgress = diaconnG8Pump.tbStatus == 1
aapsLogger.debug(LTag.PUMPCOMM, "isTempBasalInProgress > " + diaconnG8Pump.isTempBasalInProgress)
// if rate type is percent
if (diaconnG8Pump.tbInjectRateRatio >= 50000) {
diaconnG8Pump.tempBasalPercent = diaconnG8Pump.tbInjectRateRatio - 50000
var absoluteValue = diaconnG8Pump.baseAmount * (diaconnG8Pump.tempBasalPercent / 100.0)
absoluteValue = pumpDesc.pumpType.determineCorrectBasalSize(absoluteValue)
diaconnG8Pump.tempBasalAbsoluteRate = absoluteValue
}
// if rate type is absolute
if(diaconnG8Pump.tbInjectRateRatio in 1000..1600) {
diaconnG8Pump.tbInjectAbsoluteValue = (diaconnG8Pump.tbInjectRateRatio -1000) / 100.0
diaconnG8Pump.tempBasalAbsoluteRate = diaconnG8Pump.tbInjectAbsoluteValue
}
// extended bolus status
diaconnG8Pump.isExtendedInProgress = diaconnG8Pump.squareStatus == 1 || diaconnG8Pump.dualStatus == 1
if(diaconnG8Pump.squareStatus == 1) { //square
diaconnG8Pump.extendedBolusMinutes = diaconnG8Pump.squareTime
diaconnG8Pump.extendedBolusAbsoluteRate = diaconnG8Pump.squareAmount
diaconnG8Pump.extendedBolusPassedMinutes = diaconnG8Pump.squareInjTime
diaconnG8Pump.extendedBolusRemainingMinutes = diaconnG8Pump.squareTime - diaconnG8Pump.squareInjTime
diaconnG8Pump.extendedBolusDeliveredSoFar = diaconnG8Pump.squareInjAmount
} else if (diaconnG8Pump.dualStatus == 1) { //dual
diaconnG8Pump.extendedBolusMinutes = diaconnG8Pump.dualSquareTime
diaconnG8Pump.extendedBolusAbsoluteRate = diaconnG8Pump.dualSquareAmount
diaconnG8Pump.extendedBolusPassedMinutes = diaconnG8Pump.dualInjSquareTime
diaconnG8Pump.extendedBolusRemainingMinutes = diaconnG8Pump.dualSquareTime - diaconnG8Pump.dualInjSquareTime
diaconnG8Pump.extendedBolusDeliveredSoFar = diaconnG8Pump.dualInjSquareAmount
}
// pump time setting 'yyyy-MM-dd'T'HH:mm:ssZ' “2019-07-04T12:30:30+0530”
val time = DateTime(diaconnG8Pump.year, diaconnG8Pump.month, diaconnG8Pump.day, diaconnG8Pump.hour, diaconnG8Pump.minute, diaconnG8Pump.second)
diaconnG8Pump.setPumpTime(time.millis)
aapsLogger.debug(LTag.PUMPCOMM, "Pump time " + dateUtil.dateAndTimeString(time.millis))
// basal pattern from pump
diaconnG8Pump.pumpProfiles = Array(4) { Array(24) { 0.0 } }
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][0] = diaconnG8Pump.baseAmount1
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][1] = diaconnG8Pump.baseAmount2
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][2] = diaconnG8Pump.baseAmount3
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][3] = diaconnG8Pump.baseAmount4
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][4] = diaconnG8Pump.baseAmount5
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][5] = diaconnG8Pump.baseAmount6
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][6] = diaconnG8Pump.baseAmount7
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][7] = diaconnG8Pump.baseAmount8
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][8] = diaconnG8Pump.baseAmount9
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][9] = diaconnG8Pump.baseAmount10
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][10] = diaconnG8Pump.baseAmount11
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][11] = diaconnG8Pump.baseAmount12
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][12] = diaconnG8Pump.baseAmount13
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][13] = diaconnG8Pump.baseAmount14
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][14] = diaconnG8Pump.baseAmount15
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][15] = diaconnG8Pump.baseAmount16
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][16] = diaconnG8Pump.baseAmount17
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][17] = diaconnG8Pump.baseAmount18
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][18] = diaconnG8Pump.baseAmount19
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][19] = diaconnG8Pump.baseAmount20
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][20] = diaconnG8Pump.baseAmount21
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][21] = diaconnG8Pump.baseAmount22
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][22] = diaconnG8Pump.baseAmount23
diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][23] = diaconnG8Pump.baseAmount24
//incarnation no 처리
diaconnG8Pump.isPumpVersionGe2_63 = PumplogUtil.isPumpVersionGe(sp.getString(resourceHelper.gs(R.string.pumpversion), ""),2, 63)
aapsLogger.debug(LTag.PUMPCOMM, "result > " + diaconnG8Pump.result)
aapsLogger.debug(LTag.PUMPCOMM, "systemRemainInsulin > " + diaconnG8Pump.systemRemainInsulin)
aapsLogger.debug(LTag.PUMPCOMM, "systemRemainBattery > " + diaconnG8Pump.systemRemainBattery)
aapsLogger.debug(LTag.PUMPCOMM, "systemBasePattern > " + diaconnG8Pump.systemBasePattern)
aapsLogger.debug(LTag.PUMPCOMM, "systemTbStatus > " + diaconnG8Pump.systemTbStatus)
aapsLogger.debug(LTag.PUMPCOMM, "systemInjectionMealStatus > " + diaconnG8Pump.systemInjectionMealStatus)
aapsLogger.debug(LTag.PUMPCOMM, "systemInjectionSnackStatus > " + diaconnG8Pump.systemInjectionSnackStatus)
aapsLogger.debug(LTag.PUMPCOMM, "systemInjectionSquareStatue > " + diaconnG8Pump.systemInjectionSquareStatue)
aapsLogger.debug(LTag.PUMPCOMM, "systemInjectionDualStatus > " + diaconnG8Pump.systemInjectionDualStatus)
aapsLogger.debug(LTag.PUMPCOMM, "basePauseStatus > " + diaconnG8Pump.basePauseStatus)
aapsLogger.debug(LTag.PUMPCOMM, "year > " + diaconnG8Pump.year)
aapsLogger.debug(LTag.PUMPCOMM, "month > " + diaconnG8Pump.month)
aapsLogger.debug(LTag.PUMPCOMM, "day > " + diaconnG8Pump.day)
aapsLogger.debug(LTag.PUMPCOMM, "hour > " + diaconnG8Pump.hour)
aapsLogger.debug(LTag.PUMPCOMM, "minute > " + diaconnG8Pump.minute)
aapsLogger.debug(LTag.PUMPCOMM, "second > " + diaconnG8Pump.second)
aapsLogger.debug(LTag.PUMPCOMM, "country > " + diaconnG8Pump.country)
aapsLogger.debug(LTag.PUMPCOMM, "productType > " + diaconnG8Pump.productType)
aapsLogger.debug(LTag.PUMPCOMM, "makeYear > " + diaconnG8Pump.makeYear)
aapsLogger.debug(LTag.PUMPCOMM, "makeMonth > " + diaconnG8Pump.makeMonth)
aapsLogger.debug(LTag.PUMPCOMM, "makeDay > " + diaconnG8Pump.makeDay)
aapsLogger.debug(LTag.PUMPCOMM, "lotNo > " + diaconnG8Pump.lotNo)
aapsLogger.debug(LTag.PUMPCOMM, "serialNo > " + diaconnG8Pump.serialNo)
aapsLogger.debug(LTag.PUMPCOMM, "majorVersion > " + diaconnG8Pump.majorVersion)
aapsLogger.debug(LTag.PUMPCOMM, "minorVersion > " + diaconnG8Pump.minorVersion)
aapsLogger.debug(LTag.PUMPCOMM, "lastNum > " + diaconnG8Pump.pumpLastLogNum)
aapsLogger.debug(LTag.PUMPCOMM, "wrappingCount > " + diaconnG8Pump.pumpWrappingCount)
aapsLogger.debug(LTag.PUMPCOMM, "speed > " + diaconnG8Pump.speed)
aapsLogger.debug(LTag.PUMPCOMM, "tbStatus > " + diaconnG8Pump.tbStatus)
aapsLogger.debug(LTag.PUMPCOMM, "tbTime> " + diaconnG8Pump.tbTime)
aapsLogger.debug(LTag.PUMPCOMM, "tbInjectRateRatio > " + diaconnG8Pump.tbInjectRateRatio)
aapsLogger.debug(LTag.PUMPCOMM, "tbElapsedTime > " + diaconnG8Pump.tbElapsedTime)
aapsLogger.debug(LTag.PUMPCOMM, "baseStatus > " + diaconnG8Pump.baseStatus)
aapsLogger.debug(LTag.PUMPCOMM, "baseHour > " + diaconnG8Pump.baseHour)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount > " + diaconnG8Pump.baseAmount)
aapsLogger.debug(LTag.PUMPCOMM, "baseInjAmount > " + diaconnG8Pump.baseInjAmount)
aapsLogger.debug(LTag.PUMPCOMM, "mealKind > " + diaconnG8Pump.mealKind)
aapsLogger.debug(LTag.PUMPCOMM, "mealStartTime > " + diaconnG8Pump.mealStartTime)
aapsLogger.debug(LTag.PUMPCOMM, "mealStatus > " + diaconnG8Pump.mealStatus)
aapsLogger.debug(LTag.PUMPCOMM, "mealAmount > " + diaconnG8Pump.mealAmount)
aapsLogger.debug(LTag.PUMPCOMM, "mealInjAmount > " + diaconnG8Pump.mealInjAmount)
aapsLogger.debug(LTag.PUMPCOMM, "mealSpeed > " + diaconnG8Pump.mealSpeed)
aapsLogger.debug(LTag.PUMPCOMM, "snackStatus > " + diaconnG8Pump.snackStatus)
aapsLogger.debug(LTag.PUMPCOMM, "snackAmount > " + diaconnG8Pump.snackAmount)
aapsLogger.debug(LTag.PUMPCOMM, "snackInjAmount > " + diaconnG8Pump.snackInjAmount)
aapsLogger.debug(LTag.PUMPCOMM, "snackSpeed > " + diaconnG8Pump.snackSpeed)
aapsLogger.debug(LTag.PUMPCOMM, "squareStatus > " + diaconnG8Pump.squareStatus)
aapsLogger.debug(LTag.PUMPCOMM, "squareTime > " + diaconnG8Pump.squareTime)
aapsLogger.debug(LTag.PUMPCOMM, "squareInjTime > " + diaconnG8Pump.squareInjTime)
aapsLogger.debug(LTag.PUMPCOMM, "squareAmount > " + diaconnG8Pump.squareAmount)
aapsLogger.debug(LTag.PUMPCOMM, "squareInjAmount > " + diaconnG8Pump.squareInjAmount)
aapsLogger.debug(LTag.PUMPCOMM, "dualStatus > " + diaconnG8Pump.dualStatus)
aapsLogger.debug(LTag.PUMPCOMM, "dualAmount > " + diaconnG8Pump.dualAmount)
aapsLogger.debug(LTag.PUMPCOMM, "dualInjAmount > " + diaconnG8Pump.dualInjAmount)
aapsLogger.debug(LTag.PUMPCOMM, "dualSquareTime > " + diaconnG8Pump.dualSquareTime)
aapsLogger.debug(LTag.PUMPCOMM, "dualInjSquareTime > " + diaconnG8Pump.dualInjSquareTime)
aapsLogger.debug(LTag.PUMPCOMM, "dualSquareAmount > " + diaconnG8Pump.dualSquareAmount)
aapsLogger.debug(LTag.PUMPCOMM, "dualInjSquareAmount> " + diaconnG8Pump.dualInjSquareAmount)
aapsLogger.debug(LTag.PUMPCOMM, "recentKind1 > " + diaconnG8Pump.recentKind1)
aapsLogger.debug(LTag.PUMPCOMM, "recentTime1 > " + diaconnG8Pump.recentTime1)
aapsLogger.debug(LTag.PUMPCOMM, "recentAmount1 > " + diaconnG8Pump.recentAmount1)
aapsLogger.debug(LTag.PUMPCOMM, "recentKind2 > " + diaconnG8Pump.recentKind2)
aapsLogger.debug(LTag.PUMPCOMM, "recentTime2 > " + diaconnG8Pump.recentTime2)
aapsLogger.debug(LTag.PUMPCOMM, "recentAmount2 > " + diaconnG8Pump.recentAmount2)
aapsLogger.debug(LTag.PUMPCOMM, "todayBaseAmount > " + diaconnG8Pump.todayBaseAmount)
aapsLogger.debug(LTag.PUMPCOMM, "todayMealAmount > " + diaconnG8Pump.todayMealAmount)
aapsLogger.debug(LTag.PUMPCOMM, "todaySnackAmount > " + diaconnG8Pump.todaySnackAmount)
aapsLogger.debug(LTag.PUMPCOMM, "morningHour > " + diaconnG8Pump.morningHour)
aapsLogger.debug(LTag.PUMPCOMM, "morningAmount > " + diaconnG8Pump.morningAmount)
aapsLogger.debug(LTag.PUMPCOMM, "lunchHour > " + diaconnG8Pump.lunchHour)
aapsLogger.debug(LTag.PUMPCOMM, "lunchAmount > " + diaconnG8Pump.lunchAmount)
aapsLogger.debug(LTag.PUMPCOMM, "dinnerHour > " + diaconnG8Pump.dinnerHour)
aapsLogger.debug(LTag.PUMPCOMM, "dinnerAmount > " + diaconnG8Pump.dinnerAmount)
aapsLogger.debug(LTag.PUMPCOMM, "currentBasePattern > " + diaconnG8Pump.currentBasePattern)
aapsLogger.debug(LTag.PUMPCOMM, "currentBaseHour > " + diaconnG8Pump.currentBaseHour)
aapsLogger.debug(LTag.PUMPCOMM, "currentBaseTbBeforeAmount > " + diaconnG8Pump.currentBaseTbBeforeAmount)
aapsLogger.debug(LTag.PUMPCOMM, "currentBaseTbAfterAmount > " + diaconnG8Pump.currentBaseTbAfterAmount)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount1 > " + diaconnG8Pump.baseAmount1)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount2 > " + diaconnG8Pump.baseAmount2)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount3 > " + diaconnG8Pump.baseAmount3)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount4 > " + diaconnG8Pump.baseAmount4)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount5 > " + diaconnG8Pump.baseAmount5)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount6 > " + diaconnG8Pump.baseAmount6)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount7 > " + diaconnG8Pump.baseAmount7)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount8 > " + diaconnG8Pump.baseAmount8)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount9 > " + diaconnG8Pump.baseAmount9)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount10 > " + diaconnG8Pump.baseAmount10)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount11 > " + diaconnG8Pump.baseAmount11)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount12 > " + diaconnG8Pump.baseAmount12)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount13 > " + diaconnG8Pump.baseAmount13)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount14 > " + diaconnG8Pump.baseAmount14)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount15 > " + diaconnG8Pump.baseAmount15)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount16 > " + diaconnG8Pump.baseAmount16)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount17 > " + diaconnG8Pump.baseAmount17)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount18 > " + diaconnG8Pump.baseAmount18)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount19 > " + diaconnG8Pump.baseAmount19)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount20 > " + diaconnG8Pump.baseAmount20)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount21 > " + diaconnG8Pump.baseAmount21)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount22 > " + diaconnG8Pump.baseAmount22)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount23 > " + diaconnG8Pump.baseAmount23)
aapsLogger.debug(LTag.PUMPCOMM, "baseAmount24 > " + diaconnG8Pump.baseAmount24)
aapsLogger.debug(LTag.PUMPCOMM, "maxBasalPerHours > " + diaconnG8Pump.maxBasalPerHours)
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, "beepAndAlarm > " + diaconnG8Pump.beepAndAlarm)
aapsLogger.debug(LTag.PUMPCOMM, "alarmIntesity > " + diaconnG8Pump.alarmIntesity)
aapsLogger.debug(LTag.PUMPCOMM, "lcdOnTimeSec > " + diaconnG8Pump.lcdOnTimeSec)
aapsLogger.debug(LTag.PUMPCOMM, "selectedLanguage > " + diaconnG8Pump.selectedLanguage)
}
override fun getFriendlyName(): String {
return "PUMP_BIG_APS_MAIN_INFO_INQUIRE_RESPONSE"
}
}

View file

@ -21,7 +21,6 @@ import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.apache.commons.lang3.time.DateUtils
import org.joda.time.DateTime
import javax.inject.Inject
/**

View file

@ -19,6 +19,7 @@ class DiaconnG8ResponseMessageHashTable @Inject constructor(val injector: HasAnd
init {
put(BigMainInfoInquireResponsePacket(injector))
put(BigAPSMainInfoInquireResponsePacket(injector))
put(BigLogInquireResponsePacket(injector))
put(InjectionSnackInquireResponsePacket(injector))
put(SneckLimitInquireResponsePacket(injector))

View file

@ -37,7 +37,7 @@ class InjectionExtendedBolusResultReportPacket(injector: HasAndroidInjector) : D
val bolusAmountToBeDelivered = getShortToInt(bufferData) / 100.0
val deliveredBolusAmount = getShortToInt(bufferData) / 100.0
diaconnG8Pump.isExtendedInProgress = result == 0
//diaconnG8Pump.isExtendedInProgress = result == 0
diaconnG8Pump.extendedBolusMinutes = settingMinutes
diaconnG8Pump.extendedBolusAbsoluteRate = bolusAmountToBeDelivered
diaconnG8Pump.extendedBolusPassedMinutes = elapsedTime
@ -45,7 +45,6 @@ class InjectionExtendedBolusResultReportPacket(injector: HasAndroidInjector) : D
diaconnG8Pump.extendedBolusDeliveredSoFar = deliveredBolusAmount
aapsLogger.debug(LTag.PUMPCOMM, "Result: $result")
aapsLogger.debug(LTag.PUMPCOMM, "Is extended bolus running: " + diaconnG8Pump.isExtendedInProgress)
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus running: " + diaconnG8Pump.extendedBolusAbsoluteRate + " U/h")
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus duration: " + diaconnG8Pump.extendedBolusMinutes + " min")
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus so far: " + diaconnG8Pump.extendedBolusSoFarInMinutes + " min")

View file

@ -1,5 +1,7 @@
package info.nightscout.androidaps.diaconn.pumplog;
import android.annotation.SuppressLint;
import org.apache.commons.lang3.RegExUtils;
import org.apache.commons.lang3.StringUtils;
@ -17,6 +19,7 @@ public class PumplogUtil {
* @param buffer 바이트버퍼
* @return GMT 날짜 문자열
*/
@SuppressLint("SimpleDateFormat")
public static String getDttm(ByteBuffer buffer) {
byte b0 = buffer.get();
byte b1 = buffer.get();
@ -34,6 +37,7 @@ public class PumplogUtil {
* @param data 로그데이터
* @return GMT 날짜 문자열
*/
@SuppressLint("SimpleDateFormat")
public static String getDttm(String data) {
byte[] bytes = PumplogUtil.hexStringToByteArray(data);
byte b0 = bytes[0];
@ -42,7 +46,7 @@ public class PumplogUtil {
byte b3 = bytes[3];
long pumpTime = Long.parseLong(String.format("%02x%02x%02x%02x", b3, b2, b1, b0), 16);
long epochTime = new Date(0).getTime(); // 1970-01-01
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
return sdf.format(new Date(epochTime + pumpTime * 1000));
}

View file

@ -16,6 +16,7 @@ import info.nightscout.androidaps.diaconn.DiaconnG8Pump
import info.nightscout.androidaps.diaconn.R
import info.nightscout.androidaps.diaconn.events.EventDiaconnG8NewStatus
import info.nightscout.androidaps.diaconn.packet.*
import info.nightscout.androidaps.diaconn.pumplog.PumplogUtil
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.events.EventAppExit
import info.nightscout.androidaps.events.EventInitializationChanged
@ -39,6 +40,7 @@ import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.queue.commands.Command
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.StringUtils
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import io.reactivex.disposables.CompositeDisposable
@ -132,12 +134,19 @@ class DiaconnG8Service : DaggerService() {
try {
val pump = activePlugin.activePump
rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings)))
sendMessage(BasalLimitInquirePacket(injector), 2000) // basal Limit
sendMessage(SneckLimitInquirePacket(injector), 2000) // bolus Limit
sendMessage(BigMainInfoInquirePacket(injector), 2000) // Pump Main Info
sendMessage(SoundInquirePacket(injector), 2000) // sounds
sendMessage(DisplayTimeInquirePacket(injector), 2000) // display
sendMessage(LanguageInquirePacket(injector), 2000) // language
val pumpFirmwareVersion = sp.getString(resourceHelper.gs(R.string.pumpversion),"")
if(!StringUtils.emptyString(pumpFirmwareVersion) && PumplogUtil.isPumpVersionGe(pumpFirmwareVersion, 2, 83)) {
sendMessage(BigAPSMainInfoInquirePacket(injector), 2000) // APS Pump Main Info
} else {
sendMessage(BasalLimitInquirePacket(injector), 2000) // basal Limit
sendMessage(SneckLimitInquirePacket(injector), 2000) // bolus Limit
sendMessage(BigMainInfoInquirePacket(injector), 2000) // Pump Main Info
sendMessage(SoundInquirePacket(injector), 2000) // sounds
sendMessage(DisplayTimeInquirePacket(injector), 2000) // display
sendMessage(LanguageInquirePacket(injector), 2000) // language
}
diaconnG8Pump.lastConnection = System.currentTimeMillis()
@ -180,8 +189,7 @@ class DiaconnG8Service : DaggerService() {
rxBus.send(EventInitializationChanged())
return
} else {
// 폰과 휴대폰의 시간 동기화
// 임시기저가 진행 여부에 따른 시간설정 분기.
if(!diaconnG8Pump.isTempBasalInProgress) {
val msgPacket = TimeSettingPacket(injector, dateUtil.now(), offset)
sendMessage(msgPacket)
@ -434,7 +442,7 @@ class DiaconnG8Service : DaggerService() {
}
}
fun tempBasal(absoluteRate: Double, durationInHours: Int): Boolean {
fun tempBasal(absoluteRate: Double, durationInHours: Double): Boolean {
if (!isConnected) return false
if (diaconnG8Pump.isTempBasalInProgress) {
rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)))
@ -447,7 +455,7 @@ class DiaconnG8Service : DaggerService() {
}
rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)))
val tbInjectRate = ((absoluteRate*100) + 1000).toInt()
val msgTBR = TempBasalSettingPacket(injector, 1, (durationInHours * 60) / 15, tbInjectRate)
val msgTBR = TempBasalSettingPacket(injector, 1, ((durationInHours * 60) / 15).toInt(), tbInjectRate)
sendMessage(msgTBR, 2000)
// otp process
if(!processConfirm(msgTBR.msgType)) return false
@ -550,7 +558,7 @@ class DiaconnG8Service : DaggerService() {
sendMessage(msgExtended, 2000)
// otp process
if(!processConfirm(msgExtended.msgType)) return false
//diaconnG8Pump.isExtendedInProgress = true
loadHistory()
val eb = pumpSync.expectedPumpState().extendedBolus
diaconnG8Pump.fromExtendedBolus(eb)