# Subject/Title: LDT - 2953 Rinseback - SW - 02 - Q&R - 15: SIT - Software Integration Tests - Squish Qt # Functionalities: Testing all functionalities of Rinseback feature in the treatment screen # # Steps: # Rinseback Feature: # Navigate to the treatment and change the submode to Rinseback state # Send the pressure container values from the FW # Verify UI displays the correct values which are send from the FW # Send the rinseback data from FW and verify # 1. Progress circle show correct values # 2. Flow rate value displayed in the UI # Click on pause rinseback button Verify the following # 1. FW gets the request with correct opmode # Test Rejection # Verify the error message in the UI # Test accepted # Orange progress bar should be displayed # "Rinseback Paused" text should be displayed # Verify the timeout text in the UI # Click on Resume rinseback button on the UI # Verify the FW gets the request with correct opmode # Change the rinseback submode to RUN state # Click on increment and decrement rinseback button # Verify the FW gets the request with correct opmode # Click on End Rinseback button # Verify the FW gets the request with correct opmode # Change the rinseback submode to Stop state and verify the screen changes to Rinseback complete page import names import can # plugin specific from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions from leahi_dialin.protocols import CAN from leahi_dialin.ui import utils from configuration import utility,config from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.common.ui_defs import TXStates from leahi_dialin.common.td_defs import TDOpModes,TDTreatmentStates from leahi_dialin.utils import conversions td = TD_Messaging() can_interface = td.can_interface rinsebackrequest = None def change_treatmentstates(state,substate): test.startSection("Change the treatment parameter") td.td_tx_state( state, 0 , 0 , 0 , 0 , substate, 0 , 0 , 0 , 0) test.endSection() def handle_rinseback_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 rinsebackrequest rinsebackrequest = state def verify_pressure_value(): test.startSection("Verify the pressure container values") td.td_operation_mode(TDOpModes.MODE_STAN.value) change_treatmentstates(TDTreatmentStates.TREATMENT_RINSEBACK_STATE.value,TXStates.RINSEBACK_RUN_STATE) td.td_pressure(H2_arterial_pressure = -151, H14_venous_pressure = -12, limit_state = 0, H2_arterial_min = -390, H2_arterial_max = 220 , H14_venous_min = -90 , H14_venous_max = 410 , H2_arterial_long = 0 , H14_venous_long = 0 , tmp_pressure = -100 , tmp_min = -500 , tmp_max = -50) arterial = waitForObject(names.o_EndTreatmentRinseback_arterialRangeBar_TreatmentPressureComponent,3000) arterial_rangeBar = utility.get_object_from_names(arterial, error_message="arterial rangeBar object is missing") arterial_low = arterial_rangeBar.lowerBound arterial_high = arterial_rangeBar.upperBound arterial_value = utility.findObjectById(arterial, "_value") venous = waitForObject(names.o_EndTreatmentRinseback_venousRangeBar_TreatmentPressureComponent) venous_rangeBar = utility.get_object_from_names(venous, error_message="venous rangeBar object is missing") venous_low = venous_rangeBar.lowerBound venous_high = venous_rangeBar.upperBound venous_value = utility.findObjectById(venous, "_value") tmp = waitForObject(names.o_EndTreatmentRinseback_tmpRangeBar_TreatmentPressureComponent) tmp_RangeBar = utility.get_object_from_names(tmp, error_message="trancememberance rangeBar object is missing") trancememberance_low = tmp_RangeBar.lowerBound trancememberance_high = tmp_RangeBar.upperBound tmp_value = utility.findObjectById(tmp, "_value") test.compare(str(arterial_value.text),str(-151), "Arterial value should be '{}'".format(arterial_value.text)) test.compare(str(venous_value.text),str(-12), "Venous value should be '{}'".format(venous_value.text)) test.compare(str(tmp_value.text),str(-100), "Trancememberance value should be '{}'".format(tmp_value.text)) test.compare(arterial_low, -390, "Arterial low value should be '{}'".format(arterial_low)) test.compare(arterial_high, 220, "Arterial high value should be '{}'".format(arterial_high)) test.compare(venous_low, -90, "Venous low value should be '{}'".format(venous_low)) test.compare(venous_high, 410, "Venous high value should be '{}'".format(venous_high)) test.compare(trancememberance_low, -500, "Trancememberance low value should be '{}'".format(trancememberance_low)) test.compare(trancememberance_high, -50, "Trancememberance high value should be '{}'".format(trancememberance_high)) test.endSection() def verify_flow_values_rinseback(): test.startSection("Verify the Flow Rate values") td.td_rinseback_progress( vTargetVolume = 32, vDeliveredVolume = 13, vFlowRate = 150, vTimeout = 0, vCountdown = 0, vIsCompleted = 0) delivered_volume = waitForObject(names.o_EndTreatmentRinseback_deliveredVolumeText_Text) delivered_volume_text = delivered_volume.text test.compare(str(delivered_volume_text),str("13 mL"),"Delivered Volume value should be '{}'".format(delivered_volume_text)) flow_rate = waitForObject(names.o_EndTreatmentRinseback_flowRateValue_Text) flow_rate_text =flow_rate.text test.compare(str(flow_rate_text),str("150"),"Flow rate value should be '{}'".format(delivered_volume_text)) test.endSection() def verify_pause_rinseback(): test.startSection("Verify the Pause rinseback state") mouseClick(waitForObject(names.o_EndTreatmentRinseback_pauseResumeButton_TouchRect, 2000)) test.verify(waitFor( lambda: rinsebackrequest == 3, 3000), "Testing FW received Pause Rinseback request") td.td_rinseback_cmd_response(vRejectionReason = 1) rejectionReason = waitForObject(utility.setObjectText(text=config.REQUEST,obj =names.o_EndTreatmentRinseback_NotificationBar_NotificationBarSmall)) test.compare(rejectionReason.text,config.REQUEST, "Rejection Reason text should be :" + str(rejectionReason.text)) td.td_rinseback_cmd_response(vRejectionReason = 0) change_treatmentstates( TDTreatmentStates.TREATMENT_RINSEBACK_STATE.value, TXStates.RINSEBACK_PAUSED_STATE) progressbar_color = waitForObject(names.o_EndTreatmentRinseback_targetVolumeProgress_ProgressCircle).color.name test.compare(progressbar_color, "#9b864e", "Progress bar should be'{}'".format(progressbar_color)) rinseback = waitForObject(utility.setObjectText(text=config.RINSEBACK_PAUSED ,obj =names.o_EndTreatmentRinseback)) test.compare(rinseback.text, config.RINSEBACK_PAUSED, "Rinseback paused text should be'{}'".format(rinseback.text)) test.endSection() def verify_resume_rinseback(): test.startSection("Verify the resume rinseback state") td.td_rinseback_progress( vTargetVolume = 32, vDeliveredVolume = 13, vFlowRate = 150, vTimeout = 43, vCountdown = 84, vIsCompleted = 0) timeouttext = waitForObject(names.o_EndTreatmentRinseback_timeout_TimeText, 2000) timeoutValue = str(timeouttext.time) test.compare(timeoutValue,"01:24","Rinseback paused text should be'{}'".format(timeoutValue)) mouseClick(waitForObject(names.o_EndTreatmentRinseback_pauseResumeButton_TouchRect, 2000)) test.verify(waitFor( lambda: rinsebackrequest == 4, 3000), "Testing FW received Resume Rinseback request") change_treatmentstates( TDTreatmentStates.TREATMENT_RINSEBACK_STATE.value, TXStates.RINSEBACK_RUN_STATE) test.endSection() def verify_increment_decrement_rinseback_values(): test.startSection("Verify the increment and decrement values in rinseback flow values ") incrementButton = waitForObject(names.o_EndTreatmentRinseback_incrementFlowRateButton_ArrowButton,1000) mouseClick(incrementButton) test.verify(waitFor( lambda: rinsebackrequest == 1, 3000), "Testing FW received Increment value") decrementButton =waitForObject(names.o_EndTreatmentRinseback_decrementFlowRateButton_ArrowButton,1000) mouseClick(decrementButton) test.verify(waitFor( lambda: rinsebackrequest == 2, 3000), "Testing FW received Decrement Value") endRinseback = waitForObject(names.o_EndTreatmentRinseback_endButton_TouchRect,2000) mouseClick(endRinseback) test.verify(waitFor( lambda: rinsebackrequest == 5, 3000), "Testing FW received End Rinseback Value") change_treatmentstates( TDTreatmentStates.TREATMENT_RINSEBACK_STATE.value, TXStates.RINSEBACK_STOP_STATE) test.endSection() def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) global rinsebackrequest if can_interface is not None: channel_id = CAN.DenaliChannels.ui_to_td_ch_id message_id = MsgIds.MSG_ID_UI_RINSEBACK_CMD_REQUEST.value can_interface.register_receiving_publication_function(channel_id, message_id, handle_rinseback_request) verify_pressure_value() verify_flow_values_rinseback() verify_pause_rinseback() verify_resume_rinseback() verify_increment_decrement_rinseback_values() test.startSection("Verify the screen changes to Rinseback complete page") test.verify(waitForObjectExists(names.o_EndTreatmentRinsebackComplete_instructionView_InstructionView), "In Rinseback complete page") test.endSection() utils.tstDone()