Index: shared/scripts/configuration/config.py =================================================================== diff -u -r9adc943bb139152cea73c31b2d508b2cea3d6ec5 -r4dfe8f7ce0cf625ca3039ff482eba432f3cf7ade --- shared/scripts/configuration/config.py (.../config.py) (revision 9adc943bb139152cea73c31b2d508b2cea3d6ec5) +++ shared/scripts/configuration/config.py (.../config.py) (revision 4dfe8f7ce0cf625ca3039ff482eba432f3cf7ade) @@ -6,24 +6,110 @@ # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # -# @file utils.py +# @file config.py # -# @author (last) Joseph varghese -# @date (last) 18-Jan-2022 +# @author (last) LTTS +# @date (last) 08-July-2022 # ############################################################################ import os from pathlib import Path from configuration.strings import * +# -S, --disable-sd-card-fail-log-stop disable-sd-card-fail-log-stop +# -k, --enable-check-in-log Enables Check-In Log +# -K, --enable-acknow-log Enables Acknowledgment Log + AUT_NAME = "denaliSquish -k -K -S" +HOME_DIR_PATH = "/home/denali" +#service screen +SERVICE_CONF_LOCATION ="".join([str(HOME_DIR_PATH),'/Projects/application/resources/settings/Settings/System.conf']) + +#post treatment +POST_TREATMENT_LOG_LOCATION = "".join([str(HOME_DIR_PATH),'/Desktop/sd-card/treatment/*.log']) + +#instructions_imagelocation +INSTRUCTION_CONF_LOCATION = "".join([str(HOME_DIR_PATH),'/Projects/application/resources/settings/Instructions/Instructions.conf']) +IMAGE_LOCATION = "file://"+"".join([str(HOME_DIR_PATH),'/Projects/application/resources/settings/Instructions/']) +EXPECTED_IMAGE_LOCATION ="".join([str(HOME_DIR_PATH),'/Projects/application/resources/settings/Instructions/']) +TREATMENT_LOG_LOCATION = "".join([str(HOME_DIR_PATH),'/Desktop/sd-card/treatment/*.log']) + +#cloud_sync_verification +INP_BUF_FILE_LOCATION = "".join([str(HOME_DIR_PATH),'/Desktop/sd-card/cloudsync/']) +CLOUD_CREDENTIALS_LOCATION = "".join([str(HOME_DIR_PATH)+'/Desktop/cloudsync/credentials']) +ERROR_FILE_LOCATION = "".join([str(HOME_DIR_PATH)+'/Desktop/sd-card/service/']) + +#ui_logs +LOG_LOCATION = "".join([str(HOME_DIR_PATH),'/Desktop/sd-card/log/']) + +CLOUDSYNC_FOLDER_PATH = "".join([str(HOME_DIR_PATH)+'/Desktop/']) +SD_CARD_CLOUDSYNC_FOLDER_PATH = "".join([str(HOME_DIR_PATH)+'/Desktop/sd-card/']) +SD_CARD_LOCATION = "".join([str(HOME_DIR_PATH)+'/Desktop/']) +USB_DISK_FOLDER_LOCATION = "".join([str(HOME_DIR_PATH)+'/Desktop/']) +SETTINGS_FOLDER_LOCATION = "".join([str(HOME_DIR_PATH)+'/Projects/application/resources/']) +APPLICATION_FOLDER_LOCATION = "".join([str(HOME_DIR_PATH)+'/Projects/']) +CANBUS_FOLDER_LOCATION = "".join([str(HOME_DIR_PATH)+'/Projects/application/sources/']) +PEM_FILES = ['1.pem', '2.pem', '3.pem' ] + +#standby mode +GOODMORNING_START_TIME_SEC = 0 +GOODEVENING_START_TIME_SEC = 43200 +NUM_OF_REQUEST_REJECT_REASONS = 46 #Number of settings change reject codes + +#Disinfection +DISINFECT_TREATMENT_ID = ["_headStepBullet","_nextStepsBullet"] + COLOR_CODES = {"Aqua": "#81ffff", "Blue": "#017dea", "Blue 2": "#1090d5", "Green": "#29fd2d", "Grey": "#d3d3d3", "Lavender": "#db98f5", "Light Blue": "#acd7f1", "Light Teal": "#29f1da","Lime": "#b7fc36", "Magenta":"#fd28fd", "Orange": "#f2721c", "Peach":"#f1979a", "Red": "#c53b33", "Rose":"#fc178d", "Slate blue":"#7f7ffa", "Violet": "#6435c9", "White": "#ffffff", "Yellow": "#fcfc4d"} +CURRENT_COLOR = '#000000' +COMPLETE_COLOR = '#4290ec' +ENABLED_COLOR = '#fcfcfc' +INCOMPLETE_COLOR = '#607a91' +OUT_OF_RANGE_COLOR = "#c53b33" + +#main treatment screen +IN_RANGE_COLOR = "#fcfcfc" +SYSTOLIC_LOWER_LIMIT = 60 +SYSTOLIC_UPPER_LIMIT = 250 +DIASTOLIC_LOWER_LIMIT = 40 +DIASTOLIC_UPPER_LIMIT = 200 +HEART_RATE_LOWER_LIMIT = 40 +HEART_RATE_UPPER_LIMIT = 180 + +KEYBOARD_SWITCH = ["ABC", "&123"] + +TREATMENT_UNHIGHLIGHTED_COLOR = "#000000" +TREATMENT_HIGHLIGHTED_COLOR = "#135088" + +#create custom treatment +HIGHER_VALUE_OF_BLOOD_FLOW_RATE = 500 +LOWER_VALUE_OF_BLOOD_FLOW_RATE = 100 +STEP_VALUE_OF_BLOOD_FLOW_RATE = 25 +BUFFER_LOW_AND_HIGH_LIMITS = 30 +ARTERIAL_VALUE_0 = 0 +ARTERIAL_VALUE_NEGATIVE_300 = -300 +ARTERIAL_VALUE_NEGATIVE_20 = -20 +ARTERIAL_VALUE_NEGATIVE_270 = -270 +VENOUS_VALUE_600 = 600 +VENOUS_VALUE_20 = 20 +VENOUS_VALUE_50 = 50 +VENOUS_VALUE_570 = 570 +POSITIVE_BUFFER = 10 +NEGATIVE_BUFFER = -10 + +#Alarms location +CONFIG_PATH = Path(os.getcwd()) +HOME_DIR_PATH = CONFIG_PATH.parent.parent.parent +ALARMS_CONF_LOCATION = "".join([str(HOME_DIR_PATH),'/Projects/application/resources/settings/Alarms/Alarms.conf']) +ALARM_MAPPING_CSV_FILE_LOCATION = "".join([str(HOME_DIR_PATH)+'/Projects/denali/AlarmMapping.csv']) +ALARM_MAPPING_CSV_DIR_LOCATION = "".join([str(HOME_DIR_PATH)+'/Projects/denali/']) +APPLICATION_FOLDER_LOCATION = "".join([str(HOME_DIR_PATH)+'/Projects/']) + #Service password loction HOME_DIR_PATH = "/home/denali" SERVICE_CONF_LOCATION ="".join([str(HOME_DIR_PATH),'/Projects/application/resources/settings/Settings/System.conf']) @@ -32,9 +118,290 @@ GOODMORNING_START_TIME_SEC = 0 GOODEVENING_START_TIME_SEC = 43200 +NUM_OF_ALARM_PRIORITIES = 4 # Total number of alarm priorities +NUM_OF_MSG_ID = 290 + +NUM_OF_ALARM_ID = 291 +ALARM_ID_NO_ALARM = 0 +ALARM_ID_OUT_OF_RANGE = 291 + +# alarm colors +ALARMS_COLORS_HEADER = { + "ALARM_PRIORITY_NONE" : "#438feb", + "ALARM_PRIORITY_LOW" : "#db8f00", + "ALARM_PRIORITY_MEDIUM" : "#db8f00", + "ALARM_PRIORITY_HIGH" : "#831913" +} + +ALARMS_COLORS_BODY = { + "ALARM_PRIORITY_NONE" : "#254670", + "ALARM_PRIORITY_LOW" : "#f5a623", + "ALARM_PRIORITY_MEDIUM" : "#f5a623", + "ALARM_PRIORITY_HIGH" : "#c53b33" +} + +ALARM_MUTE_FLAG = 0B0000001000000000 +ALARM_UNMUTE_FLAG = 0B0000000000000000 + +ALARM_BUTTONS_OK = 0B0000000010111000 + +ALARM_BUTTONS_RESUME = 0B0000000000110000 +ALARM_BUTTONS_RESUME_RINSEBACK = 0B0000000000100000 +ALARM_BUTTONS_RESUME_END = 0B0000000000010000 + +ALARM_BUTTONS_RINSEBACK = 0B0000000000101000 +ALARM_BUTTONS_RINSEBACK_RESUME = ALARM_BUTTONS_RESUME_RINSEBACK +ALARM_BUTTONS_RINSEBACK_END = 0B0000000000001000 + +ALARM_BUTTONS_END = 0B0000000000011000 +ALARM_BUTTONS_END_RESUME = ALARM_BUTTONS_RESUME_END +ALARM_BUTTONS_END_RINSEBACK = ALARM_BUTTONS_RINSEBACK_END + +ALARM_BUTTONS_RESUME_RINSEBACK_END = 0B0000000000000000 +ALARM_BUTTONS_RINSEBACK_RESUME_END = ALARM_BUTTONS_RESUME_RINSEBACK_END +ALARM_BUTTONS_END_RESUME_RINSEBACK = ALARM_BUTTONS_RESUME_RINSEBACK_END + +#standby mode & ultrafiltration +SALINE_BOLUS_CUMULATIVE = 300 +UF_MINIMUM_VALUE = 0 +UF_MAXIMUM_VALUE = 600 + + +#pressure +PRESSURE_STEPS = 10 +ARTERIAL_PRESSURE_MINIMUM = -400 +ARTERIAL_PRESSURE_MAXIMUM = +100 +ARTERIAL_PRESSURE_LOW_MIN = -300 +ARTERIAL_PRESSURE_LOW_DEF = -300 +ARTERIAL_PRESSURE_LOW_MAX = +200 +ARTERIAL_PRESSURE_HIGH_MIN = -300 +ARTERIAL_PRESSURE_HIGH_DEF = +100 +ARTERIAL_PRESSURE_HIGH_MAX = +200 + + +VENOUS_PRESSURE_MINIMUM = -100 +VENOUS_PRESSURE_MAXIMUM = +700 +VENOUS_PRESSURE_LOW_MIN = -100 +VENOUS_PRESSURE_LOW_DEF = -100 +VENOUS_PRESSURE_LOW_MAX = +600 +VENOUS_PRESSURE_HIGH_MIN = +100 +VENOUS_PRESSURE_HIGH_DEF = +400 +VENOUS_PRESSURE_HIGH_MAX = +600 + + +#main_treatment_flows +BLOOD_FLOW_MINIMUM_VALUE = 100 +BLOOD_FLOW_BUFFER = 25 +FLOW_SLIDER_WIDTH_BUFFER = 37 +BLOOD_FLOW_MAXIMUM_VALUE = 500 +DIALYSATE_FLOW_MINIMUM_VALUE = 0 +DIALYSATE_FLOW_MAXIMUM_VALUE = 0 # Seems to be bug. need change +DIALYSATE_FLOW_BUFFER = 50 +DIALYSATE_FLOW_SLIDER_WIDTH_BUFFER = 60 + + +#main treatment screen +OUT_OF_RANGE_COLOR = "#c53b33" +RED_COLOR = "#ff0000" +GREEN_COLOR = "#008000" +IN_RANGE_COLOR = "#fcfcfc" +SYSTOLIC_LOWER_LIMIT = 60 +SYSTOLIC_UPPER_LIMIT = 250 +DIASTOLIC_LOWER_LIMIT = 40 +DIASTOLIC_UPPER_LIMIT = 200 +HEART_RATE_LOWER_LIMIT = 40 +HEART_RATE_UPPER_LIMIT = 180 +BLOOD_PRIMING_RANGE = 300 +BLOOD_PRIMING_TARGET_MAXIMUM = 300 + +#tst_pretreatment_screens +NUM_OF_PRETREATMENT_BULLETS = len(PRE_TREATMENT_SCREENS) +SALINE_BOLUS_CUMULATIVE = 300 + + +#patient id +KEYBOARD_SWITCH = ["ABC", "&123"] +PATIENT_ID_COMBINATION = { + "qwerty" : "qwerty", + "sampleid" : "sampleid", + "abcdefghijklmnop" : "abcdefghijklmnop", + "patientid" : "patientid", + "username" : "username", + "sA@MpLE#123" : "sAMpLE123", + "A@BH&321" : "ABH321", + "5432@qwerty" : "5432qwerty" +} + +#Random selection for operational parameter for custom dta +OPERATIONAL_PARAMETERS = {"Heparin Type": HEPARIN_TYPE, "Acid Concentrate": "08-1251-1", + "Bicarbonate Concentrate": BICARBONATE_CONCENTRATE, "Dialyzer Type": "BB Diacap Pro 16H"} + + +#dictionary consist of custom treatment values +CREATE_CUSTOM_TREATMENT = { + "Blood Flow Rate": 250, + "Dialysate Flow Rate": 400, + "Duration": 270, + "Heparin Dispensing Rate": 0.5, + "Heparin Bolus Volume": 1, + "Heparin Stop Time": 100, + "Saline Bolus Volume": 200, + "Dialysate Temperature": 37, + "Blood Pressure Measurement Interval": 40, + "Rinseback Flow Rate": 100, + "Arterial Pressure Limit Low" : -30, + "Arterial Pressure Limit High" : 0, + "Blood Pressure Measure Interval" : 40, + "Rinseback Rate" : 100, + "Venous Pressure Limit High" : 590, + "Venous Pressure Limit Low": 560 +} + +#dictionary consist of slider values of treatment parameters +CREATE_TREATMENT_PARAMETER_RANGE = { + "Blood Flow Rate": [100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500], + "Dialysate Flow Rate": [100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600], + "Duration": [60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 240, 255, 270, 285, 300, 315, 330, 345, 360, 375, 390, 405, 420, 435, 450, 465, 480], + "Heparin Dispensing Rate": [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1], + "Heparin Bolus Volume": [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2], + "Heparin Stop Time": [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480], + "Saline Bolus Volume": [100, 200, 300], + "Dialysate Temperature": [35.0, 35.5, 36.0, 36.5, 37.0], + "Blood Pressure Measurement Interval": [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 0], + "Rinseback Flow Rate": [50, 75, 100, 125, 150], +} + +#dictionary consist of slider minimum value, slider buffer value, width buffer of slider +CREATE_TREATMENT_SLIDER_VALUES = { + + "blood_flow_rate" : [100, 25, 46], + "dialysate_flow_rate" : [100, 50, 75], + "duration" : [60, 15, 26.6], + "heparin_dispensing_rate" : [0.2, 0.1, 93], + "heparin_bolus_volume" : [0.2, 0.1, 41], + "heparin_stop_time" : [0, 10, 15.5], + "saline_bolus" : [100, 100, 375], + "dialysate_temperature" : [35, 0.5, 187.5], + "arterial_pressure_limit_high" : [20, 10, 11.931], + "blood_pressure_measurement_interval" : [0, 5, 62], + "rinseback_flow_rate" : [50, 25, 187], +} + +#ultrafilteration volume based on flow parameters. Python list contains Rotational speed, Motor speed, +# MC speed, MC current and PWM. +TREATMENT_ULTRAFILTRATION_FLOW_PARAMETERS = { + 0 : [100, 0, 0, 0, 0, 0, 0], + 1 : [220, 1.45, 1.45, 1.45, 1.45, 1.45, 1.45], + } + +#dictionary contains uf maximum and minimum value's to set. +TREATMENT_ULTRAFILTRATION_TESTING_OPTION = { + 0 : {"uf_maximum" : 600, "uf_minimum" : 0}, + 1 : {"uf_maximum" : 480, "uf_minimum" : 250}, + } + + +#tst_pretreatment_screens +NUM_OF_PRETREATMENT_BULLETS = len(PRE_TREATMENT_SCREENS) + +#dictionary contains saline cumulative and saline delivered value +#key : saline cumulative value. +#value: saline delivered value +SALINE_BOLUS_VALUES = { + 0 : 0, + 1.0 : 1.0, + 125.56 : 100.56, + 165.87 : 145.87, + 220.65 : 220.65, + 325.25 : 300.25, + 400.86 : 380.86, + 500.00 : 500.25, + 634.76 : 634.76, + 823.65 : 800.65, + 999.99 : 999.99, + 1000 : 1000 +} + +#testing options for main treatment saline +SALINE_BOLUS_TARGET = [0, 1, 150, 155, 299, 300] #Boundary Value Analysis + +# pretreatment_patient_connection +SYSTOLIC_PRESSSURE_120 = 120 +SYSTOLIC_PRESSSURE_113 = 113 +SYSTOLIC_PRESSSURE_150 = 150 +SYSTOLIC_PRESSSURE_175 = 175 +SYSTOLIC_PRESSSURE_200 = 200 +SYSTOLIC_PRESSSURE_200 = 200 +SYSTOLIC_PRESSSURE_251 = 251 +SYSTOLIC_PRESSSURE_59 = 59 +SYSTOLIC_PRESSSURE_15 = 15 +DIASTOLIC_PRESSSURE_25 = 25 +DIASTOLIC_PRESSSURE_39 = 39 +DIASTOLIC_PRESSSURE_74 = 74 +DIASTOLIC_PRESSSURE_80 = 80 +DIASTOLIC_PRESSSURE_85 = 85 +DIASTOLIC_PRESSSURE_60 = 60 +DIASTOLIC_PRESSSURE_150 = 150 +DIASTOLIC_PRESSSURE_200 = 200 +DIASTOLIC_PRESSSURE_201 = 201 +HEART_RATE_VAL_39 = 39 +HEART_RATE_VAL_60 = 60 +HEART_RATE_VAL_70 = 70 +HEART_RATE_VAL_85 = 85 +HEART_RATE_VAL_100 = 100 +HEART_RATE_VAL_101 = 101 +HEART_RATE_VAL_110 = 110 +HEART_RATE_VAL_181 = 181 +HEART_RATE_VAL_200 = 200 +UF_MINIMUM_SLIDER_WIDTH = -2 +UF_MAXIMUM_SLIDER_WIDTH = 638.00 +UF_VALID_RANGE = 700 +TRAINING_INDICATOR_SCREEN = 4 +ULTRAFILTRATION_VOLUME_COMBINATION_FROM_ULTRAFILTRATION_SETUP_SCREEN = { + "OPTION_1" : {"uf_maximum" : 800, "uf_minimum" : 0}, + "OPTION_2" : {"uf_maximum" : 500, "uf_minimum" : 0}, + "OPTION_3" : {"uf_maximum" : 550, "uf_minimum" : 0}, + "OPTION_4" : {"uf_maximum" : 300, "uf_minimum" : 0}, + "OPTION_5" : {"uf_maximum" : 280, "uf_minimum" : 0}, + "OPTION_6" : {"uf_maximum" : 765, "uf_minimum" : 0}, + "OPTION_7" : {"uf_maximum" : 680, "uf_minimum" : 0}, + "OPTION_8" : {"uf_maximum" : 1500, "uf_minimum" : 0}, + "OPTION_9" : {"uf_maximum" : 390, "uf_minimum" : 0}, + "OPTION_10" : {"uf_maximum" : 800, "uf_minimum" : 0}, + "OPTION_11" : {"uf_maximum" : 1000, "uf_minimum" : 0}, + "OPTION_12" : {"uf_maximum" : 1250, "uf_minimum" : 0}, + } + + +#pre-treatment_priming +NOT_VISIBLE = False +VISIBLE = True +FOCUS = True +NOT_IN_FOCUS = False +TIME_OUT_DURATION_300 = 300 +TIME_OUT_DURATION_200 = 200 +TIME_OUT_DURATION_100 = 100 +COUNT_DOWN_TIME_100 = 100 +MINIMUM_COUNTDOWN_TIME = 0 ENABLED = True -DISABLED = False +DISABLED = False + +#pre-treatment_priming +ACCEPTED = True +REJECTED = False + +#Filter Flush + +MAXIMUM_COUNTDOWN_TIME = 300 +MINIMUM_COUNTDOWN_TIME = 0 +TIME_OUT_DURATION_300 = 300 +TIME_OUT_DURATION_200 = 200 +TIME_OUT_DURATION_100 = 100 +COUNT_DOWN_TIME_100 = 100 +MINIMUM_COUNTDOWN_TIME = 0 +CONSUMABLE_SELF_TEST_BICARB_PUMP_CHECK_STATE = 3 + #settings information BRIGHTNESS_MIN_VAL = 20 BRIGHTNESS_MAX_VAL = 100 @@ -50,12 +417,108 @@ SUBNET_MASK = {"valid" : "255.255.255.0", "invalid" : "3.4.2.1"} DNS = {"valid" : "0.0.0.0", "invalid" : "3.2.1.3"} +#dictionary consist of review parameters values of post treatment +POST_TREATMENT_REVIEW_PARAMETER_RANGE = { + "Patient ID": ["abcd", "xyz"], + "Heparin Stop": [0, 101], + "Device ID": [1234, 1234], + "Heparin Delivered Volume": [10.1, 10.5], + "Blood Flow Rate": [100, 125], + "Treatment Start DateTime": [1654519251, 1623382321], + "Dialysate Flow Rate": [100, 150], + "Treatment End DateTime": [1654519251, 1623382321], + "Treatment Duration": [70, 75], + "Water Sample Test Result": [0, 1], + "Actual Treatment Duration": [62, 126], + "Dialysate Volume Used": [4.0, 6.0], + "Acid ConcentrateType": [0, 1], + "Prescribed UF Volume": [0.3, 0.5], + "Bicarbonate Concentrate Type": [0, 0], + "Target UF Volume": [10.1, 10.5], + "Potassium Concentration": [60, 75], + "Actual UF Volume": [0.3, 0.5], + "Calcium Concentration": [3, 56], + "Prescribed UF Rate": [0.1, 0.55], + "Bicarbonate Concentration": [14, 50], + "Target UF Rate": [0.2, 0.56], + "Sodium Concentration": [4, 6], + "Actual UF Rate": [0.5, 0.6], + "Dialysate Temperature": [35.0, 35.5], + "Saline Bolus Volume": [300, 250], + "Dialyzer Type": [0, 1], + "Average Blood Flow": [54.3, 67.3], + "Heparin Type": [0, 0], + "Average Dialysate Flow": [0.6, 0.5], + "Average Dialysate Temp": [35.0, 35.5], + "Heparin Bolus Volume": [0.0, 0.1], + "Average Arterial Pressure": [0.0, 11.56], + "Heparin Dispense Rate": [0.0, 0.1], + "Average Venous Pressure": [20.0, 101.45], +} + + +VALID = True +INVALID = False + +#cloud sync index +EPOCH_INDEX = 0 +SEQUENCE_INDEX = 1 +CRC_INDEX = 2 +CODE_INDEX = 3 +PARAMETER_COUNT = 4 +PARAMETER_INDEX = 5 + +#cloud_sync_hd_opmodes +OPMODE_INDEX = 5 +SUBMODE = 6 +HD_OPMODES_MSG_PARAMETER_LEN = 7 +HD_OPMODES_CREDENTIAL_PARAMETER_LEN = 6 + +#ui_logs +RESET_BINARY = "0" +SET_BINARY = "1" + + +TREATMENT_DATA_PARAMETER = { + "Blood flow rate" : [1, 2], + "Dialysate flow rate" : [3, 5], + "Uf rate" : [1.234, 3.452], + "Arterial pressure" : [10.123, 10.567], + "Venous pressure" : [10.323, 10.634], + + } +TREATMENT_ALARM_PARAMETER = { + "Alarm Id" : [2, 4], + "Parameter1" : [2.3, 3.7], + "Parameter2" : [3.4, 4.5], + + } +TREATMENT_EVENT_PARAMETER = { + "Event id" : [2, 3], + "Old Value" : [1.523, 1.945], + "New Value" : [2.523, 3.567], + + } + +UF_MINIMUM_SLIDER_WIDTH = -2 +UF_MAXIMUM_SLIDER_WIDTH = 638.00 + + #dg cleaning WATER_FLUSH_TIME_HOUR = {"valid" : "23","invalid" : "24"} WATER_FLUSH_TIME_MINUTE = {"valid" : "59","invalid" : "60"} WATER_FLUSH_CYCLE = {"valid" : "1", "invalid" : "8"} - HEAT_DISINFECTION_TIME_HOUR = {"valid" : "23","invalid" : "24"} HEAT_DISINFECTION_TIME_MINUTE = {"valid" : "59","invalid" : "60"} HEAT_DISINFECTION_CYCLE = {"valid" : "7", "invalid" : "61"} +#main-treatment heparin +NUM_OF_REQUEST_REJECT_REASONS = 46 + + +#heparin cumualtive values +HEPARIN_VALUES = {"Cumulative Value": [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 1.0, 15.0, 17.8, 20.0]} +COMPLETE_COLOR= '#4290ec' +ENABLED_COLOR = '#fcfcfc' +INCOMPLETE_COLOR = '#607a91' +NUM_OF_REQUEST_REJECT_REASONS = 46 Index: shared/scripts/configuration/strings.py =================================================================== diff -u -raea720dc4efe66713d2b9a00a7d6a2497dbcaea4 -r4dfe8f7ce0cf625ca3039ff482eba432f3cf7ade --- shared/scripts/configuration/strings.py (.../strings.py) (revision aea720dc4efe66713d2b9a00a7d6a2497dbcaea4) +++ shared/scripts/configuration/strings.py (.../strings.py) (revision 4dfe8f7ce0cf625ca3039ff482eba432f3cf7ade) @@ -1062,6 +1062,11 @@ SSID_TEXT = "SSID" SCAN_TEXT = "SCAN" SCAN_FINISHED_TEXT = "Scan Finished" +BACK_BUTTON_TEXT = "BACK" +IP_FAILED_MSG = "Failed to set static IP Address" +GATEWAY_FAILED_MSG = "Failed to set gateway." +SUBNET_FAILED_MSG = "Failed to set subnet mask." +DNS_FAILED_MSG = "Failed to set DNS." #Bluetooth cuff BLUETOOTH_CUFF_TITLE_TEXT = "Bluetooth Cuff" Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r9adc943bb139152cea73c31b2d508b2cea3d6ec5 -r4dfe8f7ce0cf625ca3039ff482eba432f3cf7ade --- shared/scripts/configuration/utility.py (.../utility.py) (revision 9adc943bb139152cea73c31b2d508b2cea3d6ec5) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 4dfe8f7ce0cf625ca3039ff482eba432f3cf7ade) @@ -6,30 +6,215 @@ # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # @file utils.py -# -# @author (last) Joseph varghese + +# @author (last) LTTS # @date (last) 15-Jan-2022 # ############################################################################ -import os + +import builtins +import csv +import glob +import math import names +import os +import object +import sys import squish import shutil +import time import test -import csv -from dialin.ui import utils +from builtins import format from builtins import str as pyStr from builtins import int as pyInt +from dialin.ui import utils +from configuration import config +from dialin.utils import * +from dialin.common.msg_ids import MsgIds +from dialin.ui.hd_simulator import HDSimulator +from dialin.protocols import DenaliMessage, DenaliCanMessenger, DenaliChannels +from datetime import timezone +from datetime import datetime +def color_verification(exp_val = "Red", act_val = "#c53b33"): + test.compare(config.COLOR_CODES[color_name],(act_val.color[name])) + -def scroll_to_zone(zone=None, screen_object=None): +def get_text_object(screen_obj, txt): """ - scroll to the numeric if object is hidden - @param zone - UI object - @param screen_object - UI object (UI Home screen = waveforms + numerics) - @return boolean true/false + To obtain a text object based on text provided + @param screen_obj: provides the container on which the txt must be present + @returns a real name object + """ + names.o_text_object["container"] = screen_obj + names.o_text_object["text"] = txt + return names.o_text_object + +def get_bullet_object(screen_obj, num): """ + To obtain a bullet object based on occurrence provided. + @param screen_obj: provides the container on which the bullet must be present + @param num: provides the occurrence value + @returns a real name object + """ + names.o_bullet_object["container"] = screen_obj + names.o_bullet_object["occurrence"] = num + 1 + return names.o_bullet_object + +def get_indicators(screen_obj, txt): + """ + Verifying the busy indicators for BiCarb Pump Check and Acid Pump Check. + indicator object of expected text + @param step - (str) expected text + @return indicators - (obj) list of busy and check indicator + """ + parent_obj = object.parent(squish.waitForObjectExists(get_text_object(screen_obj,txt))) + children_obj = object.children(parent_obj) + indicator_parent = children_obj[2] + indicators = object.children(indicator_parent) + return indicators + + +def check_if_object_is_within_the_container(obj=None, container=None): + """ + check if an object is inside a container + @param obj - child UI object + @param container - container UI object + @return boolean True/False + """ + container = squish.findObject(container) + containerPos = container.mapToGlobal(squish.QPoint(0, 0)) + container_x, container_y = pyInt(containerPos.x), pyInt(containerPos.y) + container_width, container_height = pyInt(container.width), pyInt(container.height) + + obj = squish.findObject(obj) + objPos = obj.mapToGlobal(squish.QPoint(0, 0)) + obj_x, obj_y = pyInt(objPos.x), pyInt(objPos.y) + obj_width, obj_height = pyInt(obj.width), pyInt(obj.height) + + if obj_x >= container_x and obj_y >= container_y: + if (obj_x + obj_width) <= (container_x + container_width) and (obj_y + obj_height) <= (container_y + container_height): + return True + + return False + + +def pressure_pop_up_text_obj(text): + names.o_pop_up_pressure_text_obj["text"] = text + return names.o_pop_up_pressure_text_obj + return names.o_bullet_object + + +def verify_bullet_navigation(num, num_of_instructions, screen_obj): + """ + Method to verify status of bullets based + on number of instruction screen + @param num - (int) number of indicator + @param num_of_instructions- (int) count the number of instructions + @param object - screen_obj - (str) Screen object + """ + test.startSection("instruction bullet verification for screens") + for instruction in range(1, num_of_instructions): + bullet_children = object.children(squish.waitForObjectExists(get_bullet_object(screen_obj,(0 + instruction) - 1))) + bullet_circle_color = bullet_children[0].color.name + bullet_border_color = bullet_children[0].border.color.name + if instruction <= num: + test.compare(bullet_circle_color, config.COMPLETE_COLOR) + test.compare(bullet_border_color,config.COMPLETE_COLOR) + test.log(str(instruction) + " Complete bullet") + else: + test.compare(bullet_circle_color, config.CURRENT_COLOR) + test.compare(bullet_border_color,config.INCOMPLETE_COLOR) + test.log(str(instruction) + " Incomplete bullet") + test.endSection() + +def convert_seconds_into_min_and_sec(seconds, time_format="%M:%S"): + """ + Method to convert seconds into minute format. + @param seconds - time in seconds. + @param time_format (str) - time format. + @return (int) - minute time + """ + seconds = int(seconds) + min_and_sec = time.strftime(time_format, time.gmtime(seconds)) + return min_and_sec + + +def verify_missing_object(object_to_check): + """ + Method to verify the given object is invisible or is not present on the screen + @param object_to_check: the object whose invisibility must be verified + """ + try: + squish.testSettings.objectNotFoundDebugging = False + squish.waitForObject(object_to_check,3000) + test.fail("Given object should not be present initially") + except LookupError as _: + test.passes("object is not present as expected") + squish.testSettings.objectNotFoundDebugging = True + + +def pressure_pop_up_text_obj(text): + names.o_pop_up_pressure_text_obj["text"] = text + return names.o_pop_up_pressure_text_obj + +def pressure_text_obj(text): + names.o_pressure_text_obj["text"] = text + return names.o_pressure_text_obj + +def get_current_date_and_time(date_format='%Y/%b/%d - %H:%M'): + date = datetime.now() + return str(date.strftime(date_format)) + + +def vitals_reading_obj(reading): + names.o_vitals_reading["text"] = reading + return names.o_vitals_reading + + +def enter_keypad_value(entry): + """ + Method to enter user desired + value using keypad + @param entry: (int) User expected value + """ + test.startSection("Entering {}".format(entry)) + entry = pyStr(entry) + for value in entry: + squish.mouseClick(squish.waitForObject(keypad_input(value))) + test.endSection() + +def erase_entered_value(input_field): + """ + Method to erase the entered value + @param input_field - (obj) object of input field + """ + test.startSection("Erasing value") + input_field= squish.waitForObject(input_field) + entered_value = str(input_field.text) + for value in range(len(entered_value)+1): + utils.waitForGUI(0.1) + squish.mouseClick(squish.waitForObjectExists(names.o_back_space_key)) + test.compare(str(input_field.text), "", "Input field should be empty") + test.endSection() + +def vitals_reading_obj(reading): + names.o_vitals_reading["text"] = reading + return names.o_vitals_reading + +def keypad_input(key_value): + names.o_keypad_input["text"] = key_value + return names.o_keypad_input + + +def scroll_to_zone(zone=None, screen_object=None, direction = 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: @@ -41,37 +226,928 @@ else: raise RuntimeError except RuntimeError: - ScreenObj = squish.waitForObject(screen_object) + ScreenObj = squish.findObject(screen_object) screenHeight = pyInt(ScreenObj.height) screenWidth = pyInt(ScreenObj.width) - squish.mouseWheel(ScreenObj, screenWidth-1000, screenHeight-10, 0, -50, squish.Qt.NoModifier) - + if direction is None: + squish.mouseWheel(ScreenObj, (screenWidth-100), 107, 0, -(screenHeight-460), squish.Qt.NoModifier) + else: + squish.mouseWheel(ScreenObj, (screenWidth-100), -(screenHeight-700), 0, 200, squish.Qt.NoModifier) + raise LookupError("zone object is not in view to the user after trying 100 times") + + +def get_alarm_id_obj(id): + names.o_alarm_id["text"] = id + return names.o_alarm_id + +def get_alarm_msg_obj(msg): + names.o_alarm_message["text"] = msg + return names.o_alarm_message + +def rejection_msg(text): + names.o_rejection_msg["text"] = text + return names.o_rejection_msg + +def verify_page_step_indicator(screen_obj, treatment_step, treatment_screens): + """ + Method to verify the Page Step indicators [the object on top of the screen which indicates the steps passed, current, remained] + @param treatment_step : indicates the Current treatment step + """ + test.startSection("verification of page step indicators") + for page in range(len(treatment_screens)): + bullet_children = object.children(squish.waitForObjectExists(get_bullet_object(screen_obj, page))) + bullet_circle_color = bullet_children[0].color.name + bullet_border_color = bullet_children[0].border.color.name + step_title = squish.waitForObjectExists(get_text_object(screen_obj, treatment_screens[page])) + + #To verify the step indicators of the completed treatment screens + if page < treatment_step: + test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete) + test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current) + test.compare(bullet_circle_color, config.COMPLETE_COLOR) + test.compare(bullet_border_color,config.COMPLETE_COLOR) + test.compare(step_title.color.name,config.ENABLED_COLOR) + #To verify the step indicators of the current treatment screen + elif page == treatment_step: + test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current) + test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete) + test.compare(bullet_circle_color, config.CURRENT_COLOR) + test.compare(bullet_border_color, config.COMPLETE_COLOR) + test.compare(step_title.color.name, config.ENABLED_COLOR) + test.verify(step_title.font.bold) + #To verify the step indicators of the remaining treatment screens + else: + test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current,) + test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete,) + test.compare(step_title.color.name, config.INCOMPLETE_COLOR) + test.compare(bullet_circle_color, config.CURRENT_COLOR) + test.compare(bullet_border_color, config.INCOMPLETE_COLOR) + test.endSection() + + +def set_arterial_ranges_min_val(art_low): + """ + Method to set the Arterial range maximum value to user expected value + @param art_low - (int) user expected value + """ + test.startSection("Set Arterial range minimum value to {}".format(art_low)) + arterial_min = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) + arterial_min = pyInt(arterial_min.minimum) + arterial_max = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) + arterial_max = pyInt(arterial_max.maximum) + low_handler_parent = object.parent(squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery)) + low_handler_children = object.children(low_handler_parent) + low_handler = low_handler_children[-2] + width = pyInt(low_handler.width) - 8 + height = pyInt(low_handler.height)- 10 + if arterial_min == art_low: + test.passes("Arterial range minimum is already set to {}".format(art_low)) + elif arterial_min < art_low: + while arterial_min != art_low: + squish.mouseDrag(low_handler, width, height, 1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + arterial_min += 10 + # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg + if arterial_min == arterial_max - config.BUFFER_LOW_AND_HIGH_LIMITS: + squish.mouseDrag(low_handler, width, height, 1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + test.log("Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) + break + else: + continue + elif arterial_min > art_low: + while arterial_min != art_low: + squish.mouseDrag(low_handler, width, height, -1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + arterial_min -= 10 + # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg + if arterial_min == arterial_max - config.BUFFER_LOW_AND_HIGH_LIMITS: + squish.mouseDrag(low_handler, width, height, -1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + test.log("Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) + break + else: + continue + # arterial blood pressure low limit should be lower than the high limit by atleast 30mmHg + if arterial_min == arterial_max - config.BUFFER_LOW_AND_HIGH_LIMITS: + test.compare(low_handler_parent.minValue, arterial_min, "Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) + else: + test.compare(arterial_min, art_low, "Actual Arterial range minimum value: {} is equal to Expected value: {}".format(arterial_min, art_low)) + test.endSection() + +def set_arterial_ranges_max_val(art_high): + """ + Method to set the Arterial range maximum value to user expected value + @param art_high - (int) user expected value + """ + test.startSection("Set Arterial range maximum value to {}".format(art_high)) + arterial_max = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) + arterial_max = pyInt(arterial_max.maximum) + arterial_min = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) + arterial_min = pyInt(arterial_min.minimum) + high_handler_parent = object.parent(squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery)) + high_handler_children = object.children(high_handler_parent) + high_handler = high_handler_children[-1] + width = pyInt(high_handler.width) - 20 + height = pyInt(high_handler.height) - 25 + if arterial_max == art_high: + test.passes("Arterial range maximum is already set to {}".format(art_high)) + elif arterial_max < art_high: + while arterial_max != art_high: + squish.mouseDrag(high_handler, -1, height, width, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + arterial_max += 10 + # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg + if arterial_max == arterial_min + config.BUFFER_LOW_AND_HIGH_LIMITS: + squish.mouseDrag(high_handler, width, height, 1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + test.log("Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) + break + else: + continue + elif arterial_max > art_high: + while arterial_max != art_high: + squish.mouseDrag(high_handler, width, height, -1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + arterial_max -= 10 + # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg + if arterial_max == arterial_min + config.BUFFER_LOW_AND_HIGH_LIMITS: + squish.mouseDrag(high_handler, width, height, -1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + test.log("Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) + break + else: + continue + # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg + if arterial_max == arterial_min + config.BUFFER_LOW_AND_HIGH_LIMITS: + test.compare(high_handler_parent.maxValue, arterial_max, "Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) + else: + test.compare(arterial_max, art_high, "Actual Arterial range maximum value: {} is equal to Expected value: {}".format(arterial_max, art_high)) + test.endSection() - -def check_if_object_is_within_the_container(obj=None, container=None): +def set_venous_ranges_max_val(ven_high): """ - check if an object is inside a container - @param obj - child UI object - @param container - container UI object - @return boolean true/false + Method to set the Venous range maximum value to user expected value + @param ven_high - (int) user expected value """ - container = squish.findObject(container) - containerPos = container.mapToGlobal(squish.QPoint(0, 0)) - container_x, container_y = pyInt(containerPos.x), pyInt(containerPos.y) - container_width, container_height = pyInt(container.width), pyInt(container.height) + test.startSection("Set Venous range maximum value to {}".format(ven_high)) + ven_max = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous) + ven_max = pyInt(ven_max.maximum) + ven_min = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous) + ven_min = pyInt(ven_min.minimum) + high_handler_parent = object.parent(squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous)) + high_handler_children = object.children(high_handler_parent) + high_handler = high_handler_children[-1] + width = pyInt(high_handler.width) - 15 + height = pyInt(high_handler.height) - 10 + if ven_max == ven_high: + test.passes("Venous range maximum is already set to {}".format(ven_high)) + elif ven_max < ven_high: + while ven_max != ven_high: + squish.mouseDrag(high_handler, width, height, 1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + ven_max += 10 + # venous blood pressure low limit should be lower than the high limit by at least 30mmHg + if ven_max == ven_min + config.BUFFER_LOW_AND_HIGH_LIMITS: + squish.mouseDrag(high_handler, width, height, 1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + test.log("Venous range maximum value cannot be moved beyond {}".format(ven_max)) + break + else: + continue + elif ven_max > ven_high: + while ven_max != ven_high: + squish.mouseDrag(high_handler, width, height, -1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + ven_max -= 10 + # venous blood pressure low limit should be lower than the high limit by at least 30mmHg + if ven_max == ven_min + config.BUFFER_LOW_AND_HIGH_LIMITS: + squish.mouseDrag(high_handler, width, height, -1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + test.log("Venous range maximum value cannot be moved beyond {}".format(ven_max)) + break + else: + continue + # venous blood pressure low limit should be lower than the high limit by at least 30mmHg + if ven_max == ven_min + config.BUFFER_LOW_AND_HIGH_LIMITS: + test.compare(high_handler_parent.maxValue, ven_max, "Venous range maximum value cannot be moved beyond {}".format(ven_max)) + else: + test.compare(ven_max, ven_high, "Actual Venous range maximum value: {} is equal to Expected value: {}".format(ven_max, ven_high)) + test.endSection() + +#Methods for create custom treatment +def set_venous_ranges_min_val(ven_low): + """ + Method to set the Venous range maximum value to user expected value + @param ven_low - (int) user expected value + """ + test.startSection("set Venous range minimum value to {}".format(ven_low)) + ven_min = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous) + ven_min = pyInt(ven_min.minimum) + ven_max = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous) + ven_max = pyInt(ven_max.maximum) + low_handler_parent = object.parent(squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous)) + low_handler_children = object.children(low_handler_parent) + low_handler = low_handler_children[-2] + width = pyInt(low_handler.width) - 15 + height = pyInt(low_handler.height) - 10 + if ven_min == ven_low: + test.passes("Venous range minimum is already set to {}".format(ven_low)) + elif ven_min < ven_low: + while ven_min != ven_low: + squish.mouseDrag(low_handler, width, height, 1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + ven_min += 10 + if ven_min == ven_max - config.BUFFER_LOW_AND_HIGH_LIMITS: # venous blood pressure low limit should be lower than the high limit by at least 30mmHg + squish.mouseDrag(low_handler, width, height, 1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + test.log("Venous range minimum value cannot be moved beyond {}".format(ven_min)) + break + else: + continue + elif ven_min > ven_low: + while ven_min != ven_low: + squish.mouseDrag(low_handler, width, height, -1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + ven_min -= 10 + # venous blood pressure low limit should be lower than the high limit by at least 30mmHg + if ven_min == ven_max - config.BUFFER_LOW_AND_HIGH_LIMITS: + squish.mouseDrag(low_handler, width, height, -1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) + test.log("Venous range minimum value cannot be moved beyond {}".format(ven_min)) + break + else: + continue + # venous blood pressure low limit should be lower than the high limit by at least 30mmHg + if ven_min == ven_max - config.BUFFER_LOW_AND_HIGH_LIMITS: + test.compare(low_handler_parent.minValue, ven_min, "Venous range minimum value cannot be moved beyond {}".format(ven_min)) + else: + test.compare(ven_min, ven_low, "Actual Venous range minimum value: {} is equal to Expected value: {}".format(ven_min, ven_low)) + test.endSection() + - obj = squish.findObject(obj) - objPos = obj.mapToGlobal(squish.QPoint(0, 0)) - obj_x, obj_y = pyInt(objPos.x), pyInt(objPos.y) - obj_width, obj_height = pyInt(obj.width), pyInt(obj.height) +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 + +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(HDOpModes.MODE_PRET.value,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 self_test_dry_check_list_text(text): + names.o_self_test_dry_check_list_text["text"] = text + return names.o_self_test_dry_check_list_text + +def get_time(screen_title): + """ + Method to return the current count down + in the application + @param screen_title - (str) current title of the screen + @return time_text - (str) count down in the application + """ + if screen_title == config.BEGIN_PRIME_TITLE or screen_title == config.PRIMING_TITLE: + parent_object = object.parent(squish.waitForObjectExists(self_test_dry_check_list_text(screen_title))) + elif screen_title == config.SYSTEM_SELF_TEST_TITLE: + parent_object = object.parent(squish.waitForObjectExists(names.o_system_self_test)) + else: + parent_object = object.parent(squish.waitForObjectExists(names.o_PreTreatmentBase_Filter_Flush_Text)) + time_parent_children = object.children(parent_object) + progress_circle_parent = time_parent_children[4] + progress_circle_parent = object.children(progress_circle_parent) + progress_circle_parent = progress_circle_parent[0] + progress_circle_parent = object.children(progress_circle_parent) + progress_circle_children = object.children(progress_circle_parent[0]) + time_text = progress_circle_children[1] + return time_text.time + +def verify_countdown(screen_title, time_out, hd_simulator, dg_simulator): + """ + Method to verify the count down + time in application + @param screen_title - (str) current title of the screen + @param time_out - (int) time out duration in secs + @Param hd_simulator - Instance of class HDSimulator + @Param dg_simulator - Instance of class DGSimulator + """ + test.startSection("Verify the count down time in application") + for count_down in range(config.COUNT_DOWN_TIME_100, config.MINIMUM_COUNTDOWN_TIME-1, -1): + if screen_title == config.BEGIN_PRIME_TITLE: + hd_simulator.cmd_send_pre_treatment_self_test_dry_progress_data(time_out, count_down) + elif screen_title == config.PRIMING_TITLE: + hd_simulator.cmd_send_pre_treatment_disposables_prime_progress_data(time_out, count_down) + elif screen_title == config.SYSTEM_SELF_TEST_TITLE: + hd_simulator.cmd_send_pre_treatment_self_test_no_cartridge_progress_data(time_out, count_down) + else: + dg_simulator.cmd_send_dg_pre_treatment_filter_flush_progress_data(time_out, count_down) + actual_time = get_time(screen_title) + expected_time = convert_seconds_into_min_and_sec(count_down) + test.compare(actual_time, expected_time, "Actual count down time: {} should be equal to expected count down time {}".format(actual_time, expected_time)) + verify_the_progress(count_down, screen_title, time_out) + test.endSection() + +def verify_the_progress(count_down, screen_title, time_out): + """ + Method to verify the current progress + @param count_down - (int) current count down time + @param screen_title - (str) current title of the screen + @param time_out - (int) time out duration in secs + """ + test.startSection("Verifying the current progress") + if screen_title == config.BEGIN_PRIME_TITLE or screen_title == config.PRIMING_TITLE: + current_progress = (squish.waitForObjectExists(names.o_self_test_dry_progress)).progressValue + elif screen_title == config.SYSTEM_SELF_TEST_TITLE: + current_progress = (squish.waitForObjectExists(names.o_system_self_test_progress)).progressValue + else: + current_progress = (squish.waitForObjectExists(names.o_filter_flush_progress)).progressValue + #Since progress value is equal maximum count down value - current count down value + expected_progress = time_out - count_down + test.compare(current_progress, expected_progress, "{} should be the current progress".format(expected_progress)) + test.endSection() + +def verify_page_step_indicator(screen_obj, treatment_step, treatment_screens): + """ + Method to verify the Page Step indicators [the object on top of the screen which indicates the steps passed, current, remained] + @param treatment_step : (int) indicates the Current treatment step + """ + test.startSection("verification of page step indicators") + for page in range(len(treatment_screens)): + bullet_children = object.children(squish.waitForObjectExists(get_bullet_object(screen_obj, page))) + bullet_circle_color = bullet_children[0].color.name + bullet_border_color = bullet_children[0].border.color.name + step_title = squish.waitForObjectExists(get_text_object(screen_obj, treatment_screens[page])) + #To verify the step indicators of the completed treatment screens + if page < treatment_step: + test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete) + test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current) + test.compare(bullet_circle_color, config.COMPLETE_COLOR) + test.compare(bullet_border_color, config.COMPLETE_COLOR) + test.compare(step_title.color.name, config.ENABLED_COLOR) + #To verify the step indicators of the current treatment screen + elif page == treatment_step: + test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current,) + test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete) + test.compare(bullet_circle_color, config.CURRENT_COLOR) + test.compare(bullet_border_color, config.COMPLETE_COLOR) + test.compare(step_title.color.name, config.ENABLED_COLOR) + test.verify(step_title.font.bold) + #To verify the step indicators of the remaining treatment screens + else: + test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current,) + test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete,) + test.compare(step_title.color.name, config.INCOMPLETE_COLOR) + test.compare(bullet_circle_color, config.CURRENT_COLOR) + test.compare(bullet_border_color, config.INCOMPLETE_COLOR) + test.endSection() + +def verify_missing_object(object_to_check): + """ + Method to verify the given object is invisible or is not present on the screen + @param object_to_check: the object whose invisibility must be verified + """ + try: + squish.testSettings.objectNotFoundDebugging = False + squish.waitForObject(object_to_check,3000) + test.fail("Given object should not be present initially") + except LookupError as _: + test.passes("object is not present as expected") + squish.testSettings.objectNotFoundDebugging = True - if obj_x >= container_x and obj_y >= container_y: - if (obj_x + obj_width) <= (container_x + container_width) and (obj_y + obj_height) <= (container_y + container_height): +def get_text_object(screen_obj, txt): + """ + To obtain a text object based on text provided + @param screen_obj: provides the container on which the txt must be present + @returns a real name object + """ + names.o_text_object["container"] = screen_obj + names.o_text_object["text"] = txt + return names.o_text_object + + +def verify_color_of_entry(entry, vital_parameter, input_field): + """ + Method to verify the color of entry + of systolic, diastolic and heart rate + @param entry: (int) user user entered value + @param vital_parameter - (str) parameter name under which user is entering value (sys/dia/heart rate) + @param input_field - (obj) object of input field + """ + test.startSection("Verify the color of {} value {}".format(vital_parameter, entry)) + input_field_color = input_field.color.name + entry = pyInt(entry) + if vital_parameter is config.SYSTOLIC_TEXT: + if (entry < config.SYSTOLIC_LOWER_LIMIT) or (entry > config.SYSTOLIC_UPPER_LIMIT): + test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "systolic value {} is out of range, systolic value should be in range of {} and {}".format(entry, config.SYSTOLIC_LOWER_LIMIT, config.SYSTOLIC_UPPER_LIMIT)) + elif (entry >= config.SYSTOLIC_LOWER_LIMIT) and (entry <= config.SYSTOLIC_UPPER_LIMIT): + test.compare(input_field_color, config.IN_RANGE_COLOR, "systolic value {} is in range of {} and {}".format(entry, config.SYSTOLIC_LOWER_LIMIT, config.SYSTOLIC_UPPER_LIMIT)) + elif vital_parameter is config.DIASTOLIC_TEXT: + if (entry < config.DIASTOLIC_LOWER_LIMIT) or (entry > config.DIASTOLIC_UPPER_LIMIT): + test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "diastolic value {} is out of range, diastolic value should be in range of {} and {}".format(entry, config.DIASTOLIC_LOWER_LIMIT, config.DIASTOLIC_UPPER_LIMIT)) + elif (entry >= config.DIASTOLIC_LOWER_LIMIT) and (entry <= config.DIASTOLIC_UPPER_LIMIT): + test.compare(input_field_color, config.IN_RANGE_COLOR, "diastolic value {} is in range of {} and {}".format(entry, config.DIASTOLIC_LOWER_LIMIT, config.DIASTOLIC_UPPER_LIMIT)) + elif vital_parameter is config.HEART_RATE_TITLE: + if (entry < config.HEART_RATE_LOWER_LIMIT) or (entry > config.HEART_RATE_UPPER_LIMIT): + test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Heart Rate value {} is out of range, Heart Rate value should be in range of {} and {}".format(entry, config.HEART_RATE_LOWER_LIMIT, config.HEART_RATE_UPPER_LIMIT)) + elif (entry >= config.HEART_RATE_LOWER_LIMIT) and (entry <= config.HEART_RATE_UPPER_LIMIT): + test.compare(input_field_color, config.IN_RANGE_COLOR, "Heart Rate value {} is in range of {} and {}".format(entry, config.HEART_RATE_LOWER_LIMIT, config.HEART_RATE_UPPER_LIMIT)) + test.endSection() + + +def keypad_input(key_value): + """ + Method to enter values using application UI keyboard + @param key_value: (str) User expected value + """ + if key_value is not None: + names.o_keypad_input["text"] = key_value + return names.o_keypad_input + else: + test.log("Invalid text for object.") + names.o_keypad_input["text"] = None + + +def enter_keypad_value(entry): + """ + Method to enter user desired + value using keypad + @param entry: (str) User expected value + """ + test.startSection("Entering {}".format(entry)) + entry = pyStr(entry) #type casted into string format + for value in entry: + squish.mouseClick(squish.waitForObject(keypad_input(value))) + test.endSection() + +def is_float(num): + """ + This function checks the value is adaptable for float conversion. + @param num - (string) input value for conversion. + @return True/False- (bool) returns True if the value can type casted into float, else False + """ + try: + if '.' in num: + float(num) return True + except ValueError: + return False + +def is_intiger(num): + """ + This function checks the value is adaptable for integer conversion. + @param num - (string) (string) input value for conversion. + @return True/False- (bool) returns True if the value can type casted into int, else False + """ + try: + if num.isdigit(): + return True + except ValueError: + return False + +def get_extracted_file(): + """ + This function is the handler for getting file from log folder. + This handler will go inside log folder and looks for newly added log based on current time. + if it satisfied that condition, it will return the exact path of newly created log. + Application log file is automatically created on '/home/denali/Desktop/sd-card/log/ {current_date}_denaliSquish.log' + @return latest_file - (string) returns latest file that append on log folder from sd-data + """ + try: + current_date = get_current_date_and_time(date_format = "%Y_%m_%d") + latest_file = config.LOG_LOCATION + current_date + '_denaliSquish.log' + return latest_file + except: + return False + +def get_message_from_log(file_name, message_text): + + """ + This method intended to extract the message from application log. + For row[index], index represent column to be extracted. + @param file_name - (string) path of the latest log file created. + @param message_text - (string) message text to be extracted. + @return message - (list) API arguments displayed in log. + """ + message = [] + count = 0 + try: + with open(file_name, 'r') as csv_file: + try: + for row in reversed(list(csv.reader(csv_file))): + if row[0].isalpha(): + pass + else: + row_length = sum(1 for values in row) + if row_length >= 4: + if row[3]!= None and row[3] == message_text: + if count == 30: + test.fail("handler unable to find message text from log file.") + message_length = sum(1 for values in row) + for column in range(4, message_length, 1): + message.append(row[column]) + count +=1 + for value in range(len(message)): + float_status = is_float(message[value]) + int_status = is_intiger(message[value]) + if float_status is True: + message[value] = float(message[value]) + if int_status is True: + message[value] = int(message[value]) + test.log(str(message)) + return message + else: + pass + except: + 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_ack_request_details(file_name, message_text): + """ + This method intended to extract acknowledgement request status, negative requested acknowledgement + and message id from application log. + For row[index], were index represent column to be extracted. + @param file_name - (string) path of the latest log file created. + @param message_text - (string) message text to be extracted from log. + @return row[3] - (string) acknowledgement request status. + @return row[4] - (string) Negative requested acknowledgement value (Sq). + @return message_id - (string) formatted message id from log. + """ + try: + message_id = " ID" + with open(file_name, 'r') as csv_file: + try: + for row in reversed(list(csv.reader(csv_file))): + if row[0].isalpha(): + pass + else: + row_length = sum(1 for values in row) + if row_length == 6 and row[3] != message_text: + if row[5].split(':')[0] == message_id: + extracted_message_id = pyInt(row[5].split(':')[1], 16) + formatted_message_id = format(extracted_message_id, '#0x') + # MSG_ID_HD_DEBUG_EVENT (0xFFF1) and MSG_ID_DG_DEBUG_EVENT (0xFFF2) hex values are reversed in log. + string_format_id = str(formatted_message_id) + first_two_char = string_format_id[2:4] + last_two_char = string_format_id[-2:] + if last_two_char != '00': + return row[3], row[4], ('0x'+last_two_char+first_two_char) + else: + return row[3], row[4], formatted_message_id.replace("00", "") + else: + pass + except: + test.fail("application log data is corrupted - unable to fetch data") + except: + 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. + For row[index], were index represent column to be extracted. + @param file_name - (string) path of the latest log file created. + @param ack_bak_value - (string) Positive back acknowledgement value (Sq). + @return row[3] - (string) acknowledgement back status. + """ + try: + with open(file_name, 'r') as csv_file: + try: + for row in reversed(list(csv.reader(csv_file))): + if row[0].isalpha(): + pass + else: + row_length = sum(1 for values in row) + if row_length >= 5: + if row[4] == ack_bak_value: + return row[3] + else: + pass + else: + pass + except: + 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. + logs are automatically created in path :"/home/denali/Desktop/sd-card/log/*.log". + In row[index], index represent column to be extracted. + @param message_ack - (bool) 'True' - if ack is satisfied in log / 'False' - if ack condition is not satisfied + @param message_text - (string) message text to be extracted from log. + @return content_record - (list) list contains extracted data (ack_req, ack_bak, message, message_id). + """ + content_record = [] + file_name = get_extracted_file() + if message_text != None: + message = get_message_from_log(file_name, message_text) + content_record.append(message) + if message_ack != False: + ack_req_status, ack_req_value, message_id = get_ack_request_details(file_name, message_text) + ack_bak_value = ack_req_value.replace(":-", ":") # getting negative requested ack from positive requested ack + content_record.append(ack_req_status) + content_record.append(message_id.lower()) + if message_ack != False and ack_bak_value != None: + ack_bak_status = get_bak_request_details(file_name, ack_bak_value) + content_record.append(ack_bak_status) + return content_record + +def rename_file(path,filename): + """ + This method Rename the original folder name to dummy name. + """ + folder_path = os.listdir(path) + for files in folder_path: + if files == filename+"_1": + if os.path.exists(path+filename+"_1"): + shutil.rmtree(path+filename+"_1") + test.log(str(filename+" name changed to "+files)) + if files == filename: + if os.path.exists(path+filename): + utils.waitForGUI(1) + os.rename(path+filename,path+filename+"_1") + test.log(str(files+" name changed to "+filename+"_1")) + +def rename_old_name(path,filename): + """ + This method Rename the dummy name to original folder name . + """ + folder_path = os.listdir(path) + for files in folder_path: + if files == filename: + if os.path.exists(path+filename): + shutil.rmtree(path+filename) + test.log(str(files+"_1 name changed to "+filename)) + utils.waitForGUI(5) + if files != filename: + if (files == filename+"_1"): + os.rename(path+files,path+filename) + test.log(str(files+" name changed to "+filename)) + +def vitals_interval_obj(interval): + names.o_time_interval_obj["text"] = interval + return names.o_time_interval_obj + +def keyboard_input(key_value): + names.o_keyboard_object["text"] = key_value + return names.o_keyboard_object + +def enter_keyboard_numeric_value(entry): + """ + Method to enter user desired + value using keypad + @param entry: (str) User expected value + """ + test.startSection("Entering {}".format(entry)) + for value in entry: + if value.isalpha(): + value = pyStr(value) + else: + value = pyInt(value) + key_val = squish.waitForObject(keyboard_input(value)) + squish.mouseClick(key_val) + utils.waitForGUI(0.1) + test.endSection() + + +def end_treatment_states_rejection_msg(text): + names.o_end_treatment_state_rejection_msg["text"] = text + return names.o_end_treatment_state_rejection_msg + +def verify_parameter_from_post_treatment_log(msg_text): + """ + To obtain the details of parameter from post treatment log file. + @param msg_text: parameter to be extracted. + @returns message value and message unit + """ + try: + log_location = str(get_extracted_file_from_post_treatment()) + with open(log_location, 'r') as csv_file: + try: + for row in csv_file: + reader = csv.reader(csv_file) + for row in reader: + row_length = sum(1 for values in row) + for row1 in row: + if row[0]!= None and row[0] == msg_text and row_length == 3: + return (row[1],row[2]) + else: + pass + except: + test.fail("Treatment 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_extracted_file_from_post_treatment(): + """ + This function is the handler for getting file from log folder. + This handler will go inside log folder and looks for newly added log based on current time. + if it satisfied that condition, it will return the exact path of newly created log. + @return latest_file - (string) returns latest file that append on log folder from sd-data + """ + try: + list_of_files = glob.glob(config.POST_TREATMENT_LOG_LOCATION) + latest_file = max(list_of_files, key=os.path.getctime) + return latest_file + except: + test.fail("log file is not created during application interaction") + return False + + +def rinseback_rejection_msg(text): + names.o_rinseback_rejection_msg["text"] = text + return names.o_rinseback_rejection_msg + squish.testSettings.objectNotFoundDebugging = True + + +def recirculate_rejection_msg(text): + names.o_recirculate_rejection_msg["text"] = text + return names.o_recirculate_rejection_msg + + +def get_current_date_and_time_in_utc(date_format='%Y/%m/%d - %H:%M:%S'): + """ + Method to get current date and time. + @input date_format (str) - format of date to be retrieved. + @return (str) - date in specified format. + """ + date = datetime.now(timezone.utc) + return str(date.strftime(date_format)) + - return False +def get_disinfect_bullet_object(id, screen_obj): + """ + To set a custom object based on item from parameters + @param screen_obj (String): provides the custom container for the object + @param id (String): provides the custom id for the object + @returns a real name object + """ + names.o_disinfect_dynamic_StepBullet["container"] = screen_obj + names.o_disinfect_dynamic_StepBullet["id"] = id + return names.o_disinfect_dynamic_StepBullet + +def verify_page_step_indicator_for_disinfect(screen_obj, treatment_id, treatment_step, treatment_screens): + """ + Method to verify the Page Step indicators [the object on top of the screen which indicates the steps passed, current, remained] + @param screen_obj (Dict) : Parent objject of page step indicator. + @param treatment_id (List) : disinfection id's for disinfection types. + @param treatment_step (Int) : indicates the Current treatment step. + @param treatment_screens(List): Type of disinfection. + """ + test.startSection("verification of page step indicators") + for page in range(len(treatment_screens)): + bullet_children = object.children(squish.waitForObjectExists(get_disinfect_bullet_object(treatment_id[page], screen_obj))) + bullet_circle_color = bullet_children[0].color.name + bullet_border_color = bullet_children[0].border.color.name + step_title = squish.waitForObjectExists(get_disinfect_text_object(treatment_screens[page], screen_obj)) + #To verify the step indicators of the completed treatment screens + if page < treatment_step: + test.verify(squish.waitForObjectExists(get_disinfect_bullet_object(treatment_id[page], screen_obj)).complete) + test.verify(not squish.waitForObjectExists(get_disinfect_bullet_object(treatment_id[page], screen_obj)).current) + test.compare(bullet_circle_color, config.COMPLETE_COLOR) + test.compare(bullet_border_color,config.COMPLETE_COLOR) + test.compare(step_title.color.name,config.ENABLED_COLOR) + #To verify the step indicators of the current treatment screen + elif page == treatment_step: + test.verify(squish.waitForObjectExists(get_disinfect_bullet_object(treatment_id[page], screen_obj)).current) + test.verify(not squish.waitForObjectExists(get_disinfect_bullet_object(treatment_id[page], screen_obj)).complete) + test.compare(bullet_circle_color, config.CURRENT_COLOR) + test.compare(bullet_border_color, config.COMPLETE_COLOR) + test.compare(step_title.color.name, config.ENABLED_COLOR) + test.verify(step_title.font.bold) + #To verify the step indicators of the remaining treatment screens + else: + test.verify(not squish.waitForObjectExists(get_disinfect_bullet_object(treatment_id[page], screen_obj)).current) + test.verify(not squish.waitForObjectExists(get_disinfect_bullet_object(treatment_id[page], screen_obj)).complete) + test.compare(step_title.color.name, config.INCOMPLETE_COLOR) + test.compare(bullet_circle_color, config.CURRENT_COLOR) + test.compare(bullet_border_color, config.INCOMPLETE_COLOR) + test.endSection() + + +def get_disinfect_text_object(text, screen_obj): + """ + To set a custom object based on item from parameters + @param screen_obj (String): provides the custom container for the object + @param text (String) : provides the custom text for the object + @returns a real name object + """ + names.o_disinfect_dynamic_StepBullet_Text["container"] = screen_obj + names.o_disinfect_dynamic_StepBullet_Text["text"] = text + return names.o_disinfect_dynamic_StepBullet_Text + + +def append_cloudsync_credentials_file(): + """ + This function is used for creating .pem files in the cloudsync folder. + pem files is created on '/home/denali/Desktop/cloudsync/credentials' + """ + try: + os.makedirs(config.CLOUD_CREDENTIALS_LOCATION, exist_ok = True) + test.log("Directory created successfully") + for file_handler in range(len(config.PEM_FILES)): + path = os.path.join(config.CLOUD_CREDENTIALS_LOCATION, config.PEM_FILES[file_handler]) + with open(path, 'w') as file_reader: + pass + except OSError: + test.log("Directory can not be created") + + +def get_cloud_sync_input_file(): + """ + This function is the handler for getting file from log folder. + Application log file is automatically created on '/home/denali/Desktop/sd-card/cloudsync/ {current_date}_inp.log' + @return latest_file - (string) returns latest input log file path from sd-data + """ + try: + current_date = get_current_date_and_time_in_utc(date_format = "%Y_%m_%d") + latest_file = config.INP_BUF_FILE_LOCATION+current_date+'_inp.buf' + return latest_file + except: + return False + + +def get_cloud_sync_output_file(): + """ + This function is the handler for getting file from log folder. + Application log file is automatically created on '/home/denali/Desktop/sd-card/cloudsync/ {current_date}_out.log' + @return latest_file - (string) returns latest output log file path from sd-data + """ + try: + current_date = get_current_date_and_time_in_utc(date_format = "%Y_%m_%d") + latest_file = config.INP_BUF_FILE_LOCATION+current_date+'_out.buf' + return latest_file + except: + return False + + +def get_current_date_and_time_in_utc(date_format='%Y/%m/%d - %H:%M:%S'): + """ + Method to get current date and time. + @input date_format (str) - format of date to be retrieved. + @return (str) - date in specified format. + """ + date = datetime.now(timezone.utc) + return str(date.strftime(date_format)) + + +def get_extracted_input_buf_file(): + """ + This function is the handler for getting file from cloudsync folder. + This handler will go inside cloudsync folder and looks for newly added input buf file based on current time. + if it satisfied that condition, it will return the exact path of newly created input buf file. + Application input buf file is automatically created in '/home/denali/Desktop/sd-card/cloudsync/ {current_date}_inp.buf' + @return latest_file - (string) returns latest file that append in cloudsync folder + """ + try: + current_date = get_current_date_and_time_in_utc(date_format = "%Y_%m_%d") + latest_file = config.INP_BUF_FILE_LOCATION + current_date + '_inp.buf' + return latest_file + except: + return False + +def retrive_log_data(readline_count = 1): + """ + This function is the handler for getting file from cloudsync folder. + Application log data is automatically appended on '/home/denali/Desktop/sd-card/cloudsync/ {current_date}_inp.buf' + @param: (int) readline_count + @return: (list) cloudsync_data returns latest file that append in cloudsync folder + """ + cloudsync_data = [] + count = 0 + file_name = get_extracted_input_buf_file() + try: + with open(file_name,mode = 'r') as filereader: + contents = csv.reader(filereader) + try: + for reader in reversed(list(contents)): + if readline_count == count: + return cloudsync_data + cloudsync_data.append(reader) + count = count + 1 + except: + 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_epoch_value_consistancy(current_epoch_value, expected_epoch_value): + """ + This function is verify consistancy of epoch value. + @input current_epoch_value (float) - current epoch time + @input expected_epoch_value (str) - epoch time from the cloud-sync log. + @return (bool) - True/False + """ + expected_epoch_value = int(expected_epoch_value) + maximum_epoch_value = int(current_epoch_value + 25) + minimum_epoch_value = int(current_epoch_value - 25) + + if expected_epoch_value > minimum_epoch_value and expected_epoch_value < maximum_epoch_value : + return True + return False + def keyboard_input(key_value): names.o_keyboard_object["text"] = key_value return names.o_keyboard_object @@ -93,7 +1169,60 @@ utils.waitForGUI(0.1) test.endSection() +def get_extracted_alarm_mapping_file(): + """ + This function is the handler for getting error file from service folder. + + Application log file is automatically created on '/home/denali/Desktop/sd-card/service/ {current_date}_denaliSquish.err ' + @return latest_file - (string) returns latest file that append on log folder from service + """ + try: + latest_file = config.ALARM_MAPPING_CPP_FILE_LOCATION + return latest_file + 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 get_extracted_error_file(): + """ + This function is the handler for getting error file from service folder. + Application log file is automatically created on '/home/denali/Desktop/sd-card/service/ {current_date}_denaliSquish.err ' + @return latest_file - (string) returns latest file that append on log folder from service + """ + try: + current_date = get_current_date_and_time(date_format = "%Y_%m_%d") + latest_file = config.ERROR_FILE_LOCATION + current_date + '_denaliSquish.err' + return latest_file + except: + return False + + raise LookupError("value object is not in view to the user after trying 100 times") def rename_file(path,filename): """ @@ -122,11 +1251,14 @@ shutil.rmtree(path+filename) test.log(str(files+"_1 name changed to "+filename)) utils.waitForGUI(5) + if files != filename: + if (files == filename+"_1"): os.rename(path+files,path+filename) test.log(str(files+" name changed to "+filename)) + def scroll_to_zone(zone=None, screen_object=None, direction = None): """ scroll to the to the value if object is hidden @@ -155,10 +1287,3 @@ raise LookupError("zone object is not in view to the user after trying 100 times") - - - - - - - \ No newline at end of file Index: shared/scripts/names.py =================================================================== diff -u -raea720dc4efe66713d2b9a00a7d6a2497dbcaea4 -r4dfe8f7ce0cf625ca3039ff482eba432f3cf7ade --- shared/scripts/names.py (.../names.py) (revision aea720dc4efe66713d2b9a00a7d6a2497dbcaea4) +++ shared/scripts/names.py (.../names.py) (revision 4dfe8f7ce0cf625ca3039ff482eba432f3cf7ade) @@ -950,7 +950,7 @@ #volume and brightness o_SettingsBase_SettingsVolumeBrightness = {"container": o_Gui_MainView, "objectName": "_SettingsBase", "type": "SettingsVolumeBrightness", "visible": True} o_SettingsBase_Volume_And_Brightness_Text = {"container": o_SettingsBase_SettingsVolumeBrightness, "type": "Text", "unnamed": 1, "visible": True} -o_brightness_parent_obj = {"container": o_SettingsBase_SettingsVolumeBrightness, "gradient": 0, "id": "_brightness", "type": "Slider", "unnamed": 1, "visible": True} +o_brightness_parent_obj = {"container": o_SettingsBase_SettingsVolumeBrightness, "id": "_brightness", "type": "Slider", "unnamed": 1, "visible": True} #Containers for End treatment o_EndTreatmentEndStack_EndTreatmentEndStack = {"container": o_Gui_MainView, "objectName": "_EndTreatmentEndStack", "type": "EndTreatmentEndStack", "visible": True} @@ -1200,7 +1200,9 @@ o_show_password = {"container": o_userConfirmation_UserConfirmation, "id": "_showPassword", "source": "qrc:/images/iEye", "type": "Image", "unnamed": 1, "visible": True} o_switch_keyboard_to_keypad = {"container": o_Gui_MainView, "text": "&123", "type": "Text", "unnamed": 1, "visible": True} o_keyboard_object = {"container": o_Gui_MainView, "type": "Text", "unnamed": 1, "visible": True} +o_SettingsBase_ScrollBar = {"container": o_SettingsBase_SettingsBase, "type": "ScrollBar", "unnamed": 1, "visible": True} + #virtal keypad input field o_keypad_input = {"container": o_Gui_MainView, "id": "_keyText", "type": "Text", "unnamed": 1, "visible": True} #virtal keypad back space key @@ -1231,10 +1233,12 @@ o_wifi_settings_back_button = {"container": o_SettingsBase_SettingsWiFi, "id": "_mouseArea", "type": "MouseArea", "unnamed": 1, "visible": True} o_SettingsBase_Scan_Finished_Text = {"container": o_SettingsBase_SettingsWiFi, "text": "Scan Finished", "type": "Text", "unnamed": 1, "visible": True} o_scan_wifi_setting_button = {"container": o_SettingsBase_SettingsWiFi, "id": "_mouseArea", "occurrence": 2, "type": "MouseArea", "unnamed": 1, "visible": True} +o_bluetooth_cuff_button_rect ={"container": o_SettingsHome_SettingsHome_2, "id": "_mouseArea", "occurrence": 4, "type": "MouseArea", "unnamed": 1, "visible": True} #Manager o_manager_Text = {"container": o_Gui_MainView, "text": "Manager", "type": "Text", "unnamed": 1, "visible": True} o_treatment_management = {"container": o_Gui_MainView, "text": "Treatment Management", "type": "Text", "unnamed": 1, "visible": True} + o_treatmentHome_mouseArea_MouseArea_2 = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "id": "_mouseArea", "occurrence": 15, "type": "MouseArea", "unnamed": 1, "visible": True} o_treatmentStack_TreatmentStack = {"container": o_Gui_MainView, "objectName": "TreatmentStack", "type": "TreatmentStack", "visible": True} o_treatmentStack_modal_MouseArea = {"container": o_treatmentStack_TreatmentStack, "id": "_modal", "type": "MouseArea", "unnamed": 1, "visible": False} @@ -1249,3 +1253,10 @@ o_treatment_duration = {"container": o_treatmentHome, "objectName": "TreatmentTime", "type": "TreatmentTime", "visible": True} o_pop_up_close_button = {"container": o_Overlay, "id": "_image", "source": "qrc:/images/iClose", "type": "Image", "unnamed": 1, "visible": True} +o_Gui_MainView_2 = {"type": "Gui::MainView", "unnamed": 1, "visible": True} +o_hideKeyIcon_Image = {"container": o_Gui_MainView_2, "id": "_hideKeyIcon", "source": "qrc:/plugins/QtQuick/VirtualKeyboard/Styles/denali/images/iHidekeyboard.svg", "type": "Image", "unnamed": 1, "visible": True} +o_hideKeyBackground_Rectangle = {"container": o_Gui_MainView_2, "id": "_hideKeyBackground", "type": "Rectangle", "unnamed": 1, "visible": True} +o_SettingsBase_Failed_to_set_static_IP_Address_Text = {"container": o_SettingsBase_SettingsWiFi, "text": "Failed to set static IP Address", "type": "Text", "unnamed": 1, "visible": True} +o_SettingsBase_Failed_to_set_gateway_Text = {"container": o_SettingsBase_SettingsWiFi, "text": "Failed to set gateway.", "type": "Text", "unnamed": 1, "visible": True} +o_SettingsBase_Failed_to_set_subnet_mask_Text = {"container": o_SettingsBase_SettingsWiFi, "text": "Failed to set subnet mask.", "type": "Text", "unnamed": 1, "visible": True} +o_SettingsBase_Failed_to_set_DNS_Text = {"container": o_SettingsBase_SettingsWiFi, "text": "Failed to set DNS.", "type": "Text", "unnamed": 1, "visible": True}