1. 변수 이름 변경

2. 확장볼러스 에러 처리.
3. 에러메시지 추가
4. TDD 조회시 정렬 처리.
This commit is contained in:
miyeongkim 2021-06-23 11:08:29 +09:00
parent ab26919f54
commit 0050857973
22 changed files with 55 additions and 27 deletions

View file

@ -26,6 +26,7 @@ import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.queue.Callback
@ -232,11 +233,15 @@ class TDDStatsActivity : NoSplashAppCompatActivity() {
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
private fun loadDataFromDB() { private fun loadDataFromDB() {
historyList.clear() historyList.clear()
historyList.addAll(repository.getLastTotalDailyDoses(10, false).blockingGet()) // timestamp DESC sorting!
historyList.addAll(repository.getLastTotalDailyDoses(10, true).blockingGet())
//only use newest 10 //only use newest 10
historyList = historyList.subList(0, min(10, historyList.size)) historyList = historyList.subList(0, min(10, historyList.size))
// dummies reset
dummies.clear()
//fill single gaps //fill single gaps
val df: DateFormat = SimpleDateFormat("dd.MM.", Locale.getDefault()) val df: DateFormat = SimpleDateFormat("dd.MM.", Locale.getDefault())
for (i in 0 until historyList.size - 1) { for (i in 0 until historyList.size - 1) {

View file

@ -268,7 +268,7 @@ class DiaconnG8Plugin @Inject constructor(
if(result.success) result.enacted = true if(result.success) result.enacted = true
if (!result.success) { if (!result.success) {
setErrorMsg(diaconnG8Pump.bolusStartErrorCode, result) setErrorMsg(diaconnG8Pump.resultErrorCode, result)
} else result.comment = resourceHelper.gs(R.string.ok) } else result.comment = resourceHelper.gs(R.string.ok)
aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered) aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered)
result result
@ -409,7 +409,7 @@ class DiaconnG8Plugin @Inject constructor(
result.enacted = false result.enacted = false
result.success = false result.success = false
setErrorMsg(diaconnG8Pump.bolusStartErrorCode, result) setErrorMsg(diaconnG8Pump.resultErrorCode, result)
aapsLogger.error("setExtendedBolus: Failed to extended bolus") aapsLogger.error("setExtendedBolus: Failed to extended bolus")
return result return result
} }
@ -422,6 +422,7 @@ class DiaconnG8Plugin @Inject constructor(
result.success = !diaconnG8Pump.isTempBasalInProgress result.success = !diaconnG8Pump.isTempBasalInProgress
result.enacted = true result.enacted = true
result.isTempCancel = true result.isTempCancel = true
if(!result.success) setErrorMsg(diaconnG8Pump.resultErrorCode, result)
} else { } else {
result.success = true result.success = true
result.enacted = false result.enacted = false
@ -438,6 +439,11 @@ class DiaconnG8Plugin @Inject constructor(
diaconnG8Service?.extendedBolusStop() diaconnG8Service?.extendedBolusStop()
result.success = !diaconnG8Pump.isExtendedInProgress result.success = !diaconnG8Pump.isExtendedInProgress
result.enacted = true result.enacted = true
if(!result.success) {
setErrorMsg(diaconnG8Pump.resultErrorCode, result)
diaconnG8Service?.readPumpStatus()
}
} else { } else {
result.success = true result.success = true
result.enacted = false result.enacted = false
@ -560,6 +566,11 @@ class DiaconnG8Plugin @Inject constructor(
13 -> result.comment = resourceHelper.gs(R.string.diaconn_g8_errorcode_13) 13 -> result.comment = resourceHelper.gs(R.string.diaconn_g8_errorcode_13)
14 -> result.comment = resourceHelper.gs(R.string.diaconn_g8_errorcode_14) 14 -> result.comment = resourceHelper.gs(R.string.diaconn_g8_errorcode_14)
15 -> result.comment = resourceHelper.gs(R.string.diaconn_g8_errorcode_15) 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" else -> result.comment = "not defined Error code: $errorCode"
} }
} }

View file

@ -174,9 +174,9 @@ class DiaconnG8Pump @Inject constructor(
var selectedLanguage = 0 var selectedLanguage = 0
var bolusSpeed = 0 var bolusSpeed = 0
var resultErrorCode: Int = 0 // last start bolus erroCode
// Bolus settings // Bolus settings
var bolusStartErrorCode: Int = 0 // last start bolus erroCode
var historyDoneReceived: Boolean = false // true when last history message is received var historyDoneReceived: Boolean = false // true when last history message is received
var bolusingTreatment: EventOverviewBolusProgress.Treatment? = null // actually delivered treatment var bolusingTreatment: EventOverviewBolusProgress.Treatment? = null // actually delivered treatment
var bolusAmountToBeDelivered = 0.0 // amount to be delivered var bolusAmountToBeDelivered = 0.0 // amount to be delivered

View file

@ -30,7 +30,7 @@ class AppCancelSettingResponsePacket(
val bufferData = prefixDecode(data) val bufferData = prefixDecode(data)
result = getByteToInt(bufferData) result = getByteToInt(bufferData)
if(!isSuccSettingResponseResult(result)) { if(!isSuccSettingResponseResult(result)) {
diaconnG8Pump.bolusStartErrorCode = result diaconnG8Pump.resultErrorCode = result
failed = true failed = true
return return
} }

View file

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

View file

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

View file

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

View file

@ -21,6 +21,7 @@ import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.apache.commons.lang3.time.DateUtils import org.apache.commons.lang3.time.DateUtils
import org.joda.time.DateTime
import javax.inject.Inject import javax.inject.Inject
/** /**
@ -299,6 +300,9 @@ class BigLogInquireResponsePacket(
pumpSerial = diaconnG8Pump.serialNo.toString()) 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") 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 //Diaconn History
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
diaconnG8HistoryRecord.timestamp = logDateTime diaconnG8HistoryRecord.timestamp = logDateTime
@ -441,7 +445,7 @@ class BigLogInquireResponsePacket(
val logDateTime = logStartDate.time val logDateTime = logStartDate.time
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_DAILY 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 diaconnG8HistoryRecord.dailyBolus = logItem.extAmount / 100.0 + logItem.mealAmount / 100.0
val recordDateStr = "" + diaconnG8HistoryRecord.timestamp val recordDateStr = "" + diaconnG8HistoryRecord.timestamp
@ -488,7 +492,7 @@ class BigLogInquireResponsePacket(
val logDateTime = logStartDate.time val logDateTime = logStartDate.time
diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_DAILY diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_DAILY
diaconnG8HistoryRecord.timestamp = logDateTime diaconnG8HistoryRecord.timestamp = DateTime(logDateTime).withTimeAtStartOfDay().millis
diaconnG8HistoryRecord.dailyBasal = logItem.amount / 100.0 diaconnG8HistoryRecord.dailyBasal = logItem.amount / 100.0
val recordDateStr = "" + diaconnG8HistoryRecord.timestamp val recordDateStr = "" + diaconnG8HistoryRecord.timestamp

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -231,11 +231,11 @@ class DiaconnG8Service : DaggerService() {
result.comment = "pump not initialized" result.comment = "pump not initialized"
return result return result
} }
sendMessage(LogStatusInquirePacket(injector), 1000) sendMessage(LogStatusInquirePacket(injector))
// pump version check // pump version check
if(diaconnG8Pump.isPumpVersionGe2_63) { if(diaconnG8Pump.isPumpVersionGe2_63) {
sendMessage(IncarnationInquirePacket(injector), 1000) sendMessage(IncarnationInquirePacket(injector))
} }
val result = PumpEnactResult(injector) val result = PumpEnactResult(injector)
@ -423,7 +423,6 @@ class DiaconnG8Service : DaggerService() {
fun bolusStop() { fun bolusStop() {
val stop = InjectionCancelSettingPacket(injector, 0x07.toByte()) val stop = InjectionCancelSettingPacket(injector, 0x07.toByte())
diaconnG8Pump.bolusStopForced = true diaconnG8Pump.bolusStopForced = true
if (isConnected) { if (isConnected) {
sendMessage(stop) sendMessage(stop)
@ -483,7 +482,6 @@ class DiaconnG8Service : DaggerService() {
} }
rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))) rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)))
val tbTime = 2 // 2: 30min, 3:45min, 4:60min val tbTime = 2 // 2: 30min, 3:45min, 4:60min
var newAbsoluteRate = absoluteRate var newAbsoluteRate = absoluteRate
if (absoluteRate < 0.0) newAbsoluteRate = 0.0 if (absoluteRate < 0.0) newAbsoluteRate = 0.0
@ -586,7 +584,7 @@ class DiaconnG8Service : DaggerService() {
sendMessage(msgStop) sendMessage(msgStop)
// otp process // otp process
if(!processConfirm(msgStop.msgType)) return false if(!processConfirm(msgStop.msgType)) return false
loadHistory() loadHistory() // pump log sync( db update)
val eb = pumpSync.expectedPumpState().extendedBolus val eb = pumpSync.expectedPumpState().extendedBolus
diaconnG8Pump.fromExtendedBolus(eb) diaconnG8Pump.fromExtendedBolus(eb)
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING))
@ -617,7 +615,7 @@ class DiaconnG8Service : DaggerService() {
sendMessage(requestReqPacket4) sendMessage(requestReqPacket4)
// otp process // otp process
if(!processConfirm(0x0B)) return false if(!processConfirm(requestReqPacket4.msgType)) return false
// pump saving time about 30 second // pump saving time about 30 second
aapsLogger.debug(LTag.PUMPCOMM, "30 seconds Waiting!!") aapsLogger.debug(LTag.PUMPCOMM, "30 seconds Waiting!!")
SystemClock.sleep(30000) SystemClock.sleep(30000)

View file

@ -140,4 +140,9 @@
<string name="diaconn_g8_logtubechange_title">튜브 교체</string> <string name="diaconn_g8_logtubechange_title">튜브 교체</string>
<string name="diaconn_g8_logtubechange_summary">로그 동기화 시 \"튜브 교체\" 노트 정보 자동 업로드</string> <string name="diaconn_g8_logtubechange_summary">로그 동기화 시 \"튜브 교체\" 노트 정보 자동 업로드</string>
<string name="diaconn_g8_logtempstart">임시Basal 시작</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> </resources>

View file

@ -161,6 +161,11 @@
<string name="diaconn_g8_logtubechange_title">Log tube change</string> <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_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_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> </resources>