- created 2 modules: rileylink and medtronic

- refactored some classes
This commit is contained in:
Andy Rozman 2020-07-12 20:15:11 +01:00
parent cae6abfbbc
commit ea80eb3c9b
228 changed files with 1165 additions and 638 deletions

View file

@ -239,6 +239,8 @@ dependencies {
implementation project(':dana')
implementation project(':danars')
implementation project(':danar')
implementation project(':rileylink')
implementation project(':medtronic')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-wearable:17.0.0'

View file

@ -256,16 +256,7 @@
android:name=".plugins.pump.medtronic.service.RileyLinkMedtronicService"
android:enabled="true"
android:exported="true" />
<activity android:name=".plugins.pump.common.dialog.RileyLinkBLEScanActivity">
<intent-filter>
<action android:name="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEScanActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity"
android:label="@string/title_activity_rileylink_settings"
android:theme="@style/Theme.AppCompat.NoTitle" />
<activity android:name=".plugins.pump.medtronic.dialog.MedtronicHistoryActivity" />
<uses-library android:name="org.apache.http.legacy" android:required="false"/>

View file

@ -76,7 +76,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
@Inject lateinit var insulinOrefFreePeakPlugin: InsulinOrefFreePeakPlugin
@Inject lateinit var loopPlugin: LoopPlugin
@Inject lateinit var localInsightPlugin: LocalInsightPlugin
@Inject lateinit var medtronicPumpPlugin: MedtronicPumpPlugin
@Inject lateinit var medtronicPumpPlugin: info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
@Inject lateinit var nsClientPlugin: NSClientPlugin
@Inject lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin
@Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin

View file

@ -69,4 +69,28 @@ public class DatabaseHelperProvider implements DatabaseHelperInterface {
@Override public long roundDateToSec(long date) {
return MainApp.getDbHelper().roundDateToSec(date);
}
@Override public void createOrUpdateTDD(@NotNull TDD record) {
MainApp.getDbHelper().createOrUpdateTDD(record);
}
@Override public void createOrUpdate(@NotNull TemporaryBasal tempBasal) {
MainApp.getDbHelper().createOrUpdate(tempBasal);
}
@NotNull @Override public TemporaryBasal findTempBasalByPumpId(long id) {
return MainApp.getDbHelper().findTempBasalByPumpId(id);
}
@NotNull @Override public List<TemporaryBasal> getTemporaryBasalsDataFromTime(long mills, boolean ascending) {
return MainApp.getDbHelper().getTemporaryBasalsDataFromTime(mills, ascending);
}
@NotNull @Override public CareportalEvent getCareportalEventFromTimestamp(long timestamp) {
return MainApp.getDbHelper().getCareportalEventFromTimestamp(timestamp);
}
@NotNull @Override public List<TDD> getTDDsForLastXDays(int days) {
return MainApp.getDbHelper().getTDDsForLastXDays(days);
}
}

View file

@ -10,7 +10,6 @@ import info.nightscout.androidaps.plugins.general.maintenance.activities.PrefImp
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity
import info.nightscout.androidaps.plugins.general.smsCommunicator.activities.SmsCommunicatorOtpActivity
import info.nightscout.androidaps.plugins.pump.common.dialog.RileyLinkBLEScanActivity
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightAlertActivity
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingActivity
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingInformationActivity
@ -27,11 +26,11 @@ abstract class ActivitiesModule {
@ContributesAndroidInjector abstract fun contributesInsightPairingInformationActivity(): InsightPairingInformationActivity
@ContributesAndroidInjector abstract fun contributesLogSettingActivity(): LogSettingActivity
@ContributesAndroidInjector abstract fun contributeMainActivity(): MainActivity
@ContributesAndroidInjector abstract fun contributesMedtronicHistoryActivity(): MedtronicHistoryActivity
@ContributesAndroidInjector abstract fun contributesMedtronicHistoryActivity(): info.nightscout.androidaps.plugins.pump.medtronic.dialog.MedtronicHistoryActivity
@ContributesAndroidInjector abstract fun contributesPreferencesActivity(): PreferencesActivity
@ContributesAndroidInjector abstract fun contributesQuickWizardListActivity(): QuickWizardListActivity
@ContributesAndroidInjector abstract fun contributesRequestDexcomPermissionActivity(): RequestDexcomPermissionActivity
@ContributesAndroidInjector abstract fun contributesRileyLinkStatusActivity(): RileyLinkStatusActivity
@ContributesAndroidInjector abstract fun contributesRileyLinkStatusActivity(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
@ContributesAndroidInjector abstract fun contributesRileyLinkBLEScanActivity(): RileyLinkBLEScanActivity
@ContributesAndroidInjector abstract fun contributesSetupWizardActivity(): SetupWizardActivity
@ContributesAndroidInjector abstract fun contributesSingleFragmentActivity(): SingleFragmentActivity

View file

@ -10,7 +10,6 @@ import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBFragment
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesFragment
import info.nightscout.androidaps.plugins.constraints.objectives.activities.ObjectivesExamDialog
import info.nightscout.androidaps.dialogs.NtpProgressDialog
import info.nightscout.androidaps.plugins.general.actions.ActionsFragment
import info.nightscout.androidaps.plugins.general.automation.AutomationFragment
import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseActionDialog
@ -30,9 +29,6 @@ import info.nightscout.androidaps.plugins.insulin.InsulinFragment
import info.nightscout.androidaps.plugins.profile.local.LocalProfileFragment
import info.nightscout.androidaps.plugins.profile.ns.NSProfileFragment
import info.nightscout.androidaps.plugins.pump.combo.ComboFragment
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusGeneralFragment
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusHistoryFragment
import info.nightscout.androidaps.danars.dialogs.PairingProgressDialog
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightFragment
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.RileyLinkStatusDeviceMedtronic
@ -67,7 +63,7 @@ abstract class FragmentsModule {
@ContributesAndroidInjector abstract fun contributesLocalInsightFragment(): LocalInsightFragment
@ContributesAndroidInjector abstract fun contributesLoopFragment(): LoopFragment
@ContributesAndroidInjector abstract fun contributesMaintenanceFragment(): MaintenanceFragment
@ContributesAndroidInjector abstract fun contributesMedtronicFragment(): MedtronicFragment
@ContributesAndroidInjector abstract fun contributesMedtronicFragment(): info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment
@ContributesAndroidInjector abstract fun contributesOmnipodFragment(): OmnipodFragment
@ContributesAndroidInjector abstract fun contributesNSProfileFragment(): NSProfileFragment
@ContributesAndroidInjector abstract fun contributesNSClientFragment(): NSClientFragment
@ -110,7 +106,7 @@ abstract class FragmentsModule {
@ContributesAndroidInjector abstract fun contributesPasswordCheck(): PasswordCheck
@ContributesAndroidInjector abstract fun contributesRileyLinkStatusGeneral(): RileyLinkStatusGeneralFragment
@ContributesAndroidInjector abstract fun contributesRileyLinkStatusHistoryFragment(): RileyLinkStatusHistoryFragment
@ContributesAndroidInjector abstract fun contributesRileyLinkStatusDeviceMedtronic(): RileyLinkStatusDeviceMedtronic
@ContributesAndroidInjector abstract fun contributesRileyLinkStatusGeneral(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusGeneralFragment
@ContributesAndroidInjector abstract fun contributesRileyLinkStatusHistoryFragment(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusHistoryFragment
@ContributesAndroidInjector abstract fun contributesRileyLinkStatusDeviceMedtronic(): info.nightscout.androidaps.plugins.pump.medtronic.dialog.RileyLinkStatusDeviceMedtronic
}

View file

@ -2,39 +2,25 @@ package info.nightscout.androidaps.dependencyInjection
import dagger.Module
import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.plugins.general.automation.AutomationEvent
import info.nightscout.androidaps.plugins.general.automation.actions.*
import info.nightscout.androidaps.plugins.general.automation.elements.*
import info.nightscout.androidaps.plugins.general.automation.triggers.*
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkBLE
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SendAndListen
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SetPreamble
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioPacket
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioResponse
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.*
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask
import info.nightscout.androidaps.queue.CommandQueue
import info.nightscout.androidaps.queue.commands.*
@Module
@Suppress("unused")
abstract class MedtronicModule {
@ContributesAndroidInjector abstract fun rileyLinkCommunicationManagerProvider(): RileyLinkCommunicationManager
@ContributesAndroidInjector abstract fun medtronicCommunicationManagerProvider(): MedtronicCommunicationManager
@ContributesAndroidInjector abstract fun medtronicUITaskProvider(): MedtronicUITask
@ContributesAndroidInjector abstract fun serviceTaskProvider(): ServiceTask
@ContributesAndroidInjector abstract fun pumpTaskProvider(): PumpTask
@ContributesAndroidInjector abstract fun discoverGattServicesTaskProvider(): DiscoverGattServicesTask
@ContributesAndroidInjector abstract fun initializePumpManagerTaskProvider(): InitializePumpManagerTask
@ContributesAndroidInjector abstract fun resetRileyLinkConfigurationTaskProvider(): ResetRileyLinkConfigurationTask
@ContributesAndroidInjector abstract fun wakeAndTuneTaskProvider(): WakeAndTuneTask
@ContributesAndroidInjector abstract fun radioResponseProvider(): RadioResponse
@ContributesAndroidInjector abstract fun rileyLinkBLEProvider(): RileyLinkBLE
@ContributesAndroidInjector abstract fun rfSpyProvider(): RFSpy
@ContributesAndroidInjector abstract fun sendAndListenProvider(): SendAndListen
@ContributesAndroidInjector abstract fun setPreambleProvider(): SetPreamble
@ContributesAndroidInjector abstract fun radioPacketProvider(): RadioPacket
@ContributesAndroidInjector abstract fun rileyLinkCommunicationManagerProvider(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager
@ContributesAndroidInjector abstract fun medtronicCommunicationManagerProvider(): info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager
@ContributesAndroidInjector abstract fun medtronicUITaskProvider(): info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask
@ContributesAndroidInjector abstract fun serviceTaskProvider(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTask
@ContributesAndroidInjector abstract fun pumpTaskProvider(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.PumpTask
@ContributesAndroidInjector abstract fun discoverGattServicesTaskProvider(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.DiscoverGattServicesTask
@ContributesAndroidInjector abstract fun initializePumpManagerTaskProvider(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.InitializePumpManagerTask
@ContributesAndroidInjector abstract fun resetRileyLinkConfigurationTaskProvider(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ResetRileyLinkConfigurationTask
@ContributesAndroidInjector abstract fun wakeAndTuneTaskProvider(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.WakeAndTuneTask
@ContributesAndroidInjector abstract fun radioResponseProvider(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioResponse
@ContributesAndroidInjector abstract fun rileyLinkBLEProvider(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkBLE
@ContributesAndroidInjector abstract fun rfSpyProvider(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy
@ContributesAndroidInjector abstract fun sendAndListenProvider(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SendAndListen
@ContributesAndroidInjector abstract fun setPreambleProvider(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SetPreamble
@ContributesAndroidInjector abstract fun radioPacketProvider(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioPacket
}

View file

@ -145,7 +145,7 @@ abstract class PluginsModule {
@PumpDriver
@IntoMap
@IntKey(150)
abstract fun bindMedtronicPumpPlugin(plugin: MedtronicPumpPlugin): PluginBase
abstract fun bindMedtronicPumpPlugin(plugin: info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin): PluginBase
@Binds
@NotNSClient

View file

@ -16,9 +16,9 @@ abstract class ReceiversModule {
@ContributesAndroidInjector abstract fun contributesChargingStateReceiver(): ChargingStateReceiver
@ContributesAndroidInjector abstract fun contributesDataReceiver(): DataReceiver
@ContributesAndroidInjector abstract fun contributesKeepAliveReceiver(): KeepAliveReceiver
@ContributesAndroidInjector abstract fun contributesRileyLinkBluetoothStateReceiver(): RileyLinkBluetoothStateReceiver
@ContributesAndroidInjector abstract fun contributesRileyLinkBluetoothStateReceiver(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkBluetoothStateReceiver
@ContributesAndroidInjector abstract fun contributesSmsReceiver(): SmsReceiver
@ContributesAndroidInjector abstract fun contributesTimeDateOrTZChangeReceiver(): TimeDateOrTZChangeReceiver
@ContributesAndroidInjector abstract fun contributesCarbSuggestionReceiver(): CarbSuggestionReceiver
@ContributesAndroidInjector abstract fun contributesRileyLinkBroadcastReceiver(): RileyLinkBroadcastReceiver
@ContributesAndroidInjector abstract fun contributesRileyLinkBroadcastReceiver(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkBroadcastReceiver
}

View file

@ -6,7 +6,6 @@ import info.nightscout.androidaps.plugins.general.nsclient.services.NSClientServ
import info.nightscout.androidaps.plugins.general.overview.notifications.DismissNotificationService
import info.nightscout.androidaps.plugins.general.persistentNotification.DummyService
import info.nightscout.androidaps.plugins.general.wear.wearintegration.WatchUpdaterService
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService
import info.nightscout.androidaps.plugins.pump.insight.InsightAlertService
import info.nightscout.androidaps.plugins.pump.insight.connection_service.InsightConnectionService
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService
@ -28,7 +27,7 @@ abstract class ServicesModule {
@ContributesAndroidInjector abstract fun contributesWatchUpdaterService(): WatchUpdaterService
@ContributesAndroidInjector abstract fun contributesInsightAlertService(): InsightAlertService
@ContributesAndroidInjector abstract fun contributesInsightConnectionService(): InsightConnectionService
@ContributesAndroidInjector abstract fun contributesRileyLinkService(): RileyLinkService
@ContributesAndroidInjector abstract fun contributesRileyLinkMedtronicService(): RileyLinkMedtronicService
@ContributesAndroidInjector abstract fun contributesRileyLinkService(): info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService
@ContributesAndroidInjector abstract fun contributesRileyLinkMedtronicService(): info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService
@ContributesAndroidInjector abstract fun contributesRileyLinkOmnipodService(): RileyLinkOmnipodService
}

View file

@ -8,7 +8,6 @@ import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject

View file

@ -20,7 +20,6 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo;

View file

@ -1,30 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.defs;
import info.nightscout.androidaps.R;
/**
* Created by andy on 6/11/18.
*/
public enum PumpDeviceState {
NeverContacted(R.string.medtronic_pump_status_never_contacted), //
Sleeping(R.string.medtronic_pump_status_sleeping), //
WakingUp(R.string.medtronic_pump_status_waking_up), //
Active(R.string.medtronic_pump_status_active), //
ErrorWhenCommunicating(R.string.medtronic_pump_status_error_comm), //
TimeoutWhenCommunicating(R.string.medtronic_pump_status_timeout_comm), //
// ProblemContacting(R.string.medtronic_pump_status_problem_contacting), //
PumpUnreachable(R.string.medtronic_pump_status_pump_unreachable), //
InvalidConfiguration(R.string.medtronic_pump_status_invalid_config);
Integer resourceId;
PumpDeviceState(int resourceId) {
this.resourceId = resourceId;
}
public Integer getResourceId() {
return resourceId;
}
}

View file

@ -1,30 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.events
import info.nightscout.androidaps.events.Event
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState
class EventMedtronicDeviceStatusChange : Event {
private var rileyLinkServiceState: RileyLinkServiceState? = null
private var rileyLinkError: RileyLinkError? = null
private var pumpDeviceState: PumpDeviceState? = null
private var errorDescription: String? = null
constructor(rileyLinkServiceState: RileyLinkServiceState?, rileyLinkError: RileyLinkError?) {
this.rileyLinkServiceState = rileyLinkServiceState
this.rileyLinkError = rileyLinkError
}
constructor(pumpDeviceState: PumpDeviceState?) {
this.pumpDeviceState = pumpDeviceState
}
constructor(pumpDeviceState: PumpDeviceState?, errorDescription: String?) {
this.pumpDeviceState = pumpDeviceState
this.errorDescription = errorDescription
}
}

View file

@ -85,7 +85,7 @@ class OmnipodFragment : DaggerFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
omnipod_rl_status.text = resourceHelper.gs(RileyLinkServiceState.NotStarted.getResourceId(RileyLinkTargetDevice.Omnipod))
omnipod_rl_status.text = resourceHelper.gs(info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState.NotStarted.getResourceId(info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice.Omnipod))
omnipod_pod_status.setTextColor(Color.WHITE)
omnipod_pod_status.text = "{fa-bed}"
@ -114,7 +114,7 @@ class OmnipodFragment : DaggerFragment() {
omnipod_stats.setOnClickListener {
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
startActivity(Intent(context, RileyLinkStatusActivity::class.java))
startActivity(Intent(context, info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity::class.java))
} else {
displayNotConfiguredDialog()
}
@ -211,16 +211,16 @@ class OmnipodFragment : DaggerFragment() {
aapsLogger.info(LTag.PUMP, "setDeviceStatus: [pumpStatus={}]", omnipodPumpStatus)
val resourceId = omnipodPumpStatus.rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.Omnipod)
val resourceId = omnipodPumpStatus.rileyLinkServiceState.getResourceId(info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice.Omnipod)
val rileyLinkError = omnipodPumpPlugin.rileyLinkService?.error
omnipod_rl_status.text =
when {
omnipodPumpStatus.rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
omnipodPumpStatus.rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
omnipodPumpStatus.rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
omnipodPumpStatus.rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump))
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
omnipodPumpStatus.rileyLinkServiceState == info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
omnipodPumpStatus.rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
omnipodPumpStatus.rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
omnipodPumpStatus.rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice.MedtronicPump))
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
}
omnipod_rl_status.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE)
@ -229,7 +229,7 @@ class OmnipodFragment : DaggerFragment() {
omnipod_errors.text =
omnipodPumpStatus.rileyLinkError?.let {
resourceHelper.gs(it.getResourceId(RileyLinkTargetDevice.Omnipod))
resourceHelper.gs(it.getResourceId(info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice.Omnipod))
} ?: "-"
val driverState = omnipodUtil.getDriverState();

View file

@ -418,6 +418,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
rileyLinkOmnipodService.doTuneUpDevice();
}
@Override
public void triggerPumpConfigurationChangedEvent() {
rxBus.send(new EventOmnipodPumpValuesChanged());
}
@Override
public RileyLinkOmnipodService getRileyLinkService() {

View file

@ -9,6 +9,7 @@ import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
@ -17,7 +18,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RLMe
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RLMessageType;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkBLEError;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.OmnipodAction;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommunicationException;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalMessageAddressException;

View file

@ -1,7 +1,5 @@
package info.nightscout.androidaps.plugins.pump.omnipod.comm.message;
import java.util.Arrays;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RLMessage;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PacketType;

View file

@ -0,0 +1,40 @@
package info.nightscout.androidaps.plugins.pump.omnipod.data;
import org.joda.time.LocalDateTime;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
public class RLHistoryItemOmnipod extends RLHistoryItem {
private OmnipodCommandType omnipodCommandType;
public RLHistoryItemOmnipod(OmnipodCommandType omnipodCommandType) {
super(new LocalDateTime(), RLHistoryItemSource.OmnipodCommand, RileyLinkTargetDevice.Omnipod);
this.omnipodCommandType = omnipodCommandType;
}
public String getDescription(ResourceHelper resourceHelper) {
switch (this.source) {
case RileyLink:
return "State: " + resourceHelper.gs(serviceState.getResourceId(targetDevice))
+ (this.errorCode == null ? "" : ", Error Code: " + errorCode);
case MedtronicPump:
return resourceHelper.gs(pumpDeviceState.getResourceId());
case OmnipodCommand:
return omnipodCommandType.name();
default:
return "Unknown Description";
}
}
}

View file

@ -5,7 +5,6 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentPulseLog;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
public interface OmnipodCommunicationManagerInterface {

View file

@ -5,7 +5,7 @@ import info.nightscout.androidaps.R;
/**
* Created by andy on 4.8.2019
*/
// TODO remove this class and use PumpDeviceState instead
public enum PodDeviceState {
// FIXME

View file

@ -8,14 +8,14 @@ import javax.inject.Singleton;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicDeviceStatusChange;
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
@ -53,7 +53,7 @@ public class OmnipodPumpStatus extends PumpStatus {
public String podNumber;
public PodDeviceState podDeviceState = PodDeviceState.NeverContacted;
public boolean podAvailable = false;
public Boolean podAvailable = false;
public boolean podAvailibityChecked = false;
public boolean ackAlertsAvailable = false;
public String ackAlertsText = null;
@ -101,6 +101,21 @@ public class OmnipodPumpStatus extends PumpStatus {
return (this.errorDescription == null) ? "-" : this.errorDescription;
}
@Override
public <E> E getCustomData(String key, Class<E> clazz) {
switch(key) {
case "POD_LOT_NUMBER":
return (E)podLotNumber;
case "POD_AVAILABLE":
return (E)podAvailable;
default:
return null;
}
}
// public boolean setNotInPreInit() {
// this.inPreInit = false;
@ -187,7 +202,7 @@ public class OmnipodPumpStatus extends PumpStatus {
rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(pumpDeviceState, RileyLinkTargetDevice.Omnipod));
rxBus.send(new EventMedtronicDeviceStatusChange(pumpDeviceState));
rxBus.send(new EventRileyLinkDeviceStatusChange(pumpDeviceState));
}
}

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps.plugins.pump.omnipod.driver.db;
import androidx.annotation.IdRes;
import androidx.annotation.StringRes;
import java.util.HashMap;

View file

@ -11,14 +11,14 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionStat
*/
class EventOmnipodDeviceStatusChange : Event {
var rileyLinkServiceState: RileyLinkServiceState? = null
var rileyLinkError: RileyLinkError? = null
var rileyLinkServiceState: info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState? = null
var rileyLinkError: info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError? = null
var podSessionState: PodSessionState? = null
var errorDescription: String? = null
var podDeviceState: PodDeviceState? = null
@JvmOverloads
constructor(rileyLinkServiceState: RileyLinkServiceState?, rileyLinkError: RileyLinkError? = null) {
constructor(rileyLinkServiceState: info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState?, rileyLinkError: info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError? = null) {
this.rileyLinkServiceState = rileyLinkServiceState
this.rileyLinkError = rileyLinkError
}

View file

@ -14,6 +14,7 @@ import javax.inject.Inject;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
@ -23,7 +24,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.Rile
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;

View file

@ -1,7 +1,5 @@
package info.nightscout.androidaps.plugins.pump.omnipod.util;
import android.content.Context;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
@ -17,8 +15,6 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
@ -27,14 +23,15 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodManager;
import info.nightscout.androidaps.plugins.pump.omnipod.data.RLHistoryItemOmnipod;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPodType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange;
import info.nightscout.androidaps.utils.alertDialogs.OKDialog;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
@ -103,7 +100,7 @@ public class OmnipodUtil {
this.currentCommand = currentCommand;
if (currentCommand != null)
rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(currentCommand));
rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItemOmnipod(currentCommand));
}

View file

@ -12,7 +12,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunication
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
/**
* Created by andy on 4.8.2019

View file

@ -8,7 +8,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.gson.GsonBuilder;
import org.jetbrains.annotations.NotNull;
@ -605,6 +604,12 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
return newRecordCreated;
}
public TreatmentUpdateReturn createOrUpdateMedtronic(Treatment treatment, boolean fromNightScout) {
TreatmentService.UpdateReturn resultRecord = getService().createOrUpdateMedtronic(treatment, fromNightScout);
return new TreatmentUpdateReturn(resultRecord.success, resultRecord.newRecord);
}
// return true if new record is created
@Override
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo, boolean allowUpdate) {

View file

@ -0,0 +1 @@
# danars-support-lib

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1242,175 +1242,8 @@
<string name="preconditions">Preconditions:</string>
<!-- Pump Abstract -->
<string name="pump_operation_not_supported_by_pump_driver">Operation not supported by pump and/or driver.</string>
<string name="pump_operation_not_yet_supported_by_pump">Operation not YET supported by pump.</string>
<!-- Medtronic (MDT) - Base -->
<string name="medtronic_name" translatable="false">Medtronic</string>
<string name="medtronic_name_short" translatable="false">MDT</string>
<string name="description_pump_medtronic">Pump integration for Medtronic, requires RileyLink device and specific Pump Model</string>
<!-- MDT Configuration -->
<string name="key_medtronic_serial" translatable="false">pref_medtronic_serial</string>
<string name="key_medtronic_pump_type" translatable="false">pref_medtronic_pump_type</string>
<string name="key_medtronic_frequency" translatable="false">pref_medtronic_frequency</string>
<string name="key_medtronic_max_bolus" translatable="false">pref_medtronic_max_bolus</string>
<string name="key_medtronic_max_basal" translatable="false">pref_medtronic_max_basal</string>
<string name="key_medtronic_bolus_delay" translatable="false">pref_medtronic_bolus_delay</string>
<string name="key_medtronic_encoding" translatable="false">pref_medtronic_encoding</string>
<string name="key_medtronic_battery_type" translatable="false">pref_medtronic_battery_type</string>
<string name="key_medtronic_bolus_debug" translatable="false">pref_medtronic_bolus_debug</string>
<string name="key_rileylink_mac_address" translatable="false">pref_rileylink_mac_address</string>
<string name="key_medtronic_pump_frequency_us_ca" translatable="false">medtronic_pump_frequency_us_ca</string>
<string name="key_medtronic_pump_frequency_worldwide" translatable="false">medtronic_pump_frequency_worldwide</string>
<string name="key_medtronic_pump_encoding_4b6b_local" translatable="false">medtronic_pump_encoding_4b6b_local</string>
<string name="key_medtronic_pump_encoding_4b6b_rileylink" translatable="false">medtronic_pump_encoding_4b6b_rileylink</string>
<string name="key_medtronic_pump_battery_no" translatable="false">medtronic_pump_battery_no</string>
<string name="key_medtronic_pump_battery_alkaline" translatable="false">medtronic_pump_battery_alkaline</string>
<string name="key_medtronic_pump_battery_lithium" translatable="false">medtronic_pump_battery_lithium</string>
<string name="key_medtronic_pump_battery_nizn" translatable="false">medtronic_pump_battery_nizn</string>
<string name="key_medtronic_pump_battery_nimh" translatable="false">medtronic_pump_battery_nimh</string>
<string name="medtronic_serial_number">Pump Serial Number</string>
<string name="medtronic_pump_type">Pump Type</string>
<string name="medtronic_pump_frequency">Pump Frequency</string>
<string name="medtronic_pump_bolus_delay">Delay before Bolus is started (s)</string>
<string name="medtronic_pump_max_bolus">Max Bolus on Pump (U)</string>
<string name="medtronic_pump_max_basal">Max Basal on Pump (U/h)</string>
<string name="medtronic_pump_encoding">Medtronic Encoding</string>
<string name="medtronic_pump_frequency_us_ca">US &amp; Canada (916 MHz)</string>
<string name="medtronic_pump_frequency_worldwide">Worldwide (868 Mhz)</string>
<string name="medtronic_pump_encoding_4b6b_local">Software 4b6b Encoding</string>
<string name="medtronic_pump_encoding_4b6b_rileylink">Hardware 4b6b Encoding</string>
<string name="medtronic_custom_action_wake_and_tune">Wake and Tune Up</string>
<string name="medtronic_custom_action_clear_bolus_block">Clear Bolus Block</string>
<string name="medtronic_custom_action_reset_rileylink">Reset RileyLink Config</string>
<string name="medtronic_pump_battery_select">Battery Type (Power View)</string>
<string name="medtronic_pump_battery_no">Not selected (Simple view)</string>
<string name="medtronic_pump_battery_alkaline">Alkaline (Extended view)</string>
<string name="medtronic_pump_battery_lithium">Lithium (Extended view)</string>
<string name="medtronic_pump_battery_nizn">NiZn (Extended view)</string>
<string name="medtronic_pump_battery_nimh">NiMH (Extended view)</string>
<string name="medtronic_bolus_debugging">Bolus/Treatments Debugging</string>
<!-- RL BLE Scanning -->
<string name="rileylink_scanner_scan_scan">SCAN</string>
<string name="rileylink_scanner_scan_stop">STOP</string>
<string name="rileylink_scanner_selected_device">Selected</string>
<string name="rileylink_scanner_title">RileyLink Scan</string>
<string name="location_yes">Enable</string>
<string name="location_no">No</string>
<string name="rileylink_scanner_scanning">Scanning</string>
<string name="rileylink_scanner_scanning_finished">Scanning finished</string>
<string name="rileylink_scanner_scanning_error">Scanning error: %1$d</string>
<string name="common_never">Never</string>
<!-- RL Status Page -->
<string name="rileylink_settings_tab1">Settings</string>
<string name="rileylink_settings_tab2">History</string>
<string name="rileylink_status">RileyLink Status</string>
<string name="medtronic_pump_status">Pump Status</string>
<string name="title_activity_rileylink_settings">RileyLink Settings</string>
<string name="rileylink_title">RileyLink</string>
<string name="rileylink_configured_address">Configured Address</string>
<string name="rileylink_connected_device">Connected Device</string>
<string name="rileylink_connection_status">Connection Status</string>
<string name="rileylink_connection_error">Connection Error</string>
<string name="rileylink_device">Device</string>
<string name="rileylink_device_type">Device Type</string>
<string name="rileylink_device_model">Device Model</string>
<string name="rileylink_last_used_frequency">Last used frequency</string>
<string name="rileylink_last_device_contact">Last device contact</string>
<string name="rileylink_firmware_version">RL Firmware</string>
<!-- RL State -->
<string name="rileylink_state_bt_init">Bluetooth Initializing…</string>
<string name="rileylink_state_bt_error">Bluetooth Error</string>
<string name="rileylink_state_bt_ready">Bluetooth Ready</string>
<string name="rileylink_state_not_started">Not Started</string>
<string name="rileylink_state_rl_init">RileyLink Initialization…</string>
<string name="rileylink_state_rl_error">RileyLink Error</string>
<string name="rileylink_state_pc_tune_up">Tuning up RileyLink and Pump</string>
<string name="rileylink_state_pc_error">Problem connecting to Pump</string>
<string name="rileylink_state_connected">Connected</string>
<!-- RL Errors -->
<string name="rileylink_error_not_rl">Device is not RileyLink</string>
<string name="rileylink_error_unreachable">RileyLink unreachable</string>
<string name="rileylink_error_bt_disabled">Bluetooth disabled</string>
<string name="rileylink_error_no_bt_adapter">No Bluetooth Adapter</string>
<string name="rileylink_error_tuneup_failed">TuneUp Failed</string>
<string name="rileylink_error_pump_unreachable">Pump unreachable</string>
<string name="rileylink_error_pod_unreachable">Pod unreachable</string>
<!-- RL Target Device -->
<string name="rileylink_target_device_medtronic">Medtronic Pump</string>
<string name="rileylink_target_device_omnipod">Omnipod</string>
<!-- MDT Errors -->
<string name="medtronic_errors">Errors</string>
<string name="medtronic_error_serial_not_set">Serial # not set.</string>
<string name="medtronic_error_serial_invalid">Serial # invalid.</string>
<string name="medtronic_error_pump_type_not_set">Pump Type not set.</string>
<string name="medtronic_error_pump_type_invalid">Pump Type unsupported.</string>
<string name="medtronic_error_pump_frequency_not_set">Pump Frequency not set.</string>
<string name="medtronic_error_pump_frequency_invalid">Pump Frequency unsupported.</string>
<string name="medtronic_error_rileylink_address_invalid">RileyLink Address invalid.</string>
<string name="medtronic_error_pump_type_set_differs_from_detected">Pump type detected is not the same as configured type.</string>
<string name="medtronic_error_pump_basal_profiles_not_enabled">Basal profiles/patterns setting is not enabled on pump. Enable it on the pump.</string>
<string name="medtronic_error_pump_incorrect_basal_profile_selected">Basal profile set on pump is incorrect (must be STD).</string>
<string name="medtronic_error_pump_wrong_tbr_type_set">Wrong TBR type set on pump (must be Absolute).</string>
<string name="medtronic_error_pump_wrong_max_bolus_set">Wrong Max Bolus set on Pump (must be %1$.2f).</string>
<string name="medtronic_error_pump_wrong_max_basal_set">Wrong Max Basal set on Pump (must be %1$.2f).</string>
<string name="medtronic_error_operation_not_possible_no_configuration">Operation is not possible.\n\n You need to configure Medtronic Pump first, before you can use this operation.</string>
<string name="medtronic_error_pump_24h_time_change_requested">Over 24h Time change was requested.</string>
<!-- MDT History -->
<string name="medtronic_history_group_basal">Basals</string>
<string name="medtronic_history_group_configuration">Configurations</string>
<string name="medtronic_history_group_notification">Notifications</string>
<string name="medtronic_history_group_statistic">Statistics</string>
<string name="medtronic_history_group_unknown">Unknowns</string>
<string name="medtronic_history_group_all">All</string>
<string name="medtronic_pump_history">Medtronic Pump History</string>
<!-- MDT Pump Status -->
<string name="medtronic_pump_status_never_contacted">Never contacted</string>
<string name="medtronic_pump_status_waking_up">Waking up</string>
<string name="medtronic_pump_status_error_comm">Error with communication</string>
<string name="medtronic_pump_status_timeout_comm">Timeout on communication</string>
<string name="medtronic_pump_status_pump_unreachable">Pump unreachable</string>
<string name="medtronic_pump_status_invalid_config">Invalid configuration</string>
<string name="medtronic_pump_status_active">Active</string>
<string name="medtronic_pump_status_sleeping">Sleeping</string>
<!-- <string name="medtronic_cmd_profile_not_set">Remote Basal profile setting is not supported. Please modify Basal profile on your pump manually.</string> -->
<string name="medtronic_cmd_cancel_bolus_not_supported">You cancelled Bolus, after it was already set on Pump. Since Medtronic Pump doesn\'t support cancel, you will need to manually cancel it. Put the Pump into Suspend mode and then do Resume (if you still want to cancel). Application will pick up changes, on next update (in less than 5 minutes).</string>
<string name="medtronic_cmd_cant_read_tbr">Could not read current TBR.</string>
<string name="medtronic_cmd_cant_cancel_tbr_stop_op">Could not cancel current TBR. Stopping operation.</string>
<string name="medtronic_cmd_set_profile_pattern_overflow">Profile set failed, because following patterns, have too big basal rate: %1$s</string>
<string name="medtronic_cmd_bolus_could_not_be_delivered">Bolus could not be delivered.</string>
<string name="medtronic_cmd_bolus_could_not_be_delivered_no_insulin">Bolus could not be delivered, because available insulin amount (%1$.2f) is less than bolus required (%2$.2f).</string>
<string name="medtronic_cmd_tbr_could_not_be_delivered">TBR could not be set.</string>
<string name="medtronic_cmd_cant_cancel_tbr">Could not cancel current TBR.</string>
<string name="medtronic_cmd_basal_profile_could_not_be_set">Basal profile could not be set.</string>
<string name="medtronic_cmd_basal_profile_not_set_is_same">Basal profile is the same, so it will not be set again.</string>
<string name="medtronic_cmd_desc_get_history">Get History - Page %1$d (%2$d/16)</string>
<string name="medtronic_cmd_desc_get_history_request">Get History - Page %1$d</string>
<string name="medtronic_cmd_desc_get_time">Get Pump Time</string>
<string name="medtronic_cmd_desc_get_settings">Get Settings</string>
<string name="medtronic_cmd_desc_get_model">Get Pump Model</string>
<string name="medtronic_cmd_desc_get_basal_profile">Get Basal Profile</string>
<string name="medtronic_cmd_desc_set_basal_profile">Set Basal Profile</string>
<string name="medtronic_cmd_desc_get_tbr">Get Temporary Basal</string>
<string name="medtronic_cmd_desc_set_tbr">Set Temporary Basal</string>
<string name="medtronic_cmd_desc_set_bolus">Set Bolus</string>
<string name="profilename">Change profile to</string>
<string name="changengetoprofilename">Change profile to %1$s</string>
<string name="automation_trigger_pump_last_connection_label">Last connection to pump</string>
@ -1565,6 +1398,17 @@
<string name="skin">Skin</string>
<!-- MDT Pump Status - removed when PodDeviceState is removed -->
<string name="medtronic_pump_status_never_contacted">Never contacted</string>
<string name="medtronic_pump_status_waking_up">Waking up</string>
<string name="medtronic_pump_status_error_comm">Error with communication</string>
<string name="medtronic_pump_status_timeout_comm">Timeout on communication</string>
<string name="medtronic_pump_status_pump_unreachable">Pump unreachable</string>
<string name="medtronic_pump_status_invalid_config">Invalid configuration</string>
<string name="medtronic_pump_status_active">Active</string>
<string name="medtronic_pump_status_sleeping">Sleeping</string>
<!-- Omnipod -->
<!-- Omnipod - Base -->

View file

@ -6,8 +6,6 @@ import junit.framework.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
public class DateTimeUtilUTest {
@Test

View file

@ -1,15 +1,6 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm;
import java.util.Map;
import org.junit.Ignore;
import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.PumpSettingDTO;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
/**
* Created by andy on 1/30/19.

View file

@ -1,18 +1,5 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm;
import android.util.Log;
import org.junit.Before;
import java.util.List;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.RawHistoryPage;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
import static org.mockito.Mockito.when;
//import uk.org.lidalia.slf4jtest.TestLogger;
//import uk.org.lidalia.slf4jtest.TestLoggerFactory;

View file

@ -1,10 +1,8 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
import org.junit.Before;
import org.junit.Ignore;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
/**
* Created by andy on 11/1/18.

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
import org.junit.Assert;
import org.junit.Test;
import java.util.Date;

View file

@ -1,20 +1,9 @@
package info.nightscout.androidaps.plugins.pump.medtronic.data.dto;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.powermock.api.mockito.PowerMockito;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.T;
import static org.mockito.Mockito.when;
/**
* Created by andy on 6/16/18.

View file

@ -75,6 +75,9 @@ dependencies {
implementation "com.j256.ormlite:ormlite-core:${ormLiteVersion}"
implementation "com.j256.ormlite:ormlite-android:${ormLiteVersion}"
// pumpCommon
implementation "com.google.code.gson:gson:2.8.6"
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

View file

@ -1,11 +1,7 @@
package info.nightscout.androidaps.interfaces
import com.j256.ormlite.dao.CloseableIterator
import info.nightscout.androidaps.db.BgReading
import info.nightscout.androidaps.db.CareportalEvent
import info.nightscout.androidaps.db.DanaRHistoryRecord
import info.nightscout.androidaps.db.DbRequest
import info.nightscout.androidaps.db.TDD
import info.nightscout.androidaps.db.*
interface DatabaseHelperInterface {
@ -21,4 +17,10 @@ interface DatabaseHelperInterface {
fun deleteDbRequestbyMongoId(action: String, _id: String)
fun getDbRequestInterator(): CloseableIterator<DbRequest>
fun roundDateToSec(date: Long): Long
fun createOrUpdateTDD(record: TDD)
fun createOrUpdate(tempBasal: TemporaryBasal)
fun findTempBasalByPumpId(id: Long) : TemporaryBasal
fun getTemporaryBasalsDataFromTime(mills: Long, ascending: Boolean) : List<TemporaryBasal>
fun getCareportalEventFromTimestamp(timestamp: Long): CareportalEvent
fun getTDDsForLastXDays(days: Int): List<TDD>
}

View file

@ -14,6 +14,7 @@ import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.plugins.treatments.TreatmentUpdateReturn;
/**
* Created by mike on 14.06.2016.
@ -84,4 +85,6 @@ public interface TreatmentsInterface {
long oldestDataAvailable();
TreatmentUpdateReturn createOrUpdateMedtronic(Treatment treatment, boolean fromNightScout);
}

View file

@ -13,8 +13,7 @@ import org.json.JSONObject;
import java.util.Date;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.core.R;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
@ -37,7 +36,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.medtronic.data.MedtronicHistoryData;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.DecimalFormatter;
@ -118,7 +116,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
@Override
protected void onStart() {
super.onStart();
// TODO: moved from constructor .... test if it works
initPumpStatusData();
Intent intent = new Intent(context, getServiceClass());
@ -418,8 +416,8 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
// bolus needed, ask pump to deliver it
return deliverBolus(detailedBolusInfo);
} else {
if (MedtronicHistoryData.doubleBolusDebug)
aapsLogger.debug("DoubleBolusDebug: deliverTreatment::(carb only entry)");
//if (MedtronicHistoryData.doubleBolusDebug)
// aapsLogger.debug("DoubleBolusDebug: deliverTreatment::(carb only entry)");
// no bolus required, carb only treatment
activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, true);
@ -433,7 +431,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
aapsLogger.debug(LTag.PUMP, "deliverTreatment: Carb only treatment.");
return new PumpEnactResult(getInjector()).success(true).enacted(true).bolusDelivered(0d)
.carbsDelivered(detailedBolusInfo.carbs).comment(getResourceHelper().gs(R.string.virtualpump_resultok));
.carbsDelivered(detailedBolusInfo.carbs).comment(getResourceHelper().gs(R.string.common_resultok));
}
} finally {
triggerUIChange();

View file

@ -49,7 +49,7 @@ public abstract class PumpStatus {
public int tempBasalRatio = 0;
public int tempBasalRemainMin = 0;
public Date tempBasalStart;
private PumpType pumpType;
public PumpType pumpType;
//protected PumpDescription pumpDescription;
@ -69,9 +69,20 @@ public abstract class PumpStatus {
this.lastConnection = System.currentTimeMillis();
}
public void setLastFailedCommunicationToNow() {
this.lastErrorConnection = System.currentTimeMillis();
}
public abstract String getErrorInfo();
public abstract <E> E getCustomData(String key, Class<E> clazz);
public String getCustomDataAsString(String key) {
return getCustomData(key, String.class);
}
}

View file

@ -2,11 +2,6 @@ package info.nightscout.androidaps.plugins.pump.common.data;
import com.google.gson.annotations.Expose;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.logging.L;
public class TempBasalPair {
@Expose

View file

@ -0,0 +1,29 @@
package info.nightscout.androidaps.plugins.pump.common.defs;
import info.nightscout.androidaps.core.R;
/**
* Created by andy on 6/11/18.
*/
public enum PumpDeviceState {
NeverContacted(R.string.pump_status_never_contacted), //
Sleeping(R.string.pump_status_sleeping), //
WakingUp(R.string.pump_status_waking_up), //
Active(R.string.pump_status_active), //
ErrorWhenCommunicating(R.string.pump_status_error_comm), //
TimeoutWhenCommunicating(R.string.pump_status_timeout_comm), //
// ProblemContacting(R.string.medtronic_pump_status_problem_contacting), //
PumpUnreachable(R.string.pump_status_pump_unreachable), //
InvalidConfiguration(R.string.pump_status_invalid_config);
Integer resourceId;
PumpDeviceState(int resourceId) {
this.resourceId = resourceId;
}
public Integer getResourceId() {
return resourceId;
}
}

View file

@ -3,7 +3,8 @@ package info.nightscout.androidaps.plugins.pump.common.defs;
import java.util.ArrayList;
import java.util.List;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.core.R;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
@ -16,16 +17,16 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
public enum PumpHistoryEntryGroup {
All(R.string.medtronic_history_group_all),
Bolus(R.string.danar_history_bolus),
Basal(R.string.medtronic_history_group_basal),
Prime(R.string.danar_history_prime),
Configuration(R.string.medtronic_history_group_configuration),
Alarm(R.string.danar_history_alarm),
Glucose(R.string.danar_history_glucose),
Notification(R.string.medtronic_history_group_notification),
Statistic(R.string.medtronic_history_group_statistic),
Unknown(R.string.medtronic_history_group_unknown),
All(R.string.history_group_all),
Bolus(R.string.history_group_bolus),
Basal(R.string.history_group_basal),
Prime(R.string.history_group_prime),
Configuration(R.string.history_group_configuration),
Alarm(R.string.history_group_alarm),
Glucose(R.string.history_group_glucose),
Notification(R.string.history_group_notification),
Statistic(R.string.history_group_statistic),
Unknown(R.string.history_group_unknown),
;
private int resourceId;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.pump.medtronic.events
package info.nightscout.androidaps.plugins.pump.common.events
import info.nightscout.androidaps.events.Event

View file

@ -6,15 +6,10 @@ package info.nightscout.androidaps.plugins.pump.common.utils;
import org.joda.time.LocalDateTime;
import org.joda.time.Minutes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Calendar;
import java.util.GregorianCalendar;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
/**
* This is simple version of ATechDate, limited only to one format (yyyymmddHHMIss)
*/

View file

@ -0,0 +1,27 @@
package info.nightscout.androidaps.plugins.treatments;
import info.nightscout.androidaps.db.Treatment;
public class TreatmentUpdateReturn {
public TreatmentUpdateReturn(boolean success, boolean newRecord) {
this.success = success;
this.newRecord = newRecord;
}
boolean newRecord;
boolean success;
@Override
public String toString() {
return "UpdateReturn [" +
"newRecord=" + newRecord +
", success=" + success +
']';
}
}

View file

@ -220,4 +220,57 @@
<!-- Ntp-->
<string name="timedetection">Time detection</string>
<!-- PumoCommon - Pump Abstract -->
<string name="pump_operation_not_supported_by_pump_driver">Operation not supported by pump and/or driver.</string>
<string name="pump_operation_not_yet_supported_by_pump">Operation not YET supported by pump.</string>
<string name="common_resultok">OK</string>
<!-- PumoCommon - Pump Status -->
<string name="pump_status_never_contacted">Never contacted</string>
<string name="pump_status_waking_up">Waking up</string>
<string name="pump_status_error_comm">Error with communication</string>
<string name="pump_status_timeout_comm">Timeout on communication</string>
<string name="pump_status_pump_unreachable">Pump unreachable</string>
<string name="pump_status_invalid_config">Invalid configuration</string>
<string name="pump_status_active">Active</string>
<string name="pump_status_sleeping">Sleeping</string>
<!-- PumpCommon - History Group -->
<string name="history_group_basal">Basals</string>
<string name="history_group_configuration">Configurations</string>
<string name="history_group_notification">Notifications</string>
<string name="history_group_statistic">Statistics</string>
<string name="history_group_unknown">Unknowns</string>
<string name="history_group_all">All</string>
<string name="history_group_bolus">Boluses</string>
<string name="history_group_prime">Prime</string>
<string name="history_group_alarm">Alarms</string>
<string name="history_group_glucose">Glucose</string>
<!-- <string name="medtronic_pump_status_never_contacted">Never contacted</string>-->
<!-- <string name="medtronic_pump_status_waking_up">Waking up</string>-->
<!-- <string name="medtronic_pump_status_error_comm">Error with communication</string>-->
<!-- <string name="medtronic_pump_status_timeout_comm">Timeout on communication</string>-->
<!-- <string name="medtronic_pump_status_pump_unreachable">Pump unreachable</string>-->
<!-- <string name="medtronic_pump_status_invalid_config">Invalid configuration</string>-->
<!-- <string name="medtronic_pump_status_active">Active</string>-->
<!-- <string name="medtronic_pump_status_sleeping">Sleeping</string>-->
<!-- <string name="danar_history_alarm">Alarms</string>-->
<!-- <string name="danar_history_glucose">Glucose</string>-->
<!-- All(R.string.medtronic_history_group_all), //-->
<!-- Bolus(R.string.danar_history_bolus), //-->
<!-- Basal(R.string.medtronic_history_group_basal), //-->
<!-- Prime(R.string.danar_history_prime), //-->
<!-- Configuration(R.string.medtronic_history_group_configuration), //-->
<!-- Alarm(R.string.danar_history_alarm), //-->
<!-- Glucose(R.string.danar_history_glucose), //-->
<!-- Notification(R.string.medtronic_history_group_notification), //-->
<!-- Statistic(R.string.medtronic_history_group_statistic),-->
<!-- Unknown(R.string.medtronic_history_group_unknown), //-->
</resources>

1
medtronic/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

83
medtronic/build.gradle Normal file
View file

@ -0,0 +1,83 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
kotlinOptions {
jvmTarget = '1.8'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled(project.hasProperty('coverage'))
}
firebaseDisable {
System.setProperty("disableFirebase", "true")
ext.enableCrashlytics = false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(':core')
implementation project(':rileylink')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation "androidx.preference:preference-ktx:1.1.1"
implementation "androidx.activity:activity-ktx:${activityVersion}"
implementation 'com.google.android.material:material:1.1.0'
implementation "io.reactivex.rxjava2:rxandroid:${rxandroid_version}"
// Graphview cannot be upgraded
implementation "com.jjoe64:graphview:4.0.1"
implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.2.2"
// medtronic - start
implementation 'org.apache.commons:commons-lang3:3.10'
implementation 'net.danlew:android.joda:2.10.6'
implementation 'org.slf4j:slf4j-api:1.7.30'
implementation "com.google.code.gson:gson:2.8.6"
// medtronic - end
implementation "com.google.dagger:dagger-android:$dagger_version"
implementation "com.google.dagger:dagger-android-support:$dagger_version"
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger_version"
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

View file

21
medtronic/proguard-rules.pro vendored Normal file
View 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

View file

@ -0,0 +1,27 @@
package info.nightscout.androidaps.plugins.pump.medtronic;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("info.nightscout.androidaps.plugins.pump.medtronic.test", appContext.getPackageName());
}
}

View file

@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.nightscout.androidaps.plugins.pump.medtronic" />

View file

@ -8,8 +8,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventExtendedBolusChange
import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.events.EventTempBasalChange
@ -18,20 +16,14 @@ import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.MedtronicHistoryActivity
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicDeviceStatusChange
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpConfigurationChanged
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpValuesChanged
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventRefreshButtonState
import info.nightscout.androidaps.plugins.pump.common.events.EventRefreshButtonState
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.queue.events.EventQueueChanged
@ -49,7 +41,7 @@ import javax.inject.Inject
class MedtronicFragment : DaggerFragment() {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var mainApp: MainApp
//@Inject lateinit var mainApp: MainApp
@Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var rxBus: RxBusWrapper
@ -57,10 +49,10 @@ class MedtronicFragment : DaggerFragment() {
@Inject lateinit var activePlugin: ActivePluginProvider
@Inject lateinit var medtronicPumpPlugin: MedtronicPumpPlugin
@Inject lateinit var warnColors: WarnColors
@Inject lateinit var rileyLinkUtil: RileyLinkUtil
@Inject lateinit var rileyLinkUtil: info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
@Inject lateinit var medtronicUtil: MedtronicUtil
@Inject lateinit var medtronicPumpStatus: MedtronicPumpStatus
@Inject lateinit var rileyLinkServiceData: RileyLinkServiceData
@Inject lateinit var rileyLinkServiceData: info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData
private var disposable: CompositeDisposable = CompositeDisposable()
@ -83,7 +75,7 @@ class MedtronicFragment : DaggerFragment() {
medtronic_pumpstatus.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder))
medtronic_rl_status.text = resourceHelper.gs(RileyLinkServiceState.NotStarted.getResourceId(RileyLinkTargetDevice.MedtronicPump))
medtronic_rl_status.text = resourceHelper.gs(info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState.NotStarted.getResourceId(info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice.MedtronicPump))
medtronic_pump_status.setTextColor(Color.WHITE)
medtronic_pump_status.text = "{fa-bed}"
@ -112,7 +104,7 @@ class MedtronicFragment : DaggerFragment() {
medtronic_stats.setOnClickListener {
if (medtronicPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
startActivity(Intent(context, RileyLinkStatusActivity::class.java))
startActivity(Intent(context, info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity::class.java))
} else {
displayNotConfiguredDialog()
}
@ -128,7 +120,7 @@ class MedtronicFragment : DaggerFragment() {
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ medtronic_refresh.isEnabled = it.newState }, { fabricPrivacy.logException(it) })
disposable += rxBus
.toObservable(EventMedtronicDeviceStatusChange::class.java)
.toObservable(EventRileyLinkDeviceStatusChange::class.java)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
aapsLogger.debug(LTag.PUMP, "onStatusEvent(EventMedtronicDeviceStatusChange): $it")
@ -175,34 +167,34 @@ class MedtronicFragment : DaggerFragment() {
@Synchronized
private fun setDeviceStatus() {
val resourceId = rileyLinkServiceData.rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.MedtronicPump)
val resourceId = rileyLinkServiceData.rileyLinkServiceState.getResourceId(info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice.MedtronicPump)
val rileyLinkError = medtronicPumpPlugin.rileyLinkService?.error
medtronic_rl_status.text =
when {
rileyLinkServiceData.rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
rileyLinkServiceData.rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
rileyLinkServiceData.rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
rileyLinkServiceData.rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump))
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
rileyLinkServiceData.rileyLinkServiceState == info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
rileyLinkServiceData.rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
rileyLinkServiceData.rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
rileyLinkServiceData.rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice.MedtronicPump))
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
}
medtronic_rl_status.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE)
medtronic_errors.text =
rileyLinkServiceData.rileyLinkError?.let {
resourceHelper.gs(it.getResourceId(RileyLinkTargetDevice.MedtronicPump))
resourceHelper.gs(it.getResourceId(info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice.MedtronicPump))
} ?: "-"
when (medtronicPumpStatus.pumpDeviceState) {
null,
PumpDeviceState.Sleeping -> medtronic_pump_status.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name());
PumpDeviceState.NeverContacted,
PumpDeviceState.WakingUp,
PumpDeviceState.PumpUnreachable,
PumpDeviceState.ErrorWhenCommunicating,
PumpDeviceState.TimeoutWhenCommunicating,
PumpDeviceState.InvalidConfiguration -> medtronic_pump_status.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId)
info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState.Sleeping -> medtronic_pump_status.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name());
info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState.NeverContacted,
info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState.WakingUp,
info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState.PumpUnreachable,
info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState.ErrorWhenCommunicating,
info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState.TimeoutWhenCommunicating,
info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState.InvalidConfiguration -> medtronic_pump_status.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId)
PumpDeviceState.Active -> {
info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState.Active -> {
val cmd = medtronicUtil.getCurrentCommand()
if (cmd == null)
medtronic_pump_status.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId)
@ -235,7 +227,7 @@ class MedtronicFragment : DaggerFragment() {
private fun displayNotConfiguredDialog() {
context?.let {
OKDialog.show(it, resourceHelper.gs(R.string.combo_warning),
OKDialog.show(it, resourceHelper.gs(R.string.medtronic_warning),
resourceHelper.gs(R.string.medtronic_error_operation_not_possible_no_configuration), null)
}
}
@ -252,7 +244,7 @@ class MedtronicFragment : DaggerFragment() {
val minAgo = DateUtil.minAgo(resourceHelper, medtronicPumpStatus.lastConnection)
val min = (System.currentTimeMillis() - medtronicPumpStatus.lastConnection) / 1000 / 60
if (medtronicPumpStatus.lastConnection + 60 * 1000 > System.currentTimeMillis()) {
medtronic_lastconnection.setText(R.string.combo_pump_connected_now)
medtronic_lastconnection.setText(R.string.medtronic_pump_connected_now)
medtronic_lastconnection.setTextColor(Color.WHITE)
} else if (medtronicPumpStatus.lastConnection + 30 * 60 * 1000 < System.currentTimeMillis()) {
@ -260,13 +252,13 @@ class MedtronicFragment : DaggerFragment() {
medtronic_lastconnection.text = resourceHelper.gs(R.string.minago, min)
} else if (min < 1440) {
val h = (min / 60).toInt()
medtronic_lastconnection.text = (resourceHelper.gq(R.plurals.objective_hours, h, h) + " "
medtronic_lastconnection.text = (resourceHelper.gq(R.plurals.duration_hours, h, h) + " "
+ resourceHelper.gs(R.string.ago))
} else {
val h = (min / 60).toInt()
val d = h / 24
// h = h - (d * 24);
medtronic_lastconnection.text = (resourceHelper.gq(R.plurals.objective_days, d, d) + " "
medtronic_lastconnection.text = (resourceHelper.gq(R.plurals.duration_days, d, d) + " "
+ resourceHelper.gs(R.string.ago))
}
medtronic_lastconnection.setTextColor(Color.RED)
@ -285,13 +277,13 @@ class MedtronicFragment : DaggerFragment() {
val unit = resourceHelper.gs(R.string.insulin_unit_shortname)
val ago: String
if (agoMsc < 60 * 1000) {
ago = resourceHelper.gs(R.string.combo_pump_connected_now)
ago = resourceHelper.gs(R.string.medtronic_pump_connected_now)
} else if (bolusMinAgo < 60) {
ago = DateUtil.minAgo(resourceHelper, medtronicPumpStatus.lastBolusTime.time)
} else {
ago = DateUtil.hourAgo(medtronicPumpStatus.lastBolusTime.time, resourceHelper)
}
medtronic_lastbolus.text = resourceHelper.gs(R.string.combo_last_bolus, bolus, unit, ago)
medtronic_lastbolus.text = resourceHelper.gs(R.string.mdt_last_bolus, bolus, unit, ago)
} else {
medtronic_lastbolus.text = ""
}

View file

@ -30,13 +30,13 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.activities.ErrorHelperActivity;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
@ -79,8 +79,9 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicNotificat
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicStatusRefreshType;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicUIResponseType;
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpConfigurationChanged;
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpValuesChanged;
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventRefreshButtonState;
import info.nightscout.androidaps.plugins.pump.common.events.EventRefreshButtonState;
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
@ -242,10 +243,16 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
return true;
}
@Override public void doTuneUpDevice() {
@Override
public void doTuneUpDevice() {
rileyLinkMedtronicService.doTuneUpDevice();
}
@Override
public void triggerPumpConfigurationChangedEvent() {
rxBus.send(new EventMedtronicPumpConfigurationChanged());
}
private void migrateSettings() {
if ("US (916 MHz)".equals(sp.getString(MedtronicConst.Prefs.PumpFrequency, "US (916 MHz)"))) {
@ -860,7 +867,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
Intent i = new Intent(context, ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.boluserror);
i.putExtra("status", getResourceHelper().gs(R.string.medtronic_cmd_cancel_bolus_not_supported));
i.putExtra("title", getResourceHelper().gs(R.string.combo_warning));
i.putExtra("title", getResourceHelper().gs(R.string.medtronic_warning));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
@ -1538,7 +1545,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
Intent i = new Intent(context, ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.boluserror);
i.putExtra("status", getResourceHelper().gs(R.string.medtronic_error_operation_not_possible_no_configuration));
i.putExtra("title", getResourceHelper().gs(R.string.combo_warning));
i.putExtra("title", getResourceHelper().gs(R.string.medtronic_warning));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
@ -1571,7 +1578,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
this.hasTimeDateOrTimeZoneChanged = true;
}
@Override public boolean setNeutralTempAtFullHour() {
@Override
public boolean setNeutralTempAtFullHour() {
return sp.getBoolean(R.string.key_set_neutral_temps, true);
}

View file

@ -12,9 +12,9 @@ import java.util.Map;
import javax.inject.Inject;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
@ -24,8 +24,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RLMe
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioPacket;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioResponse;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RLMessageType;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.WakeAndTuneTask;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
@ -48,7 +46,6 @@ import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.PumpSettingDTO
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
@ -151,6 +148,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
PumpDeviceState state = medtronicPumpStatus.getPumpDeviceState();
// check connection
byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.ReadSimpleData); // simple
RFSpyResponse rfSpyResponse = rfspy.transmitThenReceive(new RadioPacket(injector, pumpMsgContent), (byte) 0, (byte) 200,
(byte) 0, (byte) 0, 25000, (byte) 0);

View file

@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm.history;
import com.google.gson.annotations.Expose;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.List;

View file

@ -8,15 +8,15 @@ import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfile;
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicUIResponseType;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicDeviceStatusChange;
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange;
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpValuesChanged;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
@ -201,10 +201,10 @@ public class MedtronicUITask {
}
if (responseType == MedtronicUIResponseType.Invalid) {
rxBus.send(new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
rxBus.send(new EventRileyLinkDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
"Unsupported command in MedtronicUITask"));
} else if (responseType == MedtronicUIResponseType.Error) {
rxBus.send(new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
rxBus.send(new EventRileyLinkDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
errorDescription));
} else {
rxBus.send(new EventMedtronicPumpValuesChanged());

View file

@ -22,7 +22,6 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.DbObjectBase;
@ -31,6 +30,7 @@ import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TDD;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
@ -52,8 +52,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.db.Treatment;
import info.nightscout.androidaps.plugins.treatments.TreatmentService;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.plugins.treatments.TreatmentUpdateReturn;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.Round;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
@ -81,6 +80,7 @@ public class MedtronicHistoryData {
private final NSUpload nsUpload;
private final MedtronicUtil medtronicUtil;
private final MedtronicPumpHistoryDecoder medtronicPumpHistoryDecoder;
private final DatabaseHelperInterface databaseHelper;
private List<PumpHistoryEntry> allHistory;
private List<PumpHistoryEntry> newHistory = null;
@ -98,8 +98,10 @@ public class MedtronicHistoryData {
* Double bolus debug. We seem to have small problem with double Boluses (or sometimes also missing boluses
* from history. This flag turns on debugging for that (default is off=false)... Debuging is pretty detailed,
* so log files will get bigger.
* Note: June 2020. Since this seems to be fixed, I am disabling this per default. I will leave code inside
* in case we need it again. Code that turns this on is commented out RileyLinkMedtronicService#verifyConfiguration()
*/
public static boolean doubleBolusDebug = false;
public static final boolean doubleBolusDebug = false;
@Inject
public MedtronicHistoryData(
@ -109,7 +111,8 @@ public class MedtronicHistoryData {
ActivePluginProvider activePlugin,
NSUpload nsUpload,
MedtronicUtil medtronicUtil,
MedtronicPumpHistoryDecoder medtronicPumpHistoryDecoder
MedtronicPumpHistoryDecoder medtronicPumpHistoryDecoder,
DatabaseHelperInterface databaseHelperInterface
) {
this.allHistory = new ArrayList<>();
@ -120,6 +123,7 @@ public class MedtronicHistoryData {
this.nsUpload = nsUpload;
this.medtronicUtil = medtronicUtil;
this.medtronicPumpHistoryDecoder = medtronicPumpHistoryDecoder;
this.databaseHelper = databaseHelperInterface;
}
private Gson gson() {
@ -532,7 +536,7 @@ public class MedtronicHistoryData {
private void uploadCareportalEvent(long date, String event) {
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date) != null)
if (databaseHelper.getCareportalEventFromTimestamp(date) != null)
return;
try {
JSONObject data = new JSONObject();
@ -545,7 +549,7 @@ public class MedtronicHistoryData {
careportalEvent.source = Source.USER;
careportalEvent.eventType = event;
careportalEvent.json = data.toString();
MainApp.getDbHelper().createOrUpdate(careportalEvent);
databaseHelper.createOrUpdate(careportalEvent);
nsUpload.uploadCareportalEntryToNS(data);
} catch (JSONException e) {
aapsLogger.error("Unhandled exception", e);
@ -559,7 +563,7 @@ public class MedtronicHistoryData {
aapsLogger.debug(LTag.PUMP, getLogPrefix() + "TDDs found: {}.\n{}", tdds.size(), gson().toJson(tdds));
List<TDD> tddsDb = MainApp.getDbHelper().getTDDsForLastXDays(3);
List<TDD> tddsDb = databaseHelper.getTDDsForLastXDays(3);
for (PumpHistoryEntry tdd : tdds) {
@ -575,7 +579,7 @@ public class MedtronicHistoryData {
aapsLogger.debug(LTag.PUMP, "TDD Add: {}", tddNew);
MainApp.getDbHelper().createOrUpdateTDD(tddNew);
databaseHelper.createOrUpdateTDD(tddNew);
} else {
@ -584,7 +588,7 @@ public class MedtronicHistoryData {
aapsLogger.debug(LTag.PUMP, "TDD Edit: {}", tddDbEntry);
MainApp.getDbHelper().createOrUpdateTDD(tddDbEntry);
databaseHelper.createOrUpdateTDD(tddDbEntry);
}
}
}
@ -745,7 +749,7 @@ public class MedtronicHistoryData {
tempBasal.durationInMinutes = tempBasalProcessDTO.getDuration();
MainApp.getDbHelper().createOrUpdate(tempBasal);
databaseHelper.createOrUpdate(tempBasal);
aapsLogger.debug(LTag.PUMP, "Edit " + ProcessHistoryRecord.TBR.getDescription() + " - (entryFromDb={}) ", tempBasal);
} else {
@ -793,7 +797,7 @@ public class MedtronicHistoryData {
}
}
TemporaryBasal tempBasal = MainApp.getDbHelper().findTempBasalByPumpId(pumpId);
TemporaryBasal tempBasal = databaseHelper.findTempBasalByPumpId(pumpId);
return tempBasal;
}
@ -884,7 +888,7 @@ public class MedtronicHistoryData {
if (processHistoryRecord == ProcessHistoryRecord.Bolus) {
return activePlugin.getActiveTreatments().getTreatmentsFromHistoryAfterTimestamp(startTimestamp);
} else {
return MainApp.getDbHelper().getTemporaryBasalsDataFromTime(startTimestamp, true);
return databaseHelper.getTemporaryBasalsDataFromTime(startTimestamp, true);
}
}
@ -992,7 +996,7 @@ public class MedtronicHistoryData {
treatment.pumpId = bolus.getPumpId();
treatment.insulin = bolusDTO.getDeliveredAmount();
TreatmentService.UpdateReturn updateReturn = ((TreatmentsPlugin) activePlugin.getActiveTreatments()).getService().createOrUpdateMedtronic(treatment, false);
TreatmentUpdateReturn updateReturn = activePlugin.getActiveTreatments().createOrUpdateMedtronic(treatment, false);
if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament!=null): NewTreatment={}, UpdateReturn={}", treatment, updateReturn);
@ -1042,7 +1046,7 @@ public class MedtronicHistoryData {
treatment.setLinkedObject(temporaryBasalDb);
MainApp.getDbHelper().createOrUpdate(temporaryBasalDb);
databaseHelper.createOrUpdate(temporaryBasalDb);
aapsLogger.debug(LTag.PUMP, operation + " - [date={},pumpId={}, rate={} {}, duration={}]", //
temporaryBasalDb.date, //
@ -1058,7 +1062,7 @@ public class MedtronicHistoryData {
for (TempBasalProcessDTO tempBasalProcess : tempBasalProcessList) {
TemporaryBasal tempBasal = MainApp.getDbHelper().findTempBasalByPumpId(tempBasalProcess.itemOne.getPumpId());
TemporaryBasal tempBasal = databaseHelper.findTempBasalByPumpId(tempBasalProcess.itemOne.getPumpId());
if (tempBasal == null) {
// add
@ -1074,7 +1078,7 @@ public class MedtronicHistoryData {
tempBasalProcess.itemOne.setLinkedObject(tempBasal);
tempBasalProcess.itemTwo.setLinkedObject(tempBasal);
MainApp.getDbHelper().createOrUpdate(tempBasal);
databaseHelper.createOrUpdate(tempBasal);
}
}

View file

@ -8,7 +8,6 @@ import java.util.ArrayList;
import java.util.List;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;

Some files were not shown because too many files have changed in this diff Show more