Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r7443e628b9cf908dc16917bba5b4d23b7d7f46bf -r44765c1ac1f4bd2fe890a30449bf72a746d7577c --- shared/scripts/configuration/utility.py (.../utility.py) (revision 7443e628b9cf908dc16917bba5b4d23b7d7f46bf) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 44765c1ac1f4bd2fe890a30449bf72a746d7577c) @@ -12,13 +12,15 @@ ############################################################################ + import csv import glob import math import object import os import names import sys + import squish import time import test @@ -35,53 +37,11 @@ from dialin.protocols import DenaliMessage, DenaliCanMessenger, DenaliChannels from datetime import datetime - LOG_LOCATION = "/home/denali/Desktop/sd-card/log/*.log" -hd_simulator = HDSimulator() - def color_verification(exp_val = "Red", act_val = "#c53b33"): test.compare(config.COLOR_CODES[color_name],(act_val.color[name])) - - -def start_application(app_name): - """ - Function to start application and verify application status [running] - If application does not start or running status is false, test stops - Argument: - @param app_name : (str) - Name of the application - @param app_executable : (str) - Actual application - @return: handle for the application if the application is in running state, - or error (exist the application) - """ - counter = 0 - while True: - try: - counter += 1 - test.log("Starting {}".format(app_name)) - squish.startApplication(app_name) - if counter == 1: - test.log("Application launched at the "+str(counter)+" st try.") - elif counter == 2: - test.log("Application launched at the "+str(counter)+" nd try.") - elif counter == 3: - test.log("Application launched at the "+str(counter)+" rd try.") - else: - test.log("Application launched at the "+str(counter)+" th try.") - break - except RuntimeError: - if counter == 1: - test.log("Application failed to launch after "+str(counter)+" try - Please refer logs") - elif counter == 20: - test.log("Exiting after "+str(counter)+ " tries..") - sys.exit(1) - else: - test.log("Application failed to launch after "+str(counter)+ " tries - Please refer logs") - except: - logErrorDetails("Failed to start the application") - sys.exit(1) - - + def check_if_object_is_within_the_container(obj=None, container=None): """ check if an object is inside a container @@ -1180,6 +1140,24 @@ date = datetime.now() return str(date.strftime(date_format)) +def navigate_to_pretreatment_screen(mode): + """ + Method to navigate to sub mode under pre-treatment screen + @param mode - (int) pre treatment state + """ + hd_simulator.cmd_set_hd_operation_mode_data(5,0) + + hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=mode, water_sample_state=0,consumables_self_test_state=0, + no_cartridge_self_test_state=0,installation_state=0, dry_self_test_state=0, + prime_state=0,recirculate_state=0, patient_connection_state=0) + + + +def get_current_date_and_time(date_format='%Y/%b/%d - %H:%M:%S'): + + date = datetime.now() + return str(date.strftime(date_format)) + def is_float(num): """ This function checks the value is adaptable for float conversion. @@ -1226,7 +1204,7 @@ return latest_file except: return False - + def get_message_from_log(file_name, message_text): """ @@ -1270,7 +1248,6 @@ except: test.fail("Log file is not created or log file is not created based on standard log naming format.") - def get_ack_request_details(file_name, message_text): """ This method intended to extract acknowledgement request status, negative requested acknowledgement @@ -1313,6 +1290,7 @@ test.fail("Log file is not created or log file is not created based on standard log naming format.") + def get_bak_request_details(file_name, ack_bak_value): """ This method intended to extract the acknowledgement back status from application log. @@ -1342,9 +1320,7 @@ test.fail("application log data is corrupted") except: test.fail("Log file is not created or log file is not created based on standard log naming format.") - - - + def get_current_log_details(message_ack = False, message_text = None): """ This function is capable to perform data analysis from application log folder. @@ -1371,7 +1347,6 @@ content_record.append(ack_bak_status) return content_record - def vitals_interval_obj(interval): names.o_time_interval_obj["text"] = interval return names.o_time_interval_obj @@ -1485,8 +1460,6 @@ "Actual Arterial range maximum value: {} is equal to Expected value: {}".format(arterial_max, art_high)) test.endSection() - - def set_venous_ranges_max_val(ven_high): """ Method to set the Venous range maximum value to user expected value @@ -1666,4 +1639,44 @@ except: return False +def scroll_to_value_on_pop_up(value=None, container=None): + """ + scroll to the to the value if object is hidden + @param value - (obj) value object + @param container - (obj) Container of the value + @return boolean true and false + """ + counter = 0 + while counter <= 100: + try: + counter += 1 + squish.findObject(value) + squish.snooze(0.5) + if check_if_object_is_within_the_container(obj=value, container=container): + return True + else: + raise RuntimeError + except RuntimeError: + ScreenObj = squish.waitForObject(container) + screenHeight = pyInt(ScreenObj.height) + screenWidth = pyInt(ScreenObj.width) + squish.mouseWheel(ScreenObj, screenWidth//2, + screenHeight//2, 0, -50, squish.Qt.NoModifier) + + raise LookupError("value object is not in view to the user after " + \ + "trying 100 times") + +def expected_heparin_value(val): + names.o_heparin_value["text"] = val + return names.o_heparin_value + + +def msg(string): + """ + Added ### at the right side of the string to make sure that it is a message. + @param string: (str) the string to add trailing ### to + @return pad_str: (str) padded string + """ + padded_str = "###"+string + return padded_str