# Subject/Title: Pre-Treatment - SW - 02 - Foundation - Q&R # # Functionalities: Testing of Pre-Treatment Foundation # # Steps: # 1 Handle startTreatment sent messages from UI # 2 Update Advanced Mode back to deLDfault, Start Leahi Application and simulate TD standby mode # and Navigate to through Pre-Treatment Pages Comparing Page Title and Page Contents # Click on Start in UI and Verify FW receives the request # simulate TD Treatment mode and simulate TD Post Treatment mode # Navigate to Device settings using service password and Toggle Advanced Mode Switch # Navigate to Through Pre-Treatment Pages Comparing Page Title and Page Contents import names from configuration import config, utility, navigation, application_init from leahi_dialin.ui import utils from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.common.td_defs import TDOpModes, TDTreatmentStates from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions from leahi_dialin.protocols import CAN from leahi_dialin.utils import conversions td_simulator = TD_Messaging() # handler for messages from UI to FW def handle_start_treatment_request(message, timestamp=0.0): """ Called when the user requests to firmware from UI @return: None """ message = message["message"] index = MsgFieldPositions.START_POS_FIELD_1 state, index = conversions.bytearray_to_integer(message, index) global startTreatment startTreatment = str(state) def main(): utils.tstStart(__file__) test.startSection("Pre-Treatment Foundation") can_interface = td_simulator.can_interface global startTreatment # handle bloodSetAutoLoad sent messages from UI if can_interface is not None: channel_id = CAN.DenaliChannels.ui_to_td_ch_id message_id = MsgIds.MSG_ID_UI_ADJUST_START_TREATMENT_REQUEST.value can_interface.register_receiving_publication_function( channel_id, message_id, handle_start_treatment_request ) application_init.reset_system_setting("AdvancedMode") startApplication(utility.aut("-q")) td_simulator.td_operation_mode(TDOpModes.MODE_STAN.value) mouseClick(waitForObject(names.o_createTreatmentRect_TouchRect, 3000)) td_simulator.td_operation_mode(TDOpModes.MODE_PRET.value) pre_treatment = waitForObjectExists( names.o_preTreatmentStack_PreTreatmentStack, 3000 ) concentrates_page_title_text = waitForObjectExists( names.o_PreTreatmentBase_instructionView_InstructionView, 3000 ).title test.compare( concentrates_page_title_text, config.CONCENTRATES_PAGE_TITLE, "Comparison of Concentrates Page Title Text", ) instruction_view_container = waitForObjectExists( names.o_PreTreatmentBase_instructionView_InstructionView, 3000 ) connect_dry_bicarbonate_option = utility.findChildByText( instruction_view_container, config.CONCENTRATES_PAGE_CONTENTS[1] ) mouseClick(connect_dry_bicarbonate_option) mouseClick(waitForObject(utility.findChildByText(pre_treatment, config.NEXT), 3000)) installation_stepper_1_page_title_text = waitForObjectExists( names.o_pretreatmentInstallation_instructionView_InstructionView, 3000 ).title test.compare( installation_stepper_1_page_title_text, config.INSTALLATION_STEPPER_1_PAGE_TITLE, "Comparison of Installation Page Stepper 1 Title Text", ) for content in config.INSTALL_BLOOD_TUBING_SET_CONTENTS[1:4]: install_bloodlines_content = waitForObject( utility.setObjectText(names.o_preTreatmentStack_Text, content), 3000 ) mouseClick(install_bloodlines_content) mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.AUTO_LOAD)) td_simulator.td_blood_set_auto_load_response(0) installation_stepper_2_page_title_text = waitForObject( utility.setObjectText( names.o_preTreatmentStack_Text, config.INSTALLATION_STEPPER_2_PAGE_TITLE ), 3000, ) test.compare( installation_stepper_2_page_title_text.text, config.INSTALLATION_STEPPER_2_PAGE_TITLE, "Comparison of Installation Page Stepper 2 Title Text", ) for content in config.INSTALL_BLOODLINES_CONTENTS[1:5]: install_bloodlines_content = waitForObject( utility.setObjectText(names.o_preTreatmentStack_Text, content), 3000 ) mouseClick(install_bloodlines_content) mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.NEXT)) installation_stepper_3_page_title_text = waitForObject( utility.setObjectText( names.o_preTreatmentStack_Text, config.INSTALLATION_STEPPER_3_PAGE_TITLE ), 3000, ) test.compare( installation_stepper_3_page_title_text.text, config.INSTALLATION_STEPPER_3_PAGE_TITLE, "Comparison of Installation Page Stepper 3 Title Text", ) for content in config.INSTALL_PRESSURE_LINES_CONTENTS[1:7]: install_pressure_lines_content = waitForObject( utility.setObjectText(names.o_preTreatmentStack_Text, content), 3000 ) mouseClick(install_pressure_lines_content) mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.NEXT)) for content in config.SELF_TESTS_PAGE_CONTENTS: slef_test_page_content = waitForObjectExists( utility.setObjectText(names.o_preTreatmentStack_Text, content) ) test.compare( slef_test_page_content.text, content, "Comparison of Self Tests Page Contents".format(content), ) mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.NEXT)) saline_page_title = waitForObject( utility.setObjectText(names.o_preTreatmentStack_Text, config.SALINE_PAGE_TITLE), 3000, ) test.compare( saline_page_title.text, config.SALINE_PAGE_TITLE, "Comparison of Saline Page Title Text", ) for content in config.SALINE_PAGE_CONTENTS[1:5]: saline_page_content = waitForObject( utility.setObjectText(names.o_preTreatmentStack_Text, content), 3000 ) mouseClick(saline_page_content) mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.NEXT)) for content in config.PRIME_PAGE_CONTENTS: prime_page_content = waitForObjectExists( utility.setObjectText(names.o_preTreatmentStack_Text, content) ) test.compare( prime_page_content.text, content, "Comparison of Prime Page Contents".format(content), ) mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.NEXT)) utility.set_value_based_on_target( names.o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster, 50 ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_dialysateFlowRateControl_ValueAdjuster, 50 ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_durationControl_ValueAdjuster, 60 ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_heparinBolusVolumeControl_ValueAdjuster, "0.2" ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_heparinDispensingRateControl_ValueAdjuster, "0.2" ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_heparinStopTimeControl_ValueAdjuster, 60 ) utility.select_different_dropdown( names.o_PreTreatmentCreate_acidConcentrateComboBox_BaseComboBox, config.ACID_CONCENTRATE, 2, ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_dialysateTemperatureControl_ValueAdjuster, 37.0 ) utility.select_different_dropdown( names.o_PreTreatmentCreate_dialyzerTypeComboBox_BaseComboBox, config.DIALYZER_TYPE, 2, ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_salineBolusVolumeControl_ValueAdjuster, 100 ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_bpMeasurementIntervalControl_ValueAdjusterCustom, 6.0 ) utility.select_different_dropdown( names.o_PreTreatmentCreate_bicarbonateConcentrateComboBox_BaseComboBox, config.BICARBONATE, 0, ) mouseClick( waitForObjectExists(names.o_preTreatmentStack_confirmButton_ConfirmButton, 3000) ) td_simulator.td_Treatment_Parameters_Validation(vAccepted=1) mouseClick( waitForObjectExists(names.o_preTreatmentStack_confirmButton_ConfirmButton, 3000) ) connect_page_title = waitForObject( utility.setObjectText( names.o_preTreatmentStack_Text, config.CONNECT_PAGE_TITLE ), 3000, ) test.compare( connect_page_title.text, config.CONNECT_PAGE_TITLE, "Comparison of Connect Page Title Text", ) for content in config.CONNECT_PAGE_CONTENTS[1:5]: connect_page_content = waitForObject( utility.setObjectText(names.o_preTreatmentStack_Text, content), 3000 ) mouseClick(connect_page_content) mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.START)) test.verify( waitFor("'startTreatment == 1'", 3000), "Testing UI -> TD message Auto Load" ) td_simulator.td_operation_mode(TDOpModes.MODE_TREA.value, 0) td_simulator.td_tx_state( TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) td_simulator.td_operation_mode(TDOpModes.MODE_POST.value, 0) post_treatment = waitForObjectExists( names.o_PostTreatmentStack_PostTreatmentStack, 3000 ) disconnect_page_title = waitForObject( utility.findChildByText(post_treatment, config.DISCONNECT_PAGE_TITLE), 3000 ) test.compare( disconnect_page_title.text, config.DISCONNECT_PAGE_TITLE, "Comparison of Disconnect Page Title Text", ) disconnect_page_content = waitForObject( utility.findChildByText(post_treatment, config.DISCONNECT_PAGE_CONTENTS[1]), 3000, ) mouseClick(disconnect_page_content) mouseClick( waitForObject(utility.findChildByText(post_treatment, config.AUTO_EJECT), 3000) ) td_simulator.td_blood_set_auto_eject_response(0) td_simulator.td_operation_mode(TDOpModes.MODE_INIT.value, 0) navigation.navigate_to_device_settings_using_service_password() grid_container = waitForObject(names.o_DeviceSettingsGrid, 2000) mouseClick(utility.findChildByText(grid_container, config.ADVANCED_MODE)) advanced_mode_switch = waitForObject(names.o_settingsAdvancedMode_BaseSwitch, 1000) # Check current state and toggle Advanced Mode Switch and store the initial state was_checked = advanced_mode_switch.checked test.log( f"Initial Advanced Mode switch state: {'Checked' if was_checked else 'Unchecked'}" ) # Perform the toggle action mouseClick(advanced_mode_switch) mouseClick(waitForObjectExists(names.o_SettingsBase_backButton_AdvancedMode, 3000)) main_menu_container = waitForObject(names.o_mainMenu_MainMenu, 2000) mouseClick(utility.findChildByText(main_menu_container, config.PRESCRIPTIONS)) mouseClick(utility.findChildByText(main_menu_container, config.TREATMENT)) mouseClick(waitForObject(names.o_createTreatmentRect_TouchRect, 2000)) td_simulator.td_operation_mode(TDOpModes.MODE_PRET.value) installation_page_title = waitForObject( utility.setObjectText( names.o_preTreatmentStack_Text, config.INSTALLATION_PAGE_TITLE ), 3000, ) test.compare( installation_page_title.text, config.INSTALLATION_PAGE_TITLE, "Comparison of Installation Page Title Text", ) installation_page_content = waitForObject( utility.setObjectText( names.o_preTreatmentStack_Text, config.INSTALLATION_PAGE_CONTENTS[1] ), 3000, ) mouseClick(installation_page_content) mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.AUTO_LOAD)) td_simulator.td_blood_set_auto_load_response(0) for content in config.SELF_TESTS_PAGE_CONTENTS: slef_test_page_content = waitForObjectExists( utility.setObjectText(names.o_preTreatmentStack_Text, content) ) test.compare( slef_test_page_content.text, content, "Comparison of Self Tests Page Contents".format(content), ) mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.NEXT)) saline_page_title = waitForObject( utility.setObjectText(names.o_preTreatmentStack_Text, config.SALINE_PAGE_TITLE), 3000, ) test.compare( saline_page_title.text, config.SALINE_PAGE_TITLE, "Comparison of Saline Page Title Text", ) mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.NEXT)) for content in config.PRIME_PAGE_CONTENTS: prime_page_content = waitForObjectExists( utility.setObjectText(names.o_preTreatmentStack_Text, content) ) test.compare( prime_page_content.text, content, "Comparison of Prime Page Contents".format(content), ) mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.NEXT)) utility.set_value_based_on_target( names.o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster, 60 ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_dialysateFlowRateControl_ValueAdjuster, 75 ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_durationControl_ValueAdjuster, 75 ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_heparinBolusVolumeControl_ValueAdjuster, "0.3" ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_heparinDispensingRateControl_ValueAdjuster, "0.3" ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_heparinStopTimeControl_ValueAdjuster, 60 ) utility.select_different_dropdown( names.o_PreTreatmentCreate_acidConcentrateComboBox_BaseComboBox, config.ACID_CONCENTRATE, 2, ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_dialysateTemperatureControl_ValueAdjuster, 38.0 ) utility.select_different_dropdown( names.o_PreTreatmentCreate_dialyzerTypeComboBox_BaseComboBox, config.DIALYZER_TYPE, 2, ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_salineBolusVolumeControl_ValueAdjuster, 200 ) utility.set_value_based_on_target( names.o_PreTreatmentCreate_bpMeasurementIntervalControl_ValueAdjusterCustom, 3.0 ) utility.select_different_dropdown( names.o_PreTreatmentCreate_bicarbonateConcentrateComboBox_BaseComboBox, config.BICARBONATE, 0, ) mouseClick( waitForObjectExists(names.o_preTreatmentStack_confirmButton_ConfirmButton, 3000) ) td_simulator.td_Treatment_Parameters_Validation(vAccepted=1) mouseClick( waitForObjectExists(names.o_preTreatmentStack_confirmButton_ConfirmButton, 3000) ) connect_page_title = waitForObject( utility.setObjectText( names.o_preTreatmentStack_Text, config.CONNECT_PAGE_TITLE ), 3000, ) test.compare( connect_page_title.text, config.CONNECT_PAGE_TITLE, "Comparison of Connect Page Title Text", ) mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.START)) test.endSection()