This commit is contained in:
Milos Kozak 2022-07-10 23:05:34 +02:00
parent 5cde729c54
commit 89d2290ed9
3 changed files with 15 additions and 15 deletions

View file

@ -34,6 +34,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.WakeAndTuneTask
import info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntryTBR
import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncEntriesCreator
import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil
import info.nightscout.androidaps.plugins.pump.common.utils.ProfileUtil
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry
@ -90,7 +91,7 @@ class MedtronicPumpPlugin @Inject constructor(
dateUtil: DateUtil,
aapsSchedulers: AapsSchedulers,
pumpSync: PumpSync,
pumpSyncStorage: info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage
pumpSyncStorage: PumpSyncStorage
) : PumpPluginAbstract(
PluginDescription() //
.mainType(PluginType.PUMP) //

View file

@ -29,6 +29,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpSta
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage
import info.nightscout.shared.sharedPreferences.SP
import org.apache.commons.lang3.StringUtils
import org.joda.time.LocalDateTime
@ -57,7 +58,7 @@ class MedtronicHistoryData @Inject constructor(
val medtronicPumpHistoryDecoder: MedtronicPumpHistoryDecoder,
val medtronicPumpStatus: MedtronicPumpStatus,
val pumpSync: PumpSync,
val pumpSyncStorage: info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage
val pumpSyncStorage: PumpSyncStorage
) {
val allHistory: MutableList<PumpHistoryEntry> = mutableListOf()

View file

@ -26,6 +26,7 @@ import info.nightscout.androidaps.utils.DecimalFormatter.to0Decimal
import info.nightscout.androidaps.utils.DecimalFormatter.to2Decimal
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
@ -39,9 +40,9 @@ import org.json.JSONObject
*/
// When using this class, make sure that your first step is to create mConnection (see MedtronicPumpPlugin)
abstract class PumpPluginAbstract protected constructor(
pluginDescription: PluginDescription?,
pluginDescription: PluginDescription,
pumpType: PumpType,
injector: HasAndroidInjector?,
injector: HasAndroidInjector,
rh: ResourceHelper,
aapsLogger: AAPSLogger,
commandQueue: CommandQueue,
@ -53,8 +54,8 @@ abstract class PumpPluginAbstract protected constructor(
var dateUtil: DateUtil,
var aapsSchedulers: AapsSchedulers,
var pumpSync: PumpSync,
var pumpSyncStorage: info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage
) : PumpPluginBase(pluginDescription!!, injector!!, aapsLogger, rh, commandQueue), Pump, Constraints, info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncEntriesCreator {
var pumpSyncStorage: PumpSyncStorage
) : PumpPluginBase(pluginDescription, injector, aapsLogger, rh, commandQueue), Pump, Constraints, info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncEntriesCreator {
private val disposable = CompositeDisposable()
@ -84,7 +85,7 @@ abstract class PumpPluginAbstract protected constructor(
disposable.add(rxBus
.toObservable(EventAppExit::class.java)
.observeOn(aapsSchedulers.io)
.subscribe({ _ -> context.unbindService(serviceConnection!!) }) { throwable: Throwable? -> fabricPrivacy.logException(throwable!!) }
.subscribe({ context.unbindService(serviceConnection!!) }) { throwable: Throwable? -> fabricPrivacy.logException(throwable!!) }
)
onStartCustomActions()
}
@ -265,19 +266,16 @@ abstract class PumpPluginAbstract protected constructor(
override fun shortStatus(veryShort: Boolean): String {
var ret = ""
if (pumpStatusData.lastConnection == 0L) {
ret += "LastConn: never\n"
ret += if (pumpStatusData.lastConnection == 0L) {
"LastConn: never\n"
} else {
val agoMsec = System.currentTimeMillis() - pumpStatusData.lastConnection
val agoMin = (agoMsec / 60.0 / 1000.0).toInt()
ret += "LastConn: $agoMin min ago\n"
"LastConn: $agoMin min ago\n"
}
if (pumpStatusData.lastBolusTime != null && pumpStatusData.lastBolusTime!!.time != 0L) {
ret += """
LastBolus: ${to2Decimal(pumpStatusData.lastBolusAmount!!)}U @${DateFormat.format("HH:mm", pumpStatusData.lastBolusTime)}
""".trimIndent()
if (pumpStatusData.lastBolusTime?.time != 0L) {
ret += "LastBolus: ${to2Decimal(pumpStatusData.lastBolusAmount!!)}U @${DateFormat.format("HH:mm", pumpStatusData.lastBolusTime)}"
}
val activeTemp = pumpSync.expectedPumpState().temporaryBasal
if (activeTemp != null) {