# Subject/Title: Blood Set Auto-Load and Auto-Eject - SW - 02 - Q&R # # Functionalities: Testing of Blood Set Auto Load and Eject # # Steps: # 1 Handle bloodSetAutoLoad sent messages from UI and handle bloodSetAutoEject sent messages from UI # Update Advanced Mode back to default # 2 Start Leahi Application and simulate TD standby mode and navigate to the Installation Page # Click on Auto Load Button in UI and Verify FW receives the request, Test Rejection Reason # Test No Rejection and Navigate Create Rx and Fill it, Validate it and Confirm it # simulate TD Treatment mode and simulate TD Post Treatment mode, Click on Auto Load Button in UI # And Verify FW receives the request, Test Rejection Reason and Test No Rejection # Navigate to Device settings using service password and Toggle Advanced Mode Switch # Navigate to Pre-Treatment No Concentrate Page, instead 3 Installation pages single Installation Page displayed import names import re 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_blood_set_auto_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) def main(): utils.tstStart(__file__) test.startSection("Blood Set Auto Load and Eject") td_interface = TD_Messaging() can_interface = td_interface.can_interface global bloodSetAutoLoad global bloodSetAutoEject # 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_DISPOSABLES_CONFIRM_REQUEST.value can_interface.register_receiving_publication_function( channel_id, message_id, handle_blood_set_auto_request ) # handle bloodSetAutoEject 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_DISPOSABLES_REMOVAL_CONFIRM_REQUEST.value can_interface.register_receiving_publication_function( channel_id, message_id, handle_blood_set_auto_request ) application_init.update_advanced_mode_back_to_default() 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 ) mouseClick(utility.findChildByText(pre_treatment, "Next")) mouseClick(utility.findChildByText(pre_treatment, "Auto Load")) test.verify( waitFor("'bloodSetAutoLoad == 1'", 5000), "Testing UI -> TD message Auto Load" ) td_simulator.td_blood_set_auto_load_response(1) auto_load_reject_notification = utility.findChildByText( pre_treatment, config.BLOOD_SET_AUTO_LOAD_REJECTION ) auto_load_reject_notification_text = str(auto_load_reject_notification.text) digit = re.sub(r"^.*?\[(\d+)\].*$", r"\1", auto_load_reject_notification_text) if digit: digit_int = int(float(digit)) test.compare(1, digit_int, f"Rejection reason number comparison for reason {1}") test.log(f"Rejection reason text is {auto_load_reject_notification_text}") td_simulator.td_blood_set_auto_load_response(0) stepcount = waitForObjectExists(names.o_preTreatmentStack_repeater_Repeater) td_simulator.td_blood_set_auto_load_response(vRejectionReason=0) stepId = waitForObjectExists(names.o_preTreatmentStack_stepIndicator_StepIndicator) values = utility.findAllObjectsById(stepId, "_text") if stepcount.count == 9: for input_field in values[3:]: if str(input_field.text) == "Water Sample": mouseClick( waitForObject(names.o_PreTreatmentSampleStack_button_TouchRect) ) if str(input_field.text) == config.CREATERX: break else: Nextbutton = utility.setObjectText( obj=names.o_preTreatmentStack_Text, text=config.NEXT ) mouseClick(Nextbutton) else: for input_field in values[3:]: test.log(str(input_field.text)) if str(input_field.text) == "Water Sample": mouseClick( waitForObject(names.o_PreTreatmentSampleStack_button_TouchRect) ) if str(input_field.text) == config.CREATERX: break else: Nextbutton = utility.setObjectText( obj=names.o_preTreatmentStack_Text, text=config.NEXT ) mouseClick(Nextbutton) mouseClick( waitForObject(names.o_PreTreatmentCreate_pretreatmentPatientIDEntry_TextEntry) ) waitForObject( names.o_PreTreatmentCreate_pretreatmentPatientIDEntry_TextEntry ).text = "abcd" 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, ) pre_treatment = waitForObjectExists( names.o_preTreatmentStack_PreTreatmentStack, 3000 ) validate_button = utility.findChildByText(pre_treatment, "Validate") mouseClick(validate_button) td_simulator.td_Treatment_Parameters_Validation(vAccepted=1) mouseClick( waitForObjectExists(names.o_preTreatmentStack_confirmButton_ConfirmButton, 3000) ) mouseClick(utility.findChildByText(pre_treatment, "Next")) mouseClick(utility.findChildByText(pre_treatment, "Start")) 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 ) mouseClick(utility.findChildByText(post_treatment, "Auto Eject")) test.verify( waitFor("'bloodSetAutoEject == 1'", 5000), "Testing UI -> TD message Auto Eject" ) td_simulator.td_blood_set_auto_eject_response(1) auto_eject_reject_notification = utility.findChildByText( post_treatment, config.BLOOD_SET_AUTO_EJECT_REJECTION ) auto_eject_reject_notification_text = str(auto_eject_reject_notification.text) digit = re.sub(r"^.*?\[(\d+)\].*$", r"\1", auto_eject_reject_notification_text) if digit: digit_int = int(float(digit)) test.compare(1, digit_int, f"Rejection reason number comparison for reason {1}") test.log(f"Rejection reason text is {auto_eject_reject_notification_text}") 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, "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, "Prescriptions")) mouseClick(utility.findChildByText(main_menu_container, "Treatment")) mouseClick(waitForObject(names.o_createTreatmentRect_TouchRect, 2000)) td_simulator.td_operation_mode(TDOpModes.MODE_PRET.value) pre_treatment = waitForObjectExists( names.o_preTreatmentStack_PreTreatmentStack, 3000 ) mouseClick(utility.findChildByText(pre_treatment, "Auto Load")) td_simulator.td_blood_set_auto_load_response(0) mouseClick(utility.findChildByText(pre_treatment, "Next")) test.endSection()