Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.annotation.VisibleForTesting
import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.logging.LTag
import app.aaps.core.interfaces.rx.bus.RxBus
import app.aaps.core.interfaces.notifications.NotificationManager
import app.aaps.core.interfaces.ui.UiInteraction
import app.aaps.core.keys.interfaces.Preferences
import app.aaps.pump.common.defs.PumpDriverState
Expand Down Expand Up @@ -70,7 +71,8 @@ class HistoryRetriever @Inject constructor(
val rxBus: RxBus,
var context: Context,
val dbDataHandler: DbDataHandler,
val uiInteraction: UiInteraction
val uiInteraction: UiInteraction,
val notificationManager: NotificationManager

) {

Expand Down Expand Up @@ -115,7 +117,8 @@ class HistoryRetriever @Inject constructor(
context = context,
pumpUtil = pumpUtil,
aapsLogger= aapsLogger,
uiInteraction = uiInteraction)
uiInteraction = uiInteraction,
notificationManager = notificationManager)

communication.historyRetriever = this
this.communication.tandemCommunicationManager = tandemPumpConnector.getCommunicationManager()
Expand Down Expand Up @@ -186,7 +189,8 @@ class HistoryRetriever @Inject constructor(
context = context,
pumpUtil = pumpUtil,
aapsLogger= aapsLogger,
uiInteraction = uiInteraction)
uiInteraction = uiInteraction,
notificationManager = notificationManager)

