Index: suite_leahi/shared/scripts/configuration/config.py =================================================================== diff -u -rfbc172d248cc82326d08b47cfced0eb99a346990 -rbfa2437fb24685645c4437fd529b7500985d71ec --- suite_leahi/shared/scripts/configuration/config.py (.../config.py) (revision fbc172d248cc82326d08b47cfced0eb99a346990) +++ suite_leahi/shared/scripts/configuration/config.py (.../config.py) (revision bfa2437fb24685645c4437fd529b7500985d71ec) @@ -94,4 +94,4 @@ # Blood Prime TOTAL_SALINE_DELIVERED = "Total Saline Delivered" DELIVERING_SALINE = "Delivering Saline" - +BLOOD_PRIME_PAUSED_NOTIFICATION = "Blood Prime Paused" Index: suite_leahi/shared/scripts/names.py =================================================================== diff -u -r8e4d215c4b5dde81774657c667171bf95660015c -rbfa2437fb24685645c4437fd529b7500985d71ec --- suite_leahi/shared/scripts/names.py (.../names.py) (revision 8e4d215c4b5dde81774657c667171bf95660015c) +++ suite_leahi/shared/scripts/names.py (.../names.py) (revision bfa2437fb24685645c4437fd529b7500985d71ec) @@ -234,3 +234,16 @@ o_TreatmentBloodPrime_fluidProgressBar_ProgressBar = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "id": "_fluidProgressBar", "type": "ProgressBar", "unnamed": 1 } o_TreatmentBloodPrime_treatmentSaline = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "objectName": "_treatmentSaline", "type": "TreatmentSaline", } o_TreatmentBloodPrime_currentBolusVolume = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "type": "Label", "unnamed": 1 } +o_TreatmentBloodPrime_volumeText_Text = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "objectName": "_volumeText", "type": "Text", } +o_TreatmentBloodPrime_Blood_Prime_Paused_Text = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "type": "Text", "unnamed": 1 } +o_TreatmentBloodPrime_volumeProgress_ProgressCircle = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "objectName": "_volumeProgress", "type": "ProgressCircle", } +o_TreatmentBloodPrime_pausedNotification = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "objectName": "_pausedNotification", "type": "NotificationBarSmall", } +o_TreatmentBloodPrime_TimeText_hour_Text = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "objectName": "_TimeText_hour", "type": "Text", } +o_TreatmentBloodPrime_TimeText_minute_Text = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "objectName": "_TimeText_minute", "type": "Text", } +o_TreatmentBloodPrime_TimeText_second_Text = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "objectName": "_TimeText_second", "type": "Text", } +o_TreatmentBloodPrime_flowRateValue_Text = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "objectName": "_flowRateValue", "type": "Text", } +o_TreatmentBloodPrime_flowRateUnit_Text = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "objectName": "_flowRateUnit", "type": "Text", } +o_TreatmentBloodPrime_decrementFlowRateButton_ArrowButton = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "objectName": "_decrementFlowRateButton", "type": "ArrowButton", } +o_TreatmentBloodPrime_incrementFlowRateButton_ArrowButton = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "objectName": "_incrementFlowRateButton", "type": "ArrowButton", } +o_TreatmentBloodPrime_pauseResumeButton_TouchRect = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "objectName": "_pauseResumeButton", "type": "TouchRect", } +o_TreatmentBloodPrime_NotificationBar = {"container": o_TreatmentBloodPrime_TreatmentBloodPrime, "objectName": "NotificationBar", "type": "NotificationBarSmall", } Index: suite_leahi/tst_blood_prime/test.py =================================================================== diff -u -rf25828c547b6a140c4a01d6392d0c1d71e5ce678 -rbfa2437fb24685645c4437fd529b7500985d71ec --- suite_leahi/tst_blood_prime/test.py (.../test.py) (revision f25828c547b6a140c4a01d6392d0c1d71e5ce678) +++ suite_leahi/tst_blood_prime/test.py (.../test.py) (revision bfa2437fb24685645c4437fd529b7500985d71ec) @@ -4,14 +4,15 @@ # # Steps: # 1 Start Leahi Application and simulate TD standby mode and navigate to the Blood Prime Screen -# Test Saline component Different saline states, Progress bar, Start and stop button -# 2 Test Blood Prime Pressure Ranges +# 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 -import names +import names, re from configuration import utility, config from leahi_dialin.ui import utils from leahi_dialin.ui.td_messaging import TD_Messaging @@ -21,8 +22,11 @@ from leahi_dialin.protocols import CAN from leahi_dialin.utils import conversions -td_simulator = TD_Messaging() - +td_simulator = TD_Messaging() +can_interface = td_simulator.can_interface +bloodFlowrate = None +bloodPrimeState = None +salineBolusStartState = None ART_LOW_VAL_MINUS_390 = -390 ART_HIGH_VAL_220 = 220 VENOUS_LOW_VAL_MINUS_90 = -90 @@ -34,55 +38,68 @@ total_time_list = [90, 120] -def test_pressure_displayed_in_blood_prime_screen_range_bar(): +def handle_solution_infusion_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 salineBolusStartState + salineBolusStartState = state + + +def test_pressure_displayed_in_blood_prime_screen_range_bar(): TREATMENT_PRESSURE_ADJUSTMENT_TD_TEST_VALUES = [ { - "arterial_pressure" : 100, - "arterial_limit_low" : -300, - "arterial_limit_high" : 120, - "venous_pressure" : 140, - "venous_limit_low" : -100, - "venous_limit_high" : 250, + "arterial_pressure": 100, + "arterial_limit_low": -300, + "arterial_limit_high": 120, + "venous_pressure": 140, + "venous_limit_low": -100, + "venous_limit_high": 250, "pressure_limit_state": 2, - "tmp_pressure" : 250, - "tmp_limit_low" : -400, - "tmp_limit_high" : 200, + "tmp_pressure": 250, + "tmp_limit_low": -400, + "tmp_limit_high": 200, }, { - "arterial_pressure" : -200, - "arterial_limit_low" : -150, - "arterial_limit_high" : 120, - "venous_pressure" : 140, - "venous_limit_low" : -100, - "venous_limit_high" : 250, + "arterial_pressure": -200, + "arterial_limit_low": -150, + "arterial_limit_high": 120, + "venous_pressure": 140, + "venous_limit_low": -100, + "venous_limit_high": 250, "pressure_limit_state": 2, - "tmp_pressure" : 200, - "tmp_limit_low" : -300, - "tmp_limit_high" : 200, + "tmp_pressure": 200, + "tmp_limit_low": -300, + "tmp_limit_high": 200, }, { - "arterial_pressure" : 110, - "arterial_limit_low" : 100, - "arterial_limit_high" : 120, - "venous_pressure" : -100, - "venous_limit_low" : -50, - "venous_limit_high" : 250, + "arterial_pressure": 110, + "arterial_limit_low": 100, + "arterial_limit_high": 120, + "venous_pressure": -100, + "venous_limit_low": -50, + "venous_limit_high": 250, "pressure_limit_state": 2, - "tmp_pressure" : 250, - "tmp_limit_low" : -200, - "tmp_limit_high" : 400, + "tmp_pressure": 250, + "tmp_limit_low": -200, + "tmp_limit_high": 400, }, { - "arterial_pressure" : -130, - "arterial_limit_low" : -140, - "arterial_limit_high" : 120, - "venous_pressure" : 200, - "venous_limit_low" : -100, - "venous_limit_high" : 150, + "arterial_pressure": -130, + "arterial_limit_low": -140, + "arterial_limit_high": 120, + "venous_pressure": 200, + "venous_limit_low": -100, + "venous_limit_high": 150, "pressure_limit_state": 2, - "tmp_pressure" : 250, - "tmp_limit_low" : -100, - "tmp_limit_high" : 600, + "tmp_pressure": 250, + "tmp_limit_low": -100, + "tmp_limit_high": 600, }, ] for index in range(0, len(TREATMENT_PRESSURE_ADJUSTMENT_TD_TEST_VALUES), 1): @@ -124,18 +141,18 @@ ] td_simulator.td_pressure( - H2_arterial_pressure = target_arterial_pressure, - H14_venous_pressure = target_venous_pressure, - limit_state = target_pressure_state, - H2_arterial_min = target_arterial_min_limit, - H2_arterial_max = target_arterial_max_limit, - H14_venous_min = target_venous_min_limit, - H14_venous_max = target_venous_max_limit, - H2_arterial_long = 0, - H14_venous_long = 0, - tmp_pressure = target_tmp_pressure, - tmp_min = target_tmp_min_limit, - tmp_max = target_tmp_max_limit, + H2_arterial_pressure=target_arterial_pressure, + H14_venous_pressure=target_venous_pressure, + limit_state=target_pressure_state, + H2_arterial_min=target_arterial_min_limit, + H2_arterial_max=target_arterial_max_limit, + H14_venous_min=target_venous_min_limit, + H14_venous_max=target_venous_max_limit, + H2_arterial_long=0, + H14_venous_long=0, + tmp_pressure=target_tmp_pressure, + tmp_min=target_tmp_min_limit, + tmp_max=target_tmp_max_limit, ) # check the range bar's upper and lower bounds @@ -312,13 +329,10 @@ """ Verify the Different Saline States, ProgressBar, Start and Stop button """ - + test.startSection( "Verify the Different Saline States, ProgressBar, Start and Stop button" ) - can_interface = td_simulator.can_interface - global salineBolusStartState - # handle sent messages from UI if can_interface is not None: channel_id = CAN.DenaliChannels.ui_to_td_ch_id @@ -336,10 +350,12 @@ ) # verify send start bolus req message - mouseClick(waitForObject(names.o_TreatmentBloodPrime_startFluidButton_TouchRect)) + mouseClick( + waitForObject(names.o_TreatmentBloodPrime_startFluidButton_TouchRect, 3000) + ) test.verify( - waitFor("'salineBolusStartState == 1'", 5000), - "Testing UI -> TD message start bolus", + waitFor(lambda: salineBolusStartState == 1, 10000), + "Verifying FW received Saline Bolus Start State in Blood Priming screen", ) # change state to in progress @@ -399,8 +415,8 @@ # verify send stop bolus req message mouseClick(waitForObject(names.o_TreatmentBloodPrime_startFluidButton_TouchRect)) test.verify( - waitFor("'salineBolusStartState == 0'", 5000), - "Testing UI -> TD message stop bolus", + waitFor(lambda: salineBolusStartState == 0, 10000), + "Verifying FW received Saline Bolus Start State in Blood Priming screen", ) # change state to idle @@ -422,19 +438,172 @@ test.endSection() -# handler for messages from UI to FW -def handle_solution_infusion_request(message, timestamp=0.0): +def handle_blood_flow_rate_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 salineBolusStartState - salineBolusStartState = str(state) + global bloodFlowrate + bloodFlowrate = state +def handle_pause_blood_prime_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 bloodPrimeState + bloodPrimeState = state + + +def test_blood_flow_rate(): + """ + Verifying Blood Prime Progress Data and Blood flow component + """ + test.startSection( + "Verifying Blood Prime Progress Data and Blood flow component" + ) + td_simulator.td_blood_prime_progress(1000, 500, 0, 0) + blood_prime_progress_maximum_volume = waitForObject( + names.o_TreatmentBloodPrime_volumeProgress_ProgressCircle, 3000 + ).maximum + test.compare( + blood_prime_progress_maximum_volume, + 1000, + "Comparison of Blood Prime Progress Maximum volume", + ) + blood_prime_progress_delivered_volume = waitForObject( + names.o_TreatmentBloodPrime_volumeText_Text, 3000 + ).text + test.compare( + blood_prime_progress_delivered_volume, + "500 mL", + "Comparison of Blood Prime Progress Delivered volume", + ) + + td_simulator.td_treatment_set_points(70, 0, 0) + if can_interface is not None: + channel_id = CAN.DenaliChannels.ui_to_td_ch_id + message_id = ( + MsgIds.MSG_ID_UI_TREATMENT_SET_POINT_BLOOD_FLOW_CHANGE_REQUEST.value + ) + can_interface.register_receiving_publication_function( + channel_id, message_id, handle_blood_flow_rate_request + ) + blood_flow_rate_value = waitForObject( + names.o_TreatmentBloodPrime_flowRateValue_Text, 3000 + ).text + test.compare(blood_flow_rate_value, "70", "Comparison of Flow Rate Value") + blood_flow_rate_unit = waitForObject( + names.o_TreatmentBloodPrime_flowRateUnit_Text, 3000 + ).text + test.compare(blood_flow_rate_unit, "mL/min", "Comparison of Flow Rate Unit") + mouseClick( + waitForObject( + names.o_TreatmentBloodPrime_incrementFlowRateButton_ArrowButton, 3000 + ) + ) + test.verify( + waitFor(lambda: bloodFlowrate == 80, 10000), + "Verifying FW received Increased Blood flow Value in Blood Priming screen", + ) + td_simulator.td_treatment_set_points(70, 0, 0) + mouseClick( + waitForObject( + names.o_TreatmentBloodPrime_decrementFlowRateButton_ArrowButton, 3000 + ) + ) + test.verify( + waitFor(lambda: bloodFlowrate == 60, 10000), + "Verifying FW received Decreased Blood flow Value in Blood Priming screen", + ) + + if can_interface is not None: + channel_id = CAN.DenaliChannels.ui_to_td_ch_id + message_id = MsgIds.MSG_ID_UI_BLOOD_PRIME_CMD_REQUEST.value + can_interface.register_receiving_publication_function( + channel_id, message_id, handle_pause_blood_prime_request + ) + mouseClick( + waitForObject(names.o_TreatmentBloodPrime_pauseResumeButton_TouchRect, 3000) + ) + test.verify( + waitFor(lambda: bloodPrimeState == 0, 10000), + "Verifying FW received Pause State of Blood Flow Rate in Blood Priming screen", + ) + + td_simulator.td_blood_prime_cmd_response(0, 2) + blood_priming_reject_notification = utility.get_object_from_names( + names.o_TreatmentBloodPrime_NotificationBar + ) + blood_priming_reject_notification_text = str(blood_priming_reject_notification.text) + digit = re.sub(r"^.*?\[(\d+)\].*$", r"\1", blood_priming_reject_notification_text) + + if digit: + digit_int = int(float(digit)) + test.compare(2, digit_int, f"Rejection reason number comparison for reason {2}") + test.log(f"Rejection reason text is {blood_priming_reject_notification_text}") + + td_simulator.td_tx_state( + TDTreatmentStates.TREATMENT_BLOOD_PRIME_STATE.value, 2, 0, 0, 0, 0, 0, 0, 0, 0 + ) + blood_prime_progress_paused_state = waitForObject( + names.o_TreatmentBloodPrime_pausedNotification, 3000 + ).text + test.compare( + blood_prime_progress_paused_state, + config.BLOOD_PRIME_PAUSED_NOTIFICATION, + "Comparison of Blood Prime Progress Paused State", + ) + + td_simulator.td_blood_prime_progress(1000, 500, 500, 250) + blood_prime_progress_paused_minute_countdown = waitForObject( + names.o_TreatmentBloodPrime_TimeText_minute_Text, 3000 + ).text + test.compare( + blood_prime_progress_paused_minute_countdown, + "10", + "Comparison of Blood Prime Progress Paused Minute Countdown", + ) + blood_prime_progress_paused_hour_countdown = waitForObject( + names.o_TreatmentBloodPrime_TimeText_hour_Text, 3000 + ).text + test.compare( + blood_prime_progress_paused_hour_countdown, + "04", + "Comparison of Blood Prime Progress Paused Hour Countdown", + ) + + mouseClick( + waitForObject(names.o_TreatmentBloodPrime_pauseResumeButton_TouchRect, 3000) + ) + test.verify( + waitFor(lambda: bloodPrimeState == 1, 10000), + "Verifying FW received Resume State of Blood Flow Rate in Blood Priming screen", + ) + + td_simulator.td_tx_state( + TDTreatmentStates.TREATMENT_BLOOD_PRIME_STATE.value, 1, 0, 0, 0, 0, 0, 0, 0, 0 + ) + td_simulator.td_blood_prime_progress(1000, 500, 0, 0) + mouseClick( + waitForObject(names.o_TreatmentBloodPrime_pauseResumeButton_TouchRect, 3000) + ) + test.verify( + waitFor(lambda: bloodPrimeState == 0, 10000), + "Verifying FW received Pause State of Blood Flow Rate in Blood Priming screen", + ) + test.endSection() + + def main(): utils.tstStart(__file__) startApplication(utility.aut("-q")) @@ -446,22 +615,24 @@ TDTreatmentStates.TREATMENT_BLOOD_PRIME_STATE.value, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) + test_blood_flow_rate() + test_blood_prime_saline_delivery() test_pressure_displayed_in_blood_prime_screen_range_bar() td_simulator.td_pressure( - H2_arterial_pressure = 0, - H14_venous_pressure = 0, - limit_state = 0, - H2_arterial_min = ART_LOW_VAL_MINUS_390, - H2_arterial_max = ART_HIGH_VAL_220, - H14_venous_min = VENOUS_LOW_VAL_MINUS_90, - H14_venous_max = VENOUS_HIGH_VAL_410, - H2_arterial_long = 0, - H14_venous_long = 0, - tmp_pressure = 0, - tmp_min = TMP_LOW_VAL_MINUS_640, - tmp_max = TMP_HIGH_VAL_210, + H2_arterial_pressure=0, + H14_venous_pressure=0, + limit_state=0, + H2_arterial_min=ART_LOW_VAL_MINUS_390, + H2_arterial_max=ART_HIGH_VAL_220, + H14_venous_min=VENOUS_LOW_VAL_MINUS_90, + H14_venous_max=VENOUS_HIGH_VAL_410, + H2_arterial_long=0, + H14_venous_long=0, + tmp_pressure=0, + tmp_min=TMP_LOW_VAL_MINUS_640, + tmp_max=TMP_HIGH_VAL_210, ) verify_arterial_and_venous_value_in_blood_prime_screen(