diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index ff53f4004f..3646d57340 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -6,6 +6,7 @@
+
@@ -124,6 +125,7 @@
+
diff --git a/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt b/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt
index 58b939b2cb..0e29d22b00 100644
--- a/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt
+++ b/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt
@@ -26,6 +26,7 @@ import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.AAPSLogger
+import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.queue.Callback
@@ -232,11 +233,15 @@ class TDDStatsActivity : NoSplashAppCompatActivity() {
@SuppressLint("SetTextI18n")
private fun loadDataFromDB() {
historyList.clear()
- historyList.addAll(repository.getLastTotalDailyDoses(10, false).blockingGet())
+ // timestamp DESC sorting!
+ historyList.addAll(repository.getLastTotalDailyDoses(10, true).blockingGet())
//only use newest 10
historyList = historyList.subList(0, min(10, historyList.size))
+ // dummies reset
+ dummies.clear()
+
//fill single gaps
val df: DateFormat = SimpleDateFormat("dd.MM.", Locale.getDefault())
for (i in 0 until historyList.size - 1) {
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Fragment.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Fragment.kt
index 3e7e9a2e01..0c3ff324d7 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Fragment.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Fragment.kt
@@ -169,8 +169,10 @@ class DiaconnG8Fragment : DaggerFragment() {
binding.lastbolus.text = ""
}
- binding.dailyunits.text = resourceHelper.gs(R.string.reservoirvalue, (pump.todayBaseAmount + pump.todaySnackAmount + pump.todayMealAmount), ((pump.maxBasal.toInt() * 24) + pump.maxBolusePerDay.toInt()))
- warnColors.setColor(binding.dailyunits, pump.baseInjAmount, pump.baseAmount * 0.75, pump.baseAmount * 0.9)
+ val todayInsulinAmount = (pump.todayBaseAmount + pump.todaySnackAmount + pump.todayMealAmount)
+ val todayInsulinLimitAmount = (pump.maxBasal.toInt() * 24) + pump.maxBolusePerDay.toInt()
+ binding.dailyunits.text = resourceHelper.gs(R.string.reservoirvalue, todayInsulinAmount, todayInsulinLimitAmount)
+ warnColors.setColor(binding.dailyunits, todayInsulinAmount, todayInsulinLimitAmount * 0.75, todayInsulinLimitAmount * 0.9)
binding.basabasalrate.text = pump.baseInjAmount.toString() +" / "+ resourceHelper.gs(R.string.pump_basebasalrate, plugin.baseBasalRate)
binding.tempbasal.text = diaconnG8Pump.temporaryBasalToString()
@@ -179,7 +181,6 @@ class DiaconnG8Fragment : DaggerFragment() {
warnColors.setColorInverse(binding.reservoir, pump.systemRemainInsulin , 50.0, 20.0)
binding.battery.text = "{fa-battery-" + pump.systemRemainBattery / 25 + "}" + " ("+ pump.systemRemainBattery + " %)"
warnColors.setColorInverse(binding.battery, pump.systemRemainBattery.toDouble(), 51.0, 26.0)
- //binding.tdd.text = "basal: " +pump.todayBaseAmount + "/ bolus: "+ (pump.todaySnackAmount + pump.todayMealAmount)
binding.firmware.text = resourceHelper.gs(R.string.diaconn_g8_pump) + "\nVersion: " + pump.majorVersion.toString() + "." + pump.minorVersion.toString() + "\nCountry: "+pump.country.toString() + "\nProductType: "+ pump.productType.toString() + "\nManufacture: " + pump.makeYear + "." + pump.makeMonth + "." + pump.makeDay
binding.basalstep.text = pump.basalStep.toString()
binding.bolusstep.text = pump.bolusStep.toString()
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Plugin.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Plugin.kt
index e586e45c3f..168c0f3fa5 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Plugin.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Plugin.kt
@@ -268,7 +268,7 @@ class DiaconnG8Plugin @Inject constructor(
if(result.success) result.enacted = true
if (!result.success) {
- setErrorMsg(diaconnG8Pump.bolusStartErrorCode, result)
+ setErrorMsg(diaconnG8Pump.resultErrorCode, result)
} else result.comment = resourceHelper.gs(R.string.ok)
aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered)
result
@@ -409,7 +409,7 @@ class DiaconnG8Plugin @Inject constructor(
result.enacted = false
result.success = false
- setErrorMsg(diaconnG8Pump.bolusStartErrorCode, result)
+ setErrorMsg(diaconnG8Pump.resultErrorCode, result)
aapsLogger.error("setExtendedBolus: Failed to extended bolus")
return result
}
@@ -422,6 +422,7 @@ class DiaconnG8Plugin @Inject constructor(
result.success = !diaconnG8Pump.isTempBasalInProgress
result.enacted = true
result.isTempCancel = true
+ if(!result.success) setErrorMsg(diaconnG8Pump.resultErrorCode, result)
} else {
result.success = true
result.enacted = false
@@ -438,6 +439,11 @@ class DiaconnG8Plugin @Inject constructor(
diaconnG8Service?.extendedBolusStop()
result.success = !diaconnG8Pump.isExtendedInProgress
result.enacted = true
+ if(!result.success) {
+ setErrorMsg(diaconnG8Pump.resultErrorCode, result)
+ diaconnG8Service?.readPumpStatus()
+ }
+
} else {
result.success = true
result.enacted = false
@@ -560,6 +566,11 @@ class DiaconnG8Plugin @Inject constructor(
13 -> result.comment = resourceHelper.gs(R.string.diaconn_g8_errorcode_13)
14 -> result.comment = resourceHelper.gs(R.string.diaconn_g8_errorcode_14)
15 -> result.comment = resourceHelper.gs(R.string.diaconn_g8_errorcode_15)
+ 32 -> result.comment = resourceHelper.gs(R.string.diaconn_g8_errorcode_32)
+ 33 -> result.comment = resourceHelper.gs(R.string.diaconn_g8_errorcode_33)
+ 34 -> result.comment = resourceHelper.gs(R.string.diaconn_g8_errorcode_34)
+ 35 -> result.comment = resourceHelper.gs(R.string.diaconn_g8_errorcode_35)
+ 36 -> result.comment = resourceHelper.gs(R.string.diaconn_g8_errorcode_36)
else -> result.comment = "not defined Error code: $errorCode"
}
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt
index 8906295137..77739cf9e9 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt
@@ -58,27 +58,41 @@ class DiaconnG8Pump @Inject constructor(
var bolusBlocked = false
var lastBolusTime: Long = 0
var lastBolusAmount = 0.0
- var extendedBolusMinutes = 0
- var extendedBolusSoFarInMinutes = 0
- var extendedBolusDeliveredSoFar = 0.0
+
/*
* TEMP BASALS
*/
- var isTempBasalInProgress = false
- var tempBasalPercent = 0
var tempBasalStart: Long = 0
+ var tempBasalDuration: Long = 0 // in milliseconds
var tempBasalAbsoluteRate: Double = 0.0
- var tempBasalDuration: Long = 0
+ var tempBasalPercent: Int = 0
+ var tempBasalTotalSec: Long
+ set(durationInSec) {
+ tempBasalDuration = T.secs(durationInSec).msecs()
+ }
+ get() = T.msecs(tempBasalDuration).mins()
+ var isTempBasalInProgress: Boolean
+ get() = tempBasalStart != 0L && dateUtil.now() in tempBasalStart..tempBasalStart + tempBasalDuration
+ set(isRunning) {
+ if (isRunning) throw IllegalArgumentException("Use to cancel TBR only")
+ else {
+ tempBasalStart = 0L
+ tempBasalDuration = 0L
+ tempBasalAbsoluteRate = 0.0
+ }
+ }
val tempBasalRemainingMin: Int
- get() = max(tbElapsedTime, 0)
+ get() = max(T.msecs(tempBasalStart + tempBasalDuration - dateUtil.now()).mins().toInt(), 0)
fun temporaryBasalToString(): String {
if (!isTempBasalInProgress) return ""
- return tempBasalAbsoluteRate.toString() + "U @" +
+
+ val passedMin = ((min(dateUtil.now(), tempBasalStart + tempBasalDuration) - tempBasalStart) / 60.0 / 1000).roundToInt()
+ return tempBasalAbsoluteRate.toString() + "U/h @" +
dateUtil.timeString(tempBasalStart) +
- " " + tbElapsedTime + "/" + T.msecs(tempBasalDuration).mins() + "'"
+ " " + passedMin + "/" + T.msecs(tempBasalDuration).mins() + "'"
}
fun fromTemporaryBasal(tbr: PumpSync.PumpState.TemporaryBasal?) {
@@ -99,6 +113,7 @@ class DiaconnG8Pump @Inject constructor(
var extendedBolusStart: Long = 0
var extendedBolusDuration: Long = 0
var extendedBolusAmount = 0.0
+
var isExtendedInProgress: Boolean
get() = extendedBolusStart != 0L && dateUtil.now() in extendedBolusStart..extendedBolusStart + extendedBolusDuration
set(isRunning) {
@@ -109,15 +124,26 @@ class DiaconnG8Pump @Inject constructor(
extendedBolusAmount = 0.0
}
}
- var extendedBolusPassedMinutes = 0
- var extendedBolusRemainingMinutes = 0
- var extendedBolusAbsoluteRate = 0.0
+ val extendedBolusPassedMinutes:Int
+ get() = T.msecs(max(0, dateUtil.now() - extendedBolusStart)).mins().toInt()
+ val extendedBolusRemainingMinutes: Int
+ get() = max(T.msecs(extendedBolusStart + extendedBolusDuration - dateUtil.now()).mins().toInt(), 0)
+ private val extendedBolusDurationInMinutes: Int
+ get() = T.msecs(extendedBolusDuration).mins().toInt()
+
+ var extendedBolusAbsoluteRate: Double
+ get() = extendedBolusAmount * T.hours(1).msecs() / extendedBolusDuration
+ set(rate) {
+ extendedBolusAmount = rate * extendedBolusDuration / T.hours(1).msecs()
+ }
fun extendedBolusToString(): String {
if (!isExtendedInProgress) return ""
- return "E "+ DecimalFormatter.to2Decimal(extendedBolusDeliveredSoFar) +"/" + DecimalFormatter.to2Decimal(extendedBolusAbsoluteRate) + "U/h @" +
+ //return "E "+ DecimalFormatter.to2Decimal(extendedBolusDeliveredSoFar) +"/" + DecimalFormatter.to2Decimal(extendedBolusAbsoluteRate) + "U/h @" +
+ // " " + extendedBolusPassedMinutes + "/" + extendedBolusMinutes + "'"
+ return "E "+ DecimalFormatter.to2Decimal(extendedBolusAbsoluteRate) + "U/h @" +
dateUtil.timeString(extendedBolusStart) +
- " " + extendedBolusPassedMinutes + "/" + extendedBolusMinutes + "'"
+ " " + extendedBolusPassedMinutes + "/" + extendedBolusDurationInMinutes + "'"
}
fun fromExtendedBolus(eb: PumpSync.PumpState.ExtendedBolus?) {
@@ -148,9 +174,9 @@ class DiaconnG8Pump @Inject constructor(
var selectedLanguage = 0
var bolusSpeed = 0
+ var resultErrorCode: Int = 0 // last start bolus erroCode
// Bolus settings
- var bolusStartErrorCode: Int = 0 // last start bolus erroCode
var historyDoneReceived: Boolean = false // true when last history message is received
var bolusingTreatment: EventOverviewBolusProgress.Treatment? = null // actually delivered treatment
var bolusAmountToBeDelivered = 0.0 // amount to be delivered
@@ -231,7 +257,7 @@ class DiaconnG8Pump @Inject constructor(
var maxBasalPerHours = 0.0
// 7. Tempbasal status
- var tbStatus = 0 // 임시기저 상태
+ var tbStatus = 0 // 임시기저 상태 (1 : running, 2:not running )
var tbTime = 0 // 임시기저 시간
var tbInjectRateRatio = 0 // 임시기저 주입량/률 1000(0.00U)~1600(6.00U), 50000(0%)~50200(200%), 50000이상이면 주입률로 판정
var tbElapsedTime = 0 // 임시기저 경과 시간(0~1425분)
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/AppCancelSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/AppCancelSettingResponsePacket.kt
index bdba88b35f..97f2e09403 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/AppCancelSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/AppCancelSettingResponsePacket.kt
@@ -30,7 +30,7 @@ class AppCancelSettingResponsePacket(
val bufferData = prefixDecode(data)
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/AppConfirmSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/AppConfirmSettingResponsePacket.kt
index 096516e501..f54fc49d4a 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/AppConfirmSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/AppConfirmSettingResponsePacket.kt
@@ -31,7 +31,7 @@ class AppConfirmSettingResponsePacket(
aapsLogger.debug(LTag.PUMPCOMM, "Result --> ${result}")
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BasalPauseSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BasalPauseSettingResponsePacket.kt
index 649ed7ff5e..5ec73cbe3c 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BasalPauseSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BasalPauseSettingResponsePacket.kt
@@ -32,7 +32,7 @@ class BasalPauseSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BasalSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BasalSettingResponsePacket.kt
index 10ee5d139a..d7902d76f9 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BasalSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BasalSettingResponsePacket.kt
@@ -31,7 +31,7 @@ class BasalSettingResponsePacket(
val bufferData = prefixDecode(data)
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigAPSMainInfoInquireResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigAPSMainInfoInquireResponsePacket.kt
index cc607c93da..6c784ba1e7 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigAPSMainInfoInquireResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigAPSMainInfoInquireResponsePacket.kt
@@ -183,40 +183,6 @@ class BigAPSMainInfoInquireResponsePacket(
// 20. language
diaconnG8Pump.selectedLanguage = getByteToInt(bufferData) // language (1=Chiness, 2=Korean, 3=English)
- // 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
- 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)
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigLogInquireResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigLogInquireResponsePacket.kt
index 02bac875cf..e75008d66c 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigLogInquireResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigLogInquireResponsePacket.kt
@@ -21,6 +21,7 @@ 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
/**
@@ -98,14 +99,12 @@ class BigLogInquireResponsePacket(
val diaconnG8HistoryRecord = DiaconnHistoryRecord(0)
when(pumplogKind) {
- LOG_INJECT_MEAL_SUCCESS.LOG_KIND -> { // 8(식사주입성공)
+ LOG_INJECT_MEAL_SUCCESS.LOG_KIND -> {
val logItem = LOG_INJECT_MEAL_SUCCESS.parse(logDataToHexString)
aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
-
val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
val logDateTime = logStartDate.time
val detailedBolusInfo = detailedBolusInfoStorage.findDetailedBolusInfo(logDateTime, logItem.injectAmount / 100.0)
-
val newRecord = pumpSync.syncBolusWithPumpId(
timestamp = logDateTime,
amount = logItem.injectAmount / 100.0,
@@ -114,7 +113,6 @@ class BigLogInquireResponsePacket(
pumpType = PumpType.DIACONN_G8,
pumpSerial = diaconnG8Pump.serialNo.toString())
aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT MEALBOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U ")
-
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
diaconnG8HistoryRecord.timestamp = logDateTime
diaconnG8HistoryRecord.value = logItem.injectAmount / 100.0
@@ -139,7 +137,6 @@ class BigLogInquireResponsePacket(
pumpType = PumpType.DIACONN_G8,
pumpSerial = diaconnG8Pump.serialNo.toString())
aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT MEALBOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U ")
-
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
diaconnG8HistoryRecord.timestamp = logDateTime
diaconnG8HistoryRecord.value = if ((logItem.injectAmount / 100.0) < 0) 0.0 else (logItem.injectAmount / 100.0)
@@ -165,8 +162,6 @@ class BigLogInquireResponsePacket(
pumpType = PumpType.DIACONN_G8,
pumpSerial = diaconnG8Pump.serialNo.toString())
aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U ")
-
-
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
diaconnG8HistoryRecord.timestamp = logDateTime
diaconnG8HistoryRecord.value = logItem.injectAmount / 100.0
@@ -193,8 +188,6 @@ class BigLogInquireResponsePacket(
pumpType = PumpType.DIACONN_G8,
pumpSerial = diaconnG8Pump.serialNo.toString())
aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U ")
-
-
// Diaconn History Process
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
diaconnG8HistoryRecord.timestamp = logDateTime
@@ -220,7 +213,6 @@ class BigLogInquireResponsePacket(
pumpType = PumpType.DIACONN_G8,
pumpSerial = diaconnG8Pump.serialNo.toString())
aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTART (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Amount: " + logItem.setAmount / 100.0 + "U Duration: " + logItem.getInjectTime() * 10 + "min")
-
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
diaconnG8HistoryRecord.timestamp = logDateTime
diaconnG8HistoryRecord.value = logItem.setAmount / 100.0
@@ -234,10 +226,8 @@ class BigLogInquireResponsePacket(
LOG_INJECT_SQUARE_SUCCESS.LOG_KIND -> {
val logItem = LOG_INJECT_SQUARE_SUCCESS.parse(logDataToHexString)
aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
-
val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
val logDateTime = logStartDate.time
-
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
diaconnG8HistoryRecord.timestamp = logDateTime
diaconnG8HistoryRecord.duration = logItem.getInjectTime()
@@ -258,7 +248,6 @@ class BigLogInquireResponsePacket(
pumpType = PumpType.DIACONN_G8,
pumpSerial = diaconnG8Pump.serialNo.toString())
aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTOP (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Delivered: " + logItem.injectAmount / 100.0 + "U RealDuration: " + logItem.getInjectTime() + "min")
-
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
diaconnG8HistoryRecord.timestamp = logDateTime
diaconnG8HistoryRecord.value = logItem.injectAmount / 100.0
@@ -272,9 +261,9 @@ class BigLogInquireResponsePacket(
LOG_SET_DUAL_INJECTION.LOG_KIND -> {
val logItem = LOG_SET_DUAL_INJECTION.parse(logDataToHexString)
aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
-
val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
val logDateTime = logStartDate.time
+
// dual square 처리.
val newRecord = pumpSync.syncExtendedBolusWithPumpId(
timestamp = logDateTime,
@@ -285,8 +274,6 @@ class BigLogInquireResponsePacket(
pumpType = PumpType.DIACONN_G8,
pumpSerial = diaconnG8Pump.serialNo.toString())
aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTART (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Amount: " + logItem.setSquareAmount / 100.0 + "U Duration: " + logItem.getInjectTime() * 10 + "min")
-
-
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
diaconnG8HistoryRecord.timestamp = logDateTime
diaconnG8HistoryRecord.value = logItem.setSquareAmount / 100.0
@@ -313,6 +300,9 @@ class BigLogInquireResponsePacket(
pumpSerial = diaconnG8Pump.serialNo.toString())
aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U Duration: " + logItem.getInjectTime() + "min")
+ diaconnG8Pump.lastBolusAmount = logItem.injectAmount / 100.0
+ diaconnG8Pump.lastBolusTime = logDateTime
+
//Diaconn History
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
diaconnG8HistoryRecord.timestamp = logDateTime
@@ -345,6 +335,13 @@ class BigLogInquireResponsePacket(
aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
val logDateTime = logStartDate.time
+ val newRecord = pumpSync.syncStopExtendedBolusWithPumpId(
+ timestamp = logDateTime,
+ endPumpId = logDateTime,
+ pumpType = PumpType.DIACONN_G8,
+ pumpSerial = diaconnG8Pump.serialNo.toString())
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTOP (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Delivered: " + logItem.injectSquareAmount / 100.0 + "U RealDuration: " + logItem.getInjectTime() + "min")
+
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
diaconnG8HistoryRecord.timestamp = logDateTime
diaconnG8HistoryRecord.value = logItem.injectNormAmount / 100.0 + logItem.injectSquareAmount / 100.0
@@ -385,7 +382,6 @@ class BigLogInquireResponsePacket(
aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
val logDateTime = logStartDate.time
-
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_SUSPEND
diaconnG8HistoryRecord.timestamp = logDateTime
diaconnG8HistoryRecord.stringValue = resourceHelper.gs(R.string.diaconn_g8_lgorelease, logItem.getBasalPattern())
@@ -408,8 +404,6 @@ class BigLogInquireResponsePacket(
)
aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT INSULINCHANGE(" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Amount: " + logItem.remainAmount / 100.0 + "U")
}
-
-
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_REFILL
diaconnG8HistoryRecord.timestamp = logDateTime
diaconnG8HistoryRecord.value = logItem.remainAmount / 100.0
@@ -451,7 +445,7 @@ class BigLogInquireResponsePacket(
val logDateTime = logStartDate.time
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_DAILY
- diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.timestamp = DateTime(logDateTime).withTimeAtStartOfDay().millis
diaconnG8HistoryRecord.dailyBolus = logItem.extAmount / 100.0 + logItem.mealAmount / 100.0
val recordDateStr = "" + diaconnG8HistoryRecord.timestamp
@@ -498,7 +492,7 @@ class BigLogInquireResponsePacket(
val logDateTime = logStartDate.time
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_DAILY
- diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.timestamp = DateTime(logDateTime).withTimeAtStartOfDay().millis
diaconnG8HistoryRecord.dailyBasal = logItem.amount / 100.0
val recordDateStr = "" + diaconnG8HistoryRecord.timestamp
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigMainInfoInquireResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigMainInfoInquireResponsePacket.kt
index ff5a0fda97..e93d32e973 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigMainInfoInquireResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigMainInfoInquireResponsePacket.kt
@@ -180,40 +180,6 @@ class BigMainInfoInquireResponsePacket(
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)
- // 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
- 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)
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BolusSpeedSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BolusSpeedSettingResponsePacket.kt
index efc55b2a49..8a5b22f5da 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BolusSpeedSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BolusSpeedSettingResponsePacket.kt
@@ -31,7 +31,7 @@ class BolusSpeedSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/DiaconnG8Packet.java b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/DiaconnG8Packet.java
index 54bb487fd3..922335e612 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/DiaconnG8Packet.java
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/DiaconnG8Packet.java
@@ -267,7 +267,7 @@ public class DiaconnG8Packet {
break;
case 10:
- aapsLogger.error(LTag.PUMPCOMM, "Pump canceled due to non-response.");
+ aapsLogger.error(LTag.PUMPCOMM, "Canceled due to the opt number did not match.");
break;
case 11:
@@ -290,6 +290,26 @@ public class DiaconnG8Packet {
aapsLogger.error(LTag.PUMPCOMM, "After base setting is completed, base injection can be made.");
break;
+ case 32:
+ aapsLogger.error(LTag.PUMPCOMM, "During LGS running, injection is restricted");
+ break;
+
+ case 33:
+ aapsLogger.error(LTag.PUMPCOMM, "LGS status is ON, ON Command is declined.");
+ break;
+
+ case 34:
+ aapsLogger.error(LTag.PUMPCOMM, "LGS status is OFF, OFF Command is declined.");
+ break;
+
+ case 35:
+ aapsLogger.error(LTag.PUMPCOMM, "Tempbasal start is rejected when tempbasal is running");
+ break;
+
+ case 36:
+ aapsLogger.error(LTag.PUMPCOMM, "Tempbasal stop is rejected when tempbasal is not running");
+ break;
+
default:
aapsLogger.error(LTag.PUMPCOMM, "It cannot be set to a system error.");
break;
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/DisplayTimeoutSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/DisplayTimeoutSettingResponsePacket.kt
index 9582da53e5..d3a1aff191 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/DisplayTimeoutSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/DisplayTimeoutSettingResponsePacket.kt
@@ -31,7 +31,7 @@ class DisplayTimeoutSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionBasalSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionBasalSettingResponsePacket.kt
index c9912472ce..921b7cfdf8 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionBasalSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionBasalSettingResponsePacket.kt
@@ -31,7 +31,7 @@ class InjectionBasalSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionCancelSettingPacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionCancelSettingPacket.kt
index bfab75fe6a..b883154ad9 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionCancelSettingPacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionCancelSettingPacket.kt
@@ -21,7 +21,7 @@ class InjectionCancelSettingPacket(
}
override fun encode(msgSeq:Int): ByteArray {
- var buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
+ val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
buffer.put(reqMsgType)
return suffixEncode(buffer)
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionCancelSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionCancelSettingResponsePacket.kt
index 9099e5ba0c..922198207d 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionCancelSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionCancelSettingResponsePacket.kt
@@ -31,7 +31,7 @@ class InjectionCancelSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionExtendedBolusResultReportPacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionExtendedBolusResultReportPacket.kt
index 2bf21aa02b..53f2f6e96e 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionExtendedBolusResultReportPacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionExtendedBolusResultReportPacket.kt
@@ -37,19 +37,17 @@ class InjectionExtendedBolusResultReportPacket(injector: HasAndroidInjector) : D
val bolusAmountToBeDelivered = getShortToInt(bufferData) / 100.0
val deliveredBolusAmount = getShortToInt(bufferData) / 100.0
- //diaconnG8Pump.isExtendedInProgress = result == 0
- diaconnG8Pump.extendedBolusMinutes = settingMinutes
- diaconnG8Pump.extendedBolusAbsoluteRate = bolusAmountToBeDelivered
- diaconnG8Pump.extendedBolusPassedMinutes = elapsedTime
- diaconnG8Pump.extendedBolusRemainingMinutes = settingMinutes - elapsedTime
- diaconnG8Pump.extendedBolusDeliveredSoFar = deliveredBolusAmount
+ diaconnG8Pump.isExtendedInProgress = result == 0
+ diaconnG8Pump.squareTime = settingMinutes
+ diaconnG8Pump.squareInjTime = elapsedTime
+ diaconnG8Pump.squareAmount = bolusAmountToBeDelivered
+ diaconnG8Pump.squareInjAmount = deliveredBolusAmount
aapsLogger.debug(LTag.PUMPCOMM, "Result: $result")
- 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")
- aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus remaining minutes: " + diaconnG8Pump.extendedBolusRemainingMinutes + " min")
- aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus delivered so far: " + diaconnG8Pump.extendedBolusDeliveredSoFar + " U")
+ aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus running: " + diaconnG8Pump.squareAmount + " U/h")
+ aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus duration: " + diaconnG8Pump.squareTime + " min")
+ aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus so far: " + diaconnG8Pump.squareInjTime + " min")
+ aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus delivered so far: " + diaconnG8Pump.squareInjAmount + " U")
}
override fun getFriendlyName(): String {
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionExtendedBolusSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionExtendedBolusSettingResponsePacket.kt
index a17ecd3bfb..051612ba2c 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionExtendedBolusSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionExtendedBolusSettingResponsePacket.kt
@@ -31,7 +31,7 @@ class InjectionExtendedBolusSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionMealSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionMealSettingResponsePacket.kt
index 7e30ef8c3c..802e95985e 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionMealSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionMealSettingResponsePacket.kt
@@ -31,7 +31,7 @@ class InjectionMealSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionSnackSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionSnackSettingResponsePacket.kt
index dec3271e47..aa60b70c1a 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionSnackSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/InjectionSnackSettingResponsePacket.kt
@@ -31,7 +31,7 @@ class InjectionSnackSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/LanguageSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/LanguageSettingResponsePacket.kt
index 91a29ddae7..4a560dd979 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/LanguageSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/LanguageSettingResponsePacket.kt
@@ -31,7 +31,7 @@ class LanguageSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/LogStatusInquirePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/LogStatusInquirePacket.kt
index 21e0431d66..29f5823037 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/LogStatusInquirePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/LogStatusInquirePacket.kt
@@ -23,6 +23,6 @@ class LogStatusInquirePacket(
}
override fun getFriendlyName(): String {
- return "PUMP_OG_STATUS_INQUIRE"
+ return "PUMP_LOG_STATUS_INQUIRE"
}
}
\ No newline at end of file
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/SoundSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/SoundSettingResponsePacket.kt
index 474dc3997c..fba733ee8c 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/SoundSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/SoundSettingResponsePacket.kt
@@ -31,7 +31,7 @@ class SoundSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TempBasalInquireResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TempBasalInquireResponsePacket.kt
index 5f45ab3abd..2b6d5db384 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TempBasalInquireResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TempBasalInquireResponsePacket.kt
@@ -42,11 +42,6 @@ open class TempBasalInquireResponsePacket(
diaconnG8Pump.tbInjectRateRatio = getShortToInt(bufferData) //임시기저 주입량/률
diaconnG8Pump.tbElapsedTime = getShortToInt(bufferData) // 임시기저 경과시간
- diaconnG8Pump.isTempBasalInProgress = diaconnG8Pump.tbStatus == 1
- if (diaconnG8Pump.tbInjectRateRatio >= 50000) {
- diaconnG8Pump.tempBasalPercent = diaconnG8Pump.tbInjectRateRatio - 50000
- }
-
aapsLogger.debug(LTag.PUMPCOMM, "Result --> $result")
aapsLogger.debug(LTag.PUMPCOMM, "tbStatus > " + diaconnG8Pump.tbStatus)
aapsLogger.debug(LTag.PUMPCOMM, "tbTime> " + diaconnG8Pump.tbTime)
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TempBasalReportPacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TempBasalReportPacket.kt
index 73fa041172..d2eec42bcd 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TempBasalReportPacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TempBasalReportPacket.kt
@@ -31,21 +31,21 @@ class TempBasalReportPacket(
val bufferData = prefixDecode(data)
diaconnG8Pump.tbStatus = getByteToInt(bufferData)
- diaconnG8Pump.isTempBasalInProgress = diaconnG8Pump.tbStatus == 1
+ //diaconnG8Pump.isTempBasalInProgress = diaconnG8Pump.tbStatus == 1
// 응답받은 임시기저 상태가 주입중이면, pump객체에 정보를 갱신.
- if(diaconnG8Pump.isTempBasalInProgress) {
- diaconnG8Pump.tbTime = getByteToInt(bufferData)
- diaconnG8Pump.tbInjectRateRatio = getShortToInt(bufferData)
- if (diaconnG8Pump.tbInjectRateRatio >= 50000) {
- diaconnG8Pump.tempBasalPercent = diaconnG8Pump.tbInjectRateRatio - 50000
- }
-
- if(diaconnG8Pump.tbInjectRateRatio in 1000..1600) {
- diaconnG8Pump.tbInjectAbsoluteValue = (diaconnG8Pump.tbInjectRateRatio -1000) / 100.0
- diaconnG8Pump.tempBasalAbsoluteRate = diaconnG8Pump.tbInjectAbsoluteValue
- }
- }
+ // if(diaconnG8Pump.isTempBasalInProgress) {
+ // diaconnG8Pump.tbTime = getByteToInt(bufferData)
+ // diaconnG8Pump.tbInjectRateRatio = getShortToInt(bufferData)
+ // if (diaconnG8Pump.tbInjectRateRatio >= 50000) {
+ // diaconnG8Pump.tempBasalPercent = diaconnG8Pump.tbInjectRateRatio - 50000
+ // }
+ //
+ // if(diaconnG8Pump.tbInjectRateRatio in 1000..1600) {
+ // diaconnG8Pump.tbInjectAbsoluteValue = (diaconnG8Pump.tbInjectRateRatio -1000) / 100.0
+ // diaconnG8Pump.tempBasalAbsoluteRate = diaconnG8Pump.tbInjectAbsoluteValue
+ // }
+ // }
aapsLogger.debug(LTag.PUMPCOMM, "tbStatus > " + diaconnG8Pump.tbStatus)
aapsLogger.debug(LTag.PUMPCOMM, "tbTime> " + diaconnG8Pump.tbTime)
aapsLogger.debug(LTag.PUMPCOMM, "tbInjectRateRatio > " + diaconnG8Pump.tbInjectRateRatio)
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TempBasalSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TempBasalSettingResponsePacket.kt
index 843f245e96..3ef1cf5668 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TempBasalSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TempBasalSettingResponsePacket.kt
@@ -31,7 +31,7 @@ class TempBasalSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TimeSettingResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TimeSettingResponsePacket.kt
index ef78bf735f..75523537f8 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TimeSettingResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/TimeSettingResponsePacket.kt
@@ -31,7 +31,7 @@ class TimeSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
- diaconnG8Pump.bolusStartErrorCode = result
+ diaconnG8Pump.resultErrorCode = result
failed = true
return
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt
index 567d66da68..d6196efb78 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt
@@ -138,14 +138,14 @@ class DiaconnG8Service : DaggerService() {
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
+ sendMessage(BigAPSMainInfoInquirePacket(injector)) // 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
+ sendMessage(BasalLimitInquirePacket(injector)) // basal Limit
+ sendMessage(SneckLimitInquirePacket(injector)) // bolus Limit
+ sendMessage(BigMainInfoInquirePacket(injector)) // Pump Main Info
+ sendMessage(SoundInquirePacket(injector)) // sounds
+ sendMessage(DisplayTimeInquirePacket(injector)) // display
+ sendMessage(LanguageInquirePacket(injector)) // language
}
diaconnG8Pump.lastConnection = System.currentTimeMillis()
@@ -231,11 +231,11 @@ class DiaconnG8Service : DaggerService() {
result.comment = "pump not initialized"
return result
}
- sendMessage(LogStatusInquirePacket(injector), 1000)
+ sendMessage(LogStatusInquirePacket(injector))
// pump version check
if(diaconnG8Pump.isPumpVersionGe2_63) {
- sendMessage(IncarnationInquirePacket(injector), 1000)
+ sendMessage(IncarnationInquirePacket(injector))
}
val result = PumpEnactResult(injector)
@@ -322,10 +322,7 @@ class DiaconnG8Service : DaggerService() {
else -> null
} ?: return result.success(false)
- sendMessage(msg, 2000)
-
-
-
+ sendMessage(msg )
// pump confirm
if(diaconnG8Pump.otpNumber == 0) {
aapsLogger.error(LTag.PUMPCOMM, "otp is not received yet")
@@ -333,9 +330,7 @@ class DiaconnG8Service : DaggerService() {
result.comment("펌프와 연결 상태를 확인해주세요.")
return result
}
-
sendMessage(AppConfirmSettingPacket(injector, msg.msgType, diaconnG8Pump.otpNumber))
-
diaconnG8Pump.otpNumber = 0
SystemClock.sleep(100)
return result.success(true)
@@ -353,13 +348,13 @@ class DiaconnG8Service : DaggerService() {
// aps speed check
if(!isSpeedSyncToPump) {
val msg = BolusSpeedSettingPacket(injector, apsPrefBolusSpeed)
- sendMessage(msg, 2000)
+ sendMessage(msg)
sendMessage(AppConfirmSettingPacket(injector, msg.msgType, diaconnG8Pump.otpNumber))
diaconnG8Pump.otpNumber = 0
}
// pump bolus speed inquire
- sendMessage(BolusSpeedInquirePacket(injector), 1000)
+ sendMessage(BolusSpeedInquirePacket(injector))
diaconnG8Pump.bolusDone = false
diaconnG8Pump.bolusingTreatment = t
diaconnG8Pump.bolusAmountToBeDelivered = insulin
@@ -373,7 +368,7 @@ class DiaconnG8Service : DaggerService() {
val bolusStart = System.currentTimeMillis()
if (insulin > 0) {
if (!diaconnG8Pump.bolusStopped) {
- sendMessage(start, 1000)
+ sendMessage(start)
// otp process
if(!processConfirm(start.msgType)) return false
} else {
@@ -428,10 +423,9 @@ class DiaconnG8Service : DaggerService() {
fun bolusStop() {
val stop = InjectionCancelSettingPacket(injector, 0x07.toByte())
-
diaconnG8Pump.bolusStopForced = true
if (isConnected) {
- sendMessage(stop,2000)
+ sendMessage(stop)
// otp process
if(!processConfirm(stop.msgType)) return
while (!diaconnG8Pump.bolusStopped) {
@@ -444,11 +438,15 @@ class DiaconnG8Service : DaggerService() {
fun tempBasal(absoluteRate: Double, durationInHours: Double): Boolean {
if (!isConnected) return false
- if (diaconnG8Pump.isTempBasalInProgress) {
+
+ // temp state check
+ sendMessage(TempBasalInquirePacket(injector))
+
+ if (diaconnG8Pump.tbStatus ==1 ) {
rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)))
val msgPacket = TempBasalSettingPacket(injector, 2, diaconnG8Pump.tbTime, diaconnG8Pump.tbInjectRateRatio)
// tempbasal stop
- sendMessage(msgPacket, 2000)
+ sendMessage(msgPacket)
// otp process
if(!processConfirm(msgPacket.msgType)) return false
diaconnG8Pump.tempBasalStart= dateUtil.now()
@@ -456,7 +454,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).toInt(), tbInjectRate)
- sendMessage(msgTBR, 2000)
+ sendMessage(msgTBR)
// otp process
if(!processConfirm(msgTBR.msgType)) return false
// pump tempbasal status inquire
@@ -469,11 +467,14 @@ class DiaconnG8Service : DaggerService() {
}
fun highTempBasal(absoluteRate: Double): Boolean {
- if (diaconnG8Pump.isTempBasalInProgress) {
+ // temp state check
+ sendMessage(TempBasalInquirePacket(injector))
+
+ if (diaconnG8Pump.tbStatus ==1 ) {
rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)))
val msgPacket = TempBasalSettingPacket(injector, 2, diaconnG8Pump.tbTime, diaconnG8Pump.tbInjectRateRatio)
// tempbasal stop
- sendMessage(msgPacket, 2000)
+ sendMessage(msgPacket)
// otp process
if(!processConfirm(msgPacket.msgType)) return false
diaconnG8Pump.tempBasalStart= dateUtil.now()
@@ -481,7 +482,6 @@ class DiaconnG8Service : DaggerService() {
}
rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)))
-
val tbTime = 2 // 2: 30min, 3:45min, 4:60min
var newAbsoluteRate = absoluteRate
if (absoluteRate < 0.0) newAbsoluteRate = 0.0
@@ -490,7 +490,7 @@ class DiaconnG8Service : DaggerService() {
aapsLogger.debug(LTag.PUMPCOMM, "APS Temp basal start absoluteRate: $newAbsoluteRate duration 30 min")
val tbInjectRate = absoluteRate * 100 + 1000
val msgTBR = TempBasalSettingPacket(injector, 1, tbTime, tbInjectRate.toInt())
- sendMessage(msgTBR, 2000)
+ sendMessage(msgTBR)
// otp process
if(!processConfirm(msgTBR.msgType)) return false
sendMessage(TempBasalInquirePacket(injector))
@@ -507,11 +507,14 @@ class DiaconnG8Service : DaggerService() {
aapsLogger.error(LTag.PUMPCOMM, "Wrong duration param")
return false
}
- if (diaconnG8Pump.isTempBasalInProgress) {
+
+ // temp state check
+ sendMessage(TempBasalInquirePacket(injector))
+ if (diaconnG8Pump.tbStatus ==1 ) {
rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)))
val msgPacket = TempBasalSettingPacket(injector, 2, diaconnG8Pump.tbTime, diaconnG8Pump.tbInjectRateRatio)
// tempbasal stop
- sendMessage(msgPacket, 2000)
+ sendMessage(msgPacket)
// otp process
if(!processConfirm(msgPacket.msgType)) return false
SystemClock.sleep(500)
@@ -519,7 +522,7 @@ class DiaconnG8Service : DaggerService() {
rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)))
val tbInjectRate = absoluteRate * 100 + 1000
val msgTBR = TempBasalSettingPacket(injector, 1, 2, tbInjectRate.toInt())
- sendMessage(msgTBR, 2000)
+ sendMessage(msgTBR)
// otp process
if(!processConfirm(msgTBR.msgType)) return false
sendMessage(TempBasalInquirePacket(injector))
@@ -533,20 +536,27 @@ class DiaconnG8Service : DaggerService() {
fun tempBasalStop(): Boolean {
if (!isConnected) return false
rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)))
- val msgPacket = TempBasalSettingPacket(injector, 2, diaconnG8Pump.tbTime, diaconnG8Pump.tbInjectRateRatio)
- // tempbasal stop
- sendMessage(msgPacket, 2000)
- // otp process
- if(!processConfirm(msgPacket.msgType)) return false
- SystemClock.sleep(500)
- if(diaconnG8Pump.isTempBasalInProgress) {
- sendMessage(TempBasalInquirePacket(injector), 2000)
+ // temp state check
+ sendMessage(TempBasalInquirePacket(injector))
+ if(diaconnG8Pump.tbStatus == 1) {
+ val msgPacket = TempBasalSettingPacket(
+ injector,
+ 2,
+ diaconnG8Pump.tbTime,
+ diaconnG8Pump.tbInjectRateRatio
+ )
+ // tempbasal stop
+ sendMessage(msgPacket)
+ // otp process
+ if (!processConfirm(msgPacket.msgType)) return false
+ SystemClock.sleep(500)
}
+
loadHistory()
val tbr = pumpSync.expectedPumpState().temporaryBasal
diaconnG8Pump.fromTemporaryBasal(tbr)
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING))
- return msgPacket.success()
+ return true
}
fun extendedBolus(insulin: Double, durationInMinutes: Int): Boolean {
@@ -555,7 +565,7 @@ class DiaconnG8Service : DaggerService() {
aapsLogger.error(LTag.PUMPCOMM, "insulin: $insulin durationInMinutes: $durationInMinutes")
val msgExtended = InjectionExtendedBolusSettingPacket(injector, (insulin * 100).toInt(), durationInMinutes, dateUtil.now())
- sendMessage(msgExtended, 2000)
+ sendMessage(msgExtended)
// otp process
if(!processConfirm(msgExtended.msgType)) return false
//diaconnG8Pump.isExtendedInProgress = true
@@ -569,11 +579,12 @@ class DiaconnG8Service : DaggerService() {
fun extendedBolusStop(): Boolean {
if (!isConnected) return false
rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)))
- val msgStop = InjectionCancelSettingPacket(injector, 0x08.toByte())
- sendMessage(msgStop, 2000)
+ val msgType = if(diaconnG8Pump.dualStatus == 1) 0x09.toByte() else 0x08.toByte()
+ val msgStop = InjectionCancelSettingPacket(injector, msgType)
+ sendMessage(msgStop)
// otp process
if(!processConfirm(msgStop.msgType)) return false
- loadHistory()
+ loadHistory() // pump log sync( db update)
val eb = pumpSync.expectedPumpState().extendedBolus
diaconnG8Pump.fromExtendedBolus(eb)
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING))
@@ -604,13 +615,13 @@ class DiaconnG8Service : DaggerService() {
sendMessage(requestReqPacket4)
// otp process
- if(!processConfirm(0x0B)) return false
+ if(!processConfirm(requestReqPacket4.msgType)) return false
// pump saving time about 30 second
aapsLogger.debug(LTag.PUMPCOMM, "30 seconds Waiting!!")
SystemClock.sleep(30000)
val msgPacket = InjectionBasalSettingPacket(injector, 1)
- sendMessage(msgPacket, 2000)
+ sendMessage(msgPacket)
// otp process
if(!processConfirm(msgPacket.msgType)) return false
readPumpStatus()
diff --git a/diaconn/src/main/res/values-ko-rKR/strings.xml b/diaconn/src/main/res/values-ko-rKR/strings.xml
index 9690702616..f6673736a2 100644
--- a/diaconn/src/main/res/values-ko-rKR/strings.xml
+++ b/diaconn/src/main/res/values-ko-rKR/strings.xml
@@ -140,4 +140,9 @@
튜브 교체
로그 동기화 시 \"튜브 교체\" 노트 정보 자동 업로드
임시Basal 시작
+ LGS 동작 중 볼러스 주입 거절
+ LGS ON일때, ON 거절
+ LGS OFF일 때, OFF 거절
+ 임시기저 설정중인 상태일 때, 임시기저 시작 명령 거절
+ 임시기저 설정이 안 된 상태일 때, 임시기저 중지 명령 거절
diff --git a/diaconn/src/main/res/values/strings.xml b/diaconn/src/main/res/values/strings.xml
index d86a3f9bf1..3a51a9ff15 100644
--- a/diaconn/src/main/res/values/strings.xml
+++ b/diaconn/src/main/res/values/strings.xml
@@ -161,6 +161,11 @@
Log tube change
Add \"Tube Change\" event to Note when detected in history
TempBasal Start
+ During LGS running, injection is restricted
+ LGS status is ON, ON Command is declined.
+ LGS status is OFF, OFF Command is declined.
+ Tempbasal start is rejected when tempbasal is running
+ Tempbasal stop is rejected when tempbasal is not running
\ No newline at end of file