Index: suite_leahi/tst_pre_treatment_foundation/test.py =================================================================== diff -u -r84e0faeef60a1bf44bcbde97981b6955c19baa5d -r80c156369f3fe3fee359b0ad651db28ee18137e5 --- suite_leahi/tst_pre_treatment_foundation/test.py (.../test.py) (revision 84e0faeef60a1bf44bcbde97981b6955c19baa5d) +++ suite_leahi/tst_pre_treatment_foundation/test.py (.../test.py) (revision 80c156369f3fe3fee359b0ad651db28ee18137e5) @@ -21,21 +21,18 @@ from leahi_dialin.protocols import CAN from leahi_dialin.utils import conversions -td_simulator = TD_Messaging() -can_interface = td_simulator.can_interface -startTreatment = "-1" +td_simulator = TD_Messaging() +can_interface = td_simulator.can_interface +startTreatment = None # handler for messages from UI to FW -def handle_start_treatment_request(message, timestamp=0.0): +def handle_start_treatment_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 startTreatment - startTreatment = str(state) + startTreatment = True def send_start_treatment_response(vRejectionReason: int): @@ -138,20 +135,20 @@ def verify_start_treatment_request(): click_text(None, config.START) test.verify( - waitFor("'startTreatment == 1'", 3000), "Testing UI -> TD message Auto Load" + waitFor(lambda: startTreatment == True, 10000), "Testing UI -> TD message Start Treatment" ) def main(): utils.tstStart(__file__) test.startSection("Pre-Treatment Foundation") - global startTreatment - if can_interface: + # handle startTreatment sent messages from UI + if can_interface is not None: + channel_id = CAN.DenaliChannels.ui_to_td_ch_id + message_id = MsgIds.MSG_ID_UI_ADJUST_START_TREATMENT_REQUEST.value can_interface.register_receiving_publication_function( - CAN.DenaliChannels.ui_to_td_ch_id, - MsgIds.MSG_ID_UI_ADJUST_START_TREATMENT_REQUEST.value, - handle_start_treatment_request, + channel_id, message_id, handle_start_treatment_request ) application_init.reset_system_setting("AdvancedMode")