Index: suite_leahi/tst_main_treatment/test.py =================================================================== diff -u -rf9812770166a529dd87003269cb05d12153e57de -r14b4280d72f6b236cb2e2c3902e2dea5e10270be --- suite_leahi/tst_main_treatment/test.py (.../test.py) (revision f9812770166a529dd87003269cb05d12153e57de) +++ suite_leahi/tst_main_treatment/test.py (.../test.py) (revision 14b4280d72f6b236cb2e2c3902e2dea5e10270be) @@ -20,11 +20,15 @@ # -Set lower and upper bound for dialysate cond and test each limit import names -from leahi_dialin.ui import utils +from leahi_dialin.ui import utils from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.ui.dd_messaging import DD_Messaging -from configuration import utility, config -from leahi_dialin.common.td_defs import TDOpModes,TDTreatmentStates +from configuration import utility, config +from leahi_dialin.common.td_defs import TDOpModes,TDTreatmentStates +from leahi_dialin.common.ui_defs import TXStates +from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.utils import conversions +from leahi_dialin.protocols import CAN ART_LOW_VAL_MINUS_390 = -390 ART_HIGH_VAL_220 = 220 @@ -40,13 +44,27 @@ {"uf_volume": 1, "uf_rate": 0.53, "vol_delivered": 0.37 }, {"uf_volume": 10, "uf_rate": 5.05, "vol_delivered": 2.37 }, {"uf_volume": 20, "uf_rate": 10.0, "vol_delivered": 5.0 }, - {"uf_volume": 100,"uf_rate": 140.0,"vol_delivered": 156.0 }, {"uf_volume": 0, "uf_rate": 0.0, "vol_delivered": 0.0 } ] td = TD_Messaging() dd = DD_Messaging() +can_interface = td.can_interface +newTreatmentDuration = None + +def handle_new_treatment_duration_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 newTreatmentDuration + newTreatmentDuration = state + def verify_arterial_and_venous_value_in_main_treatment_screen(accepted, art_low, art_high, ven_low, ven_high,tmp_low,tmp_high): """ Method to verify Arterial low and high @@ -141,10 +159,12 @@ H14_venous_max = target_venous_max_limit, H2_arterial_long = 0 , H14_venous_long = 0 , - tmp_pressure = target_tmp_pressure, + tmp_pressure = target_tmp_pressure, + tmp_long = 0.0, tmp_min = target_tmp_min_limit, - tmp_max = target_tmp_max_limit) - + tmp_max = target_tmp_max_limit, + barometric = 0.0) + # check the range bar's upper and lower bounds arterial_rangeBar = waitForObjectExists(names.o_arterial_RangeBar) if arterial_rangeBar is not None: @@ -192,7 +212,7 @@ @return: N/A """ test.compare(utility.get_object_from_names(names.o_treatmentUltrafiltration).visible, True, "UltraFiltration section is visible") - test.compare(waitForObjectExists(names.o_UF_Volume_Text).topText, "UF Volume", "UF Volume text verified") + test.compare(waitForObjectExists(names.o_UF_Volume_Text).topText, "UF Volume Goal", "UF Volume text verified") test.compare(waitForObjectExists(names.o_UF_Rate_Text).topText, "UF Rate", "UF Rate text verified") def start_test_treatment_ultrafiltration(uf_volume,uf_rate,vol_delivered): @@ -240,11 +260,11 @@ #TX Parameter set points def verify_setPoints_from_main_treatement(): TREATMENT_PARAMETER_SETPOINTS_TD_TEST_VALUES = [ - {"blood flow": 56, "dial flow": 22, "dial tmp": 20.0, "dial cond": 34.0 }, - {"blood flow": 99, "dial flow": 78, "dial tmp": 87.0, "dial cond": 55.0 }, - {"blood flow": 34, "dial flow": 99, "dial tmp": 99.0, "dial cond": 99.0 }, - {"blood flow": 100, "dial flow": 100,"dial tmp": 100.0,"dial cond": 100.0}, - {"blood flow": 110, "dial flow": 110,"dial tmp": 110.0,"dial cond": 110.0} + {"blood flow": 56, "dial flow": 22, "dial tmp": 20.0, "dial cond": 100.0 }, + {"blood flow": 99, "dial flow": 78, "dial tmp": 87.0, "dial cond": 200.0 }, + {"blood flow": 34, "dial flow": 99, "dial tmp": 99.0, "dial cond": 300.0 }, + {"blood flow": 100, "dial flow": 100,"dial tmp": 100.0,"dial cond": 400.0}, + {"blood flow": 110, "dial flow": 110,"dial tmp": 110.0,"dial cond": 500.0} ] #Verify the title values in the set points @@ -267,26 +287,75 @@ bloodFlow = utility.get_object_from_names(names.o_blood_flow_value) bloodFlow_properties = object.properties(bloodFlow) - test.compare(str(bloodFlow_properties["value"]), str(target_blood_flow), "Blood Flow value should be :" + str(target_blood_flow)) + test.compare(bloodFlow_properties["value"], target_blood_flow, "Blood Flow value should be :" + str(target_blood_flow)) dialFlow = utility.get_object_from_names(names.o_dial_flow_value) dialFlow_properties = object.properties(dialFlow) - test.compare(str(dialFlow_properties["value"]), str(target_dial_flow), "Dialyste flow value should be :" + str(target_dial_flow)) + test.compare(dialFlow_properties["value"], target_dial_flow, "Dialyste flow value should be :" + str(target_dial_flow)) dialTmp = utility.get_object_from_names(names.o_dial_tmp_value) dialTmp_properties = object.properties(dialTmp) test.compare(str(dialTmp_properties["value"]), str(target_dial_tmp), "Dialyste Tmp value should be :" + str(target_dial_tmp)) dd.dd_conductivity(D17 = 0, - D27 = 0, - D29 = target_dial_cond, + D27 = target_dial_cond, + D29 = 0, D43 = 0, D74 = 0) dialCond = utility.get_object_from_names(names.o_dial_cond_value) dialCond_properties = object.properties(dialCond) - test.compare(str(dialCond_properties["value"]), str(target_dial_cond), "Dialyste conductivity value should be :" + str(target_dial_cond)) + test.compare(round(float(dialCond_properties["value"]),1), round(float(target_dial_cond/1000),1), "Dialyste conductivity value should be :" + str(target_dial_cond)) + test.endSection() + +def edit_treatment_duration(): + """ + Verifying New Treatment Duration in Main Treatment Screen + """ + td.td_treatment_time(tx_duration_s=51, tx_elapsed_s=5, tx_remaining_s=6) + td.td_ultrafiltration(10, 0.53, 0.37, 0) + + td.td_param_ranges( + min_tx_time_s=50, + max_tx_time_s=300, + min_uf_volume_mL=0.0, + max_uf_volume_mL=1790, + min_dial_rate_mLH=0, + max_dial_rate_mLH=0, + ) + + treatmentEdit = waitForObject(names.o_treatment_duration) + treatmentEditbutton = utility.findObjectById(treatmentEdit, "_editTimeIcon") + mouseClick(treatmentEditbutton) + if can_interface is not None: + channel_id = CAN.CanChannels.ui_to_td_ch_id + message_id = MsgIds.MSG_ID_UI_DURATION_VALIDATE_REQUEST.value + can_interface.register_receiving_publication_function( + channel_id, message_id, handle_new_treatment_duration_request + ) + utility.set_value_based_on_target(names.o_newTreatmentDuration_ValueAdjuster, 60) + mouseClick(waitForObject(names.o_continueButton_TouchRect, 3000)) + test.verify( + waitFor(lambda: newTreatmentDuration == 60, 5000), + "Verifying FW received New Treatment Duration", + ) + td.td_duration_validate_response(0, 60, 0, 0, 0) + parent_object = waitForObject(names.o_newTreatmentDuration, 3000) + newTreatmentDuration_value_object = utility.findObjectById(parent_object, "_value") + test.log(f"New Treatment Duration value: {str(newTreatmentDuration_value_object.text)}") + + parent_object = waitForObject(names.o_ufVolumeGoal, 3000) + ufVolumeGoal_value_object = utility.findObjectById(parent_object, "_value") + test.log(f"UF Volume Goal value: {str(ufVolumeGoal_value_object.text)}") + + parent_object = waitForObject(names.o_ufRate, 3000) + ufRate_value_object = utility.findObjectById(parent_object, "_value") + test.log(f"New UF Rate value: {str(ufRate_value_object.text)}") + + mouseClick(waitForObject(names.o_confirmButton_TouchRect, 3000)) + mouseClick(waitForObject(names.o_Popup_CloseButton, 3000)) + def main(): utils.tstStart(__file__) @@ -308,10 +377,10 @@ 0 , 0 , 0) - + # verify main treatment screen test.verify(waitForObjectExists(names.mainTreatmentScreen), "In Main Treatment") - + # Pressure State test.startSection("Verifying Pressure values on main treatment screen") test_pressure_displayed_in_treatment_screen_range_bar() @@ -324,9 +393,11 @@ H14_venous_max = VENOUS_HIGH_VAL_410 , H2_arterial_long = 0 , H14_venous_long = 0 , - tmp_pressure = 0 , + tmp_pressure = 0 , + tmp_long = 0.0, tmp_min = TMP_LOW_VAL_MINUS_640 , - tmp_max = TMP_HIGH_VAL_210) + tmp_max = TMP_HIGH_VAL_210, + barometric = 0.0) verify_arterial_and_venous_value_in_main_treatment_screen(ACCEPTED,ART_LOW_VAL_MINUS_390,ART_HIGH_VAL_220,VENOUS_LOW_VAL_MINUS_90,VENOUS_HIGH_VAL_410,TMP_LOW_VAL_MINUS_640,TMP_HIGH_VAL_210) test.endSection() @@ -344,7 +415,7 @@ for value in total_time_list: treatment_time_verification(value) #Check the treatment complete text message - test.compare(utility.get_object_from_names(names.o_treatmentTimeNotificationBarSmall).text, "Treatment Complete", "Tx time completed text should be :" + str("Treatment Complete")) + test.compare(waitForObjectExists(names.o_treatmentHome_notification_NotificationBarSmall,2000).text, "Treatment Complete", "Tx time completed text should be :" + str("Treatment Complete")) td.td_treatment_time( tx_duration_s = 51 , tx_elapsed_s = 5 , tx_remaining_s = 6 ) @@ -358,12 +429,16 @@ 0 , 0 , 0 ) - test.compare(utility.get_object_from_names(names.o_treatmentTimeNotificationBarSmall).text, "Treatment Paused", "Tx time paused text should be :" + str("Treatment Paused")) + test.compare(waitForObjectExists(names.o_treatmentHome_notification_NotificationBarSmall).text, "Treatment Paused", "Tx time paused text should be :" + str("Treatment Paused")) test.endSection() #TX Parameter Set Points test.startSection("Verifying blood flow, dialysate temp,dialysate flow and dialyste cond on main treatment screen") verify_setPoints_from_main_treatement() + test.endSection() - utils.tstDone() + test.startSection("Verifying New Treatment Duration in Main Treatment Screen") + edit_treatment_duration() test.endSection() + + utils.tstDone()