# -*- coding: utf-8 -*- # from dialin.hd.alarms import * # from dialin.ui.hd_simulator_alarms import HDAlarmsSimulator, NONE # import logging # from dialin.protocols.CAN import DenaliCanMessenger from dialin.ui import HDSimulator from dialin.ui import DGSimulator from dialin.ui import utils # from dialin.hd.ui_proxy import HDUIProxy from configuration import utility from configuration import config import builtins # from email import message from dialin.ui.utils import waitForGUI from dialin.common.msg_ids import MsgIds hd = HDSimulator() dg = DGSimulator() yes = 'Y' def verify_log(msg_id, ack = None, msg = None): utils.waitForGUI(0.1) message_extracted = utility.get_current_log_details(message_ack = ack, message_text = msg) if ack == yes: test.verify(config.ACK_REQ_STATUS in message_extracted, "ack request is verified") test.verify(config.ACK_BAK_STATUS in message_extracted, "ack back is verified") # if msg != None: # test.verify(msg in message_extracted, "message is verified") message_id_hex = builtins.hex(builtins.int(msg_id)) message_id_str = builtins.str(message_id_hex) test.log(message_id_str) test.log(str(message_extracted)) test.verify(message_id_str in message_extracted, "message ID is verified") def main(): startApplication("denaliSquish") #HD Broadcast #0x0D00 hd.cmd_set_treatment_time(200,60) verify_log(msg_id = MsgIds.MSG_ID_TREATMENT_TIME.value, ack = yes, msg = "TreatmentTime") #0x0500 hd.cmd_set_treatment_blood_flow_rate(flow_set_pt=20, measured_flow=10.5, rot_speed = 112.2 , mot_speed = 120.3, mc_speed = 100.0, mc_current = 12.5, pwm = 32.3, rotor_count = 30) verify_log(msg_id = MsgIds.MSG_ID_BLOOD_FLOW_DATA.value, ack = yes, msg = "BloodFlow") #0x0800 hd.cmd_set_treatment_dialysate_flow_rate(flow_set_pt=20, measured_flow=10.5, rot_speed = 112.2 , mot_speed = 120.3, mc_speed = 100.0, mc_current = 12.5, pwm = 32.3) verify_log(msg_id = MsgIds.MSG_ID_DIALYSATE_FLOW_DATA.value, ack = yes, msg = "DialysateFlow") #0x0900 hd.cmd_set_pressure_occlusion_data(arterial_prs = 54.5, venous_prs = 20.1, blood_pump_occlusion = 3, dialysate_inlet_pump_occlusion = 2, dialysate_outlet_pump_occlusion = 5) verify_log(msg_id = MsgIds.MSG_ID_PRESSURE_OCCLUSION_DATA.value, ack = yes, msg = "Pressure/Occlusion") #0x0B00 hd.cmd_set_treatment_ultrafiltration_outlet_flow_data(ref_uf_vol = 77.5, measured_uf_vol = 22.6, rot_speed = 54.0, mot_speed = 66.2, mc_speed = 33.3, mc_current = 21.2, pwm = 322.2) verify_log(msg_id = MsgIds.MSG_ID_DIALYSATE_OUT_FLOW_DATA.value, ack = yes, msg = "OutletFlow") #0x1A00 hd.cmd_set_treatment_parameter_ranges(min_treatment_duration = 300, max_treatment_duration = 500, min_uf_volume = 22.6, max_uf_volume = 34.2, min_dialysate_flow_rate = 3, max_dialysate_flow_rate = 5) verify_log(msg_id = str(MsgIds.MSG_ID_TREATMENT_PARAM_CHANGE_RANGES.value), ack = yes, msg = "TreatmentRanges") #0x2F00 hd.cmd_set_treatment_saline_bolus_data(target = 2, cumulative = 90.0, delivered = 67.2) verify_log(msg_id = MsgIds.MSG_ID_SALINE_BOLUS_DATA.value, ack = yes, msg = "Saline") #0x4D00 hd.cmd_set_treatment_heparin_data(cumulative = 4) verify_log(msg_id = MsgIds.MSG_ID_HD_HEPARIN_DATA_BROADCAST.value, ack = yes, msg = "Heparin") #0x3300 hd.cmd_send_accelerometer_hd_data(x = 12.3, y = 22.2, z = 4.0, x_max = 14.0, y_max = 30.2, z_max = 10.5, x_tilt = 11.0, y_tilt = 22.1, z_tilt = 5.5) verify_log(msg_id = MsgIds.MSG_ID_HD_ACCELEROMETER_DATA.value, ack = yes, msg = "Accel") #0x3A00 hd.cmd_send_hd_general_response(message_id = 58, accepted = 1, reason = 1) verify_log(msg_id = MsgIds.MSG_ID_HD_VALVES_DATA.value, ack = yes, msg = "~HD_Valves_Data") #0x3E00 #hd.cmd_send_hd_general_response(message_id = 62, accepted = 1, reason = 1) hd.cmd_send_hd_air_trap_data(lower_level = 1, upper_level = 10) verify_log(msg_id = MsgIds.MSG_ID_HD_AIR_TRAP_DATA.value, ack = yes, msg = "AirTrap") #0x6900 hd.cmd_send_hd_general_response(message_id = 105, accepted = 1, reason = 1) verify_log(msg_id = MsgIds.MSG_ID_HD_SYRINGE_PUMP_DATA.value, ack = yes) #0x6A00 hd.cmd_send_hd_general_response(message_id = 106, accepted = 1, reason = 1) verify_log(msg_id = MsgIds.MSG_ID_HD_FLUID_LEAK_STATE.value, ack = yes, msg = "~HD_Fluid_Leak_Data") #0x6C00 hd.cmd_send_hd_blood_leak_data(blood_leak_status = 0, blood_leak_state = 1, blood_leak_zero_status_counter = 2, blood_leak_counter = 3, blood_leak_zeroed_status = 2, blood_leak_detect_set_point = 1, blood_leak_detect_level = 1, blood_leak_st_count = 1, blood_leak_led_intensity = 2, blood_leak_register_counter = 3) verify_log(msg_id = MsgIds.MSG_ID_HD_BLOOD_LEAK_DATA.value, ack = yes, msg = "BloodLeak") #0x9300 hd.cmd_send_hd_air_bubble_data(venous_air_bubble_status = 2, venous_air_bubble_state = 0) verify_log(msg_id = MsgIds.MSG_ID_HD_BUBBLES_DATA.value, ack = yes, msg = "AirBubble") #0x7B00 hd.cmd_send_hd_general_response(message_id = 123, accepted = 1, reason = 1) verify_log(msg_id = MsgIds.MSG_ID_HD_VOLTAGES_DATA.value, ack = yes, msg = "~HD_Voltages_Data") #0x7D00 hd.cmd_send_hd_general_response(message_id = 125, accepted = 1, reason = 1) verify_log(msg_id = MsgIds.MSG_ID_HD_ALARM_INFORMATION.value, ack = yes, msg = "~HD_Alarm_Information") #0xA200 hd.cmd_send_hd_general_response(message_id = 162, accepted = 1, reason = 1) verify_log(msg_id = MsgIds.MSG_ID_HD_SWITCHES_DATA.value, ack = yes, msg = "~HD_Switches_Data") #0x9D00 hd.cmd_send_hd_general_response(message_id = 157, accepted = 1, reason = 1) verify_log(msg_id = MsgIds.MSG_ID_HD_TEMPERATURES_DATA.value, ack = yes, msg = "~HD_Temperature_Data") #0xA300 hd.cmd_send_hd_general_response(message_id = 163, accepted = 1, reason = 1) verify_log(msg_id = MsgIds.MSG_ID_HD_FANS_DATA.value, ack = yes, msg = "~HD_Fans_Data") #0xA800 hd.cmd_send_hd_general_response(message_id = 168, accepted = 1, reason = 1) verify_log(msg_id = MsgIds.MSG_ID_HD_RESERVOIRS_DATA.value, ack = yes, msg = "~HD_Reservoirs_Data") #HD Operation Mode #0x2500 for mode in range(9): hd.cmd_send_hd_operation_mode(op_mode = mode) verify_log(msg_id = MsgIds.MSG_ID_HD_OP_MODE.value, ack = yes, msg = "OpMode") #0x5C00 for s_mode in range(9): hd.cmd_send_pre_treatment_state_data(sub_mode = s_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) verify_log(msg_id = MsgIds.MSG_ID_PRE_TREATMENT_STATE.value, ack = yes, msg = "PreTreatmentStates") #0x0F00 for s_mode in range(3): hd.cmd_set_treatment_states_data(sub_mode = s_mode, uf_state = 0, saline_state = 0, heparin_state = 0, rinseback_state = 0, recirculate_state = 0, blood_prime_state = 0, treatment_end_state = 0, treatment_stop_state = 0, dialysis_state = 0) verify_log(msg_id = MsgIds.MSG_ID_TREATMENT_STATE.value, ack = yes, msg = "TreatmentStates") #0x7700 #for s_mode in range(3): hd.cmd_send_hd_general_response(message_id = 119, accepted = 1, reason = 1) verify_log(msg_id = MsgIds.MSG_ID_HD_POST_TREATMENT_STATE.value, ack = yes, msg = "PostTreatmentStates") #0x7E00 for s_mode in range(3): hd.cmd_send_hd_disinfection_state(sub_mode = s_mode, flush_mode = 0, heat_mode = 0, chemical_mode = 0) verify_log(msg_id = MsgIds.MSG_ID_HD_DISINFECT_STANDBY_DATA.value, ack = yes, msg = "DisinfectStates") #0x9A00 UI-HD #0x9B00 # hd.cmd_send_hd_disinfect_response(accepted = True, reason =1) hd.cmd_send_hd_general_response(message_id = 155, accepted = 1, reason = 1) verify_log(msg_id = MsgIds.MSG_ID_HD_SET_STANDBY_DISINFECT_SUB_MODE_RESPONSE.value, ack = yes, msg = "~HD_Set_Standby_Disinfect_State_Response") #RINSEBACK #0x5200 UI-HD #0x5300 hd.cmd_send_treatment_adjust_rinseback_response(accepted = 1, reason = 0) verify_log(msg_id = MsgIds.MSG_ID_HD_RINSEBACK_CMD_RESPONSE.value, ack = yes, msg = "AdjustRinseback") #0x5400 #0x5500 hd.cmd_send_treatment_adjust_recirculate_response(accepted = 1, reason = 0) verify_log(msg_id = MsgIds.MSG_ID_HD_RECIRC_CMD_RESPONSE.value, ack = yes, msg = "AdjustRecirculate") #0x5600 hd.cmd_send_treatment_rinseback_data(target_vol = 2.4, current_vol = 1.9, flow_rate = 1, timeout = 4, timeout_countdown = 8, is_completed = False) verify_log(msg_id = MsgIds.MSG_ID_HD_RINSEBACK_PROGRESS.value, ack = yes, msg = "Rinseback") #0x5A00 hd.cmd_send_treatment_recirculate_data(timeout_total = 200, timeout_count_down = 100) verify_log(msg_id = MsgIds.MSG_ID_HD_RECIRC_PROGRESS.value, ack = yes, msg = "Recirculate") #0x5800 hd.cmd_send_treatment_adjust_end_response(accepted = 1, reason = 0) verify_log(msg_id = MsgIds.MSG_ID_HD_TX_END_CMD_RESPONSE.value, ack = yes, msg = "AdjustTxEnd") #0x5900 hd.cmd_send_treatment_blood_prime_data(target = 22.2, current = 33.3) verify_log(msg_id = MsgIds.MSG_ID_HD_BLOOD_PRIME_PROGRESS.value, ack = yes, msg = "BloodPrime") #0x4900 hd.cmd_send_hd_general_response(message_id = 73, accepted = 1, reason = 1) verify_log(msg_id = MsgIds.MSG_ID_HD_TREATMENT_STOP_TIMER_DATA.value, ack = yes, msg = "Stop") #RTC #0x0A00 hd.cmd_send_hd_general_response(message_id = 10, accepted = 1, reason = 1) verify_log(msg_id = MsgIds.MSG_ID_RTC_EPOCH.value, ack = yes, msg = "~HD_RTC_Epoch_Data") #0x6E00 hd.cmd_send_set_rtc_response(response = 1, reason = 0) verify_log(msg_id = MsgIds.MSG_ID_HD_UI_SET_RTC_RESPONSE.value, ack = yes, msg = "AdjustHDDateTime") #0x7000 dg.cmd_send_set_rtc_response(response = 1, reason = 0) verify_log(msg_id = MsgIds.MSG_ID_DG_UI_SET_RTC_RESPONSE.value, ack = yes, msg = "AdjustDGDateTime")