Merge pull request #576 from miyeongkim/diaconn

Some Error fixed
This commit is contained in:
Milos Kozak 2021-06-24 08:44:59 +02:00 committed by GitHub
commit 626a1d22a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 208 additions and 203 deletions

View file

@ -6,6 +6,7 @@
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="6" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="6" />
<option name="BLANK_LINES_AROUND_BLOCK_WHEN_BRANCHES" value="1" />
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="METHOD_ANNOTATION_WRAP" value="0" />
@ -124,6 +125,7 @@
</arrangement>
</codeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />
<option name="LINE_COMMENT_ADD_SPACE" value="true" />
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />

View file

@ -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) {

View file

@ -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()

View file

@ -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"
}
}

View file

@ -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분)

View file

@ -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
}

View file

@ -31,7 +31,7 @@ class AppConfirmSettingResponsePacket(
aapsLogger.debug(LTag.PUMPCOMM, "Result --> ${result}")
if(!isSuccSettingResponseResult(result)) {
diaconnG8Pump.bolusStartErrorCode = result
diaconnG8Pump.resultErrorCode = result
failed = true
return
}

View file

@ -32,7 +32,7 @@ class BasalPauseSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
diaconnG8Pump.bolusStartErrorCode = result
diaconnG8Pump.resultErrorCode = result
failed = true
return
}

View file

@ -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
}

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -31,7 +31,7 @@ class BolusSpeedSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
diaconnG8Pump.bolusStartErrorCode = result
diaconnG8Pump.resultErrorCode = result
failed = true
return
}

View file

@ -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;

View file

@ -31,7 +31,7 @@ class DisplayTimeoutSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
diaconnG8Pump.bolusStartErrorCode = result
diaconnG8Pump.resultErrorCode = result
failed = true
return
}

View file

@ -31,7 +31,7 @@ class InjectionBasalSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
diaconnG8Pump.bolusStartErrorCode = result
diaconnG8Pump.resultErrorCode = result
failed = true
return
}

View file

@ -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)
}

View file

@ -31,7 +31,7 @@ class InjectionCancelSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
diaconnG8Pump.bolusStartErrorCode = result
diaconnG8Pump.resultErrorCode = result
failed = true
return
}

View file

@ -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 {

View file

@ -31,7 +31,7 @@ class InjectionExtendedBolusSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
diaconnG8Pump.bolusStartErrorCode = result
diaconnG8Pump.resultErrorCode = result
failed = true
return
}

View file

@ -31,7 +31,7 @@ class InjectionMealSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
diaconnG8Pump.bolusStartErrorCode = result
diaconnG8Pump.resultErrorCode = result
failed = true
return
}

View file

@ -31,7 +31,7 @@ class InjectionSnackSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
diaconnG8Pump.bolusStartErrorCode = result
diaconnG8Pump.resultErrorCode = result
failed = true
return
}

View file

@ -31,7 +31,7 @@ class LanguageSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
diaconnG8Pump.bolusStartErrorCode = result
diaconnG8Pump.resultErrorCode = result
failed = true
return
}

View file

@ -23,6 +23,6 @@ class LogStatusInquirePacket(
}
override fun getFriendlyName(): String {
return "PUMP_OG_STATUS_INQUIRE"
return "PUMP_LOG_STATUS_INQUIRE"
}
}

View file

@ -31,7 +31,7 @@ class SoundSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
diaconnG8Pump.bolusStartErrorCode = result
diaconnG8Pump.resultErrorCode = result
failed = true
return
}

View file

@ -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)

View file

@ -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)

View file

@ -31,7 +31,7 @@ class TempBasalSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
diaconnG8Pump.bolusStartErrorCode = result
diaconnG8Pump.resultErrorCode = result
failed = true
return
}

View file

@ -31,7 +31,7 @@ class TimeSettingResponsePacket(
result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) {
diaconnG8Pump.bolusStartErrorCode = result
diaconnG8Pump.resultErrorCode = result
failed = true
return
}

View file

@ -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()

View file

@ -140,4 +140,9 @@
<string name="diaconn_g8_logtubechange_title">튜브 교체</string>
<string name="diaconn_g8_logtubechange_summary">로그 동기화 시 \"튜브 교체\" 노트 정보 자동 업로드</string>
<string name="diaconn_g8_logtempstart">임시Basal 시작</string>
<string name="diaconn_g8_errorcode_32">LGS 동작 중 볼러스 주입 거절</string>
<string name="diaconn_g8_errorcode_33">LGS ON일때, ON 거절</string>
<string name="diaconn_g8_errorcode_34">LGS OFF일 때, OFF 거절</string>
<string name="diaconn_g8_errorcode_35">임시기저 설정중인 상태일 때, 임시기저 시작 명령 거절</string>
<string name="diaconn_g8_errorcode_36">임시기저 설정이 안 된 상태일 때, 임시기저 중지 명령 거절</string>
</resources>

View file

@ -161,6 +161,11 @@
<string name="diaconn_g8_logtubechange_title">Log tube change</string>
<string name="diaconn_g8_logtubechange_summary">Add \"Tube Change\" event to Note when detected in history</string>
<string name="diaconn_g8_logtempstart">TempBasal Start</string>
<string name="diaconn_g8_errorcode_32">During LGS running, injection is restricted</string>
<string name="diaconn_g8_errorcode_33">LGS status is ON, ON Command is declined.</string>
<string name="diaconn_g8_errorcode_34">LGS status is OFF, OFF Command is declined.</string>
<string name="diaconn_g8_errorcode_35">Tempbasal start is rejected when tempbasal is running</string>
<string name="diaconn_g8_errorcode_36">Tempbasal stop is rejected when tempbasal is not running</string>
</resources>