# 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() can_interface = td_simulator.can_interface bloodSetAutoLoad = None bloodSetAutoEject = None # handler for messages from UI to FW def handle_blood_set_auto_load_request( message, timestamp = 0.0): """ Called when the user requests to firmware from UI @return: None """ global bloodSetAutoLoad bloodSetAutoLoad = True # handler for messages from UI to FW def handle_blood_set_auto_eject_request( message, timestamp = 0.0): """ Called when the user requests to firmware from UI @return: None """ global bloodSetAutoEject bloodSetAutoEject = True def main(): utils.tstStart(__file__) if can_interface is None: test.fail("CAN Interface is not available. Stopping tests.") return channel_id = CAN.DenaliChannels.ui_to_td_ch_id # Register Blood Set Auto Load Request 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_load_request ) # Register Blood Set Auto Eject Request 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_eject_request ) test.startSection("Blood Set Auto Load and Eject") application_init.reset_system_setting("AdvancedMode") startApplication(utility.aut("-q")) td_simulator.td_operation_mode(TDOpModes.MODE_STAN.value) td_simulator.td_operation_mode(TDOpModes.MODE_PRET.value) pre_treatment = waitForObjectExists( names.o_preTreatmentStack_PreTreatmentStack, 3000 ) mouseClick(waitForObject(utility.findChildByText(pre_treatment, config.NEXT), 3000)) mouseClick(waitForObject(utility.setObjectText(names.o_preTreatmentStack_Text, config.AUTO_LOAD), 3000)) test.verify( waitFor(lambda: bloodSetAutoLoad == True, 10000), "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(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) == config.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) == config.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 ="1234" parent_obj = waitForObject(names.o_PreTreatmentCreate_leftColumn_Column, 3000) blood_flow_rate = utility.findObjectById(parent_obj, "_bloodFlowRate") utility.set_value_based_on_target(blood_flow_rate, 60) dialysate_flow_rate = utility.findObjectById(parent_obj, "_dialysateFlowRate") utility.set_value_based_on_target(dialysate_flow_rate, 75) duration = utility.findObjectById(parent_obj,"_duration") utility.set_value_based_on_target(duration, 75) right_obj = waitForObject(names.o_PreTreatmentCreate_rightColumn_Column) ultrafiltration_volume = utility.findObjectById(right_obj,"_ufVolume") utility.set_value_based_on_target(ultrafiltration_volume,0.10) heparin_rx = utility.findObjectById(right_obj,"_heparinRx") heparin_right_arrow = utility.findObjectById(heparin_rx, "_rightArrow") mouseClick(heparin_right_arrow) heparin_obj = waitForObject(names.o_LabelUnitValueAdjuster_LabelUnitValueAdjuster) heparin_bolus = utility.findObjectById(heparin_obj,"_heparinBolusVolume") utility.set_value_based_on_target(heparin_bolus, 0.2) utility.set_value_based_on_target(names.o_heparinDispensingRate_LabelUnitValueAdjuster,0.3) utility.set_value_based_on_target(names.o_heparinDeliveryDuration_LabelUnitValueAdjuster, 75) mouseClick(waitForObject(names.o_confirmButton_ConfirmButton)) utility.select_different_dropdown(names.o_PreTreatmentCreate_acidConcentrateComboBox_BaseComboBox,config.ACID_CONCENTRATE,2) utility.select_different_dropdown(names.o_PreTreatmentCreate_dialyzerTypeComboBox_BaseComboBox,config.DIALYZER_TYPE,2) utility.select_different_dropdown(names.o_PreTreatmentCreate_bicarbonateConcentrateComboBox_BaseComboBox,config.BICARBONATE,0) Nextbutton = utility.setObjectText(obj =names.o_preTreatmentStack_Text, text =config.NEXT) mouseClick(waitForObject(Nextbutton)) utility.set_value_based_on_target(names.o_PreTreatmentCreate_sodium_LabelUnitValueAdjuster, 139) utility.set_value_based_on_target(names.o_PreTreatmentCreate_bicarbonate_LabelUnitValueAdjuster, 35) utility.set_value_based_on_target(names.o_PreTreatmentCreate_fluidBolusVolume_LabelUnitValueAdjuster,300) utility.set_value_based_on_target(names.o_PreTreatmentCreate_primeRinsebackVolume_LabelUnitValueAdjuster,310) confirm_button = waitForObjectExists(names.o_preTreatmentStack_confirmButton_ConfirmButton) mouseClick(confirm_button) td_simulator.td_Treatment_Parameters_Validation(vAccepted= 1) 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(waitForObject(utility.findChildByText(post_treatment, config.AUTO_EJECT), 3000)) test.verify( waitFor(lambda: bloodSetAutoEject == True, 10000), "Testing UI -> TD message Auto Eject" ) td_simulator.td_blood_set_auto_eject_response(0,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,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)) td_simulator.td_operation_mode(TDOpModes.MODE_PRET.value) pre_treatment = waitForObjectExists( names.o_preTreatmentStack_PreTreatmentStack, 3000 ) mouseClick(utility.findChildByText(pre_treatment, config.AUTO_LOAD)) td_simulator.td_blood_set_auto_load_response(0) mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.NEXT)) test.endSection()