- refactorings kotlin !!
- moved 2 filed into pump-common module (newly created)
This commit is contained in:
parent
fb5ff409f8
commit
e24af3934f
27 changed files with 187 additions and 148 deletions
|
@ -186,6 +186,7 @@ dependencies {
|
|||
implementation project(':danars')
|
||||
implementation project(':danar')
|
||||
implementation project(':insight')
|
||||
implementation project(':pump-common')
|
||||
implementation project(':rileylink')
|
||||
implementation project(':medtronic')
|
||||
implementation project(':omnipod-common')
|
||||
|
|
|
@ -77,27 +77,36 @@ open class AppModule {
|
|||
pumpSync: PumpSync,
|
||||
sp: SP,
|
||||
aapsLogger: AAPSLogger
|
||||
): PumpSyncStorage {
|
||||
return PumpSyncStorage(pumpSync, sp, aapsLogger)
|
||||
): info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage {
|
||||
return info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage(pumpSync, sp, aapsLogger)
|
||||
}
|
||||
|
||||
@Module
|
||||
interface AppBindings {
|
||||
|
||||
@Binds fun bindContext(mainApp: MainApp): Context
|
||||
@Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector
|
||||
@Binds fun bindActivePluginProvider(pluginStore: PluginStore): ActivePlugin
|
||||
@Binds fun bindCommandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider
|
||||
@Binds fun bindConfigInterface(config: ConfigImpl): Config
|
||||
@Binds fun bindConfigBuilderInterface(configBuilderPlugin: ConfigBuilderPlugin): ConfigBuilder
|
||||
@Binds
|
||||
fun bindConfigBuilderInterface(configBuilderPlugin: ConfigBuilderPlugin): ConfigBuilder
|
||||
@Binds fun bindTreatmentsInterface(treatmentsPlugin: TreatmentsPlugin): TreatmentsInterface
|
||||
@Binds fun bindDatabaseHelperInterface(databaseHelperProvider: DatabaseHelperProvider): DatabaseHelperInterface
|
||||
@Binds fun bindNotificationHolderInterface(notificationHolder: NotificationHolderImpl): NotificationHolder
|
||||
@Binds fun bindImportExportPrefsInterface(importExportPrefs: ImportExportPrefsImpl): ImportExportPrefs
|
||||
@Binds fun bindIconsProviderInterface(iconsProvider: IconsProviderImplementation): IconsProvider
|
||||
@Binds
|
||||
fun bindDatabaseHelperInterface(databaseHelperProvider: DatabaseHelperProvider): DatabaseHelperInterface
|
||||
@Binds
|
||||
fun bindNotificationHolderInterface(notificationHolder: NotificationHolderImpl): NotificationHolder
|
||||
@Binds
|
||||
fun bindImportExportPrefsInterface(importExportPrefs: ImportExportPrefsImpl): ImportExportPrefs
|
||||
@Binds
|
||||
fun bindIconsProviderInterface(iconsProvider: IconsProviderImplementation): IconsProvider
|
||||
@Binds fun bindLoopInterface(loopPlugin: LoopPlugin): LoopInterface
|
||||
@Binds fun bindIobCobCalculatorInterface(iobCobCalculatorPlugin: IobCobCalculatorPlugin): IobCobCalculator
|
||||
@Binds fun bindSmsCommunicatorInterface(smsCommunicatorPlugin: SmsCommunicatorPlugin): SmsCommunicator
|
||||
@Binds fun bindDataSyncSelector(dataSyncSelectorImplementation: DataSyncSelectorImplementation): DataSyncSelector
|
||||
@Binds
|
||||
fun bindIobCobCalculatorInterface(iobCobCalculatorPlugin: IobCobCalculatorPlugin): IobCobCalculator
|
||||
@Binds
|
||||
fun bindSmsCommunicatorInterface(smsCommunicatorPlugin: SmsCommunicatorPlugin): SmsCommunicator
|
||||
@Binds
|
||||
fun bindDataSyncSelector(dataSyncSelectorImplementation: DataSyncSelectorImplementation): DataSyncSelector
|
||||
@Binds fun bindPumpSync(pumpSyncImplementation: PumpSyncImplementation): PumpSync
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ enum class PumpHistoryEntryGroup(val resourceId: Int) {
|
|||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private var translatedList: MutableList<PumpHistoryEntryGroup>? = null
|
||||
|
||||
private fun doTranslation(resourceHelper: ResourceHelper) {
|
||||
|
@ -43,9 +44,9 @@ enum class PumpHistoryEntryGroup(val resourceId: Int) {
|
|||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getTranslatedList(resourceHelper: ResourceHelper): List<PumpHistoryEntryGroup>? {
|
||||
fun getTranslatedList(resourceHelper: ResourceHelper): List<PumpHistoryEntryGroup> {
|
||||
if (translatedList == null) doTranslation(resourceHelper)
|
||||
return translatedList
|
||||
return translatedList!!
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,5 +16,6 @@ android {
|
|||
|
||||
dependencies {
|
||||
implementation project(':core')
|
||||
implementation project(':pump-common')
|
||||
implementation project(':rileylink')
|
||||
}
|
||||
|
|
|
@ -90,8 +90,8 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
dateUtil: DateUtil,
|
||||
aapsSchedulers: AapsSchedulers,
|
||||
pumpSync: PumpSync,
|
||||
pumpSyncStorage: PumpSyncStorage
|
||||
) : PumpPluginAbstract(PluginDescription() //
|
||||
pumpSyncStorage: info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage
|
||||
) : info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract(PluginDescription() //
|
||||
.mainType(PluginType.PUMP) //
|
||||
.fragmentClass(MedtronicFragment::class.java.name) //
|
||||
.pluginIcon(R.drawable.ic_veo_128)
|
||||
|
@ -101,7 +101,7 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
.description(R.string.description_pump_medtronic), //
|
||||
PumpType.MEDTRONIC_522_722, // we default to most basic model, correct model from config is loaded later
|
||||
injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy, dateUtil, aapsSchedulers, pumpSync, pumpSyncStorage
|
||||
), Pump, RileyLinkPumpDevice, PumpSyncEntriesCreator {
|
||||
), Pump, RileyLinkPumpDevice, info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncEntriesCreator {
|
||||
|
||||
private lateinit var rileyLinkMedtronicService: RileyLinkMedtronicService
|
||||
|
||||
|
@ -199,7 +199,7 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
SystemClock.sleep(60000)
|
||||
if (this.isInitialized) {
|
||||
val statusRefresh = workWithStatusRefresh(
|
||||
StatusRefreshAction.GetData, null, null)
|
||||
StatusRefreshAction.GetData, null, null)!!
|
||||
if (doWeHaveAnyStatusNeededRefereshing(statusRefresh)) {
|
||||
if (!commandQueue.statusInQueue()) {
|
||||
commandQueue.readStatus("Scheduled Status Refresh", null)
|
||||
|
@ -214,7 +214,7 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
override val serviceClass: Class<*>
|
||||
get() = RileyLinkMedtronicService::class.java
|
||||
|
||||
override val pumpStatusData: PumpStatus
|
||||
override val pumpStatusData: info.nightscout.androidaps.plugins.pump.common.data.PumpStatus
|
||||
get() = medtronicPumpStatus
|
||||
|
||||
override fun deviceID(): String {
|
||||
|
@ -334,7 +334,7 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
|
||||
private fun refreshAnyStatusThatNeedsToBeRefreshed() {
|
||||
val statusRefresh = workWithStatusRefresh(StatusRefreshAction.GetData, null,
|
||||
null)
|
||||
null)!!
|
||||
if (!doWeHaveAnyStatusNeededRefereshing(statusRefresh)) {
|
||||
return
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
|
||||
// execute
|
||||
val refreshTypesNeededToReschedule: MutableSet<MedtronicStatusRefreshType> = mutableSetOf()
|
||||
for ((key, value) in statusRefresh!!) {
|
||||
for ((key, value) in statusRefresh) {
|
||||
if (value > 0 && System.currentTimeMillis() > value) {
|
||||
when (key) {
|
||||
MedtronicStatusRefreshType.PumpHistory -> {
|
||||
|
@ -389,8 +389,8 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
if (resetTime) medtronicPumpStatus.setLastCommunicationToNow()
|
||||
}
|
||||
|
||||
private fun doWeHaveAnyStatusNeededRefereshing(statusRefresh: Map<MedtronicStatusRefreshType, Long>?): Boolean {
|
||||
for ((_, value) in statusRefresh!!) {
|
||||
private fun doWeHaveAnyStatusNeededRefereshing(statusRefresh: Map<MedtronicStatusRefreshType, Long>): Boolean {
|
||||
for ((_, value) in statusRefresh) {
|
||||
if (value > 0 && System.currentTimeMillis() > value) {
|
||||
return true
|
||||
}
|
||||
|
@ -583,10 +583,10 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
scheduleNextRefresh(MedtronicStatusRefreshType.PumpTime, 0)
|
||||
}
|
||||
|
||||
override fun deliverBolus(detailedBolusInfo: DetailedBolusInfo?): PumpEnactResult {
|
||||
override fun deliverBolus(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult {
|
||||
aapsLogger.info(LTag.PUMP, "MedtronicPumpPlugin::deliverBolus - " + BolusDeliveryType.DeliveryPrepared)
|
||||
setRefreshButtonEnabled(false)
|
||||
if (detailedBolusInfo!!.insulin > medtronicPumpStatus.reservoirRemainingUnits) {
|
||||
if (detailedBolusInfo.insulin > medtronicPumpStatus.reservoirRemainingUnits) {
|
||||
return PumpEnactResult(injector) //
|
||||
.success(false) //
|
||||
.enacted(false) //
|
||||
|
@ -621,7 +621,12 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
setRefreshButtonEnabled(true)
|
||||
|
||||
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Response: {}", response);
|
||||
if (response!!) {
|
||||
return if (response == null || !response) {
|
||||
PumpEnactResult(injector) //
|
||||
.success(bolusDeliveryType == BolusDeliveryType.CancelDelivery) //
|
||||
.enacted(false) //
|
||||
.comment(R.string.medtronic_cmd_bolus_could_not_be_delivered)
|
||||
} else {
|
||||
if (bolusDeliveryType == BolusDeliveryType.CancelDelivery) {
|
||||
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Delivery Canceled after Bolus started.");
|
||||
Thread(Runnable {
|
||||
|
@ -648,11 +653,6 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
.enacted(true) //
|
||||
.bolusDelivered(detailedBolusInfo.insulin) //
|
||||
.carbsDelivered(detailedBolusInfo.carbs)
|
||||
} else {
|
||||
PumpEnactResult(injector) //
|
||||
.success(bolusDeliveryType == BolusDeliveryType.CancelDelivery) //
|
||||
.enacted(false) //
|
||||
.comment(R.string.medtronic_cmd_bolus_could_not_be_delivered)
|
||||
}
|
||||
} finally {
|
||||
finishAction("Bolus")
|
||||
|
@ -739,13 +739,13 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
// CANCEL
|
||||
val responseTask2 = rileyLinkMedtronicService.medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR)
|
||||
val response = responseTask2.result as Boolean?
|
||||
if (response!!) {
|
||||
aapsLogger.info(LTag.PUMP, logPrefix + "setTempBasalAbsolute - Current TBR cancelled.")
|
||||
} else {
|
||||
if (response == null || !response) {
|
||||
aapsLogger.error(logPrefix + "setTempBasalAbsolute - Cancel TBR failed.")
|
||||
finishAction("TBR")
|
||||
return PumpEnactResult(injector).success(false).enacted(false)
|
||||
.comment(R.string.medtronic_cmd_cant_cancel_tbr_stop_op)
|
||||
} else {
|
||||
aapsLogger.info(LTag.PUMP, logPrefix + "setTempBasalAbsolute - Current TBR cancelled.")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -763,7 +763,7 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
medtronicPumpStatus.tempBasalAmount = absoluteRate
|
||||
medtronicPumpStatus.tempBasalLength = durationInMinutes
|
||||
|
||||
val tempData = PumpDbEntryTBR(absoluteRate, true, durationInMinutes, tbrType)
|
||||
val tempData = info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntryTBR(absoluteRate, true, durationInMinutes, tbrType)
|
||||
|
||||
pumpSyncStorage.addTemporaryBasalRateWithTempId(tempData, true, this)
|
||||
|
||||
|
@ -956,10 +956,13 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
val tbr = responseTask.result as TempBasalPair?
|
||||
|
||||
// we sometimes get rate returned even if TBR is no longer running
|
||||
if (tbr!!.durationMinutes == 0) {
|
||||
tbr.insulinRate = 0.0
|
||||
}
|
||||
tbr
|
||||
if (tbr != null) {
|
||||
if (tbr.durationMinutes == 0) {
|
||||
tbr.insulinRate = 0.0
|
||||
}
|
||||
tbr
|
||||
} else
|
||||
null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
@ -992,7 +995,11 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
val responseTask2 = rileyLinkMedtronicService.medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR)
|
||||
val response = responseTask2.result as Boolean?
|
||||
finishAction("TBR")
|
||||
return if (response!!) {
|
||||
return if (response == null || !response) {
|
||||
aapsLogger.info(LTag.PUMP, logPrefix + "cancelTempBasal - Cancel TBR failed.")
|
||||
PumpEnactResult(injector).success(false).enacted(false) //
|
||||
.comment(R.string.medtronic_cmd_cant_cancel_tbr)
|
||||
} else {
|
||||
aapsLogger.info(LTag.PUMP, logPrefix + "cancelTempBasal - Cancel TBR successful.")
|
||||
|
||||
val runningTBR = medtronicPumpStatus.runningTBR
|
||||
|
@ -1022,19 +1029,13 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
//pumpSyncStorage.addTemporaryBasalRateWithTempId(tempData, true, this)
|
||||
|
||||
PumpEnactResult(injector).success(true).enacted(true) //
|
||||
.isTempCancel(true)
|
||||
} else {
|
||||
aapsLogger.info(LTag.PUMP, logPrefix + "cancelTempBasal - Cancel TBR failed.")
|
||||
PumpEnactResult(injector).success(response).enacted(response) //
|
||||
.comment(R.string.medtronic_cmd_cant_cancel_tbr)
|
||||
}
|
||||
}
|
||||
|
||||
override fun manufacturer(): ManufacturerType {
|
||||
return pumpDescription.pumpType.manufacturer!!
|
||||
return ManufacturerType.Medtronic
|
||||
}
|
||||
|
||||
override fun model(): PumpType {
|
||||
|
|
|
@ -140,7 +140,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
|
|||
medtronicUtil.medtronicPumpModel = pumpModel!!
|
||||
medtronicUtil.isModelSet = true
|
||||
}
|
||||
aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "isDeviceReachable. PumpModel is %s - Valid: %b (rssi=%d)", pumpModel!!.name, valid,
|
||||
aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "isDeviceReachable. PumpModel is %s - Valid: %b (rssi=%d)", medtronicUtil.medtronicPumpModel, valid,
|
||||
radioResponse.rssi))
|
||||
if (valid) {
|
||||
if (state === PumpDeviceState.PumpUnreachable)
|
||||
|
@ -313,7 +313,9 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
|
|||
aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Problem acknowledging frame response. (retry=%d)", retries))
|
||||
}
|
||||
}
|
||||
if (nextMsg != null) currentResponse = GetHistoryPageCarelinkMessageBody(nextMsg.messageBody!!.txData) else {
|
||||
if (nextMsg != null)
|
||||
currentResponse = GetHistoryPageCarelinkMessageBody(nextMsg.messageBody!!.txData)
|
||||
else {
|
||||
aapsLogger.error(LTag.PUMPCOMM, "We couldn't acknowledge frame from pump, aborting operation.")
|
||||
}
|
||||
}
|
||||
|
@ -602,7 +604,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
|
|||
|
||||
fun getTemporaryBasal(): TempBasalPair? {
|
||||
return sendAndGetResponseWithCheck(MedtronicCommandType.ReadTemporaryBasal) { _, _, rawContent ->
|
||||
TempBasalPair(aapsLogger, rawContent!!)
|
||||
TempBasalPair(aapsLogger, rawContent)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
if (decoded === RecordDecodeStatus.OK || decoded === RecordDecodeStatus.Ignored) {
|
||||
//Log.i(TAG, "#" + record + " " + decoded.getDescription() + " " + pe);
|
||||
} else {
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "#" + record + " " + decoded!!.description + " " + pe)
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "#" + record + " " + decoded.description + " " + pe)
|
||||
}
|
||||
addToStatistics(pe, decoded, null)
|
||||
record++
|
||||
|
@ -130,7 +130,7 @@ class MedtronicPumpHistoryDecoder @Inject constructor(
|
|||
return outList
|
||||
}
|
||||
|
||||
override fun decodeRecord(record: PumpHistoryEntry): RecordDecodeStatus? {
|
||||
override fun decodeRecord(record: PumpHistoryEntry): RecordDecodeStatus {
|
||||
return try {
|
||||
decodeRecordInternal(record)
|
||||
} catch (ex: Exception) {
|
||||
|
|
|
@ -39,7 +39,7 @@ class MedtronicUIPostprocessor @Inject constructor(
|
|||
when (uiTask.commandType) {
|
||||
MedtronicCommandType.SetBasalProfileSTD -> {
|
||||
val response = uiTask.result as Boolean?
|
||||
if (response!!) {
|
||||
if (response != null && response) {
|
||||
val basalProfile = uiTask.getParameter(0) as BasalProfile
|
||||
aapsLogger.debug("D: basal profile returned after set: $basalProfile")
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class MedtronicHistoryData @Inject constructor(
|
|||
val medtronicPumpStatus: MedtronicPumpStatus,
|
||||
val databaseHelper: DatabaseHelperInterface,
|
||||
val pumpSync: PumpSync,
|
||||
val pumpSyncStorage: PumpSyncStorage
|
||||
val pumpSyncStorage: info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage
|
||||
) {
|
||||
|
||||
val allHistory: MutableList<PumpHistoryEntry> = mutableListOf()
|
||||
|
@ -381,12 +381,12 @@ class MedtronicHistoryData @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun processPrime(primeRecords: List<PumpHistoryEntry?>) {
|
||||
private fun processPrime(primeRecords: List<PumpHistoryEntry>) {
|
||||
val maxAllowedTimeInPast = DateTimeUtil.getATDWithAddedMinutes(GregorianCalendar(), -30)
|
||||
var lastPrimeRecordTime = 0L
|
||||
var lastPrimeRecord: PumpHistoryEntry? = null
|
||||
for (primeRecord in primeRecords) {
|
||||
val fixedAmount = primeRecord!!.getDecodedDataEntry("FixedAmount")
|
||||
val fixedAmount = primeRecord.getDecodedDataEntry("FixedAmount")
|
||||
if (fixedAmount != null && fixedAmount as Float == 0.0f) {
|
||||
// non-fixed primes are used to prime the tubing
|
||||
// fixed primes are used to prime the cannula
|
||||
|
@ -456,7 +456,7 @@ class MedtronicHistoryData @Inject constructor(
|
|||
pumpSync.createOrUpdateTotalDailyDose(
|
||||
DateTimeUtil.toMillisFromATD(tdd.atechDateTime),
|
||||
totalsDTO.insulinBolus,
|
||||
totalsDTO.insulinBasal!!,
|
||||
totalsDTO.insulinBasal,
|
||||
totalsDTO.insulinTotal,
|
||||
tdd.pumpId,
|
||||
medtronicPumpStatus.pumpType,
|
||||
|
@ -559,7 +559,7 @@ class MedtronicHistoryData @Inject constructor(
|
|||
if (bolus.containsDecodedData("Estimate")) {
|
||||
val bolusWizard = bolus.decodedData["Estimate"] as BolusWizardDTO
|
||||
|
||||
pumpSyncStorage.addCarbs(PumpDbEntryCarbs(
|
||||
pumpSyncStorage.addCarbs(info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntryCarbs(
|
||||
tryToGetByLocalTime(bolus.atechDateTime),
|
||||
bolusWizard.carbs.toDouble(),
|
||||
medtronicPumpStatus.pumpType,
|
||||
|
@ -571,9 +571,9 @@ class MedtronicHistoryData @Inject constructor(
|
|||
|
||||
private fun processTBREntries(entryList: MutableList<PumpHistoryEntry>) {
|
||||
Collections.reverse(entryList)
|
||||
val tbr = entryList[0].getDecodedDataEntry("Object") as TempBasalPair?
|
||||
val tbr = entryList[0].getDecodedDataEntry("Object") as TempBasalPair
|
||||
var readOldItem = false
|
||||
if (tbr!!.isCancelTBR) {
|
||||
if (tbr.isCancelTBR) {
|
||||
val oneMoreEntryFromHistory = getOneMoreEntryFromHistory(PumpHistoryEntryType.TempBasalCombined)
|
||||
if (oneMoreEntryFromHistory != null) {
|
||||
entryList.add(0, oneMoreEntryFromHistory)
|
||||
|
@ -679,12 +679,12 @@ class MedtronicHistoryData @Inject constructor(
|
|||
|
||||
if (isTBRActive(tryToGetByLocalTime(tempBasalProcessDTO.atechDateTime), tempBasalProcessDTO.duration)) {
|
||||
if (medtronicPumpStatus.runningTBR == null) {
|
||||
medtronicPumpStatus.runningTBR = PumpDbEntry(0L,
|
||||
medtronicPumpStatus.runningTBR = info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntry(0L,
|
||||
tryToGetByLocalTime(tempBasalProcessDTO.atechDateTime),
|
||||
medtronicPumpStatus.pumpType,
|
||||
medtronicPumpStatus.serialNumber,
|
||||
null,
|
||||
PumpDbEntryTBR(tbrEntry.insulinRate, !tbrEntry.isPercent, tempBasalProcessDTO.duration, PumpSync.TemporaryBasalType.NORMAL),
|
||||
info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntryTBR(tbrEntry.insulinRate, !tbrEntry.isPercent, tempBasalProcessDTO.duration, PumpSync.TemporaryBasalType.NORMAL),
|
||||
tempBasalProcessDTO.pumpId)
|
||||
}
|
||||
}
|
||||
|
@ -693,7 +693,7 @@ class MedtronicHistoryData @Inject constructor(
|
|||
} // collection
|
||||
}
|
||||
|
||||
fun isTBRActive(dbEntry: PumpDbEntry): Boolean {
|
||||
fun isTBRActive(dbEntry: info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntry): Boolean {
|
||||
return isTBRActive(dbEntry.date, dbEntry.tbrData!!.durationInMinutes)
|
||||
}
|
||||
|
||||
|
@ -716,7 +716,7 @@ class MedtronicHistoryData @Inject constructor(
|
|||
/**
|
||||
* Looks at all boluses that have temporaryId and find one that is correct for us (if such entry exists)
|
||||
*/
|
||||
private fun findDbEntry(treatment: PumpHistoryEntry, temporaryEntries: MutableList<PumpDbEntry>): PumpDbEntry? {
|
||||
private fun findDbEntry(treatment: PumpHistoryEntry, temporaryEntries: MutableList<info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntry>): info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntry? {
|
||||
|
||||
if (temporaryEntries.isEmpty()) {
|
||||
return null
|
||||
|
@ -728,7 +728,7 @@ class MedtronicHistoryData @Inject constructor(
|
|||
this.pumpTime?.let { proposedTime += (it.timeDifference * 1000) }
|
||||
|
||||
val proposedTimeDiff: LongArray = longArrayOf(proposedTime - (2 * 60 * 1000), proposedTime + (2L * 60L * 1000L))
|
||||
val tempEntriesList: MutableList<PumpDbEntry> = mutableListOf()
|
||||
val tempEntriesList: MutableList<info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntry> = mutableListOf()
|
||||
|
||||
for (temporaryEntry in temporaryEntries) {
|
||||
if (temporaryEntry.date > proposedTimeDiff[0] && temporaryEntry.date < proposedTimeDiff[1]) {
|
||||
|
@ -750,7 +750,7 @@ class MedtronicHistoryData @Inject constructor(
|
|||
sec = 59
|
||||
}
|
||||
val diff = sec * 1000
|
||||
val outList: MutableList<PumpDbEntry> = mutableListOf()
|
||||
val outList: MutableList<info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntry> = mutableListOf()
|
||||
for (treatment1 in tempEntriesList) {
|
||||
if (treatment1.date > proposedTime - diff && treatment1.date < proposedTime + diff) {
|
||||
outList.add(treatment1)
|
||||
|
|
|
@ -36,18 +36,9 @@ class BolusDTO constructor(atechDateTime: Long,
|
|||
@Expose var duration: Int = 0
|
||||
) : PumpTimeStampedRecord(atechDateTime) {
|
||||
|
||||
// @Expose
|
||||
// var requestedAmount: Double? = null
|
||||
//
|
||||
// @Expose
|
||||
// var deliveredAmount: Double? = null
|
||||
|
||||
@Expose
|
||||
var immediateAmount: Double? = null // when Multiwave this is used
|
||||
|
||||
// @Expose
|
||||
// var duration: Int? = null
|
||||
|
||||
@Expose
|
||||
lateinit var bolusType: PumpBolusType
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class DailyTotalsDTO(var entry: PumpHistoryEntry) {
|
|||
var insulinTotal = 0.0
|
||||
|
||||
@Expose
|
||||
var insulinBasal: Double? = 0.0
|
||||
var insulinBasal: Double = 0.0
|
||||
|
||||
@Expose
|
||||
var insulinBolus = 0.0
|
||||
|
@ -55,7 +55,7 @@ class DailyTotalsDTO(var entry: PumpHistoryEntry) {
|
|||
private var bolusCountFood: Int? = null
|
||||
private var bolusCountCorr: Int? = null
|
||||
private fun setDisplayable() {
|
||||
if (insulinBasal == null) {
|
||||
if (insulinBasal == 0.0) {
|
||||
entry.displayableValue = "Total Insulin: " + StringUtil.getFormatedValueUS(insulinTotal, 2)
|
||||
} else {
|
||||
entry.displayableValue = ("Basal Insulin: " + StringUtil.getFormatedValueUS(insulinBasal, 2)
|
||||
|
|
|
@ -157,8 +157,8 @@ enum class MedtronicCommandType {
|
|||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getSettings(medtronicPumpModel: MedtronicDeviceType?): MedtronicCommandType {
|
||||
return if (isSameDevice(medtronicPumpModel!!, MedtronicDeviceType.Medtronic_512_712))
|
||||
fun getSettings(medtronicPumpModel: MedtronicDeviceType): MedtronicCommandType {
|
||||
return if (isSameDevice(medtronicPumpModel, MedtronicDeviceType.Medtronic_512_712))
|
||||
Settings_512
|
||||
else
|
||||
Settings
|
||||
|
|
|
@ -13,7 +13,7 @@ enum class MedtronicStatusRefreshType(val refreshTime: Int,
|
|||
PumpTime(60, MedtronicCommandType.GetRealTimeClock //
|
||||
);
|
||||
|
||||
fun getCommandType(medtronicDeviceType: MedtronicDeviceType?): MedtronicCommandType? {
|
||||
fun getCommandType(medtronicDeviceType: MedtronicDeviceType): MedtronicCommandType? {
|
||||
return if (this == Configuration) {
|
||||
MedtronicCommandType.getSettings(medtronicDeviceType)
|
||||
} else
|
||||
|
|
|
@ -22,8 +22,8 @@ import javax.inject.Inject
|
|||
|
||||
class MedtronicHistoryActivity : DaggerActivity() {
|
||||
|
||||
@Inject lateinit var medtronicHistoryData: MedtronicHistoryData
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var medtronicHistoryData: MedtronicHistoryData
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
|
||||
lateinit var historyTypeSpinner: Spinner
|
||||
lateinit var statusView: TextView
|
||||
|
@ -33,7 +33,7 @@ class MedtronicHistoryActivity : DaggerActivity() {
|
|||
|
||||
var filteredHistoryList: MutableList<PumpHistoryEntry> = ArrayList()
|
||||
var manualChange = false
|
||||
var typeListFull: List<TypeList>? = null
|
||||
lateinit var typeListFull: List<TypeList>
|
||||
|
||||
//private var _binding: MedtronicHistoryActivityBinding? = null
|
||||
|
||||
|
@ -60,8 +60,8 @@ class MedtronicHistoryActivity : DaggerActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
recyclerViewAdapter.setHistoryListInternal(filteredHistoryList)
|
||||
recyclerViewAdapter.notifyDataSetChanged()
|
||||
recyclerViewAdapter.setHistoryListInternal(filteredHistoryList)
|
||||
recyclerViewAdapter.notifyDataSetChanged()
|
||||
|
||||
//LOG.debug("Items on filtered list: {}", filteredHistoryList.size());
|
||||
}
|
||||
|
@ -74,8 +74,8 @@ class MedtronicHistoryActivity : DaggerActivity() {
|
|||
|
||||
private fun setHistoryTypeSpinner() {
|
||||
manualChange = true
|
||||
for (i in typeListFull!!.indices) {
|
||||
if (typeListFull!![i].entryGroup === selectedGroup) {
|
||||
for (i in typeListFull.indices) {
|
||||
if (typeListFull[i].entryGroup === selectedGroup) {
|
||||
historyTypeSpinner.setSelection(i)
|
||||
break
|
||||
}
|
||||
|
@ -119,15 +119,16 @@ class MedtronicHistoryActivity : DaggerActivity() {
|
|||
})
|
||||
}
|
||||
|
||||
private fun getTypeList(list: List<PumpHistoryEntryGroup>?): List<TypeList> {
|
||||
private fun getTypeList(list: List<PumpHistoryEntryGroup>): List<TypeList> {
|
||||
val typeList = ArrayList<TypeList>()
|
||||
for (pumpHistoryEntryGroup in list!!) {
|
||||
for (pumpHistoryEntryGroup in list) {
|
||||
typeList.add(TypeList(pumpHistoryEntryGroup))
|
||||
}
|
||||
return typeList
|
||||
}
|
||||
|
||||
class TypeList internal constructor(var entryGroup: PumpHistoryEntryGroup) {
|
||||
|
||||
var name: String
|
||||
override fun toString(): String {
|
||||
return name
|
||||
|
@ -140,7 +141,6 @@ class MedtronicHistoryActivity : DaggerActivity() {
|
|||
|
||||
class RecyclerViewAdapter internal constructor(var historyList: List<PumpHistoryEntry>) : RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder>() {
|
||||
|
||||
|
||||
fun setHistoryListInternal(historyList: List<PumpHistoryEntry>) {
|
||||
// this.historyList.clear();
|
||||
// this.historyList.addAll(historyList);
|
||||
|
@ -157,22 +157,17 @@ class MedtronicHistoryActivity : DaggerActivity() {
|
|||
|
||||
override fun onBindViewHolder(holder: HistoryViewHolder, position: Int) {
|
||||
val record = historyList[position]
|
||||
//if (record != null) {
|
||||
holder.timeView.text = record.dateTimeString
|
||||
holder.typeView.text = record.entryType.description
|
||||
holder.valueView.text = record.displayableValue
|
||||
//}
|
||||
holder.timeView.text = record.dateTimeString
|
||||
holder.typeView.text = record.entryType.description
|
||||
holder.valueView.text = record.displayableValue
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return historyList.size
|
||||
}
|
||||
|
||||
override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView)
|
||||
}
|
||||
|
||||
class HistoryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
var timeView: TextView
|
||||
var typeView: TextView
|
||||
var valueView: TextView
|
||||
|
@ -188,6 +183,7 @@ class MedtronicHistoryActivity : DaggerActivity() {
|
|||
}
|
||||
|
||||
companion object {
|
||||
|
||||
var showingType: TypeList? = null
|
||||
var selectedGroup = PumpHistoryEntryGroup.All
|
||||
}
|
||||
|
|
|
@ -27,14 +27,14 @@ class MedtronicPumpStatus @Inject constructor(private val resourceHelper: Resour
|
|||
private val sp: SP,
|
||||
private val rxBus: RxBusWrapper,
|
||||
private val rileyLinkUtil: RileyLinkUtil
|
||||
) : PumpStatus(PumpType.MEDTRONIC_522_722) {
|
||||
) : info.nightscout.androidaps.plugins.pump.common.data.PumpStatus(PumpType.MEDTRONIC_522_722) {
|
||||
|
||||
var errorDescription: String? = null
|
||||
lateinit var serialNumber: String //? = null
|
||||
var pumpFrequency: String? = null
|
||||
var maxBolus: Double? = null
|
||||
var maxBasal: Double? = null
|
||||
var runningTBR: PumpDbEntry? = null
|
||||
var runningTBR: info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntry? = null
|
||||
|
||||
// statuses
|
||||
var pumpDeviceState = PumpDeviceState.NeverContacted
|
||||
|
|
1
pump-common/.gitignore
vendored
Normal file
1
pump-common/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/build
|
24
pump-common/build.gradle
Normal file
24
pump-common/build.gradle
Normal file
|
@ -0,0 +1,24 @@
|
|||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'com.hiya.jacoco-android'
|
||||
|
||||
apply from: "${project.rootDir}/gradle/android_dependencies.gradle"
|
||||
apply from: "${project.rootDir}/gradle/android_module_dependencies.gradle"
|
||||
apply from: "${project.rootDir}/gradle/test_dependencies.gradle"
|
||||
|
||||
android {
|
||||
defaultConfig {
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':core')
|
||||
//implementation project(':database')
|
||||
|
||||
implementation('com.thoughtworks.xstream:xstream:1.4.7') {
|
||||
exclude group: 'xmlpull', module: 'xmlpull'
|
||||
}
|
||||
}
|
0
pump-common/consumer-rules.pro
Normal file
0
pump-common/consumer-rules.pro
Normal file
21
pump-common/proguard-rules.pro
vendored
Normal file
21
pump-common/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
7
pump-common/src/main/AndroidManifest.xml
Normal file
7
pump-common/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<manifest package="info.nightscout.androidaps.plugins.pump.common">
|
||||
|
||||
<application>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -24,9 +24,6 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewB
|
|||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||
import info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntryCarbs
|
||||
import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncEntriesCreator
|
||||
import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter.to0Decimal
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter.to2Decimal
|
||||
|
@ -38,7 +35,6 @@ import io.reactivex.disposables.CompositeDisposable
|
|||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
|
||||
|
||||
/**
|
||||
* Created by andy on 23.04.18.
|
||||
*/
|
||||
|
@ -58,14 +54,14 @@ abstract class PumpPluginAbstract protected constructor(
|
|||
var dateUtil: DateUtil,
|
||||
var aapsSchedulers: AapsSchedulers,
|
||||
var pumpSync: PumpSync,
|
||||
var pumpSyncStorage: PumpSyncStorage
|
||||
) : PumpPluginBase(pluginDescription!!, injector!!, aapsLogger, resourceHelper, commandQueue), Pump, Constraints, PumpSyncEntriesCreator {
|
||||
var pumpSyncStorage: info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage
|
||||
) : PumpPluginBase(pluginDescription!!, injector!!, aapsLogger, resourceHelper, commandQueue), Pump, Constraints, info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncEntriesCreator {
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
|
||||
// Pump capabilities
|
||||
final override var pumpDescription = PumpDescription()
|
||||
//protected set
|
||||
//protected set
|
||||
|
||||
@JvmField protected var serviceConnection: ServiceConnection? = null
|
||||
@JvmField protected var serviceRunning = false
|
||||
|
@ -79,7 +75,6 @@ abstract class PumpPluginAbstract protected constructor(
|
|||
pumpDescription.fillFor(value)
|
||||
}
|
||||
|
||||
|
||||
protected var gson = GsonBuilder().excludeFieldsWithoutExposeAnnotation().create()
|
||||
|
||||
abstract fun initPumpStatusData()
|
||||
|
@ -282,7 +277,7 @@ abstract class PumpPluginAbstract protected constructor(
|
|||
override fun shortStatus(veryShort: Boolean): String {
|
||||
var ret = ""
|
||||
|
||||
if (pumpStatusData.lastConnection==0L) {
|
||||
if (pumpStatusData.lastConnection == 0L) {
|
||||
ret += "LastConn: never\n"
|
||||
} else {
|
||||
val agoMsec = System.currentTimeMillis() - pumpStatusData.lastConnection
|
||||
|
@ -343,7 +338,7 @@ abstract class PumpPluginAbstract protected constructor(
|
|||
detailedBolusInfo.timestamp = System.currentTimeMillis()
|
||||
|
||||
// no bolus required, carb only treatment
|
||||
pumpSyncStorage.addCarbs(PumpDbEntryCarbs(detailedBolusInfo, this))
|
||||
pumpSyncStorage.addCarbs(info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntryCarbs(detailedBolusInfo, this))
|
||||
|
||||
val bolusingEvent = EventOverviewBolusProgress
|
||||
bolusingEvent.t = EventOverviewBolusProgress.Treatment(0.0, detailedBolusInfo.carbs.toInt(), detailedBolusInfo.bolusType === DetailedBolusInfo.BolusType.SMB)
|
||||
|
@ -370,12 +365,11 @@ abstract class PumpPluginAbstract protected constructor(
|
|||
return pumpType
|
||||
}
|
||||
|
||||
|
||||
override fun canHandleDST(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
protected abstract fun deliverBolus(detailedBolusInfo: DetailedBolusInfo?): PumpEnactResult
|
||||
protected abstract fun deliverBolus(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult
|
||||
|
||||
protected abstract fun triggerUIChange()
|
||||
|
||||
|
@ -383,7 +377,6 @@ abstract class PumpPluginAbstract protected constructor(
|
|||
return PumpEnactResult(injector).success(false).enacted(false).comment(resourceId)
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
pumpDescription.fillFor(pumpType)
|
||||
this.pumpType = pumpType
|
|
@ -4,14 +4,13 @@ import info.nightscout.androidaps.data.DetailedBolusInfo
|
|||
import info.nightscout.androidaps.interfaces.PumpSync
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||
|
||||
|
||||
data class PumpDbEntry constructor(var temporaryId: Long,
|
||||
var date: Long,
|
||||
var pumpType: PumpType,
|
||||
var serialNumber: String,
|
||||
var bolusData: PumpDbEntryBolus? = null,
|
||||
var tbrData: PumpDbEntryTBR? = null,
|
||||
var pumpId: Long? = null) {
|
||||
var date: Long,
|
||||
var pumpType: PumpType,
|
||||
var serialNumber: String,
|
||||
var bolusData: PumpDbEntryBolus? = null,
|
||||
var tbrData: PumpDbEntryTBR? = null,
|
||||
var pumpId: Long? = null) {
|
||||
|
||||
constructor(temporaryId: Long,
|
||||
date: Long,
|
||||
|
@ -41,7 +40,6 @@ data class PumpDbEntry constructor(var temporaryId: Long,
|
|||
|
||||
}
|
||||
|
||||
|
||||
data class PumpDbEntryBolus(var insulin: Double,
|
||||
var carbs: Double,
|
||||
var bolusType: DetailedBolusInfo.BolusType)
|
||||
|
@ -51,11 +49,12 @@ data class PumpDbEntryCarbs(var date: Long,
|
|||
var pumpType: PumpType,
|
||||
var serialNumber: String,
|
||||
var pumpId: Long? = null) {
|
||||
|
||||
constructor(detailedBolusInfo: DetailedBolusInfo,
|
||||
creator: PumpSyncEntriesCreator) : this(detailedBolusInfo.timestamp,
|
||||
detailedBolusInfo.carbs,
|
||||
creator.model(),
|
||||
creator.serialNumber())
|
||||
detailedBolusInfo.carbs,
|
||||
creator.model(),
|
||||
creator.serialNumber())
|
||||
}
|
||||
|
||||
data class PumpDbEntryTBR(var rate: Double,
|
|
@ -2,14 +2,12 @@ package info.nightscout.androidaps.plugins.pump.common.sync
|
|||
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.thoughtworks.xstream.XStream
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||
import info.nightscout.androidaps.interfaces.PumpSync
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import java.lang.reflect.Type
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
@ -25,19 +23,17 @@ class PumpSyncStorage @Inject constructor(
|
|||
) {
|
||||
|
||||
val pumpSyncStorageKey: String = "pump_sync_storage_xstream"
|
||||
var pumpSyncStorage: MutableMap<String,MutableList<PumpDbEntry>> = mutableMapOf()
|
||||
var pumpSyncStorage: MutableMap<String, MutableList<PumpDbEntry>> = mutableMapOf()
|
||||
var TBR: String = "TBR"
|
||||
var BOLUS: String = "BOLUS"
|
||||
var storageInitialized: Boolean = false
|
||||
var gson: Gson = GsonBuilder().create()
|
||||
var xstream: XStream = XStream()
|
||||
|
||||
|
||||
init {
|
||||
initStorage()
|
||||
}
|
||||
|
||||
|
||||
fun initStorage() {
|
||||
if (storageInitialized)
|
||||
return
|
||||
|
@ -61,7 +57,6 @@ class PumpSyncStorage @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fun saveStorage() {
|
||||
if (!isStorageEmpty()) {
|
||||
sp.putString(pumpSyncStorageKey, xstream.toXML(pumpSyncStorage))
|
||||
|
@ -69,22 +64,18 @@ class PumpSyncStorage @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fun isStorageEmpty() : Boolean {
|
||||
fun isStorageEmpty(): Boolean {
|
||||
return pumpSyncStorage[BOLUS]!!.isEmpty() && pumpSyncStorage[TBR]!!.isEmpty()
|
||||
}
|
||||
|
||||
|
||||
fun getBoluses() : MutableList<PumpDbEntry> {
|
||||
fun getBoluses(): MutableList<PumpDbEntry> {
|
||||
return pumpSyncStorage[BOLUS]!!;
|
||||
}
|
||||
|
||||
|
||||
fun getTBRs() : MutableList<PumpDbEntry> {
|
||||
fun getTBRs(): MutableList<PumpDbEntry> {
|
||||
return pumpSyncStorage[TBR]!!;
|
||||
}
|
||||
|
||||
|
||||
fun addBolusWithTempId(detailedBolusInfo: DetailedBolusInfo, writeToInternalHistory: Boolean, creator: PumpSyncEntriesCreator): Boolean {
|
||||
val temporaryId = creator.generateTempId(detailedBolusInfo.timestamp)
|
||||
val result = pumpSync.addBolusWithTempId(
|
||||
|
@ -99,12 +90,12 @@ class PumpSyncStorage @Inject constructor(
|
|||
detailedBolusInfo.timestamp, temporaryId, detailedBolusInfo.insulin, detailedBolusInfo.bolusType,
|
||||
creator.serialNumber(), result))
|
||||
|
||||
if (detailedBolusInfo.carbs>0.0) {
|
||||
if (detailedBolusInfo.carbs > 0.0) {
|
||||
addCarbs(PumpDbEntryCarbs(detailedBolusInfo, creator))
|
||||
}
|
||||
|
||||
if (result && writeToInternalHistory) {
|
||||
var innerList: MutableList<PumpDbEntry> = pumpSyncStorage[BOLUS]!!
|
||||
val innerList: MutableList<PumpDbEntry> = pumpSyncStorage[BOLUS]!!
|
||||
|
||||
innerList.add(PumpDbEntry(temporaryId, detailedBolusInfo.timestamp, creator.model(), creator.serialNumber(), detailedBolusInfo))
|
||||
pumpSyncStorage[BOLUS] = innerList
|
||||
|
@ -113,7 +104,6 @@ class PumpSyncStorage @Inject constructor(
|
|||
return result
|
||||
}
|
||||
|
||||
|
||||
fun addCarbs(carbsDto: PumpDbEntryCarbs) {
|
||||
val result = pumpSync.syncCarbsWithTimestamp(
|
||||
carbsDto.date,
|
||||
|
@ -126,9 +116,8 @@ class PumpSyncStorage @Inject constructor(
|
|||
carbsDto.date, carbsDto.carbs, carbsDto.serialNumber, result))
|
||||
}
|
||||
|
||||
|
||||
fun addTemporaryBasalRateWithTempId(temporaryBasal: PumpDbEntryTBR, writeToInternalHistory: Boolean, creator: PumpSyncEntriesCreator) : Boolean {
|
||||
val timenow : Long = System.currentTimeMillis()
|
||||
fun addTemporaryBasalRateWithTempId(temporaryBasal: PumpDbEntryTBR, writeToInternalHistory: Boolean, creator: PumpSyncEntriesCreator): Boolean {
|
||||
val timenow: Long = System.currentTimeMillis()
|
||||
val temporaryId = creator.generateTempId(timenow)
|
||||
|
||||
val response = pumpSync.addTemporaryBasalWithTempId(
|
||||
|
@ -142,7 +131,7 @@ class PumpSyncStorage @Inject constructor(
|
|||
creator.serialNumber())
|
||||
|
||||
if (response && writeToInternalHistory) {
|
||||
var innerList: MutableList<PumpDbEntry> = pumpSyncStorage[TBR]!!
|
||||
val innerList: MutableList<PumpDbEntry> = pumpSyncStorage[TBR]!!
|
||||
|
||||
innerList.add(PumpDbEntry(temporaryId, timenow, creator.model(), creator.serialNumber(), null, temporaryBasal))
|
||||
pumpSyncStorage[BOLUS] = innerList
|
||||
|
@ -152,21 +141,18 @@ class PumpSyncStorage @Inject constructor(
|
|||
return response;
|
||||
}
|
||||
|
||||
|
||||
fun removeBolusWithTemporaryId(temporaryId: Long) {
|
||||
val bolusList = removeTemporaryId(temporaryId, pumpSyncStorage[BOLUS]!!)
|
||||
pumpSyncStorage[BOLUS] = bolusList
|
||||
saveStorage()
|
||||
}
|
||||
|
||||
|
||||
fun removeTemporaryBasalWithTemporaryId(temporaryId: Long) {
|
||||
val tbrList = removeTemporaryId(temporaryId, pumpSyncStorage[TBR]!!)
|
||||
pumpSyncStorage[TBR] = tbrList
|
||||
saveStorage()
|
||||
}
|
||||
|
||||
|
||||
private fun removeTemporaryId(temporaryId: Long, list: MutableList<PumpDbEntry>): MutableList<PumpDbEntry> {
|
||||
var dbEntry: PumpDbEntry? = null
|
||||
|
||||
|
@ -176,7 +162,7 @@ class PumpSyncStorage @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
if (dbEntry!=null) {
|
||||
if (dbEntry != null) {
|
||||
list.remove(dbEntry)
|
||||
}
|
||||
|
4
pump-common/src/main/res/values/strings.xml
Normal file
4
pump-common/src/main/res/values/strings.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
</resources>
|
|
@ -8,8 +8,10 @@ include ':combo'
|
|||
include ':dana'
|
||||
include ':danar'
|
||||
include ':danars'
|
||||
include ':pump-common'
|
||||
include ':rileylink'
|
||||
include ':medtronic'
|
||||
include ':omnipod-common'
|
||||
include ':omnipod-eros'
|
||||
include ':omnipod-dash'
|
||||
include ':omnipod-dash'
|
||||
|
||||
|
|
Loading…
Reference in a new issue