Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -r2d57ccb6d19e9fda0a30ee78e25a4aea0414ff97 -r96fd1aec4a34f016b03af48b8bbc34a21d307813 --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 2d57ccb6d19e9fda0a30ee78e25a4aea0414ff97) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 96fd1aec4a34f016b03af48b8bbc34a21d307813) @@ -11,4 +11,18 @@ except LookupError: test.fail("ERROR : " + error_message) return None + +def findObjectById(parent, id): + """ + Recursively searches for a child object by its id. + Returns the found object or None if not found. + """ + if str(parent.id) == id: + return parent + + for child in object.children(parent): + found = findObjectById(child, id) + if found: + return found + return None \ No newline at end of file Index: suite_leahi/shared/scripts/names.py =================================================================== diff -u -r3c058b92591ff8a31fbe80d8df985d822c8b8698 -r96fd1aec4a34f016b03af48b8bbc34a21d307813 --- suite_leahi/shared/scripts/names.py (.../names.py) (revision 3c058b92591ff8a31fbe80d8df985d822c8b8698) +++ suite_leahi/shared/scripts/names.py (.../names.py) (revision 96fd1aec4a34f016b03af48b8bbc34a21d307813) @@ -36,4 +36,7 @@ o_dialyste_tmp_title_Text = {"container": mainTreatmentScreen, "id": "_dialysateTemp", "objectName": "dialysateTempComponent", "type": "TreatmentFlowsComponent" } o_dialyste_cond_title_Text = {"container": mainTreatmentScreen, "id": "_dialysateCond", "objectName": "dialysateCondComponent", "type": "TreatmentFlowsComponent" } o_treatmentTimeNotificationBarSmall = {"container": mainTreatmentScreen, "objectName": "notification", "type": "NotificationBarSmall" } +o_treatmentHome_iconImage_Image = {"container": mainTreatmentScreen, "id": "_iconImage", "source": "qrc:/images/iPause", "type": "Image", "unnamed": 1 } +o_treatmentHome_treatmentVitals_TreatmentVitals = {"container": mainTreatmentScreen, "objectName": "treatmentVitals", "type": "TreatmentVitals" } +o_treatmentHome_vitals_IconButton = {"container": mainTreatmentScreen, "id": "_vitals", "type": "IconButton", "unnamed": 1,"visible":True} Index: suite_leahi/tst_main_treatment/test.py =================================================================== diff -u -r3c058b92591ff8a31fbe80d8df985d822c8b8698 -r96fd1aec4a34f016b03af48b8bbc34a21d307813 --- suite_leahi/tst_main_treatment/test.py (.../test.py) (revision 3c058b92591ff8a31fbe80d8df985d822c8b8698) +++ suite_leahi/tst_main_treatment/test.py (.../test.py) (revision 96fd1aec4a34f016b03af48b8bbc34a21d307813) @@ -18,14 +18,30 @@ # -Set lower and upper bound for dialysate temp and test each limit # -Set lower and upper bound for dialysate flow and test each limit # -Set lower and upper bound for dialysate cond and test each limit +# 5 Test new UF pause/resume button +# - Click on pause button +# - Check FW gets pause request +# - Check the UF state to paused +# - Click on resume button +# - Check FW gets pause request +# +# 6 Test new vitals measurement button +# - Click on heart icon in Vitals component in main treatment +# - confirm FW gets request + import names +import can + from leahi_dialin.ui import utils +from leahi_dialin.protocols import CAN from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.ui.dd_messaging import DD_Messaging from configuration import utility from leahi_dialin.common.td_defs import TDOpModes,TDTreatmentStates +from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions + ART_LOW_VAL_MINUS_390 = -390 ART_HIGH_VAL_220 = 220 VENOUS_LOW_VAL_MINUS_90 = -90 @@ -40,13 +56,15 @@ {"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 +pauseresumerequest = "-1" + 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 @@ -192,7 +210,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): @@ -267,15 +285,15 @@ 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(float(bloodFlow_properties["value"]), float(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(float(dialFlow_properties["value"]), float(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)) + test.compare(float(dialTmp_properties["value"]), float(target_dial_tmp), "Dialyste Tmp value should be :" + str(target_dial_tmp)) dd.dd_conductivity(D17 = 0, D27 = 0, @@ -286,18 +304,35 @@ 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)) + +def handle_pause_resume_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 pauseresumerequest + pauseresumerequest = state def main(): utils.tstStart(__file__) startApplication(names.AUT_NAME + " -q") - + global pauseresumerequest + if can_interface is not None: + channel_id = CAN.DenaliChannels.ui_to_td_ch_id + message_id = MsgIds.MSG_ID_UI_UF_PAUSE_RESUME_REQUEST.value + can_interface.register_receiving_publication_function(channel_id, + message_id, + handle_pause_resume_request) td.td_operation_mode(TDOpModes.MODE_STAN.value,0) # verify Standby screen test.verify(waitForObjectExists(names.o_standByScreen_MainHome), "In Standby") - td.td_operation_mode( TDOpModes.MODE_TREA.value, 0 ) + td.td_operation_mode( TDOpModes.MODE_PRET.value, 0 ) td.td_tx_state(TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value , 0 , 0 , @@ -338,6 +373,34 @@ start_test_treatment_ultrafiltration(**value) test.endSection() + #Test New UF pause/Resume button + pauseResume = waitForObject(names.o_treatmentHome_iconImage_Image,1000) + mouseClick(pauseResume) + # global pauseresumerequest + test.verify(waitFor(" 'pauseresumerequest == 0'", 3000), "Testing FW received Pause Request from the UI") + td.td_ultrafiltration( set_volume = 1.2 , + target_rate = 0.5 , + volume_delivered = 0.2 , + state = 1 ) + mouseClick(pauseResume) + test.verify(waitFor(" 'pauseresumerequest == 1'", 3000), "Testing FW received Resume Request from the UI ") + td.td_ultrafiltration( set_volume = 1.2 , + target_rate = 0.5 , + volume_delivered = 0.2 , + state = 0 ) + + + #check the vitals + mouseClick(waitForObject(names.o_treatmentHome_vitals_IconButton)) + if can_interface is not None: + channel_id = CAN.DenaliChannels.ui_to_td_ch_id + message_id = MsgIds.MSG_ID_UI_BLOOD_PRESSURE_REQUEST.value + can_interface.register_receiving_publication_function(channel_id, + message_id, + handle_pause_resume_request) + + test.verify(waitFor(" 'pauseresumerequest == 1'", 3000), "Testing FW received Request from the UI ") + #TX Time #Calculating total seconds into minutes and passing to treatment time verification test.startSection("Verifying TX time on main treatment screen")