From a5108ca4c4cce2913eb4a57c0d75ccc401217c24 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 29 Apr 2020 23:27:48 +0200 Subject: [PATCH] RS injection refactor --- .../dependencyInjection/AppModule.kt | 2 +- .../dependencyInjection/DanaRSCommModule.kt | 79 +++++++++ .../danaRS/comm/DanaRSMessageHashTable.kt | 154 ++++++++---------- .../pump/danaRS/comm/DanaRS_Packet.java | 26 ++- ...RS_Packet_APS_Basal_Set_Temporary_Basal.kt | 8 +- .../comm/DanaRS_Packet_APS_History_Events.kt | 20 +-- .../DanaRS_Packet_APS_Set_Event_History.kt | 8 +- .../DanaRS_Packet_Basal_Get_Basal_Rate.kt | 18 +- ...aRS_Packet_Basal_Get_Profile_Basal_Rate.kt | 14 +- .../DanaRS_Packet_Basal_Get_Profile_Number.kt | 12 +- ..._Packet_Basal_Get_Temporary_Basal_State.kt | 12 +- .../DanaRS_Packet_Basal_Set_Basal_Rate.kt | 8 +- ...Packet_Basal_Set_Cancel_Temporary_Basal.kt | 8 +- ...aRS_Packet_Basal_Set_Profile_Basal_Rate.kt | 8 +- .../DanaRS_Packet_Basal_Set_Profile_Number.kt | 8 +- .../DanaRS_Packet_Basal_Set_Suspend_Off.kt | 8 +- .../DanaRS_Packet_Basal_Set_Suspend_On.kt | 8 +- ...DanaRS_Packet_Basal_Set_Temporary_Basal.kt | 8 +- .../DanaRS_Packet_Bolus_Get_Bolus_Option.kt | 15 +- .../DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt | 12 +- ...acket_Bolus_Get_Calculation_Information.kt | 11 +- ...et_Carbohydrate_Calculation_Information.kt | 12 +- .../DanaRS_Packet_Bolus_Get_Dual_Bolus.kt | 12 +- .../DanaRS_Packet_Bolus_Get_Extended_Bolus.kt | 12 +- ...S_Packet_Bolus_Get_Extended_Bolus_State.kt | 12 +- ...et_Bolus_Get_Extended_Menu_Option_State.kt | 12 +- .../DanaRS_Packet_Bolus_Get_Initial_Bolus.kt | 8 +- ...Packet_Bolus_Get_Step_Bolus_Information.kt | 13 +- .../DanaRS_Packet_Bolus_Set_Bolus_Option.kt | 8 +- .../DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt | 8 +- .../DanaRS_Packet_Bolus_Set_Dual_Bolus.kt | 9 +- .../DanaRS_Packet_Bolus_Set_Extended_Bolus.kt | 9 +- ..._Packet_Bolus_Set_Extended_Bolus_Cancel.kt | 8 +- .../DanaRS_Packet_Bolus_Set_Initial_Bolus.kt | 8 +- ...anaRS_Packet_Bolus_Set_Step_Bolus_Start.kt | 11 +- ...DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt | 13 +- .../comm/DanaRS_Packet_Etc_Keep_Connection.kt | 8 +- .../DanaRS_Packet_Etc_Set_History_Save.kt | 9 +- .../DanaRS_Packet_General_Delivery_Status.kt | 8 +- ...aRS_Packet_General_Get_More_Information.kt | 10 +- .../DanaRS_Packet_General_Get_Password.kt | 12 +- .../DanaRS_Packet_General_Get_Pump_Check.kt | 14 +- ...Packet_General_Get_Shipping_Information.kt | 12 +- ...aRS_Packet_General_Get_Shipping_Version.kt | 10 +- ...Packet_General_Get_Today_Delivery_Total.kt | 12 +- ...acket_General_Get_User_Time_Change_Flag.kt | 8 +- ...cket_General_Initial_Screen_Information.kt | 10 +- ..._Packet_General_Set_History_Upload_Mode.kt | 8 +- ...General_Set_User_Time_Change_Flag_Clear.kt | 9 +- .../danaRS/comm/DanaRS_Packet_History_.kt | 10 +- .../comm/DanaRS_Packet_History_Alarm.kt | 10 +- .../comm/DanaRS_Packet_History_All_History.kt | 10 +- .../comm/DanaRS_Packet_History_Basal.kt | 10 +- .../DanaRS_Packet_History_Blood_Glucose.kt | 10 +- .../comm/DanaRS_Packet_History_Bolus.kt | 10 +- .../DanaRS_Packet_History_Carbohydrate.kt | 10 +- .../comm/DanaRS_Packet_History_Daily.kt | 10 +- .../comm/DanaRS_Packet_History_Prime.kt | 10 +- .../comm/DanaRS_Packet_History_Refill.kt | 10 +- .../comm/DanaRS_Packet_History_Suspend.kt | 6 +- .../comm/DanaRS_Packet_History_Temporary.kt | 10 +- .../danaRS/comm/DanaRS_Packet_Notify_Alarm.kt | 14 +- .../DanaRS_Packet_Notify_Delivery_Complete.kt | 14 +- ...aRS_Packet_Notify_Delivery_Rate_Display.kt | 13 +- ...DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt | 8 +- .../DanaRS_Packet_Option_Get_Pump_Time.kt | 10 +- .../DanaRS_Packet_Option_Get_User_Option.kt | 12 +- .../DanaRS_Packet_Option_Set_Pump_Time.kt | 6 +- .../DanaRS_Packet_Option_Set_User_Option.kt | 11 +- .../comm/DanaRS_Packet_Review_Bolus_Avg.kt | 8 +- ...DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt | 10 +- .../plugins/pump/danaRS/services/BLEComm.kt | 4 +- .../pump/danaRS/services/DanaRSService.kt | 104 ++++++------ .../danaRS/comm/DanaRSMessageHashTableTest.kt | 26 ++- ...acket_APS_Basal_Set_Temporary_BasalTest.kt | 22 ++- .../DanaRS_Packet_APS_History_EventsTest.kt | 20 ++- ...DanaRS_Packet_APS_Set_Event_HistoryTest.kt | 18 +- .../DanaRS_Packet_Basal_Get_Basal_RateTest.kt | 14 +- ...Packet_Basal_Get_Profile_Basal_RateTest.kt | 23 ++- ...aRS_Packet_Basal_Get_Profile_NumberTest.kt | 13 +- ...ket_Basal_Get_Temporary_Basal_StateTest.kt | 13 +- .../DanaRS_Packet_Basal_Set_Basal_RateTest.kt | 12 +- ...et_Basal_Set_Cancel_Temporary_BasalTest.kt | 12 +- ...Packet_Basal_Set_Profile_Basal_RateTest.kt | 12 +- ...aRS_Packet_Basal_Set_Profile_NumberTest.kt | 12 +- ...DanaRS_Packet_Basal_Set_Suspend_OffTest.kt | 12 +- .../DanaRS_Packet_Basal_Set_Suspend_OnTest.kt | 12 +- ...RS_Packet_Basal_Set_Temporary_BasalTest.kt | 13 +- ...anaRS_Packet_Bolus_Get_Bolus_OptionTest.kt | 15 +- ...anaRS_Packet_Bolus_Get_CIR_CF_ArrayTest.kt | 15 +- ...t_Bolus_Get_Calculation_InformationTest.kt | 13 +- ...arbohydrate_Calculation_InformationTest.kt | 13 +- .../DanaRS_Packet_Bolus_Get_Dual_BolusTest.kt | 15 +- ...aRS_Packet_Bolus_Get_Extended_BolusTest.kt | 13 +- ...cket_Bolus_Get_Extended_Bolus_StateTest.kt | 13 +- ...olus_Get_Extended_Menu_Option_StateTest.kt | 15 +- ...naRS_Packet_Bolus_Get_Initial_BolusTest.kt | 14 +- ...et_Bolus_Get_Step_Bolus_InformationTest.kt | 13 +- ...anaRS_Packet_Bolus_Set_Bolus_OptionTest.kt | 14 +- ...anaRS_Packet_Bolus_Set_CIR_CF_ArrayTest.kt | 14 +- .../DanaRS_Packet_Bolus_Set_Dual_BolusTest.kt | 14 +- ...aRS_Packet_Bolus_Set_Extended_BolusTest.kt | 14 +- ...ket_Bolus_Set_Extended_Bolus_CancelTest.kt | 14 +- ...naRS_Packet_Bolus_Set_Initial_BolusTest.kt | 14 +- ...S_Packet_Bolus_Set_Step_Bolus_StartTest.kt | 13 +- ...RS_Packet_Bolus_Set_Step_Bolus_StopTest.kt | 14 +- .../DanaRS_Packet_Etc_Keep_ConnectionTest.kt | 14 +- .../DanaRS_Packet_Etc_Set_History_SaveTest.kt | 12 +- ...naRS_Packet_General_Delivery_StatusTest.kt | 12 +- ...Packet_General_Get_More_InformationTest.kt | 15 +- .../DanaRS_Packet_General_Get_PasswordTest.kt | 17 +- ...anaRS_Packet_General_Get_Pump_CheckTest.kt | 17 +- ...et_General_Get_Shipping_InformationTest.kt | 15 +- ...Packet_General_Get_Shipping_VerisonTest.kt | 13 +- ...et_General_Get_Today_Delivery_TotalTest.kt | 17 +- ...t_General_Get_User_Time_Change_FlagTest.kt | 16 +- ..._General_Initial_Screen_InformationTest.kt | 17 +- ...ket_General_Set_History_Upload_ModeTest.kt | 14 +- ...ral_Set_User_Time_Change_Flag_ClearTest.kt | 14 +- .../comm/DanaRS_Packet_History_AlarmTest.kt | 13 +- .../DanaRS_Packet_History_All_HistoryTest.kt | 15 +- .../comm/DanaRS_Packet_History_BasalTest.kt | 15 +- ...DanaRS_Packet_History_Blood_GlucoseTest.kt | 15 +- .../comm/DanaRS_Packet_History_BolusTest.kt | 15 +- .../DanaRS_Packet_History_CarbohydrateTest.kt | 15 +- .../comm/DanaRS_Packet_History_DailyTest.kt | 15 +- .../comm/DanaRS_Packet_History_PrimeTest.kt | 15 +- .../comm/DanaRS_Packet_History_RefillTest.kt | 15 +- .../comm/DanaRS_Packet_History_SuspendTest.kt | 15 +- .../DanaRS_Packet_History_TemporaryTest.kt | 15 +- .../comm/DanaRS_Packet_Notify_AlarmTest.kt | 14 +- ...aRS_Packet_Notify_Delivery_CompleteTest.kt | 14 +- ...Packet_Notify_Delivery_Rate_DisplayTest.kt | 14 +- ...RS_Packet_Notify_Missed_Bolus_AlarmTest.kt | 14 +- .../DanaRS_Packet_Option_Get_Pump_TimeTest.kt | 13 +- ...anaRS_Packet_Option_Get_User_OptionTest.kt | 15 +- .../DanaRS_Packet_Option_Set_Pump_TimeTest.kt | 14 +- ...anaRS_Packet_Option_Set_User_OptionTest.kt | 15 +- .../DanaRS_Packet_Review_Bolus_AvgTest.kt | 12 +- ...RS_Packet_Review_Get_Pump_Dec_RatioTest.kt | 15 +- 140 files changed, 1396 insertions(+), 646 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/dependencyInjection/DanaRSCommModule.kt diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt index 6d334aa3d4..44fdc075f7 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt @@ -74,7 +74,7 @@ import info.nightscout.androidaps.utils.wizard.BolusWizard import info.nightscout.androidaps.utils.wizard.QuickWizardEntry import javax.inject.Singleton -@Module(includes = [AppModule.AppBindings::class, PluginsModule::class]) +@Module(includes = [AppModule.AppBindings::class, PluginsModule::class, DanaRSCommModule::class]) open class AppModule { @Provides diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/DanaRSCommModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/DanaRSCommModule.kt new file mode 100644 index 0000000000..fa915f8246 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/DanaRSCommModule.kt @@ -0,0 +1,79 @@ +package info.nightscout.androidaps.dependencyInjection + +import dagger.Module +import dagger.android.ContributesAndroidInjector +import info.nightscout.androidaps.plugins.pump.danaRS.comm.* + +@Module +@Suppress("unused") +abstract class DanaRSCommModule { + + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet(): DanaRS_Packet + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(): DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Get_Basal_Rate(): DanaRS_Packet_Basal_Get_Basal_Rate + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Get_Profile_Basal_Rate(): DanaRS_Packet_Basal_Get_Profile_Basal_Rate + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Get_Profile_Number(): DanaRS_Packet_Basal_Get_Profile_Number + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Basal_Rate(): DanaRS_Packet_Basal_Set_Basal_Rate + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Profile_Basal_Rate(): DanaRS_Packet_Basal_Set_Profile_Basal_Rate + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Profile_Number(): DanaRS_Packet_Basal_Set_Profile_Number + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Suspend_Off(): DanaRS_Packet_Basal_Set_Suspend_Off + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Suspend_On(): DanaRS_Packet_Basal_Set_Suspend_On + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Temporary_Basal(): DanaRS_Packet_Basal_Set_Temporary_Basal + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Get_Temporary_Basal_State(): DanaRS_Packet_Basal_Get_Temporary_Basal_State + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Bolus_Option(): DanaRS_Packet_Bolus_Get_Bolus_Option + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Initial_Bolus(): DanaRS_Packet_Bolus_Get_Initial_Bolus + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Calculation_Information(): DanaRS_Packet_Bolus_Get_Calculation_Information + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(): DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_CIR_CF_Array(): DanaRS_Packet_Bolus_Get_CIR_CF_Array + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Dual_Bolus(): DanaRS_Packet_Bolus_Get_Dual_Bolus + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Extended_Bolus(): DanaRS_Packet_Bolus_Get_Extended_Bolus + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Extended_Bolus_State(): DanaRS_Packet_Bolus_Get_Extended_Bolus_State + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(): DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Step_Bolus_Information(): DanaRS_Packet_Bolus_Get_Step_Bolus_Information + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Bolus_Option(): DanaRS_Packet_Bolus_Set_Bolus_Option + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Initial_Bolus(): DanaRS_Packet_Bolus_Set_Initial_Bolus + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_CIR_CF_Array(): DanaRS_Packet_Bolus_Set_CIR_CF_Array + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Dual_Bolus(): DanaRS_Packet_Bolus_Set_Dual_Bolus + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Extended_Bolus(): DanaRS_Packet_Bolus_Set_Extended_Bolus + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(): DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Step_Bolus_Start(): DanaRS_Packet_Bolus_Set_Step_Bolus_Start + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Step_Bolus_Stop(): DanaRS_Packet_Bolus_Set_Step_Bolus_Stop + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Etc_Keep_Connection(): DanaRS_Packet_Etc_Keep_Connection + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Etc_Set_History_Save(): DanaRS_Packet_Etc_Set_History_Save + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Delivery_Status(): DanaRS_Packet_General_Delivery_Status + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Password(): DanaRS_Packet_General_Get_Password + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Initial_Screen_Information(): DanaRS_Packet_General_Initial_Screen_Information + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Notify_Alarm(): DanaRS_Packet_Notify_Alarm + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Notify_Delivery_Complete(): DanaRS_Packet_Notify_Delivery_Complete + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Notify_Delivery_Rate_Display(): DanaRS_Packet_Notify_Delivery_Rate_Display + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Notify_Missed_Bolus_Alarm(): DanaRS_Packet_Notify_Missed_Bolus_Alarm + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Get_Pump_Time(): DanaRS_Packet_Option_Get_Pump_Time + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Get_User_Option(): DanaRS_Packet_Option_Get_User_Option + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Set_Pump_Time(): DanaRS_Packet_Option_Set_Pump_Time + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Set_User_Option(): DanaRS_Packet_Option_Set_User_Option + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_(): DanaRS_Packet_History_ + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Alarm(): DanaRS_Packet_History_Alarm + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_All_History(): DanaRS_Packet_History_All_History + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Basal(): DanaRS_Packet_History_Basal + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Blood_Glucose(): DanaRS_Packet_History_Blood_Glucose + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Bolus(): DanaRS_Packet_History_Bolus + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Review_Bolus_Avg(): DanaRS_Packet_Review_Bolus_Avg + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Carbohydrate(): DanaRS_Packet_History_Carbohydrate + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Daily(): DanaRS_Packet_History_Daily + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_More_Information(): DanaRS_Packet_General_Get_More_Information + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Pump_Check(): DanaRS_Packet_General_Get_Pump_Check + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Shipping_Information(): DanaRS_Packet_General_Get_Shipping_Information + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Today_Delivery_Total(): DanaRS_Packet_General_Get_Today_Delivery_Total + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_User_Time_Change_Flag(): DanaRS_Packet_General_Get_User_Time_Change_Flag + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Prime(): DanaRS_Packet_History_Prime + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Refill(): DanaRS_Packet_History_Refill + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Set_History_Upload_Mode(): DanaRS_Packet_General_Set_History_Upload_Mode + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(): DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Suspend(): DanaRS_Packet_History_Suspend + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Temporary(): DanaRS_Packet_History_Temporary + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_APS_Basal_Set_Temporary_Basal(): DanaRS_Packet_APS_Basal_Set_Temporary_Basal + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_APS_History_Events(): DanaRS_Packet_APS_History_Events + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_APS_Set_Event_History(): DanaRS_Packet_APS_Set_Event_History + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Shipping_Version(): DanaRS_Packet_General_Get_Shipping_Version + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Review_Get_Pump_Dec_Ratio(): DanaRS_Packet_Review_Get_Pump_Dec_Ratio +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt index cb6cbcee17..fea80dc506 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt @@ -1,29 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.interfaces.ActivePluginProvider -import info.nightscout.androidaps.logging.AAPSLogger -import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage -import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump -import info.nightscout.androidaps.utils.resources.ResourceHelper -import info.nightscout.androidaps.utils.sharedPreferences.SP import java.util.* import javax.inject.Inject import javax.inject.Singleton @Singleton class DanaRSMessageHashTable @Inject constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, - resourceHelper: ResourceHelper, - danaRPump: DanaRPump, - activePlugin: ActivePluginProvider, - constraintChecker: ConstraintChecker, - detailedBolusInfoStorage: DetailedBolusInfoStorage, - sp: SP, - injector: HasAndroidInjector + val injector: HasAndroidInjector ) { var messages: HashMap = HashMap() @@ -33,78 +17,78 @@ class DanaRSMessageHashTable @Inject constructor( } fun findMessage(command: Int): DanaRS_Packet { - return messages[command] ?: DanaRS_Packet() + return messages[command] ?: DanaRS_Packet(injector) } init { - put(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)) - put(DanaRS_Packet_Basal_Get_Basal_Rate(aapsLogger, rxBus, resourceHelper, danaRPump)) - put(DanaRS_Packet_Basal_Get_Profile_Basal_Rate(aapsLogger, danaRPump)) - put(DanaRS_Packet_Basal_Get_Profile_Number(aapsLogger, danaRPump)) - put(DanaRS_Packet_Basal_Set_Basal_Rate(aapsLogger, arrayOf())) - put(DanaRS_Packet_Basal_Set_Profile_Basal_Rate(aapsLogger, 0, arrayOf())) - put(DanaRS_Packet_Basal_Set_Profile_Number(aapsLogger)) - put(DanaRS_Packet_Basal_Set_Suspend_Off(aapsLogger)) - put(DanaRS_Packet_Basal_Set_Suspend_On(aapsLogger)) - put(DanaRS_Packet_Basal_Set_Temporary_Basal(aapsLogger)) - put(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Bolus_Option(aapsLogger, rxBus, resourceHelper, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Initial_Bolus(aapsLogger)) - put(DanaRS_Packet_Bolus_Get_Calculation_Information(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_CIR_CF_Array(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Dual_Bolus(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Extended_Bolus(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Set_Bolus_Option(aapsLogger)) - put(DanaRS_Packet_Bolus_Set_Initial_Bolus(aapsLogger)) - put(DanaRS_Packet_Bolus_Set_CIR_CF_Array(aapsLogger)) - put(DanaRS_Packet_Bolus_Set_Dual_Bolus(aapsLogger)) - put(DanaRS_Packet_Bolus_Set_Extended_Bolus(aapsLogger)) - put(DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(aapsLogger)) - put(DanaRS_Packet_Bolus_Set_Step_Bolus_Start(aapsLogger, danaRPump, constraintChecker)) - put(DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(aapsLogger, rxBus, resourceHelper, danaRPump)) - put(DanaRS_Packet_Etc_Keep_Connection(aapsLogger)) - put(DanaRS_Packet_Etc_Set_History_Save(aapsLogger)) - put(DanaRS_Packet_General_Delivery_Status(aapsLogger)) - put(DanaRS_Packet_General_Get_Password(aapsLogger, danaRPump)) - put(DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump)) - put(DanaRS_Packet_Notify_Alarm(aapsLogger, resourceHelper, rxBus)) - put(DanaRS_Packet_Notify_Delivery_Complete(aapsLogger, rxBus, resourceHelper, danaRPump)) - put(DanaRS_Packet_Notify_Delivery_Rate_Display(aapsLogger, rxBus, resourceHelper, danaRPump)) - put(DanaRS_Packet_Notify_Missed_Bolus_Alarm(aapsLogger)) - put(DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)) - put(DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump)) - put(DanaRS_Packet_Option_Set_Pump_Time(aapsLogger)) - put(DanaRS_Packet_Option_Set_User_Option(aapsLogger, danaRPump)) - //put(new DanaRS_Packet_History_()); - put(DanaRS_Packet_History_Alarm(aapsLogger, rxBus)) - put(DanaRS_Packet_History_All_History(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Basal(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Bolus(aapsLogger, rxBus)) - put(DanaRS_Packet_Review_Bolus_Avg(aapsLogger)) - put(DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Daily(aapsLogger, rxBus)) - put(DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump)) - put(DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)) - put(DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump)) - put(DanaRS_Packet_General_Get_Today_Delivery_Total(aapsLogger, danaRPump)) - put(DanaRS_Packet_General_Get_User_Time_Change_Flag(aapsLogger)) - put(DanaRS_Packet_History_Prime(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Refill(aapsLogger, rxBus)) - put(DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger)) - put(DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(aapsLogger)) - put(DanaRS_Packet_History_Suspend(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Temporary(aapsLogger, rxBus)) + put(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector)) + put(DanaRS_Packet_Basal_Get_Basal_Rate(injector)) + put(DanaRS_Packet_Basal_Get_Profile_Basal_Rate(injector)) + put(DanaRS_Packet_Basal_Get_Profile_Number(injector)) + put(DanaRS_Packet_Basal_Set_Basal_Rate(injector, arrayOf())) + put(DanaRS_Packet_Basal_Set_Profile_Basal_Rate(injector, 0, arrayOf())) + put(DanaRS_Packet_Basal_Set_Profile_Number(injector)) + put(DanaRS_Packet_Basal_Set_Suspend_Off(injector)) + put(DanaRS_Packet_Basal_Set_Suspend_On(injector)) + put(DanaRS_Packet_Basal_Set_Temporary_Basal(injector)) + put(DanaRS_Packet_Basal_Get_Temporary_Basal_State(injector)) + put(DanaRS_Packet_Bolus_Get_Bolus_Option(injector)) + put(DanaRS_Packet_Bolus_Get_Initial_Bolus(injector)) + put(DanaRS_Packet_Bolus_Get_Calculation_Information(injector)) + put(DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(injector)) + put(DanaRS_Packet_Bolus_Get_CIR_CF_Array(injector)) + put(DanaRS_Packet_Bolus_Get_Dual_Bolus(injector)) + put(DanaRS_Packet_Bolus_Get_Extended_Bolus(injector)) + put(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(injector)) + put(DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(injector)) + put(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(injector)) + put(DanaRS_Packet_Bolus_Set_Bolus_Option(injector)) + put(DanaRS_Packet_Bolus_Set_Initial_Bolus(injector)) + put(DanaRS_Packet_Bolus_Set_CIR_CF_Array(injector)) + put(DanaRS_Packet_Bolus_Set_Dual_Bolus(injector)) + put(DanaRS_Packet_Bolus_Set_Extended_Bolus(injector)) + put(DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(injector)) + put(DanaRS_Packet_Bolus_Set_Step_Bolus_Start(injector)) + put(DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(injector)) + put(DanaRS_Packet_Etc_Keep_Connection(injector)) + put(DanaRS_Packet_Etc_Set_History_Save(injector)) + put(DanaRS_Packet_General_Delivery_Status(injector)) + put(DanaRS_Packet_General_Get_Password(injector)) + put(DanaRS_Packet_General_Initial_Screen_Information(injector)) + put(DanaRS_Packet_Notify_Alarm(injector)) + put(DanaRS_Packet_Notify_Delivery_Complete(injector)) + put(DanaRS_Packet_Notify_Delivery_Rate_Display(injector)) + put(DanaRS_Packet_Notify_Missed_Bolus_Alarm(injector)) + put(DanaRS_Packet_Option_Get_Pump_Time(injector)) + put(DanaRS_Packet_Option_Get_User_Option(injector)) + put(DanaRS_Packet_Option_Set_Pump_Time(injector)) + put(DanaRS_Packet_Option_Set_User_Option(injector)) + //put(new DanaRS_Packet_History_(injector)); + put(DanaRS_Packet_History_Alarm(injector)) + put(DanaRS_Packet_History_All_History(injector)) + put(DanaRS_Packet_History_Basal(injector)) + put(DanaRS_Packet_History_Blood_Glucose(injector)) + put(DanaRS_Packet_History_Bolus(injector)) + put(DanaRS_Packet_Review_Bolus_Avg(injector)) + put(DanaRS_Packet_History_Carbohydrate(injector)) + put(DanaRS_Packet_History_Daily(injector)) + put(DanaRS_Packet_General_Get_More_Information(injector)) + put(DanaRS_Packet_General_Get_Pump_Check(injector)) + put(DanaRS_Packet_General_Get_Shipping_Information(injector)) + put(DanaRS_Packet_General_Get_Today_Delivery_Total(injector)) + put(DanaRS_Packet_General_Get_User_Time_Change_Flag(injector)) + put(DanaRS_Packet_History_Prime(injector)) + put(DanaRS_Packet_History_Refill(injector)) + put(DanaRS_Packet_General_Set_History_Upload_Mode(injector)) + put(DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(injector)) + put(DanaRS_Packet_History_Suspend(injector)) + put(DanaRS_Packet_History_Temporary(injector)) // APS - put(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 0)) - put(DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, sp, injector, 0)) - put(DanaRS_Packet_APS_Set_Event_History(aapsLogger, 0, 0, 0, 0)) + put(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(injector, 0)) + put(DanaRS_Packet_APS_History_Events(injector, 0)) + put(DanaRS_Packet_APS_Set_Event_History(injector, 0, 0, 0, 0)) // v3 - put(DanaRS_Packet_General_Get_Shipping_Version(aapsLogger, danaRPump)) - put(DanaRS_Packet_Review_Get_Pump_Dec_Ratio(aapsLogger, danaRPump)) + put(DanaRS_Packet_General_Get_Shipping_Version(injector)) + put(DanaRS_Packet_Review_Get_Pump_Dec_Ratio(injector)) } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java index 9bb70720fb..275ba6f145 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java @@ -3,16 +3,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm; import android.annotation.TargetApi; import android.os.Build; +import dagger.android.HasAndroidInjector; +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.logging.AAPSLogger; +import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption; + import org.slf4j.Logger; import java.nio.charset.StandardCharsets; import java.util.Date; +import javax.inject.Inject; + import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; public class DanaRS_Packet { - private static final Logger log = StacktraceLoggerWrapper.getLogger(DanaRS_Packet.class); + + @Inject AAPSLogger aapsLogger; + + protected HasAndroidInjector injector; protected static final int TYPE_START = 0; protected static final int OPCODE_START = 1; @@ -23,9 +33,11 @@ public class DanaRS_Packet { protected int type = BleEncryption.DANAR_PACKET__TYPE_RESPONSE; // most of the messages, should be changed for others protected int opCode; - public DanaRS_Packet() { + public DanaRS_Packet(HasAndroidInjector injector) { received = false; failed = false; + this.injector = injector; + injector.androidInjector().inject(this); } public void setReceived() { @@ -54,7 +66,7 @@ public class DanaRS_Packet { // STATIC FUNCTIONS - public static int getCommand(byte[] data) { + public int getCommand(byte[] data) { int type = byteArrayToInt(getBytes(data, TYPE_START, 1)); int opCode = byteArrayToInt(getBytes(data, OPCODE_START, 1)); return ((type & 0xFF) << 8) + (opCode & 0xFF); @@ -70,7 +82,7 @@ public class DanaRS_Packet { return "UNKNOWN_PACKET"; } - protected static byte[] getBytes(byte[] data, int srcStart, int srcLength) { + protected byte[] getBytes(byte[] data, int srcStart, int srcLength) { try { byte[] ret = new byte[srcLength]; @@ -78,7 +90,7 @@ public class DanaRS_Packet { return ret; } catch (Exception e) { - log.error("Unhandled exception", e); + aapsLogger.error(LTag.PUMPBTCOMM, "Unhandled exception", e); } return null; } @@ -148,7 +160,7 @@ public class DanaRS_Packet { return new String(strbuff, StandardCharsets.UTF_8); } - public static long dateFromBuff(byte[] buff, int offset) { + public long dateFromBuff(byte[] buff, int offset) { return new Date( 100 + byteArrayToInt(getBytes(buff, offset, 1)), @@ -159,7 +171,7 @@ public class DanaRS_Packet { @TargetApi(Build.VERSION_CODES.KITKAT) - public static String asciiStringFromBuff(byte[] buff, int offset, int length) { + public String asciiStringFromBuff(byte[] buff, int offset, int length) { byte[] strbuff = new byte[length]; System.arraycopy(buff, offset, strbuff, 0, length); for (int pos = 0; pos < length; pos++) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt index 89a2c3fac3..bfcfeac676 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt @@ -1,13 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_APS_Basal_Set_Temporary_Basal( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var percent: Int -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { var temporaryBasalRatio = 0 var temporaryBasalDuration = 0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt index 5ca6eac5a2..14da2a9b8e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt @@ -10,7 +10,6 @@ import info.nightscout.androidaps.db.TemporaryBasal import info.nightscout.androidaps.dialogs.FillDialog import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.interfaces.ActivePluginProvider -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.bolusInfo.DetailedBolusInfoStorage @@ -20,18 +19,19 @@ import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import java.util.* +import javax.inject.Inject open class DanaRS_Packet_APS_History_Events( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, - private val resourceHelper: ResourceHelper, - private val activePlugin: ActivePluginProvider, - private val danaRPump: DanaRPump, - private val detailedBolusInfoStorage: DetailedBolusInfoStorage, - private val sp: SP, - private val injector: HasAndroidInjector, + injector: HasAndroidInjector, private var from: Long -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { + + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var activePlugin: ActivePluginProvider + @Inject lateinit var danaRPump: DanaRPump + @Inject lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage + @Inject lateinit var sp: SP private var year = 0 private var month = 0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt index 861854d77b..7f6c1e342f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt @@ -1,19 +1,19 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil import java.util.* class DanaRS_Packet_APS_Set_Event_History( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var packetType: Int, private var time: Long, private var param1: Int, private var param2: Int -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt index 8cdbbe2d65..b25bc2c587 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt @@ -1,23 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* +import javax.inject.Inject class DanaRS_Packet_Basal_Get_Basal_Rate( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, - private val resourceHelper: ResourceHelper, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__GET_BASAL_RATE @@ -31,7 +33,7 @@ class DanaRS_Packet_Basal_Get_Basal_Rate( dataIndex += dataSize dataSize = 1 danaRPump.basalStep = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - danaRPump.pumpProfiles = Array(4) {Array(48) {0.0} } + danaRPump.pumpProfiles = Array(4) { Array(48) { 0.0 } } var i = 0 val size = 24 while (i < size) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt index 9b0de5603c..bbac168239 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt @@ -1,16 +1,18 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import java.util.* +import javax.inject.Inject open class DanaRS_Packet_Basal_Get_Profile_Basal_Rate( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump, + injector: HasAndroidInjector, private val profileNumber: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_BASAL_RATE @@ -26,7 +28,7 @@ open class DanaRS_Packet_Basal_Get_Profile_Basal_Rate( override fun handleMessage(data: ByteArray) { var dataIndex = DATA_START var dataSize = 2 - danaRPump.pumpProfiles = Array(4) {Array(48) {0.0} } + danaRPump.pumpProfiles = Array(4) { Array(48) { 0.0 } } var i = 0 val size = 24 while (i < size) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt index bdd586e948..c973a5aa11 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Basal_Get_Profile_Number( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_NUMBER diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt index bb5f0d8d98..709438d8df 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt @@ -1,16 +1,18 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil +import javax.inject.Inject import kotlin.math.ceil class DanaRS_Packet_Basal_Get_Temporary_Basal_State( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__TEMPORARY_BASAL_STATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt index 28d7b6b693..f16bc7c0cf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt @@ -1,13 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Basal_Set_Basal_Rate( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var profileBasalRate: Array -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt index c30b938002..c7fa4c3536 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt index 189a704e0c..ddf0adba78 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt @@ -1,14 +1,14 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Basal_Set_Profile_Basal_Rate( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var profileNumber: Int, private var profileBasalRate: Array -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_BASAL_RATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt index 2056889532..7c0994196b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt @@ -1,13 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Basal_Set_Profile_Number( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var profileNumber: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_NUMBER diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt index eff81eb0bb..3608ee30ca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Basal_Set_Suspend_Off( - private val aapsLogger: AAPSLogger - ) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_OFF diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt index e3a3f9d228..df5bee1aac 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Basal_Set_Suspend_On( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_ON diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt index f4318fb0b3..cbd91aa051 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt @@ -1,14 +1,14 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption open class DanaRS_Packet_Basal_Set_Temporary_Basal( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var temporaryBasalRatio: Int = 0, private var temporaryBasalDuration: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_TEMPORARY_BASAL diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt index 8918094938..432f0792dd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt @@ -1,23 +1,24 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Bolus_Option( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, - private val resourceHelper: ResourceHelper, - private val danaRPump: DanaRPump + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { -) : DanaRS_Packet() { + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_OPTION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt index d981da5033..4af5c48fac 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_CIR_CF_Array( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_CIR_CF_ARRAY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt index 6c19045a2f..8f618bce4f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt @@ -1,15 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Calculation_Information( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_CALCULATION_INFORMATION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt index c1bd0aeb40..ad7a5de3b7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_CARBOHYDRATE_CALCULATION_INFORMATION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt index 97d40dd0af..8334d04028 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Dual_Bolus( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_DUAL_BOLUS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt index 9d96debe56..4795b08482 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Extended_Bolus( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt index ef24b5cec1..ecf337987e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Extended_Bolus_State( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS_STATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt index cd16a68bb7..001107cfa2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_MENU_OPTION_STATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt index 50f5864e81..c301490a9f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Get_Initial_Bolus( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_RATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt index dca14ce099..6a90788340 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt @@ -1,17 +1,18 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil import org.joda.time.DateTime -import java.util.* +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Step_Bolus_Information( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_STEP_BOLUS_INFORMATION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt index 21d9b39d56..ebf19f1459 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt @@ -1,11 +1,11 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Set_Bolus_Option( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var extendedBolusOptionOnOff: Int = 0, private var bolusCalculationOption: Int = 0, private var missedBolusConfig: Int = 0, @@ -26,7 +26,7 @@ class DanaRS_Packet_Bolus_Set_Bolus_Option( private var missedBolus04EndHour: Int = 0, private var missedBolus04EndMin: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_OPTION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt index 137c1633b6..cf2bfa44d1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt @@ -1,11 +1,11 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Set_CIR_CF_Array( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var cir01: Int = 0, private var cir02: Int = 0, private var cir03: Int = 0, @@ -20,7 +20,7 @@ class DanaRS_Packet_Bolus_Set_CIR_CF_Array( private var cf05: Int = 0, private var cf06: Int = 0, private var cf07: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_CIR_CF_ARRAY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt index 919039319b..d9c18cb839 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt @@ -1,16 +1,15 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Set_Dual_Bolus( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var amount: Double = 0.0, private var extendedAmount: Double = 0.0, private var extendedBolusDurationInHalfHours: Int = 0 -) : DanaRS_Packet() { - +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_DUAL_BOLUS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt index 222152c2a8..095f9f5080 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt @@ -1,15 +1,14 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Set_Extended_Bolus( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var extendedAmount: Double = 0.0, private var extendedBolusDurationInHalfHours: Int = 0 -) : DanaRS_Packet() { - +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt index 868dd5f7b6..4b36940aaf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS_CANCEL diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt index eecd43c6ca..0229c9434c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt @@ -1,16 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Set_Initial_Bolus( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var bolusRate01: Int = 0, private var bolusRate02: Int = 0, private var bolusRate03: Int = 0, private var bolusRate04: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_RATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt index d9dc8f0d95..9dfc6016c7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt @@ -1,20 +1,21 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.Constraint -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Set_Step_Bolus_Start( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump, - constraintChecker: ConstraintChecker, + injector: HasAndroidInjector, private var amount: Double = 0.0, private var speed: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { + @Inject lateinit var danaRPump: DanaRPump + @Inject lateinit var constraintChecker: ConstraintChecker init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_START diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt index c5c1ace3b4..cf42e445ee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt @@ -1,21 +1,22 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject open class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, - private val resourceHelper: ResourceHelper, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_STOP diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt index 1038881c2e..89ae76b68e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Etc_Keep_Connection( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt index ae1fac6bff..2859aa8496 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt @@ -1,11 +1,11 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Etc_Set_History_Save( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var historyType: Int = 0, private var historyYear: Int = 0, private var historyMonth: Int = 0, @@ -15,8 +15,7 @@ class DanaRS_Packet_Etc_Set_History_Save( private var historySecond: Int = 0, private var historyCode: Int = 0, private var historyValue: Int = 0 -) : DanaRS_Packet() { - +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_ETC__SET_HISTORY_SAVE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt index 21937923fc..eb71b50be1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_General_Delivery_Status( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__DELIVERY_STATUS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt index eb7d617d3b..2d0dee2c53 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt @@ -1,16 +1,18 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil import org.joda.time.DateTime +import javax.inject.Inject class DanaRS_Packet_General_Get_More_Information( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_MORE_INFORMATION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt index 58cdf77ae9..dcbbb54136 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_General_Get_Password( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_PASSWORD diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt index be57043e89..dc942cdfe9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification @@ -9,13 +9,15 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject class DanaRS_Packet_General_Get_Pump_Check( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump, - private val rxBus: RxBusWrapper, - private val resourceHelper: ResourceHelper -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_PUMP_CHECK diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt index 6bf3296af1..99eed59d76 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt @@ -1,15 +1,17 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil +import javax.inject.Inject class DanaRS_Packet_General_Get_Shipping_Information( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_SHIPPING_INFORMATION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt index 9d3d83fbf4..e13912f666 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt @@ -1,15 +1,17 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import java.nio.charset.Charset +import javax.inject.Inject class DanaRS_Packet_General_Get_Shipping_Version( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_GENERAL__GET_SHIPPING_VERSION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt index fe9c676ca9..2075528d8a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_General_Get_Today_Delivery_Total( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_TODAY_DELIVERY_TOTAL diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt index 45e68600d7..6ff8fa6231 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_General_Get_User_Time_Change_Flag( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_USER_TIME_CHANGE_FLAG diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt index 0510c28271..586577be09 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_General_Initial_Screen_Information( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__INITIAL_SCREEN_INFORMATION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt index e26e13e6f0..969dd36c87 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt @@ -1,13 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_General_Set_History_Upload_Mode( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var mode: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SET_HISTORY_UPLOAD_MODE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt index 969f226fb0..4190545f99 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt @@ -1,17 +1,18 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR aapsLogger.debug(LTag.PUMPCOMM, "New message") } + override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) if (result == 0) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt index 4273f6ca0d..00b00a0fc0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt @@ -1,8 +1,8 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.db.DanaRHistoryRecord -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.danaR.comm.RecordTypes @@ -10,12 +10,14 @@ import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus import info.nightscout.androidaps.utils.DateUtil import org.joda.time.DateTime import java.util.* +import javax.inject.Inject abstract class DanaRS_Packet_History_( - protected val aapsLogger: AAPSLogger, - protected val rxBus: RxBusWrapper, + injector: HasAndroidInjector, protected val from: Long -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { + + @Inject lateinit var rxBus: RxBusWrapper protected var year = 0 protected var month = 0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt index bcf3ffc1df..eef5b0bac1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Alarm @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__ALARM diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt index 2b42507888..298d0005c9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_All_History( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt index 09173ed5c1..afd2469f64 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Basal @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BASAL diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt index 7f07e71680..eda50d6749 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Blood_Glucose @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt index d6f8b51707..6970681afb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Bolus @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BOLUS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt index ed3b49a8d7..2ddeae6a9a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Carbohydrate @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt index 645cab8272..4ce5d88af5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Daily @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__DAILY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt index da209b0a8a..93dd90576f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Prime @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__PRIME diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt index 8b470a0170..adeff980df 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Refill @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__REFILL diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt index 2e5ad23dd9..614b728971 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt @@ -1,15 +1,15 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper class DanaRS_Packet_History_Suspend @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SUSPEND diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt index 5689ca82c5..045457a699 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Temporary( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt index f461c65f3c..de92b18367 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt @@ -1,20 +1,22 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject class DanaRS_Packet_Notify_Alarm( - private val aapsLogger: AAPSLogger, - private val resourceHelper: ResourceHelper, - private val rxBus: RxBusWrapper -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper init { type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt index c4e5d5a06d..fd059dfe57 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt @@ -1,21 +1,23 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject import kotlin.math.min class DanaRS_Packet_Notify_Delivery_Complete( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, - private val resourceHelper: ResourceHelper, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var danaRPump: DanaRPump init { type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt index 0a256ed088..27d6c011a8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt @@ -1,22 +1,23 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject import kotlin.math.min class DanaRS_Packet_Notify_Delivery_Rate_Display( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, - private val resourceHelper: ResourceHelper, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var danaRPump: DanaRPump init { type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt index f15582f3d0..afe2599866 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Notify_Missed_Bolus_Alarm( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt index 4db309afe0..e6bca23320 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt @@ -1,16 +1,18 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil import org.joda.time.DateTime +import javax.inject.Inject class DanaRS_Packet_Option_Get_Pump_Time( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__GET_PUMP_TIME diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt index a012b1302b..6e44cdace8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Option_Get_User_Option( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__GET_USER_OPTION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt index 73cf49c6df..d6bb703beb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt @@ -1,15 +1,15 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil import org.joda.time.DateTime class DanaRS_Packet_Option_Set_Pump_Time( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var time: Long = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { var error = 0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt index d266bf765b..01ca99c2e5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt @@ -1,15 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Option_Set_User_Option( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__SET_USER_OPTION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt index ee953d8581..04751087eb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Review_Bolus_Avg( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BOLUS_AVG diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt index 23d903de0b..182f58c3fe 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Review_Get_Pump_Dec_Ratio( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_PUMP_DEC_RATIO diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt index e46aff33d7..255a86d1f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt @@ -5,6 +5,7 @@ import android.content.Context import android.content.Intent import android.os.SystemClock import android.util.Base64 +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.logging.AAPSLogger @@ -33,6 +34,7 @@ import javax.inject.Singleton @Singleton class BLEComm @Inject internal constructor( + private val injector: HasAndroidInjector, private val aapsLogger: AAPSLogger, private val resourceHelper: ResourceHelper, private val context: Context, @@ -695,7 +697,7 @@ class BLEComm @Inject internal constructor( // process common packet response private fun processMessage(decryptedBuffer: ByteArray) { val originalCommand = processedMessage?.command ?: 0xFFFF - val receivedCommand = DanaRS_Packet.getCommand(decryptedBuffer) + val receivedCommand = DanaRS_Packet(injector).getCommand(decryptedBuffer) val message: DanaRS_Packet? = if (originalCommand == receivedCommand) { // it's response to last message processedMessage diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt index 3d8a5c6a40..9c2e37214e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt @@ -112,25 +112,25 @@ class DanaRSService : DaggerService() { fun readPumpStatus() { try { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpstatus))) - sendMessage(DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_General_Initial_Screen_Information(injector)) rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingextendedbolusstatus))) - sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(injector)) rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus))) - sendMessage(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)) // last bolus, bolusStep, maxBolus + sendMessage(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(injector)) // last bolus, bolusStep, maxBolus rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingtempbasalstatus))) - sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(injector)) danaRPump.lastConnection = System.currentTimeMillis() val profile = profileFunction.getProfile() val pump = activePlugin.activePump if (profile != null && abs(danaRPump.currentBasal - profile.basal) >= pump.pumpDescription.basalStep) { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))) - sendMessage(DanaRS_Packet_Basal_Get_Basal_Rate(aapsLogger, rxBus, resourceHelper, danaRPump)) // basal profile, basalStep, maxBasal + sendMessage(DanaRS_Packet_Basal_Get_Basal_Rate(injector)) // basal profile, basalStep, maxBasal if (!pump.isThisProfileSet(profile) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE)) { rxBus.send(EventProfileNeedsUpdate()) } } rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime))) - sendMessage(DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Option_Get_Pump_Time(injector)) var timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L if (danaRPump.pumpTime == 0L) { // initial handshake was not successful @@ -143,14 +143,14 @@ class DanaRSService : DaggerService() { val now = System.currentTimeMillis() if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized) { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))) - sendMessage(DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump)) // serial no - sendMessage(DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)) // firmware - sendMessage(DanaRS_Packet_Basal_Get_Profile_Number(aapsLogger, danaRPump)) - sendMessage(DanaRS_Packet_Bolus_Get_Bolus_Option(aapsLogger, rxBus, resourceHelper, danaRPump)) // isExtendedEnabled - sendMessage(DanaRS_Packet_Basal_Get_Basal_Rate(aapsLogger, rxBus, resourceHelper, danaRPump)) // basal profile, basalStep, maxBasal - sendMessage(DanaRS_Packet_Bolus_Get_Calculation_Information(aapsLogger, danaRPump)) // target - sendMessage(DanaRS_Packet_Bolus_Get_CIR_CF_Array(aapsLogger, danaRPump)) - sendMessage(DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump)) // Getting user options + sendMessage(DanaRS_Packet_General_Get_Shipping_Information(injector)) // serial no + sendMessage(DanaRS_Packet_General_Get_Pump_Check(injector)) // firmware + sendMessage(DanaRS_Packet_Basal_Get_Profile_Number(injector)) + sendMessage(DanaRS_Packet_Bolus_Get_Bolus_Option(injector)) // isExtendedEnabled + sendMessage(DanaRS_Packet_Basal_Get_Basal_Rate(injector)) // basal profile, basalStep, maxBasal + sendMessage(DanaRS_Packet_Bolus_Get_Calculation_Information(injector)) // target + sendMessage(DanaRS_Packet_Bolus_Get_CIR_CF_Array(injector)) + sendMessage(DanaRS_Packet_Option_Get_User_Option(injector)) // Getting user options danaRPump.lastSettingsRead = now } aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds") @@ -172,13 +172,13 @@ class DanaRSService : DaggerService() { return } else { if (danaRPump.protocol >= 6) { - sendMessage(DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, DateUtil.now())) + sendMessage(DanaRS_Packet_Option_Set_Pump_Time(injector, DateUtil.now())) } else { waitForWholeMinute() // Dana can set only whole minute // add 10sec to be sure we are over minute (will be cut off anyway) - sendMessage(DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, DateUtil.now() + T.secs(10).msecs())) + sendMessage(DanaRS_Packet_Option_Set_Pump_Time(injector, DateUtil.now() + T.secs(10).msecs())) } - sendMessage(DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Option_Get_Pump_Time(injector)) timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds") } @@ -211,10 +211,10 @@ class DanaRSService : DaggerService() { SystemClock.sleep(1000) val msg: DanaRS_Packet_APS_History_Events if (lastHistoryFetched == 0L) { - msg = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, sp, injector, 0) + msg = DanaRS_Packet_APS_History_Events(injector, 0) aapsLogger.debug(LTag.PUMPCOMM, "Loading complete event history") } else { - msg = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, sp, injector, lastHistoryFetched) + msg = DanaRS_Packet_APS_History_Events(injector, lastHistoryFetched) aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched)) } sendMessage(msg) @@ -228,7 +228,7 @@ class DanaRSService : DaggerService() { } fun setUserSettings(): PumpEnactResult { - sendMessage(DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Option_Get_User_Option(injector)) return PumpEnactResult(injector).success(true) } @@ -243,11 +243,11 @@ class DanaRSService : DaggerService() { danaRPump.bolusStopped = false danaRPump.bolusStopForced = false danaRPump.bolusProgressLastTimeStamp = DateUtil.now() - val start = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(aapsLogger, danaRPump, constraintChecker, insulin, preferencesSpeed) + val start = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(injector, insulin, preferencesSpeed) if (carbs > 0) { // MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbTime, carbs); #### // sendMessage(msg); - val msgSetHistoryEntryV2 = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, carbTime, carbs, 0) + val msgSetHistoryEntryV2 = DanaRS_Packet_APS_Set_Event_History(injector, DanaRPump.CARBS, carbTime, carbs, 0) sendMessage(msgSetHistoryEntryV2) lastHistoryFetched = min(lastHistoryFetched, carbTime - T.mins(1).msecs()) } @@ -291,7 +291,7 @@ class DanaRSService : DaggerService() { override fun run() { // reread bolus status rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus))) - sendMessage(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)) // last bolus + sendMessage(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(injector)) // last bolus bolusingEvent.percent = 100 rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.disconnecting))) } @@ -301,7 +301,7 @@ class DanaRSService : DaggerService() { fun bolusStop() { aapsLogger.debug(LTag.PUMPCOMM, "bolusStop >>>>> @ " + if (bolusingTreatment == null) "" else bolusingTreatment?.insulin) - val stop = DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(aapsLogger, rxBus, resourceHelper, danaRPump) + val stop = DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(injector) danaRPump.bolusStopForced = true if (isConnected) { sendMessage(stop) @@ -318,13 +318,13 @@ class DanaRSService : DaggerService() { if (!isConnected) return false if (danaRPump.isTempBasalInProgress) { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) - sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)) + sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector)) SystemClock.sleep(500) } rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))) - sendMessage(DanaRS_Packet_Basal_Set_Temporary_Basal(aapsLogger, percent, durationInHours)) + sendMessage(DanaRS_Packet_Basal_Set_Temporary_Basal(injector, percent, durationInHours)) SystemClock.sleep(200) - sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(injector)) loadEvents() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) return true @@ -333,12 +333,12 @@ class DanaRSService : DaggerService() { fun highTempBasal(percent: Int): Boolean { if (danaRPump.isTempBasalInProgress) { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) - sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)) + sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector)) SystemClock.sleep(500) } rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))) - sendMessage(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, percent)) - sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(injector, percent)) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(injector)) loadEvents() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) return true @@ -351,12 +351,12 @@ class DanaRSService : DaggerService() { } if (danaRPump.isTempBasalInProgress) { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) - sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)) + sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector)) SystemClock.sleep(500) } rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))) - sendMessage(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, percent)) - sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(injector, percent)) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(injector)) loadEvents() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) return true @@ -365,8 +365,8 @@ class DanaRSService : DaggerService() { fun tempBasalStop(): Boolean { if (!isConnected) return false rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) - sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)) - sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector)) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(injector)) loadEvents() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) return true @@ -375,9 +375,9 @@ class DanaRSService : DaggerService() { fun extendedBolus(insulin: Double, durationInHalfHours: Int): Boolean { if (!isConnected) return false rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus))) - sendMessage(DanaRS_Packet_Bolus_Set_Extended_Bolus(aapsLogger, insulin, durationInHalfHours)) + sendMessage(DanaRS_Packet_Bolus_Set_Extended_Bolus(injector, insulin, durationInHalfHours)) SystemClock.sleep(200) - sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(injector)) loadEvents() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) return true @@ -386,8 +386,8 @@ class DanaRSService : DaggerService() { fun extendedBolusStop(): Boolean { if (!isConnected) return false rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus))) - sendMessage(DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(aapsLogger)) - sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(injector)) + sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(injector)) loadEvents() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) return true @@ -397,9 +397,9 @@ class DanaRSService : DaggerService() { if (!isConnected) return false rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.updatingbasalrates))) val basal = danaRPump.buildDanaRProfileRecord(profile) - val msgSet = DanaRS_Packet_Basal_Set_Profile_Basal_Rate(aapsLogger, 0, basal) + val msgSet = DanaRS_Packet_Basal_Set_Profile_Basal_Rate(injector, 0, basal) sendMessage(msgSet) - val msgActivate = DanaRS_Packet_Basal_Set_Profile_Number(aapsLogger, 0) + val msgActivate = DanaRS_Packet_Basal_Set_Profile_Number(injector, 0) sendMessage(msgActivate) danaRPump.lastSettingsRead = 0 // force read full settings readPumpStatus() @@ -412,25 +412,25 @@ class DanaRSService : DaggerService() { if (!isConnected) return result var msg: DanaRS_Packet_History_? = null when (type) { - RecordTypes.RECORD_TYPE_ALARM -> msg = DanaRS_Packet_History_Alarm(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_PRIME -> msg = DanaRS_Packet_History_Prime(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_BASALHOUR -> msg = DanaRS_Packet_History_Basal(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_BOLUS -> msg = DanaRS_Packet_History_Bolus(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_CARBO -> msg = DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_DAILY -> msg = DanaRS_Packet_History_Daily(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_GLUCOSE -> msg = DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_REFILL -> msg = DanaRS_Packet_History_Refill(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_SUSPEND -> msg = DanaRS_Packet_History_Suspend(aapsLogger, rxBus) + RecordTypes.RECORD_TYPE_ALARM -> msg = DanaRS_Packet_History_Alarm(injector) + RecordTypes.RECORD_TYPE_PRIME -> msg = DanaRS_Packet_History_Prime(injector) + RecordTypes.RECORD_TYPE_BASALHOUR -> msg = DanaRS_Packet_History_Basal(injector) + RecordTypes.RECORD_TYPE_BOLUS -> msg = DanaRS_Packet_History_Bolus(injector) + RecordTypes.RECORD_TYPE_CARBO -> msg = DanaRS_Packet_History_Carbohydrate(injector) + RecordTypes.RECORD_TYPE_DAILY -> msg = DanaRS_Packet_History_Daily(injector) + RecordTypes.RECORD_TYPE_GLUCOSE -> msg = DanaRS_Packet_History_Blood_Glucose(injector) + RecordTypes.RECORD_TYPE_REFILL -> msg = DanaRS_Packet_History_Refill(injector) + RecordTypes.RECORD_TYPE_SUSPEND -> msg = DanaRS_Packet_History_Suspend(injector) } if (msg != null) { - sendMessage(DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger, 1)) + sendMessage(DanaRS_Packet_General_Set_History_Upload_Mode(injector, 1)) SystemClock.sleep(200) sendMessage(msg) while (!msg.done && isConnected) { SystemClock.sleep(100) } SystemClock.sleep(200) - sendMessage(DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger, 0)) + sendMessage(DanaRS_Packet_General_Set_History_Upload_Mode(injector, 0)) } result.success = true result.comment = "OK" diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt index c5ed222313..d50ee1ba25 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt @@ -1,11 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump -import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import org.junit.Assert import org.junit.Test @@ -16,19 +17,36 @@ import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class, DanaRSPlugin::class) +@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class) class DanaRSMessageHashTableTest : DanaRSTestBase() { @Mock lateinit var activePlugin: ActivePluginProvider @Mock lateinit var constraintChecker: ConstraintChecker @Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet) { + it.aapsLogger = aapsLogger + } + if (it is DanaRS_Packet_Bolus_Set_Step_Bolus_Start) { + it.constraintChecker = constraintChecker + } + if (it is DanaRS_Packet_Bolus_Set_Step_Bolus_Start) { + it.danaRPump = danaRPump + } + if (it is DanaRS_Packet_APS_History_Events) { + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { `when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) - val danaRSMessageHashTable = DanaRSMessageHashTable(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin, constraintChecker, detailedBolusInfoStorage, sp, injector) - val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, 0, 0, 0) + val danaRSMessageHashTable = DanaRSMessageHashTable(packetInjector) + val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(packetInjector, DanaRPump.CARBS, 0, 0, 0) val testPacket: DanaRS_Packet = danaRSMessageHashTable.findMessage(forTesting.command) Assert.assertEquals(BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.getOpCode().toLong()) } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest.kt index 835a56be84..8672867161 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,30 +12,38 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_APS_Basal_Set_Temporary_Basal) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { // under 100% should last 30 min - var packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 0) + var packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 0) Assert.assertEquals(0, packet.temporaryBasalRatio) Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM30MIN, packet.temporaryBasalDuration) //constructor with param - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 10) + packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 10) Assert.assertEquals(10, packet.temporaryBasalRatio) Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM30MIN, packet.temporaryBasalDuration) // over 100% should last 15 min - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 150) + packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 150) Assert.assertEquals(150, packet.temporaryBasalRatio) Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM15MIN, packet.temporaryBasalDuration) // test low hard limit - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, -1) + packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, -1) Assert.assertEquals(0, packet.temporaryBasalRatio) Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM30MIN, packet.temporaryBasalDuration) // test high hard limit - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 550) + packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 550) Assert.assertEquals(500, packet.temporaryBasalRatio) Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM15MIN, packet.temporaryBasalDuration) // test message generation - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 260) + packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 260) val generatedCode = packet.requestParams Assert.assertEquals(3, generatedCode.size.toLong()) Assert.assertEquals(4.toByte(), generatedCode[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt index 49871ade89..97c7fbe1a5 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage @@ -20,10 +22,24 @@ class DanaRS_Packet_APS_History_EventsTest : DanaRSTestBase() { @Mock lateinit var activePlugin: ActivePluginProvider @Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_APS_History_Events) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.activePlugin = activePlugin + it.danaRPump = danaRPump + it.detailedBolusInfoStorage = detailedBolusInfoStorage + it.sp = sp + } + } + } + @Test fun runTest() { val now = DateUtil.now() - val testPacket = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, sp, injector, now) + val testPacket = DanaRS_Packet_APS_History_Events(packetInjector, now) // test getRequestedParams val returnedValues = testPacket.requestParams val expectedValues = getCalender(now) @@ -45,7 +61,7 @@ class DanaRS_Packet_APS_History_EventsTest : DanaRSTestBase() { Assert.assertEquals("APS_HISTORY_EVENTS", testPacket.friendlyName) } - fun getCalender(from: Long): ByteArray { + private fun getCalender(from: Long): ByteArray { val cal = GregorianCalendar() if (from != 0L) cal.timeInMillis = from else cal[2000, 0, 1, 0, 0] = 0 val ret = ByteArray(6) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt index 33e343ee08..b252c07830 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.utils.DateUtil import org.junit.Assert @@ -12,21 +14,29 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_APS_Set_Event_HistoryTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_APS_Set_Event_History) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { // test for negative carbs val now = DateUtil.now() - var historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, now, -1, 0) + var historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, DanaRPump.CARBS, now, -1, 0) var testparams = historyTest.requestParams Assert.assertEquals(0.toByte(), testparams[8]) // 5g carbs - historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, now, 5, 0) + historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, DanaRPump.CARBS, now, 5, 0) testparams = historyTest.requestParams Assert.assertEquals(5.toByte(), testparams[8]) // 150g carbs - historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, now, 150, 0) + historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, DanaRPump.CARBS, now, 150, 0) testparams = historyTest.requestParams Assert.assertEquals(150.toByte(), testparams[8]) // test message generation - historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, now, 5, 0) + historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, DanaRPump.CARBS, now, 5, 0) testparams = historyTest.requestParams Assert.assertEquals(5.toByte(), testparams[8]) Assert.assertEquals(11, testparams.size) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_RateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_RateTest.kt index 2c5b7ffec1..aa79c64b03 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_RateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_RateTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.bus.RxBusWrapper import org.junit.Assert import org.junit.Test @@ -11,9 +13,19 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest(RxBusWrapper::class) class DanaRS_Packet_Basal_Get_Basal_RateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Get_Basal_Rate) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.danaRPump = danaRPump + } + } + } @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Get_Basal_Rate(aapsLogger, rxBus, resourceHelper, danaRPump) + val packet = DanaRS_Packet_Basal_Get_Basal_Rate(packetInjector) // test message decoding // rate is 0.01 val array = ByteArray(100) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_RateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_RateTest.kt index 59e6356f16..7cc2d5cb5c 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_RateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_RateTest.kt @@ -1,23 +1,32 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert.assertEquals import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Basal_Get_Profile_Basal_RateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Get_Profile_Basal_Rate) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val testPacket = DanaRS_Packet_Basal_Get_Profile_Basal_Rate(aapsLogger, danaRPump, 1) + val testPacket = DanaRS_Packet_Basal_Get_Profile_Basal_Rate(packetInjector, 1) // test if pumpProfile array is set right - val basal01 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet.getBytes(createArray(50, 1.toByte()), 2, 2)) / 100.0 - val basal05 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet.getBytes(createArray(50, 5.toByte()), 2, 2)) / 100.0 - val basal12 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet.getBytes(createArray(50, 12.toByte()), 2, 2)) / 100.0 + val basal01 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet(packetInjector).getBytes(createArray(50, 1.toByte()), 2, 2)) / 100.0 + val basal05 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet(packetInjector).getBytes(createArray(50, 5.toByte()), 2, 2)) / 100.0 + val basal12 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet(packetInjector).getBytes(createArray(50, 12.toByte()), 2, 2)) / 100.0 // basal rate > 1U/hr - val basal120 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet.getBytes(createArray(50, 120.toByte()), 2, 2)) / 100.0 + val basal120 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet(packetInjector).getBytes(createArray(50, 120.toByte()), 2, 2)) / 100.0 val params = testPacket.requestParams assertEquals(1.toByte(), params[0]) testPacket.handleMessage(createArray(50, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_NumberTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_NumberTest.kt index f8468573cd..458370fdc5 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_NumberTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_NumberTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,17 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Get_Profile_NumberTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Get_Profile_Number) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Get_Profile_Number(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Basal_Get_Profile_Number(packetInjector) val array = ByteArray(100) putByteToArray(array, 0, 1.toByte()) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt index f8e3472c8e..115dba03b0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,17 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Get_Temporary_Basal_State) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Basal_Get_Temporary_Basal_State(packetInjector) // test message decoding val array = ByteArray(100) putByteToArray(array, 0, 1.toByte()) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_RateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_RateTest.kt index d4e2b2de06..58d89e6220 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_RateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_RateTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,9 +12,17 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Set_Basal_RateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Set_Basal_Rate) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { // test message decoding - val packet = DanaRS_Packet_Basal_Set_Basal_Rate(aapsLogger, createArray(24, 5.0)) + val packet = DanaRS_Packet_Basal_Set_Basal_Rate(packetInjector, createArray(24, 5.0)) val requested = packet.requestParams var lookingFor = (5 * 100 and 0xff).toByte() Assert.assertEquals(lookingFor, requested[24]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_BasalTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_BasalTest.kt index 4c127cf437..a48dc769eb 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_BasalTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_BasalTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Set_Cancel_Temporary_BasalTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger) + val packet = DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(packetInjector) // test message decoding packet.handleMessage(createArray(3, 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_RateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_RateTest.kt index d2d918726f..035387ac85 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_RateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_RateTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Set_Profile_Basal_RateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Set_Profile_Basal_Rate) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Profile_Basal_Rate(aapsLogger, 1, createArray(24, 1.0)) + val packet = DanaRS_Packet_Basal_Set_Profile_Basal_Rate(packetInjector, 1, createArray(24, 1.0)) // test params val testparams = packet.requestParams // is profile 1 diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_NumberTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_NumberTest.kt index 8b15bf2863..a39c2efde9 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_NumberTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_NumberTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Set_Profile_NumberTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Set_Profile_Number) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Profile_Number(aapsLogger, 1) + val packet = DanaRS_Packet_Basal_Set_Profile_Number(packetInjector, 1) // test params val testparams = packet.requestParams // is profile 1 diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OffTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OffTest.kt index aa6d5832ad..50ce4c0c35 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OffTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OffTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Set_Suspend_OffTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Set_Suspend_Off) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Suspend_Off(aapsLogger) + val packet = DanaRS_Packet_Basal_Set_Suspend_Off(packetInjector) // test message decoding packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OnTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OnTest.kt index cb12a85d1d..3665cd96b1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OnTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OnTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Set_Suspend_OnTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Set_Suspend_On) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Suspend_On(aapsLogger) + val packet = DanaRS_Packet_Basal_Set_Suspend_On(packetInjector) // test message decoding packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_BasalTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_BasalTest.kt index d15dff5c39..6fccfdcb81 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_BasalTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_BasalTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -7,11 +9,18 @@ import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Basal_Set_Temporary_BasalTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Set_Temporary_Basal) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val testPacket = DanaRS_Packet_Basal_Set_Temporary_Basal(aapsLogger, 50, 20) + val testPacket = DanaRS_Packet_Basal_Set_Temporary_Basal(packetInjector, 50, 20) // params val params = testPacket.requestParams // is ratio 50 diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_OptionTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_OptionTest.kt index 1b83b1df86..ac17776c70 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_OptionTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_OptionTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.bus.RxBusWrapper import org.junit.Assert import org.junit.Test @@ -11,8 +13,19 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest(RxBusWrapper::class) class DanaRS_Packet_Bolus_Get_Bolus_OptionTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Bolus_Option) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Bolus_Option(aapsLogger, rxBus, resourceHelper, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Bolus_Option(packetInjector) // test message decoding //if dataArray is 1 pump.isExtendedBolusEnabled should be true packet.handleMessage(createArray(21, 1.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_ArrayTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_ArrayTest.kt index 19f9fc5fbd..997014a92b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_ArrayTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_ArrayTest.kt @@ -1,18 +1,27 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Get_CIR_CF_ArrayTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_CIR_CF_Array) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_CIR_CF_Array(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_CIR_CF_Array(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_InformationTest.kt index 4a805821b1..f09c01657f 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_InformationTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,17 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Bolus_Get_Calculation_InformationTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Calculation_Information) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Calculation_Information(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Calculation_Information(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(createArray(24, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_InformationTest.kt index b344cf3ade..effd2fa235 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_InformationTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,17 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_InformationTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(createArray(24, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_BolusTest.kt index 315ac6f045..19ade4619b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_BolusTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Get_Dual_BolusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Dual_Bolus) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Dual_Bolus(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Dual_Bolus(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_BolusTest.kt index a62d960cdc..3d54ad98bc 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_BolusTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,17 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Bolus_Get_Extended_BolusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Extended_Bolus) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Extended_Bolus(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Extended_Bolus(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_StateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_StateTest.kt index c950a2b8e7..1e2af1ae1e 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_StateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_StateTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,17 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Bolus_Get_Extended_Bolus_StateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Extended_Bolus_State) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Extended_Bolus_State(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_StateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_StateTest.kt index 4dab05c2cf..c489cc6677 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_StateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_StateTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_StateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(createArray(34, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_BolusTest.kt index c9f2529bb7..6976effbdb 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_BolusTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Get_Initial_BolusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Initial_Bolus) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Initial_Bolus(aapsLogger) + val packet = DanaRS_Packet_Bolus_Get_Initial_Bolus(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(createArray(34, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt index c3ac9a12d6..254862a8db 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -11,8 +13,17 @@ import java.util.* @PrepareForTest() class DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Step_Bolus_Information) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Step_Bolus_Information(packetInjector) val array = createArray(13, 0.toByte()) // 11 + 2 putByteToArray(array, 0, 2) // error 2 diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_OptionTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_OptionTest.kt index b79f14552b..b4bfc7018a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_OptionTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_OptionTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Set_Bolus_OptionTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_Bolus_Option) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Bolus_Option(aapsLogger, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + val packet = DanaRS_Packet_Bolus_Set_Bolus_Option(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) // test params val testparams = packet.requestParams Assert.assertEquals(0.toByte(), testparams[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_ArrayTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_ArrayTest.kt index df29bd2439..b749f9fb99 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_ArrayTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_ArrayTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Set_CIR_CF_ArrayTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_CIR_CF_Array) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_CIR_CF_Array(aapsLogger, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + val packet = DanaRS_Packet_Bolus_Set_CIR_CF_Array(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) // test params val testparams = packet.requestParams Assert.assertEquals(0.toByte(), testparams[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_BolusTest.kt index 0e60b237d7..2aeba32298 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_BolusTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Set_Dual_BolusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_Dual_Bolus) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Dual_Bolus(aapsLogger, 0.0, 0.0, 1) + val packet = DanaRS_Packet_Bolus_Set_Dual_Bolus(packetInjector, 0.0, 0.0, 1) // test params val testparams = packet.requestParams Assert.assertEquals(0.toByte(), testparams[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_BolusTest.kt index 173a87b423..55f3620850 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_BolusTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Set_Extended_BolusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_Extended_Bolus) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Extended_Bolus(aapsLogger, 1.0, 1) + val packet = DanaRS_Packet_Bolus_Set_Extended_Bolus(packetInjector, 1.0, 1) // test params val testparams = packet.requestParams Assert.assertEquals(100.toByte(), testparams[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest.kt index adf2ec11f2..2f0615f9c2 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(aapsLogger) + val packet = DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(createArray(34, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_BolusTest.kt index 29513ced1a..1fb3c6928d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_BolusTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Set_Initial_BolusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_Initial_Bolus) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Initial_Bolus(aapsLogger, 0, 0, 0, 100) + val packet = DanaRS_Packet_Bolus_Set_Initial_Bolus(packetInjector, 0, 0, 0, 100) // test params val testparams = packet.requestParams Assert.assertEquals(0.toByte(), testparams[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt index 7b740531a0..d4b53cffcd 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt @@ -6,7 +6,6 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin import org.junit.Assert @@ -29,8 +28,18 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest : DanaRSTestBase() { private lateinit var danaRSPlugin: DanaRSPlugin + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_Step_Bolus_Start) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + it.constraintChecker = constraintChecker + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(aapsLogger, danaRPump, constraintChecker) + val packet = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(packetInjector) // test params val testparams = packet.requestParams Assert.assertEquals(0.toByte(), testparams[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt index 8b0f24ff32..2605b0ba72 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt @@ -4,10 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin import info.nightscout.androidaps.plugins.treatments.Treatment -import info.nightscout.androidaps.utils.DefaultValueHelper import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -23,8 +21,14 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest : DanaRSTestBase() { @Mock lateinit var activePlugin: ActivePluginProvider - private var treatmentInjector: HasAndroidInjector = HasAndroidInjector { + private val packetInjector = HasAndroidInjector { AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_Step_Bolus_Stop) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.danaRPump = danaRPump + } if (it is Treatment) { it.defaultValueHelper = defaultValueHelper it.resourceHelper = resourceHelper @@ -37,8 +41,8 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest : DanaRSTestBase() { @Test fun runTest() { `when`(resourceHelper.gs(Mockito.anyInt())).thenReturn("SomeString") - danaRPump.bolusingTreatment = Treatment(treatmentInjector) - val testPacket = DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(aapsLogger, rxBus, resourceHelper, danaRPump) + danaRPump.bolusingTreatment = Treatment(packetInjector) + val testPacket = DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(packetInjector) // test message decoding testPacket.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) Assert.assertEquals(false, testPacket.failed) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_ConnectionTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_ConnectionTest.kt index e1b90f30da..1a8b2e6fbc 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_ConnectionTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_ConnectionTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Etc_Keep_ConnectionTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Etc_Keep_Connection) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Etc_Keep_Connection(aapsLogger) + val packet = DanaRS_Packet_Etc_Keep_Connection(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_SaveTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_SaveTest.kt index a089eafd9a..cb82f0b277 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_SaveTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_SaveTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Etc_Set_History_SaveTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Etc_Set_History_Save) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Etc_Set_History_Save(aapsLogger, 0, 0, 0, 0, 0, 0, 0, 0, 2) + val packet = DanaRS_Packet_Etc_Set_History_Save(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 2) // test params val testparams = packet.requestParams Assert.assertEquals(2.toByte(), testparams[8]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_StatusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_StatusTest.kt index fd32e3ca30..6515062bb0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_StatusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_StatusTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_General_Delivery_StatusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Delivery_Status) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_General_Delivery_Status(aapsLogger) + val packet = DanaRS_Packet_General_Delivery_Status(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(createArray(15, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt index 12ff721a2b..d3f96c2e11 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -9,13 +11,22 @@ import java.util.* @RunWith(PowerMockRunner::class) class DanaRS_Packet_General_Get_More_InformationTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Get_More_Information) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump) + var packet = DanaRS_Packet_General_Get_More_Information(packetInjector) packet.handleMessage(createArray(14, 0.toByte())) Assert.assertTrue(packet.failed) - packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump) + packet = DanaRS_Packet_General_Get_More_Information(packetInjector) val array = createArray(15, 0.toByte()) // 13 + 2 putIntToArray(array, 0, 600) // iob 6 putIntToArray(array, 2, 1250) // daily units 12.5 diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_PasswordTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_PasswordTest.kt index 88f3ac3496..eac2fc9127 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_PasswordTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_PasswordTest.kt @@ -1,23 +1,32 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_General_Get_PasswordTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Get_Password) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_Password(aapsLogger, danaRPump) + var packet = DanaRS_Packet_General_Get_Password(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Get_Password(aapsLogger, danaRPump) + packet = DanaRS_Packet_General_Get_Password(packetInjector) packet.handleMessage(createArray(15, 0.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals("REVIEW__GET_PASSWORD", packet.friendlyName) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_CheckTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_CheckTest.kt index 5248c2b699..ed6a23541f 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_CheckTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_CheckTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.bus.RxBusWrapper import org.junit.Assert import org.junit.Test @@ -11,14 +13,25 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest(RxBusWrapper::class) class DanaRS_Packet_General_Get_Pump_CheckTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Get_Pump_Check) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper) + var packet = DanaRS_Packet_General_Get_Pump_Check(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper) + packet = DanaRS_Packet_General_Get_Pump_Check(packetInjector) packet.handleMessage(createArray(15, 0.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals("REVIEW__GET_PUMP_CHECK", packet.friendlyName) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt index 3de89db27b..d8c4e0fe66 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -8,15 +10,24 @@ import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) class DanaRS_Packet_General_Get_Shipping_InformationTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Get_Shipping_Information) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump) + var packet = DanaRS_Packet_General_Get_Shipping_Information(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) // everything ok :) - packet = DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump) + packet = DanaRS_Packet_General_Get_Shipping_Information(packetInjector) packet.handleMessage(createArray(18, 0.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals("REVIEW__GET_SHIPPING_INFORMATION", packet.friendlyName) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_VerisonTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_VerisonTest.kt index f962560115..7aef230f52 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_VerisonTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_VerisonTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -8,8 +10,17 @@ import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) class DanaRS_Packet_General_Get_Shipping_VerisonTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Get_Shipping_Version) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_General_Get_Shipping_Version(aapsLogger, danaRPump) + val packet = DanaRS_Packet_General_Get_Shipping_Version(packetInjector) // test message decoding val ver = byteArrayOf((-78).toByte(), (-127).toByte(), (66).toByte(), (80).toByte(), (78).toByte(), (45).toByte(), (51).toByte(), (46).toByte(), (48).toByte(), (46).toByte(), (48).toByte()) packet.handleMessage(ver) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_TotalTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_TotalTest.kt index 1e89db2771..8c2092a425 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_TotalTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_TotalTest.kt @@ -1,23 +1,32 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_General_Get_Today_Delivery_TotalTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Get_Today_Delivery_Total) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_Today_Delivery_Total(aapsLogger, danaRPump) + var packet = DanaRS_Packet_General_Get_Today_Delivery_Total(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Get_Today_Delivery_Total(aapsLogger, danaRPump) + packet = DanaRS_Packet_General_Get_Today_Delivery_Total(packetInjector) packet.handleMessage(createArray(18, 0.toByte())) Assert.assertEquals(false, packet.failed) packet.handleMessage(createArray(15, 1.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_FlagTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_FlagTest.kt index 18f89e1096..2dc51fb3af 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_FlagTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_FlagTest.kt @@ -1,23 +1,31 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_General_Get_User_Time_Change_FlagTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Get_User_Time_Change_Flag) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_User_Time_Change_Flag(aapsLogger) + var packet = DanaRS_Packet_General_Get_User_Time_Change_Flag(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Get_User_Time_Change_Flag(aapsLogger) + packet = DanaRS_Packet_General_Get_User_Time_Change_Flag(packetInjector) packet.handleMessage(createArray(18, 0.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals("REVIEW__GET_USER_TIME_CHANGE_FLAG", packet.friendlyName) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_InformationTest.kt index 15e9f8e99b..9f878e0be1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_InformationTest.kt @@ -1,23 +1,32 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_General_Initial_Screen_InformationTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Initial_Screen_Information) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - var packet = DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump) + var packet = DanaRS_Packet_General_Initial_Screen_Information(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump) + packet = DanaRS_Packet_General_Initial_Screen_Information(packetInjector) packet.handleMessage(createArray(17, 1.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals(true, danaRPump.pumpSuspended) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_ModeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_ModeTest.kt index d918e9d682..b0e0867b4c 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_ModeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_ModeTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_General_Set_History_Upload_ModeTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Set_History_Upload_Mode) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger, 1) + val packet = DanaRS_Packet_General_Set_History_Upload_Mode(packetInjector, 1) // test params Assert.assertEquals(1.toByte(), packet.requestParams[0]) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_ClearTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_ClearTest.kt index 45e472af3c..2ee55972da 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_ClearTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_ClearTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_General_Set_User_Time_Change_Flag_ClearTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(aapsLogger) + val packet = DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt index bc10832af9..4ebf521537 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.db.DatabaseHelper import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes @@ -26,9 +28,18 @@ class DanaRS_Packet_History_AlarmTest : DanaRSTestBase() { `when`(MainApp.getDbHelper()).thenReturn(databaseHelper) } + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Alarm) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Alarm(aapsLogger, rxBus, 0) + val packet = DanaRS_Packet_History_Alarm(packetInjector, 0) val array = createArray(12, 0.toByte()) // 10 + 2 putByteToArray(array, 0, 0x0A) // record code alarm diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt index 1f7dd00783..8730eaddec 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_All_HistoryTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_All_History) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_All_History(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_All_History(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__ALL_HISTORY", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt index 8451e90b0f..08910af3b0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_BasalTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Basal) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Basal(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Basal(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__BASAL", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt index 0442ea98b9..c6ad86d977 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_Blood_GlucoseTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Blood_Glucose) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Blood_Glucose(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__BLOOD_GLUCOSE", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt index badaa0aa10..0417bc22ae 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_BolusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Bolus) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Bolus(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Bolus(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__BOLUS", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt index 22a99fcc53..8efec691e0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_CarbohydrateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Carbohydrate) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Carbohydrate(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__CARBOHYDRATE", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt index 91d4bea862..2a4bc6b533 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_DailyTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Daily) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Daily(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Daily(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__DAILY", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt index 19c8d2ef4e..f56216ce4c 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_PrimeTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Prime) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Prime(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Prime(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__PRIME", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt index 8b75ec344f..d83499bce4 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_RefillTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Refill) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Refill(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Refill(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__REFILL", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt index 66b06f4ed7..f02425c546 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_SuspendTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Suspend) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Suspend(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Suspend(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__SUSPEND", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt index a4e436a373..76dc831eed 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_TemporaryTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Temporary) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Temporary(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Temporary(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__TEMPORARY", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_AlarmTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_AlarmTest.kt index 58e0b738db..f10bb50efd 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_AlarmTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_AlarmTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import org.junit.Assert import org.junit.Before @@ -13,8 +15,18 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest(NSUpload::class) class DanaRS_Packet_Notify_AlarmTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Notify_Alarm) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Notify_Alarm(aapsLogger, resourceHelper, rxBus) + val packet = DanaRS_Packet_Notify_Alarm(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt index 83d9d06182..31c9bbe726 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt @@ -4,10 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin import info.nightscout.androidaps.plugins.treatments.Treatment -import info.nightscout.androidaps.utils.DefaultValueHelper import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -25,8 +23,14 @@ class DanaRS_Packet_Notify_Delivery_CompleteTest : DanaRSTestBase() { @Mock lateinit var danaRSPlugin: DanaRSPlugin @Mock lateinit var activePlugin: ActivePluginProvider - private var treatmentInjector: HasAndroidInjector = HasAndroidInjector { + private val packetInjector = HasAndroidInjector { AndroidInjector { + if (it is DanaRS_Packet_Notify_Delivery_Complete) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.danaRPump = danaRPump + } if (it is Treatment) { it.defaultValueHelper = defaultValueHelper it.resourceHelper = resourceHelper @@ -39,8 +43,8 @@ class DanaRS_Packet_Notify_Delivery_CompleteTest : DanaRSTestBase() { @Test fun runTest() { `when`(resourceHelper.gs(anyInt(), anyDouble())).thenReturn("SomeString") - danaRPump.bolusingTreatment = Treatment(treatmentInjector) - val packet = DanaRS_Packet_Notify_Delivery_Complete(aapsLogger, rxBus, resourceHelper, danaRPump) + danaRPump.bolusingTreatment = Treatment(packetInjector) + val packet = DanaRS_Packet_Notify_Delivery_Complete(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt index 69bf3789b1..03712fa1c0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt @@ -7,11 +7,9 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin import info.nightscout.androidaps.plugins.treatments.Treatment -import info.nightscout.androidaps.utils.DefaultValueHelper import org.junit.Assert import org.junit.Before import org.junit.Test @@ -34,8 +32,14 @@ class DanaRS_Packet_Notify_Delivery_Rate_DisplayTest : DanaRSTestBase() { private lateinit var danaRSPlugin: DanaRSPlugin - private var treatmentInjector: HasAndroidInjector = HasAndroidInjector { + private val packetInjector = HasAndroidInjector { AndroidInjector { + if (it is DanaRS_Packet_Notify_Delivery_Rate_Display) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.danaRPump = danaRPump + } if (it is Treatment) { it.defaultValueHelper = defaultValueHelper it.resourceHelper = resourceHelper @@ -48,7 +52,7 @@ class DanaRS_Packet_Notify_Delivery_Rate_DisplayTest : DanaRSTestBase() { @Test fun runTest() { `when`(resourceHelper.gs(ArgumentMatchers.anyInt(), anyObject())).thenReturn("SomeString") // val packet = DanaRS_Packet_Notify_Delivery_Rate_Display(1.0, Treatment(treatmentInjector)) - val packet = DanaRS_Packet_Notify_Delivery_Rate_Display(aapsLogger, rxBus, resourceHelper, danaRPump) + val packet = DanaRS_Packet_Notify_Delivery_Rate_Display(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding @@ -64,6 +68,6 @@ class DanaRS_Packet_Notify_Delivery_Rate_DisplayTest : DanaRSTestBase() { @Before fun mock() { danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, fabricPrivacy) - danaRPump.bolusingTreatment = Treatment(treatmentInjector) + danaRPump.bolusingTreatment = Treatment(packetInjector) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_AlarmTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_AlarmTest.kt index 9583c89d4e..9eae04dbec 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_AlarmTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_AlarmTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Notify_Missed_Bolus_AlarmTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Notify_Missed_Bolus_Alarm) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Notify_Missed_Bolus_Alarm(aapsLogger) + val packet = DanaRS_Packet_Notify_Missed_Bolus_Alarm(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt index 2ac915644f..4d63163c4b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.joda.time.DateTime import org.junit.Assert import org.junit.Test @@ -9,8 +11,17 @@ import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) class DanaRS_Packet_Option_Get_Pump_TimeTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Option_Get_Pump_Time) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Option_Get_Pump_Time(packetInjector) val array = createArray(8, 0.toByte()) // 6 + 2 putByteToArray(array, 0, 19) // year 2019 putByteToArray(array, 1, 2) // month february diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_OptionTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_OptionTest.kt index 32e3b051c6..4412f5b1fb 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_OptionTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_OptionTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Option_Get_User_OptionTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Option_Get_User_Option) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Option_Get_User_Option(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt index bf34d76510..f2fd2ad61c 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -9,12 +11,20 @@ import java.util.* @RunWith(PowerMockRunner::class) class DanaRS_Packet_Option_Set_Pump_TimeTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Option_Set_Pump_Time) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { val date = Date() - val packet = DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, date.time) + val packet = DanaRS_Packet_Option_Set_Pump_Time(packetInjector, date.time) // test params val params = packet.requestParams - Assert.assertEquals((date.year - 100 and 0xff).toByte(), params[0]) // 2019 -> 19 + Assert.assertEquals((date.year - 100 and 0xff).toByte(), params[0]) // 2019 -> 19 Assert.assertEquals((date.month + 1 and 0xff).toByte(), params[1]) Assert.assertEquals((date.date and 0xff).toByte(), params[2]) Assert.assertEquals((date.hours and 0xff).toByte(), params[3]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_OptionTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_OptionTest.kt index 30d076e037..6f53976045 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_OptionTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_OptionTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Option_Set_User_OptionTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Option_Set_User_Option) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Option_Set_User_Option(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Option_Set_User_Option(packetInjector) // test params val params = packet.requestParams Assert.assertEquals((danaRPump.lcdOnTimeSec and 0xff).toByte(), params[3]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_AvgTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_AvgTest.kt index ff5dc4ce80..2842e99c74 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_AvgTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_AvgTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Review_Bolus_AvgTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Review_Bolus_Avg) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Review_Bolus_Avg(aapsLogger) + val packet = DanaRS_Packet_Review_Bolus_Avg(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_RatioTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_RatioTest.kt index 4bd5bbbd1a..9c5a6f824c 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_RatioTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_RatioTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Review_Get_Pump_Dec_RatioTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Review_Get_Pump_Dec_Ratio) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Review_Get_Pump_Dec_Ratio(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Review_Get_Pump_Dec_Ratio(packetInjector) val array = ByteArray(100) putByteToArray(array, 0, 4.toByte())