Index: suite_leahi/shared/scripts/configuration/config.py =================================================================== diff -u -r2ca5a72fb15c8861634dfe5fbe4f0e84ce35675c -rdc699ba85fda9e7196a496a1b5ee79a3ea248be1 --- suite_leahi/shared/scripts/configuration/config.py (.../config.py) (revision 2ca5a72fb15c8861634dfe5fbe4f0e84ce35675c) +++ suite_leahi/shared/scripts/configuration/config.py (.../config.py) (revision dc699ba85fda9e7196a496a1b5ee79a3ea248be1) @@ -222,8 +222,6 @@ RINSEBACK_PAUSED = "Rinseback Paused" BLOOD_RETURN_COUNTDOWN_DESCRIPTION_TEXT = "Blood return will NOT be allowed in:" BLOOD_RETURN_COMPLETE = "Blood Return Complete!" + #Trends and Screensaver TRENDS = "Trends" - - -# Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -r8bfb02b2b8e50dccd822549c11d340df033744c7 -rdc699ba85fda9e7196a496a1b5ee79a3ea248be1 --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 8bfb02b2b8e50dccd822549c11d340df033744c7) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision dc699ba85fda9e7196a496a1b5ee79a3ea248be1) @@ -364,3 +364,16 @@ results.extend(findAllObjectsById(child, target_id)) return results + +def get_object_value(names_dict, error_message = "Missing object text", timeout_ms = 2000): + """ + To get an object text string with try..except catching to prevent script errors when the object is not found on the GUI + @param names_dict - the dictionary element from the names.py file (ie: names.some_variable_name_of_element) + @returns the object with corresponding dictionary, otherwise "None" + """ + try: + object_value = squish.waitForObject(names_dict, timeout_ms).value + return str(object_value) + except LookupError: + test.fail("ERROR : " + error_message) + return None Index: suite_leahi/tst_trends_and_screensaver/test.py =================================================================== diff -u -r2ca5a72fb15c8861634dfe5fbe4f0e84ce35675c -rdc699ba85fda9e7196a496a1b5ee79a3ea248be1 --- suite_leahi/tst_trends_and_screensaver/test.py (.../test.py) (revision 2ca5a72fb15c8861634dfe5fbe4f0e84ce35675c) +++ suite_leahi/tst_trends_and_screensaver/test.py (.../test.py) (revision dc699ba85fda9e7196a496a1b5ee79a3ea248be1) @@ -1,15 +1,4 @@ -# Subject/Title: Blood Prime - SW - 02 - Q&R -# -# Functionalities: Testing of Blood Prime Screen Components -# -# Steps: -# 1 Start Leahi Application and simulate TD standby mode and navigate to the Blood Prime Screen -# 2 Test Blood Prime Progress Data and Blood flow component -# 3 Test Saline component Different saline states, Progress bar, Start and stop button -# 4 Test Blood Prime Pressure Ranges -# - Set lower and upper bound for Arterial and test each limit -# - Set lower and upper bound for Venous and test each limit -# - Set lower and upper bound for trancememberance and test each limit +# Subject/Title: import names, re @@ -23,40 +12,302 @@ from leahi_dialin.protocols import CAN from leahi_dialin.utils import conversions -td_simulator = TD_Messaging() -dd_simulator = DD_Messaging() -can_interface = td_simulator.can_interface +td_simulator = TD_Messaging() +dd_simulator = DD_Messaging() +vitalsrequest = None +can_interface = td_simulator.can_interface -def trends_data(target_rate, volume_delivered, H2_arterial_pressure, H14_venous_pressure, tmp_pressure, cumulative_volume, blood_flow, dialysate_flow, dialysate_temp, D29): - td_simulator.td_ultrafiltration(0,target_rate,volume_delivered,0) - td_simulator.td_pressure(H2_arterial_pressure,H14_venous_pressure,0,0,0,0,0,0,0,tmp_pressure,0,0,0,0) + +def trends_data( + target_rate, + volume_delivered, + H2_arterial_pressure, + H14_venous_pressure, + tmp_pressure, + cumulative_volume, + blood_flow, + dialysate_flow, + dialysate_temp, + D29, +): + td_simulator.td_ultrafiltration(0, target_rate, volume_delivered, 0) + td_simulator.td_pressure( + H2_arterial_pressure, + H14_venous_pressure, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + tmp_pressure, + 0, + 0, + 0, + 0, + ) td_simulator.td_saline(0, cumulative_volume, 0, 0) td_simulator.td_treatment_set_points(blood_flow, dialysate_flow, dialysate_temp) - dd_simulator.dd_conductivity(0,D29,0,0,0) - + dd_simulator.dd_conductivity(0, D29, 0, 0, 0) + + +def verify_trends_data( + systolic, + diastolic, + heartRate, + target_rate, + volume_delivered, + H2_arterial_pressure, + H14_venous_pressure, + tmp_pressure, + cumulative_volume, + blood_flow, + dialysate_flow, + dialysate_temp, + D29, +): + + test.compare( + utility.get_object_value(names.o_TreatmentTrends_bloodpressureValue_ValueText), + f"{systolic}/{diastolic}", + "Bloodpressure Value", + ) + test.compare( + utility.get_object_value(names.o_TreatmentTrends_pulseRateValue_ValueText), + str(heartRate), + "Pulse Rate Value", + ) + test.compare( + utility.get_object_value( + names.o_TreatmentTrends_ufVolumeRemovedValue_ValueText + ), + str(volume_delivered), + "UF Volume Value", + ) + test.compare( + utility.get_object_value(names.o_TreatmentTrends_ufRateValue_ValueText), + str(target_rate), + "UF Rate Value", + ) + test.compare( + utility.get_object_value( + names.o_TreatmentTrends_arterialPressureValue_ValueText + ), + str(H2_arterial_pressure), + "Arterial Pressure Value", + ) + test.compare( + utility.get_object_value(names.o_TreatmentTrends_venousPressureValue_ValueText), + str(H14_venous_pressure), + "Venous Pressure Value", + ) + test.compare( + utility.get_object_value(names.o_TreatmentTrends_tmpValue_ValueText), + str(tmp_pressure), + "TMP Value", + ) + test.compare( + utility.get_object_value( + names.o_TreatmentTrends_bolusCumulativeDeliveredValue_ValueText + ), + str(cumulative_volume), + "Cumulative Value", + ) + test.compare( + utility.get_object_value(names.o_TreatmentTrends_bloodFlowRateValue_ValueText), + str(blood_flow), + "Blood Flow Rate Value", + ) + test.compare( + utility.get_object_value( + names.o_TreatmentTrends_dialysateFlowRateValue_ValueText + ), + str(dialysate_flow), + "Dialysate Flow Rate Value", + ) + test.compare( + utility.get_object_value( + names.o_TreatmentTrends_dialysateTemperatureValue_ValueText + ), + str(dialysate_temp), + "Dialysate Temperature Value", + ) + test.compare( + utility.get_object_value(names.o_TreatmentTrends_conductivityValue_ValueText), + str(D29 / 1000), + "Conductivity Value", + ) + + +def set_value_based_on_target_patientvitals(obj, target_value): + """ + obj: dictionary containing object paths + Example: + { + "value_obj": ":mainTreatmentScreen.PressureText", + "left_arrow": ":mainTreatmentScreen.LeftArrow", + "right_arrow": ":mainTreatmentScreen.RightArrow" + } + + target_value: integer or string number, e.g. 220 + """ + target_value = target_value + + # Wait for all objects + parent_obj = waitForObjectExists(obj) + # change range as per your screen count + + left_arrow = utility.findObjectById(parent_obj, "_leftArrow") + right_arrow = utility.findObjectById(parent_obj, "_rightArrow") + + # Read current value (supports invisible text too) + parent = waitForObject(parent_obj) + current_value = utility.findObjectById(parent, "_currentItem") + current_value = str(current_value.text) + + # Determine direction + while float(current_value) != float(target_value): + if float(current_value) < float(target_value): + mouseClick(waitForObject(right_arrow)) + + elif float(current_value) > float(target_value): + mouseClick(waitForObject(left_arrow)) + + parent = waitForObject(parent_obj) + current_value = utility.findObjectById(parent, "_currentItem") + current_value = str(current_value.text) + + test.log(f"Updated value: {current_value}") + + test.log(f"✅ Target value reached: {current_value}") + + +def keyboard_object_map_helper(text): + """ + Method for setting custom object property's for keyboard keys + @return: required object property's for keys + """ + if text is not None: + names.keyboard_input["text"] = text + return names.keyboard_input + else: + test.log("Invalid ", text, " for object.") + names.o_keyboard_input["text"] = "Q" + + +def verify_valid_vitals_through_keypad( + title_name, input_field_obj, expected_value, actual_value +): + """ + Tests verifies valid patient id set through application keyboard setup . + @return: N/A + """ + input_field = waitForObject(input_field_obj) + mouseClick(input_field) + + # check the title + title = waitForObjectExists( + utility.setObjectText(text=title_name, obj=names.o_title_Text) + ) + test.compare(title_name, title.text, "Title text should be -> " + str(title_name)) + + for text in expected_value: + keyboard_value = keyboard_object_map_helper(text) + utils.waitForGUI(0.2) + mouseClick(waitForObjectExists(keyboard_value)) + utils.waitForGUI(0.2) + + test.compare( + actual_value, (input_field.text), "Value should be -> " + str(actual_value) + ) + test.log( + "User successfully authenticated through patient id -> " + + expected_value + + "using keypad." + ) + + +# handler for messages from UI to FW +def handle_patient_vitals_request(message, timestamp=0.0): + """ + Called when the user requests to firmware from UI + @return: None + """ + global vitalsrequest + vitalsrequest = True + + +def verify_automatic_vitals_request(): + + MAX_WAIT = 6 * 60 * 1000 # 5 minutes in seconds + test.verify( + waitFor(lambda: vitalsrequest == True, MAX_WAIT), + "Testing UI -> TD message Vitals Request", + ) + + def main(): utils.tstStart(__file__) + if can_interface is None: + test.fail("CAN Interface is not available. Stopping tests.") + return + + channel_id = CAN.CanChannels.ui_to_td_ch_id + + # Register Vitals Request + message_id = MsgIds.MSG_ID_UI_BLOOD_PRESSURE_REQUEST.value + can_interface.register_receiving_publication_function( + channel_id, message_id, handle_patient_vitals_request + ) + startApplication(utility.aut("-q")) td_simulator.td_operation_mode(TDOpModes.MODE_PRET.value) - td_simulator.td_tx_state(TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value, 0, 0, 0, 0, 0, 0, 0, 0, 0) - mouseClick(waitForObject(utility.setObjectText(names.o_listView_Item, config.TRENDS), 3000)) + td_simulator.td_tx_state( + TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ) + mouseClick( + waitForObject(utility.setObjectText(names.o_listView_Item, config.TRENDS), 3000) + ) - # td_simulator.td_ultrafiltration(0,1.65,1.18,0) - # td_simulator.td_pressure(150,240,0,0,0,0,0,0,0,200,0,0,0,0) - # td_simulator.td_saline(0, 150, 0, 0) - # td_simulator.td_treatment_set_points(132, 167, 15.3) - # dd_simulator.dd_conductivity(0,600,0,0,0) - - # td_simulator.td_vitals(121,81,71) - - trends_data(1.65,1.18,150,240,200,150,132,167,15.3,600) - td_simulator.td_vitals(121,81,71) - + trends_data(1.65, 1.18, 150, 240, 200, 150, 132, 167, 15.3, 600) + td_simulator.td_vitals(121, 81, 71) + verify_trends_data(121, 81, 71, 1.65, 1.18, 150, 240, 200, 150, 132, 167, 15.3, 600) + td_simulator.td_operation_mode(TDOpModes.MODE_POST.value) td_simulator.td_operation_mode(TDOpModes.MODE_TREA.value) - td_simulator.td_tx_state(TDTreatmentStates.TREATMENT_START_STATE.value, 0, 0, 0, 0, 0, 0, 0, 0, 0) - td_simulator.td_tx_state(TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value, 0, 0, 0, 0, 0, 0, 0, 0, 0) + td_simulator.td_tx_state( + TDTreatmentStates.TREATMENT_START_STATE.value, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ) + td_simulator.td_tx_state( + TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ) + mouseClick( + utility.get_object_from_names(names.o_treatmentHome_editButton_IconButton) + ) + set_value_based_on_target_patientvitals( + names.o_bpMeasurementIntervalControl_ValueAdjusterCustom, 5 + ) + mouseClick(utility.get_object_from_names(names.o_confirm_button)) + # verify_automatic_vitals_request() - dd_simulator.dd_conductivity(501,600,773.6,802,905) + mouseClick( + waitForObject(utility.setObjectText(names.o_listView_Item, config.TRENDS), 3000) + ) + trends_data(1.73, 1.26, 160, 250, 190, 170, 144, 147, 13.4, 700) + mouseClick(utility.get_object_from_names(names.o_vitalsButton_VitalsButton)) + verify_valid_vitals_through_keypad( + config.SYSTOLIC, names.o_bloodPressureSystolic_TextEntry, "122", "122" + ) + verify_valid_vitals_through_keypad( + config.DIASTOLIC, names.o_bloodPressureDiastolic_TextEntry, "82", "82" + ) + verify_valid_vitals_through_keypad( + config.HEARTRATE, names.o_heartRate_TextEntry, "72", "72" + ) + mouseClick(utility.get_object_from_names(names.o_confirm_button)) + verify_trends_data(122, 82, 72, 1.73, 1.26, 160, 250, 190, 170, 144, 147, 13.4, 700) + + verify_automatic_vitals_request()