communication.historyRetriever = this
this.communication.tandemCommunicationManager = tandemPumpConnector.getCommunicationManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ class TandemPairingManager constructor(
input.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_NORMAL

MaterialAlertDialogBuilder(context, app.aaps.core.ui.R.style.DialogTheme)
.setCustomTitle(AlertDialogHelper.buildCustomTitle(context, resourceHelper.gs(R.string.tandem_ble_config_pairing_title)))
.setTitle(resourceHelper.gs(R.string.tandem_ble_config_pairing_title))
.setMessage(resourceHelper.gs(R.string.tandem_ble_config_pairing_message, btName, btAddress))
.setView(input)
.setPositiveButton(context.getString(app.aaps.core.ui.R.string.ok)) { dialog: DialogInterface, _: Int ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package app.aaps.pump.tandem.common.comm.ui
import android.content.Context
import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.logging.LTag
import app.aaps.core.interfaces.notifications.NotificationId
import app.aaps.core.interfaces.notifications.NotificationLevel
import app.aaps.core.interfaces.notifications.NotificationManager
import app.aaps.core.interfaces.ui.UiInteraction
import app.aaps.pump.common.defs.PumpRunningState
import app.aaps.pump.tandem.common.comm.TandemCommunicationManager
Expand Down Expand Up @@ -49,7 +52,8 @@ class TandemUICommunication @Inject constructor (
var context: Context,
var aapsLogger: AAPSLogger,
var pumpUtil: TandemPumpUtil,
var uiInteraction: UiInteraction
var uiInteraction: UiInteraction,
var notificationManager: NotificationManager
): CommunicationListener {

var TAG = LTag.PUMPCOMM
Expand Down Expand Up @@ -282,10 +286,10 @@ class TandemUICommunication @Inject constructor (
aapsLogger.error(TAG,"$req was not successful. The pump returned an error fulfilling the request." )


uiInteraction.addNotification(
Notification.TANDEM_PUMP_MESSAGE_ERROR,
text = "$req was not successful. The pump returned an error fulfilling the request." ,
level = Notification.URGENT
notificationManager.post(
id = NotificationId.TANDEM_PUMP_MESSAGE_ERROR,
text = "$req was not successful. The pump returned an error fulfilling the request.",
level = NotificationLevel.URGENT
)

// val show = AlertDialog.Builder(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ class TandemPumpConnector @Inject constructor(var tandemPumpStatus: TandemPumpSt
IDPSegmentStatus.CORRECTION_FACTOR)

// TODO(jwoglom): use IDPManager which handles some of these complexities
override fun sendBasalProfile(profile: PumpProfile): DataCommandResponse<Boolean?> {
override fun sendBasalProfile(profile: Profile): DataCommandResponse<Boolean?> {

aapsLogger.info(LTag.PUMPCOMM, "sendBasalProfile")

Expand Down Expand Up @@ -989,7 +989,7 @@ class TandemPumpConnector @Inject constructor(var tandemPumpStatus: TandemPumpSt
idpSegments[0].profileBasalRate,
idpSegments[0].profileTargetBG,
idpSegments[0].profileISF,
profile.dia.toInt() * 60,
(profile.iCfg?.dia?.toInt() ?: 0) * 60,
0) // for AAPS profile we are setting this to 0

val responseMessage = getCommunicationManager()?.sendCommand(createIDPRequest) as CreateIDPResponse?
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package app.aaps.pump.tandem.di

import app.aaps.core.interfaces.di.PumpDriver
import app.aaps.core.interfaces.plugin.PluginBase
// import app.aaps.core.interfaces.ui.compose.ComposeUiFactory
// import app.aaps.implementation.ui.ComposeUiModule
import app.aaps.pump.tandem.common.comm.TandemDataConverter
import app.aaps.pump.tandem.common.comm.history.HistoryRetriever
import app.aaps.pump.tandem.common.comm.maint.TandemConnectionFixer
Expand All @@ -16,6 +14,8 @@ import app.aaps.pump.tandem.common.driver.connector.TandemPumpConnectionManager
import app.aaps.pump.tandem.common.driver.connector.TandemPumpConnector
import app.aaps.pump.tandem.common.service.TandemService
import app.aaps.pump.tandem.common.util.TandemPumpUtil
import app.aaps.pump.tandem.mobi.ui.ActionsActivity
import app.aaps.pump.tandem.mobi.ui.DataActivity
import app.aaps.pump.tandem.mobi.ui.TandemMobiPumpFragment
import app.aaps.pump.tandem.mobi.ui.wizard.TandemMobiConnectionWizardActivity
import app.aaps.pump.tandem.mobi.driver.TandemMobiPumpDriverConfiguration
Expand All @@ -29,8 +29,7 @@ import dagger.hilt.components.SingletonComponent
import dagger.multibindings.IntKey
import dagger.multibindings.IntoMap

@Module(includes = [TandemDatabaseModule::class, TandemModuleImpl::class],
subcomponents = [TandemComposeUiComponent::class])
@Module(includes = [TandemDatabaseModule::class, TandemModuleImpl::class])
@InstallIn(SingletonComponent::class)
@Suppress("unused")
abstract class TandemModule {
Expand Down Expand Up @@ -75,8 +74,8 @@ abstract class TandemModule {


// Compose UI Activities
//@ContributesAndroidInjector abstract fun contributesActionsActivity(): ActionsActivity
// @ContributesAndroidInjector abstract fun contributesTandemUICommunication(): TandemUICommunication
@ContributesAndroidInjector abstract fun contributesActionsActivity(): ActionsActivity
@ContributesAndroidInjector abstract fun contributesDataActivity(): DataActivity

// @Provides
// @Singleton
Expand All @@ -87,17 +86,13 @@ abstract class TandemModule {
// @ContributesAndroidInjector abstract fun contributesTandemPumpDriverConfiguration(): TandemPumpDriverConfiguration


// @Binds
// @IntoMap
// @ComposeUiModule("tandem")
// abstract fun bindTandemComposeUiFactory(factory: TandemComposeUiComponent.FactoryCompose): ComposeUiFactory


// Pump plugin registration — @IntKey range 1000–1200, see PluginsListModule for overview
@Binds
@PumpDriver
@IntoMap
@IntKey(1090)
@IntKey(1140)
abstract fun bindTandemMobiPumpPlugin(plugin: TandemMobiPumpPlugin): PluginBase


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import app.aaps.core.interfaces.rx.events.EventRefreshOverview
import app.aaps.core.interfaces.utils.DateUtil
import app.aaps.core.interfaces.utils.DecimalFormatter
import app.aaps.core.interfaces.utils.fabric.FabricPrivacy
import kotlinx.coroutines.runBlocking
import app.aaps.core.keys.interfaces.Preferences
import app.aaps.core.validators.preferences.AdaptiveIntPreference
import app.aaps.core.validators.preferences.AdaptiveListPreference
Expand Down Expand Up @@ -883,12 +884,14 @@ class TandemMobiPumpPlugin @Inject constructor(
}

if (tbrId!=null) {
pumpSync.syncStopTemporaryBasalWithPumpId(
timestamp = System.currentTimeMillis(),
pumpSerial = serialNumber(),
pumpType = PumpType.TANDEM_MOBI_BT,
endPumpId = getPrefixedIdForDb(pumpEventId = tbrId, isBolus = false)
)
runBlocking {
pumpSync.syncStopTemporaryBasalWithPumpId(
timestamp = System.currentTimeMillis(),
pumpSerial = serialNumber(),
pumpType = PumpType.TANDEM_MOBI_BT,
endPumpId = getPrefixedIdForDb(pumpEventId = tbrId, isBolus = false)
)
}

pumpStatus.currentTempBasalInternal = null
preferences.put(TandemLongNonPreferenceKey.LastTbrId, 0L)
Expand Down Expand Up @@ -1263,24 +1266,28 @@ class TandemMobiPumpPlugin @Inject constructor(
TandemLongNonPreferenceKey.StandardBoluses)

if (detailedBolusInfo.carbs > 0.0) {
pumpSync.syncCarbsWithTimestamp(
timestamp = now,
amount = detailedBolusInfo.carbs,
pumpId = getPrefixedIdForDb(pumpEventId = bolusData.bolusId!!, isBolus = true),
pumpType = pumpType,
pumpSerial = serialNumber()
)
runBlocking {
pumpSync.syncCarbsWithTimestamp(
timestamp = now,
amount = detailedBolusInfo.carbs,
pumpId = getPrefixedIdForDb(pumpEventId = bolusData.bolusId!!, isBolus = true),
pumpType = pumpType,
pumpSerial = serialNumber()
)
}
}

if (detailedBolusInfo.insulin > 0.0) {
pumpSync.syncBolusWithPumpId(
timestamp = now,
amount = PumpInsulin(detailedBolusInfo.insulin),
pumpId = getPrefixedIdForDb(pumpEventId = bolusData.bolusId!!, isBolus = true),
pumpType = pumpType,
pumpSerial = serialNumber(),
type = detailedBolusInfo.bolusType
)
runBlocking {
pumpSync.syncBolusWithPumpId(
timestamp = now,
amount = PumpInsulin(detailedBolusInfo.insulin),
pumpId = getPrefixedIdForDb(pumpEventId = bolusData.bolusId!!, isBolus = true),
pumpType = pumpType,
pumpSerial = serialNumber(),
type = detailedBolusInfo.bolusType
)
}
}

//readPumpHistoryAfterAction(bolusInfo = detailedBolusInfo)
Expand Down Expand Up @@ -1382,16 +1389,18 @@ class TandemMobiPumpPlugin @Inject constructor(
preferences.put(key = TandemLongNonPreferenceKey.LastTbrId,
value = controlCommandResponse.id!!)

pumpSync.syncTemporaryBasalWithPumpId(
timestamp = controlCommandResponse.start!!,
isAbsolute = false,
pumpSerial = serialNumber(),
pumpType = PumpType.TANDEM_MOBI_BT,
type = tbrType,
duration = (controlCommandResponse.durationMinutes * 60 * 1000).toLong(),
rate = PumpRate(percent.toDouble()),
pumpId = getPrefixedIdForDb(pumpEventId = controlCommandResponse.id!!, isBolus =false)
)
runBlocking {
pumpSync.syncTemporaryBasalWithPumpId(
timestamp = controlCommandResponse.start!!,
isAbsolute = false,
pumpSerial = serialNumber(),
pumpType = PumpType.TANDEM_MOBI_BT,
type = tbrType,
duration = (controlCommandResponse.durationMinutes * 60 * 1000).toLong(),
rate = PumpRate(percent.toDouble()),
pumpId = getPrefixedIdForDb(pumpEventId = controlCommandResponse.id!!, isBolus = false)
)
}

incrementStatistics(statsKey = TandemLongNonPreferenceKey.TbrsSet)

Expand Down Expand Up @@ -1514,12 +1523,14 @@ class TandemMobiPumpPlugin @Inject constructor(

val controlCommandResponse = commandResponseCancel.value as ControlCommandResponse

pumpSync.syncStopTemporaryBasalWithPumpId(
timestamp = System.currentTimeMillis(),
pumpSerial = serialNumber(),
pumpType = PumpType.TANDEM_MOBI_BT,
endPumpId = getPrefixedIdForDb(pumpEventId = controlCommandResponse.id.toLong(), isBolus = false)
)
runBlocking {
pumpSync.syncStopTemporaryBasalWithPumpId(
timestamp = System.currentTimeMillis(),
pumpSerial = serialNumber(),
pumpType = PumpType.TANDEM_MOBI_BT,
endPumpId = getPrefixedIdForDb(pumpEventId = controlCommandResponse.id.toLong(), isBolus = false)
)
}

pumpStatus.currentTempBasalInternal = null
preferences.put(TandemLongNonPreferenceKey.LastTbrId, 0L)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.logging.LTag
import app.aaps.core.interfaces.notifications.NotificationManager
import app.aaps.core.interfaces.resources.ResourceHelper
import app.aaps.core.interfaces.ui.compose.ComposeUiProvider
import app.aaps.core.interfaces.ui.compose.DaggerComponentActivity
import app.aaps.core.keys.interfaces.Preferences
import app.aaps.pump.common.test.ResourceHelperTest
import app.aaps.pump.tandem.common.comm.ui.TandemUICommunication
Expand All @@ -43,7 +42,6 @@ import app.aaps.pump.tandem.common.driver.connector.TandemPumpConnector
import app.aaps.pump.tandem.common.driver.tandemDataStore
import app.aaps.pump.tandem.common.keys.TandemLongNonPreferenceKey
import app.aaps.pump.tandem.common.util.TandemPumpUtil
import app.aaps.pump.tandem.di.TandemComposeUiComponent
import app.aaps.pump.tandem.mobi.ui.actions.Actions
import app.aaps.pump.tandem.mobi.ui.actions.PumpInfo
import app.aaps.pump.tandem.mobi.ui.actions.cartridge.CartridgeActions
Expand All @@ -54,10 +52,11 @@ import app.aaps.pump.tandem.mobi.ui.actions.cartridge.SiteReminder
import app.aaps.pump.tandem.mobi.ui.theme.TMobiScreensTheme
import app.aaps.shared.tests.AAPSLoggerTest
import com.jwoglom.pumpx2.pump.messages.Message
import dagger.android.support.DaggerAppCompatActivity
import javax.inject.Inject


class ActionsActivity : DaggerComponentActivity() {
class ActionsActivity : DaggerAppCompatActivity() {

@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var tandemPumpStatus: TandemPumpStatus
Expand All @@ -67,6 +66,7 @@ class ActionsActivity : DaggerComponentActivity() {
@Inject lateinit var tandemPumpConnector: TandemPumpConnector
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var uiInteraction: app.aaps.core.interfaces.ui.UiInteraction
@Inject lateinit var notificationManager: NotificationManager


var sectionState: ActionsLandingSection = ActionsLandingSection.ACTIONS
Expand All @@ -82,17 +82,13 @@ class ActionsActivity : DaggerComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val composeUiComponent = (application as ComposeUiProvider)
.getComposeUiModule("tandem") as TandemComposeUiComponent

composeUiComponent.inject(this)

tandemUICommunication = TandemUICommunication(dataStore = tandemDataStore,
pumpStatus = tandemPumpStatus,
context = context,
pumpUtil = tandemPumpUtil,
aapsLogger= aapsLogger,
uiInteraction = uiInteraction)
uiInteraction = uiInteraction,
notificationManager = notificationManager)

if (intent != null && intent.extras != null && intent.getStringExtra("section") != null) {
sectionState = ActionsLandingSection.entries.find {
Expand Down
Loading