fix lst bolus query and smb pocessing
This commit is contained in:
parent
74dfe80433
commit
c0dba456d7
|
@ -166,11 +166,13 @@ open class LoopPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override val isSuspended: Boolean
|
override val isSuspended: Boolean
|
||||||
get() = repository.getOfflineEventActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing
|
get() = repository.getOfflineEventActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing
|
||||||
|
|
||||||
override var enabled: Boolean
|
override var enabled: Boolean
|
||||||
get() = isEnabled()
|
get() = isEnabled()
|
||||||
set(value) { setPluginEnabled(PluginType.LOOP, value)}
|
set(value) {
|
||||||
|
setPluginEnabled(PluginType.LOOP, value)
|
||||||
|
}
|
||||||
|
|
||||||
val isLGS: Boolean
|
val isLGS: Boolean
|
||||||
get() {
|
get() {
|
||||||
|
@ -209,6 +211,17 @@ open class LoopPlugin @Inject constructor(
|
||||||
invoke(initiator, allowNotification, false)
|
invoke(initiator, allowNotification, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun isEmptyQueue(): Boolean {
|
||||||
|
val maxMinutes = 2L
|
||||||
|
val start = dateUtil.now()
|
||||||
|
while (start + T.mins(maxMinutes).msecs() > dateUtil.now()) {
|
||||||
|
if (commandQueue.size() == 0 && commandQueue.performing() == null) return true
|
||||||
|
SystemClock.sleep(100)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
operator fun invoke(initiator: String, allowNotification: Boolean, tempBasalFallback: Boolean) {
|
operator fun invoke(initiator: String, allowNotification: Boolean, tempBasalFallback: Boolean) {
|
||||||
try {
|
try {
|
||||||
|
@ -247,6 +260,12 @@ open class LoopPlugin @Inject constructor(
|
||||||
return
|
return
|
||||||
} else rxBus.send(EventLoopInvoked())
|
} else rxBus.send(EventLoopInvoked())
|
||||||
|
|
||||||
|
if (!isEmptyQueue()) {
|
||||||
|
aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.pumpbusy))
|
||||||
|
rxBus.send(EventLoopSetLastRunGui(resourceHelper.gs(R.string.pumpbusy)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare for pumps using % basals
|
// Prepare for pumps using % basals
|
||||||
if (pump.pumpDescription.tempBasalStyle == PumpDescription.PERCENT && allowPercentage()) {
|
if (pump.pumpDescription.tempBasalStyle == PumpDescription.PERCENT && allowPercentage()) {
|
||||||
apsResult.usePercent = true
|
apsResult.usePercent = true
|
||||||
|
@ -357,8 +376,7 @@ open class LoopPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (resultAfterConstraints.isChangeRequested
|
if (resultAfterConstraints.isChangeRequested
|
||||||
&& !commandQueue.bolusInQueue()
|
&& !commandQueue.bolusInQueue()) {
|
||||||
&& !commandQueue.isRunning(Command.CommandType.BOLUS)) {
|
|
||||||
val waiting = PumpEnactResult(injector)
|
val waiting = PumpEnactResult(injector)
|
||||||
waiting.queued = true
|
waiting.queued = true
|
||||||
if (resultAfterConstraints.tempBasalRequested) lastRun.tbrSetByPump = waiting
|
if (resultAfterConstraints.tempBasalRequested) lastRun.tbrSetByPump = waiting
|
||||||
|
|
|
@ -202,11 +202,11 @@ open class CommandQueue @Inject constructor(
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun bolusInQueue(): Boolean {
|
override fun bolusInQueue(): Boolean {
|
||||||
if (isRunning(CommandType.BOLUS)) return true
|
if (isRunning(CommandType.BOLUS)) return true
|
||||||
|
if (isRunning(CommandType.SMB_BOLUS)) return true
|
||||||
synchronized(queue) {
|
synchronized(queue) {
|
||||||
for (i in queue.indices) {
|
for (i in queue.indices) {
|
||||||
if (queue[i].commandType == CommandType.BOLUS) {
|
if (queue[i].commandType == CommandType.BOLUS) return true
|
||||||
return true
|
if (queue[i].commandType == CommandType.SMB_BOLUS) return true
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -243,13 +243,15 @@ open class CommandQueue @Inject constructor(
|
||||||
}
|
}
|
||||||
var type = if (detailedBolusInfo.bolusType == DetailedBolusInfo.BolusType.SMB) CommandType.SMB_BOLUS else CommandType.BOLUS
|
var type = if (detailedBolusInfo.bolusType == DetailedBolusInfo.BolusType.SMB) CommandType.SMB_BOLUS else CommandType.BOLUS
|
||||||
if (type == CommandType.SMB_BOLUS) {
|
if (type == CommandType.SMB_BOLUS) {
|
||||||
if (isRunning(CommandType.BOLUS) || isRunning(CommandType.SMB_BOLUS) || bolusInQueue()) {
|
if (bolusInQueue()) {
|
||||||
aapsLogger.debug(LTag.PUMPQUEUE, "Rejecting SMB since a bolus is queue/running")
|
aapsLogger.debug(LTag.PUMPQUEUE, "Rejecting SMB since a bolus is queue/running")
|
||||||
|
callback?.result(PumpEnactResult(injector).enacted(false).success(false))?.run()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
val lastBolusTime = repository.getLastBolusRecord()?.timestamp ?: 0L
|
val lastBolusTime = repository.getLastBolusRecord()?.timestamp ?: 0L
|
||||||
if (detailedBolusInfo.lastKnownBolusTime < lastBolusTime) {
|
if (detailedBolusInfo.lastKnownBolusTime < lastBolusTime) {
|
||||||
aapsLogger.debug(LTag.PUMPQUEUE, "Rejecting bolus, another bolus was issued since request time")
|
aapsLogger.debug(LTag.PUMPQUEUE, "Rejecting bolus, another bolus was issued since request time")
|
||||||
|
callback?.result(PumpEnactResult(injector).enacted(false).success(false))?.run()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
removeAll(CommandType.SMB_BOLUS)
|
removeAll(CommandType.SMB_BOLUS)
|
||||||
|
|
|
@ -23,6 +23,7 @@ class CommandSMBBolus(
|
||||||
override fun execute() {
|
override fun execute() {
|
||||||
val r: PumpEnactResult
|
val r: PumpEnactResult
|
||||||
val lastBolusTime = repository.getLastBolusRecord()?.timestamp ?: 0L
|
val lastBolusTime = repository.getLastBolusRecord()?.timestamp ?: 0L
|
||||||
|
aapsLogger.debug(LTag.PUMPQUEUE, "Last bolus: $lastBolusTime ${dateUtil.dateAndTimeAndSecondsString(lastBolusTime)}")
|
||||||
if (lastBolusTime != 0L && lastBolusTime + T.mins(3).msecs() > dateUtil.now()) {
|
if (lastBolusTime != 0L && lastBolusTime + T.mins(3).msecs() > dateUtil.now()) {
|
||||||
aapsLogger.debug(LTag.PUMPQUEUE, "SMB requested but still in 3 min interval")
|
aapsLogger.debug(LTag.PUMPQUEUE, "SMB requested but still in 3 min interval")
|
||||||
r = PumpEnactResult(injector).enacted(false).success(false).comment("SMB requested but still in 3 min interval")
|
r = PumpEnactResult(injector).enacted(false).success(false).comment("SMB requested but still in 3 min interval")
|
||||||
|
|
|
@ -70,7 +70,7 @@ class PumpSyncImplementation @Inject constructor(
|
||||||
|
|
||||||
if (type.description != storedType || serialNumber != storedSerial)
|
if (type.description != storedType || serialNumber != storedSerial)
|
||||||
rxBus.send(EventNewNotification(Notification(Notification.WRONG_PUMP_DATA, resourceHelper.gs(R.string.wrong_pump_data), Notification.URGENT)))
|
rxBus.send(EventNewNotification(Notification(Notification.WRONG_PUMP_DATA, resourceHelper.gs(R.string.wrong_pump_data), Notification.URGENT)))
|
||||||
aapsLogger.error(LTag.PUMP, "Ignoring pump history record Allowed: ${dateUtil.dateAndTimeAndSecondsString(storedTimestamp)} $storedType $storedSerial Received: $timestamp ${dateUtil.dateAndTimeAndSecondsString(timestamp)}${type.description} $serialNumber")
|
aapsLogger.error(LTag.PUMP, "Ignoring pump history record Allowed: ${dateUtil.dateAndTimeAndSecondsString(storedTimestamp)} $storedType $storedSerial Received: $timestamp ${dateUtil.dateAndTimeAndSecondsString(timestamp)} ${type.description} $serialNumber")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,14 +118,13 @@ open class DanaRSPacketAPSHistoryEvents(
|
||||||
val param1 = intFromBuffMsbLsb(data, 7, 2)
|
val param1 = intFromBuffMsbLsb(data, 7, 2)
|
||||||
val param2 = intFromBuffMsbLsb(data, 9, 2)
|
val param2 = intFromBuffMsbLsb(data, 9, 2)
|
||||||
val pumpId: Long
|
val pumpId: Long
|
||||||
var id = 0
|
|
||||||
if (!danaPump.usingUTC) {
|
if (!danaPump.usingUTC) {
|
||||||
datetime = dateTimeSecFromBuff(data, 1) // 6 bytes
|
datetime = dateTimeSecFromBuff(data, 1) // 6 bytes
|
||||||
pumpId = datetime
|
pumpId = datetime
|
||||||
} else {
|
} else {
|
||||||
datetime = intFromBuffMsbLsb(data, 3, 4) * 1000L
|
datetime = intFromBuffMsbLsb(data, 3, 4) * 1000L
|
||||||
id = intFromBuffMsbLsb(data, 0, 2) // range only 1-2000
|
val id = intFromBuffMsbLsb(data, 0, 2) // range only 1-2000
|
||||||
pumpId = datetime shl 16 + id
|
pumpId = datetime * 2 + id
|
||||||
}
|
}
|
||||||
val status: String
|
val status: String
|
||||||
when (recordCode) {
|
when (recordCode) {
|
||||||
|
@ -140,7 +139,7 @@ open class DanaRSPacketAPSHistoryEvents(
|
||||||
pumpId = pumpId,
|
pumpId = pumpId,
|
||||||
pumpType = PumpType.DANA_RS,
|
pumpType = PumpType.DANA_RS,
|
||||||
pumpSerial = danaPump.serialNumber)
|
pumpSerial = danaPump.serialNumber)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + (if (newRecord) "**NEW** " else "") + "EVENT TEMPSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Ratio: " + param1 + "% Duration: " + param2 + "min")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + (if (newRecord) "**NEW** " else "") + "EVENT TEMPSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Ratio: " + param1 + "% Duration: " + param2 + "min")
|
||||||
status = "TEMPSTART " + dateUtil.timeString(datetime)
|
status = "TEMPSTART " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +149,7 @@ open class DanaRSPacketAPSHistoryEvents(
|
||||||
endPumpId = pumpId,
|
endPumpId = pumpId,
|
||||||
pumpType = PumpType.DANA_RS,
|
pumpType = PumpType.DANA_RS,
|
||||||
pumpSerial = danaPump.serialNumber)
|
pumpSerial = danaPump.serialNumber)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + (if (newRecord) "**NEW** " else "") + "EVENT TEMPSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + (if (newRecord) "**NEW** " else "") + "EVENT TEMPSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")")
|
||||||
status = "TEMPSTOP " + dateUtil.timeString(datetime)
|
status = "TEMPSTOP " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +162,7 @@ open class DanaRSPacketAPSHistoryEvents(
|
||||||
pumpId = pumpId,
|
pumpId = pumpId,
|
||||||
pumpType = PumpType.DANA_RS,
|
pumpType = PumpType.DANA_RS,
|
||||||
pumpSerial = danaPump.serialNumber)
|
pumpSerial = danaPump.serialNumber)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min")
|
||||||
status = "EXTENDEDSTART " + dateUtil.timeString(datetime)
|
status = "EXTENDEDSTART " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +172,7 @@ open class DanaRSPacketAPSHistoryEvents(
|
||||||
endPumpId = pumpId,
|
endPumpId = pumpId,
|
||||||
pumpType = PumpType.DANA_RS,
|
pumpType = PumpType.DANA_RS,
|
||||||
pumpSerial = danaPump.serialNumber)
|
pumpSerial = danaPump.serialNumber)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min")
|
||||||
status = "EXTENDEDSTOP " + dateUtil.timeString(datetime)
|
status = "EXTENDEDSTOP " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +185,7 @@ open class DanaRSPacketAPSHistoryEvents(
|
||||||
pumpId = pumpId,
|
pumpId = pumpId,
|
||||||
pumpType = PumpType.DANA_RS,
|
pumpType = PumpType.DANA_RS,
|
||||||
pumpSerial = danaPump.serialNumber)
|
pumpSerial = danaPump.serialNumber)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U ")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U ")
|
||||||
status = "BOLUS " + dateUtil.timeString(datetime)
|
status = "BOLUS " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +198,7 @@ open class DanaRSPacketAPSHistoryEvents(
|
||||||
pumpId = pumpId,
|
pumpId = pumpId,
|
||||||
pumpType = PumpType.DANA_RS,
|
pumpType = PumpType.DANA_RS,
|
||||||
pumpSerial = danaPump.serialNumber)
|
pumpSerial = danaPump.serialNumber)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min")
|
||||||
status = "DUALBOLUS " + dateUtil.timeString(datetime)
|
status = "DUALBOLUS " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +211,7 @@ open class DanaRSPacketAPSHistoryEvents(
|
||||||
pumpId = pumpId,
|
pumpId = pumpId,
|
||||||
pumpType = PumpType.DANA_RS,
|
pumpType = PumpType.DANA_RS,
|
||||||
pumpSerial = danaPump.serialNumber)
|
pumpSerial = danaPump.serialNumber)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + (if (newRecord) "**NEW** " else "") + "EVENT DUALEXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + (if (newRecord) "**NEW** " else "") + "EVENT DUALEXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min")
|
||||||
status = "DUALEXTENDEDSTART " + dateUtil.timeString(datetime)
|
status = "DUALEXTENDEDSTART " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,17 +221,17 @@ open class DanaRSPacketAPSHistoryEvents(
|
||||||
endPumpId = pumpId,
|
endPumpId = pumpId,
|
||||||
pumpType = PumpType.DANA_RS,
|
pumpType = PumpType.DANA_RS,
|
||||||
pumpSerial = danaPump.serialNumber)
|
pumpSerial = danaPump.serialNumber)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + (if (newRecord) "**NEW** " else "") + "EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + (if (newRecord) "**NEW** " else "") + "EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min")
|
||||||
status = "DUALEXTENDEDSTOP " + dateUtil.timeString(datetime)
|
status = "DUALEXTENDEDSTOP " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
DanaPump.SUSPENDON -> {
|
DanaPump.SUSPENDON -> {
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT SUSPENDON (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + "EVENT SUSPENDON (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")")
|
||||||
status = "SUSPENDON " + dateUtil.timeString(datetime)
|
status = "SUSPENDON " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
DanaPump.SUSPENDOFF -> {
|
DanaPump.SUSPENDOFF -> {
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT SUSPENDOFF (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + "EVENT SUSPENDOFF (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")")
|
||||||
status = "SUSPENDOFF " + dateUtil.timeString(datetime)
|
status = "SUSPENDOFF " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,18 +244,18 @@ open class DanaRSPacketAPSHistoryEvents(
|
||||||
pumpType = danaPump.pumpType(),
|
pumpType = danaPump.pumpType(),
|
||||||
pumpSerial = danaPump.serialNumber
|
pumpSerial = danaPump.serialNumber
|
||||||
)
|
)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + (if (newRecord) "**NEW** " else "") + "EVENT REFILL (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + (if (newRecord) "**NEW** " else "") + "EVENT REFILL (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U")
|
||||||
}
|
}
|
||||||
status = "REFILL " + dateUtil.timeString(datetime)
|
status = "REFILL " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
DanaPump.PRIME -> {
|
DanaPump.PRIME -> {
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT PRIME (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + "EVENT PRIME (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U")
|
||||||
status = "PRIME " + dateUtil.timeString(datetime)
|
status = "PRIME " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
DanaPump.PROFILECHANGE -> {
|
DanaPump.PROFILECHANGE -> {
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT PROFILECHANGE (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " No: " + param1 + " CurrentRate: " + param2 / 100.0 + "U/h")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + "EVENT PROFILECHANGE (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " No: " + param1 + " CurrentRate: " + param2 / 100.0 + "U/h")
|
||||||
status = "PROFILECHANGE " + dateUtil.timeString(datetime)
|
status = "PROFILECHANGE " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +266,7 @@ open class DanaRSPacketAPSHistoryEvents(
|
||||||
pumpId = pumpId,
|
pumpId = pumpId,
|
||||||
pumpType = PumpType.DANA_RS,
|
pumpType = PumpType.DANA_RS,
|
||||||
pumpSerial = danaPump.serialNumber)
|
pumpSerial = danaPump.serialNumber)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g")
|
||||||
status = "CARBS " + dateUtil.timeString(datetime)
|
status = "CARBS " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,19 +279,19 @@ open class DanaRSPacketAPSHistoryEvents(
|
||||||
pumpType = danaPump.pumpType(),
|
pumpType = danaPump.pumpType(),
|
||||||
pumpSerial = danaPump.serialNumber
|
pumpSerial = danaPump.serialNumber
|
||||||
)
|
)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + (if (newRecord) "**NEW** " else "") + "EVENT PRIMECANNULA(" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U")
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + (if (newRecord) "**NEW** " else "") + "EVENT PRIMECANNULA(" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U")
|
||||||
}
|
}
|
||||||
status = "PRIMECANNULA " + dateUtil.timeString(datetime)
|
status = "PRIMECANNULA " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
DanaPump.TIMECHANGE -> {
|
DanaPump.TIMECHANGE -> {
|
||||||
val oldDateTime = intFromBuffMsbLsb(data, 7, 4) * 1000L
|
val oldDateTime = intFromBuffMsbLsb(data, 7, 4) * 1000L
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT TIMECHANGE(" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Previous: " + dateUtil.dateAndTimeString(oldDateTime))
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + "EVENT TIMECHANGE(" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Previous: " + dateUtil.dateAndTimeString(oldDateTime))
|
||||||
status = "TIMECHANGE " + dateUtil.timeString(datetime)
|
status = "TIMECHANGE " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "Event: " + recordCode + " " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2)
|
aapsLogger.debug(LTag.PUMPCOMM, "[" + pumpId + "] " + "Event: " + recordCode + " " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2)
|
||||||
status = "UNKNOWN " + dateUtil.timeString(datetime)
|
status = "UNKNOWN " + dateUtil.timeString(datetime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,16 +33,16 @@ internal interface BolusDao : TraceableDao<Bolus> {
|
||||||
@Query("SELECT * FROM $TABLE_BOLUSES WHERE temporaryId = :temporaryId AND pumpType = :pumpType AND pumpSerial = :pumpSerial AND referenceId IS NULL")
|
@Query("SELECT * FROM $TABLE_BOLUSES WHERE temporaryId = :temporaryId AND pumpType = :pumpType AND pumpSerial = :pumpSerial AND referenceId IS NULL")
|
||||||
fun findByPumpTempIds(temporaryId: Long, pumpType: InterfaceIDs.PumpType, pumpSerial: String): Bolus?
|
fun findByPumpTempIds(temporaryId: Long, pumpType: InterfaceIDs.PumpType, pumpSerial: String): Bolus?
|
||||||
|
|
||||||
@Query("SELECT * FROM $TABLE_BOLUSES WHERE isValid = 1 AND type <> :exclude AND referenceId IS NULL ORDER BY id ASC LIMIT 1")
|
@Query("SELECT * FROM $TABLE_BOLUSES WHERE isValid = 1 AND type <> :exclude AND referenceId IS NULL ORDER BY timestamp DESC LIMIT 1")
|
||||||
fun getLastBolusRecord(exclude: Bolus.Type = Bolus.Type.PRIMING): Bolus?
|
fun getLastBolusRecord(exclude: Bolus.Type = Bolus.Type.PRIMING): Bolus?
|
||||||
|
|
||||||
@Query("SELECT * FROM $TABLE_BOLUSES WHERE isValid = 1 AND type <> :exclude AND referenceId IS NULL ORDER BY id ASC LIMIT 1")
|
@Query("SELECT * FROM $TABLE_BOLUSES WHERE isValid = 1 AND type <> :exclude AND referenceId IS NULL ORDER BY timestamp DESC LIMIT 1")
|
||||||
fun getLastBolusRecordMaybe(exclude: Bolus.Type = Bolus.Type.PRIMING): Maybe<Bolus>
|
fun getLastBolusRecordMaybe(exclude: Bolus.Type = Bolus.Type.PRIMING): Maybe<Bolus>
|
||||||
|
|
||||||
@Query("SELECT * FROM $TABLE_BOLUSES WHERE isValid = 1 AND type == :only AND referenceId IS NULL ORDER BY id ASC LIMIT 1")
|
@Query("SELECT * FROM $TABLE_BOLUSES WHERE isValid = 1 AND type == :only AND referenceId IS NULL ORDER BY timestamp DESC LIMIT 1")
|
||||||
fun getLastBolusRecordOfType(only: Bolus.Type): Bolus?
|
fun getLastBolusRecordOfType(only: Bolus.Type): Bolus?
|
||||||
|
|
||||||
@Query("SELECT * FROM $TABLE_BOLUSES WHERE isValid = 1 AND type <> :exclude AND referenceId IS NULL ORDER BY id ASC LIMIT 1")
|
@Query("SELECT * FROM $TABLE_BOLUSES WHERE isValid = 1 AND type <> :exclude AND referenceId IS NULL ORDER BY timestamp ASC LIMIT 1")
|
||||||
fun getOldestBolusRecord(exclude: Bolus.Type = Bolus.Type.PRIMING): Bolus?
|
fun getOldestBolusRecord(exclude: Bolus.Type = Bolus.Type.PRIMING): Bolus?
|
||||||
|
|
||||||
@Query("SELECT * FROM $TABLE_BOLUSES WHERE isValid = 1 AND timestamp >= :timestamp AND referenceId IS NULL ORDER BY id DESC")
|
@Query("SELECT * FROM $TABLE_BOLUSES WHERE isValid = 1 AND timestamp >= :timestamp AND referenceId IS NULL ORDER BY id DESC")
|
||||||
|
|
Loading…
Reference in a new issue