Index: shared/scripts/configuration/config.py =================================================================== diff -u -r7bfa8590610e69d04dfa9ee4adafab65b60c187b -r353c3f31d770db01cd2a37421dffef5166d6c20a --- shared/scripts/configuration/config.py (.../config.py) (revision 7bfa8590610e69d04dfa9ee4adafab65b60c187b) +++ shared/scripts/configuration/config.py (.../config.py) (revision 353c3f31d770db01cd2a37421dffef5166d6c20a) @@ -28,3 +28,5 @@ BLOOD_PRIMING_TEXT = "Blood Priming" SALINE_UNIT = "mL" BLOOD_PRIMING_DEFAULT_VALUE = "0 mL" + +CREATE_TREATMENT_BUTTON_ACTIVE = "100 3800 4 01000000 " Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r0cc92d3b75bfb96dc4ecafd760a9ce15e455033b -r353c3f31d770db01cd2a37421dffef5166d6c20a --- shared/scripts/configuration/utility.py (.../utility.py) (revision 0cc92d3b75bfb96dc4ecafd760a9ce15e455033b) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 353c3f31d770db01cd2a37421dffef5166d6c20a) @@ -16,7 +16,10 @@ import sys import test import squish -from configuration import config +import math +from dialin.common import MsgIds +from dialin.utils import * +from dialin.protocols import DenaliMessage, DenaliCanMessenger, DenaliChannels from builtins import int as pyInt @@ -108,3 +111,73 @@ raise LookupError("zone object is not in view to the user after " + \ "trying 100 times") + + +def pad_message_with_zeros(message): + """ + Returns a packet padded with zeros that guarantees that the packet is a multiple of 8 bytes. + + @param message: packet that may or may not be multiple of 8 bytes + @return:: packet that is 8-byte multiple + + """ + PACKET_LENGTH = 4 + + message_length = len(message) + + if message_length % PACKET_LENGTH != 0: + add_these_many_zeros = math.ceil(message_length / PACKET_LENGTH) * \ + PACKET_LENGTH - message_length + + message += [0] * add_these_many_zeros + + return message + + +def ui_all_publication_handler(message: dict) -> None: + """ + This function is the default handler of the ui received messages which only prints out the received message + - This function can be used as an example. + - Be careful that there is only one ui publication method + and it will be overwritten on each call to the function set_ui_all_publication of the HDSimulator. + Look into the _init_loader of the Simulator class for example on how to register. + self.interface.hd.set_ui_all_publication(ui_all_publication_handler) + - This function is filtering the two message ID: + MsgIds.MSG_ID_UI_CHECK_IN.value, + MsgIds.MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK.value + for the simplicity of the printed message and as example of how to filter. + That filter can obviously be removed. + + @param message: the ui received message + @return: event binary from simulator + """ + exception_msg_id = { + MsgIds.MSG_ID_UI_CHECK_IN.value, + MsgIds.MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK.value + } + msg_id = DenaliMessage.get_message_id(message) + if msg_id in exception_msg_id: + return + + message_list = DenaliCanMessenger.convert_message_to_string(message) + event_binary = "" + pad_message_with_zeros(message_list) + + return event_binary + + +def cmd_set_create_treatment_click_event(response): + """ + Sends a set RTC response message + + @param response: (int) 0=NO, 1=YES + @return: N + """ + test.log("HD: Sending response {0}".format(response)) + + payload = integer_to_bytearray(response) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.ui_to_hd_ch_id, + message_id=MsgIds.MSG_ID_UI_INITIATE_TREATMENT_REQUEST.value, + payload=payload) + + return message Index: shared/scripts/names.py =================================================================== diff -u -r0cc92d3b75bfb96dc4ecafd760a9ce15e455033b -r353c3f31d770db01cd2a37421dffef5166d6c20a --- shared/scripts/names.py (.../names.py) (revision 0cc92d3b75bfb96dc4ecafd760a9ce15e455033b) +++ shared/scripts/names.py (.../names.py) (revision 353c3f31d770db01cd2a37421dffef5166d6c20a) @@ -46,6 +46,7 @@ o_uf_close_button = {"container": o_Overlay, "id": "_image", "source": "qrc:/images/iClose", "type": "Image", "unnamed": 1, "visible": True} o_fluid_text = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "text": "Volume Delivered", "type": "Text", "unnamed": 1, "visible": True} o_cumulative_fluid_text = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "text": "Cumulative Delivered", "type": "Text", "unnamed": 1, "visible": True} +o_MainHome_Create_Treatment_Button = {"container": o_MainHome_MainHome, "text": "CREATE TREATMENT", "type": "Text", "unnamed": 1, "visible": True} Index: tst_standbymode/test.py =================================================================== diff -u -r7bfa8590610e69d04dfa9ee4adafab65b60c187b -r353c3f31d770db01cd2a37421dffef5166d6c20a --- tst_standbymode/test.py (.../test.py) (revision 7bfa8590610e69d04dfa9ee4adafab65b60c187b) +++ tst_standbymode/test.py (.../test.py) (revision 353c3f31d770db01cd2a37421dffef5166d6c20a) @@ -9,7 +9,7 @@ # # file tst_standbymode # date 2022/04/01 -# author Joseph varghese +# author Joseph varghese # author Amol Shinde # author Bhavana Savanth # NOTE: @@ -26,10 +26,10 @@ hd_simulator = HDSimulator() -MORNING_MIN = "05" +MORNING_MIN = "00" MORNING_MAX = "12" -AFTERNOON_MAX = "18" + def get_current_time(): """ Tests to get current time. @@ -58,14 +58,26 @@ """ standby_text = waitForObject(names.o_standby_page) child = object.children(standby_text)[0] + print(str(current_time)) if current_time >= MORNING_MIN and current_time < MORNING_MAX: test.compare(child.text, "Good Morning") - elif current_time >= MORNING_MAX and current_time < AFTERNOON_MAX: - test.compare(child.text, "Good Afternoon") else: test.compare(child.text, "Good Evening") +def event_analysis_for_create_treatment_button(): + """ + Tests to verify binaries for create treatment button upon click + """ + mouseClick(waitForObject(names.o_MainHome_Create_Treatment_Button)) + + message = utility.cmd_set_create_treatment_click_event(response = True) + event_binary = utility.ui_all_publication_handler(message) + + test.compare(config.CREATE_TREATMENT_BUTTON_ACTIVE, str(event_binary), "binaries obtained during event-> create treatment button click should be expected") + + + def main(): utils.tstStart("tst_standbymode") @@ -74,6 +86,7 @@ hd_simulator.cmd_send_power_on_self_test_version_request() hd_simulator.cmd_send_hd_operation_mode(HDOpModes.MODE_STAN.value) + event_analysis_for_create_treatment_button() current_time = get_current_time() verify_welcome_text_on_standby_mode(current_time) verify_create_treatment_text()