Index: tst_Alarm/test.py =================================================================== diff -u -r93c52b8adc97ac2910b720f3fe1952125d430fc2 -rad6b08978df15722bc12a9ffab0be87b1c8da2ac --- tst_Alarm/test.py (.../test.py) (revision 93c52b8adc97ac2910b720f3fe1952125d430fc2) +++ tst_Alarm/test.py (.../test.py) (revision ad6b08978df15722bc12a9ffab0be87b1c8da2ac) @@ -8,133 +8,64 @@ # WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # file tst_Alarm -# date 2020/06/17 -# author Peter Lucia -from dialin.hd.hemodialysis_device import HD -import time -import sys +# date 2020/04/08 +# author Behrouz NematiPour +# -def yes_or_no(question): - message_box = QMessageBox() - message_box.setText(question) - message_box.addButton(QMessageBox.Yes) - message_box.addButton(QMessageBox.No) - which = getattr(message_box, "exec")() - return which == QMessageBox.Yes +import names +import utils +import denaliMessages -alarms_text = { - "ALARM_ID_NO_ALARM" : "", - "ALARM_ID_SOFTWARE_FAULT" : "Software Error", - "ALARM_ID_STUCK_BUTTON_TEST_FAILED" : "Indication for when no alarms is a possible situation.", - "ALARM_ID_FPGA_POST_TEST_FAILED" : "FPGA POST failure.", - "ALARM_ID_WATCHDOG_POST_TEST_FAILED" : "Watchdog POST failure.", - "ALARM_ID_UI_COMM_POST_FAILED" : "UI communication POST failure.", - "ALARM_ID_BLOOD_PUMP_MC_CURRENT_CHECK" : "Blood pump failed motor controller current check.", - "ALARM_ID_BLOOD_PUMP_MC_SPEED_CHECK" : "Blood pump failed motor controller speed check.", - "ALARM_ID_BLOOD_PUMP_MC_DIRECTION_CHECK" : "Blood pump failed motor controller direction check.", - "ALARM_ID_BLOOD_PUMP_ROTOR_SPEED_CHECK" : "Blood pump failed rotor speed check.", - "ALARM_ID_DIAL_IN_PUMP_MC_CURRENT_CHECK" : "Dialysis inlet pump failed motor controller current check.", - "ALARM_ID_DIAL_IN_PUMP_MC_SPEED_CHECK" : "Dialysis inlet pump failed motor controller speed check.", - "ALARM_ID_DIAL_IN_PUMP_MC_DIRECTION_CHECK" : "Dialysis inlet pump failed motor controller direction check.", - "ALARM_ID_DIAL_IN_PUMP_ROTOR_SPEED_CHECK" : "Dialysis inlet pump failed rotor speed check. ", - "ALARM_ID_DIAL_OUT_PUMP_MC_CURRENT_CHECK" : "Dialysis outlet pump failed motor controller current check. ", - "ALARM_ID_DIAL_OUT_PUMP_MC_SPEED_CHECK" : "Dialysis outlet pump failed motor controller speed check. ", - "ALARM_ID_DIAL_OUT_PUMP_MC_DIRECTION_CHECK" : "Dialysis outlet pump failed motor controller direction check. ", - "ALARM_ID_DIAL_OUT_PUMP_ROTOR_SPEED_CHECK" : "Dialysis outlet pump failed rotor speed check. ", - "ALARM_ID_WATCHDOG_EXPIRED" : "Watchdog expired error. ", - "ALARM_ID_RTC_COMM_ERROR" : "Real-time clock communication error. ", - "ALARM_ID_RTC_CONFIG_ERROR" : "Real-time clock configuration error. ", - "ALARM_ID_DG_COMM_TIMEOUT" : "Dialysate generator communication timeout. ", - "ALARM_ID_UI_COMM_TIMEOUT" : "User interface communication timeout. ", - "ALARM_ID_COMM_TOO_MANY_BAD_CRCS" : "Too many bad CRCs detected on received system messages. ", - "ALARM_ID_TREATMENT_STOPPED_BY_USER" : "Treatment stopped by user action - pressed stop button. ", - "ALARM_ID_BLOOD_SITTING_WARNING" : "Blood sitting too long warning (>4 min). ", - "ALARM_ID_BLOOD_SITTING_TOO_LONG_NO_RESUME" : "Blood sitting too long alarm (>5 min). ", - "ALARM_ID_BLOOD_SITTING_TOO_LONG_NO_RINSEBACK": "Blood sitting too long alarm (>10 min). ", - "ALARM_ID_CAN_MESSAGE_NOT_ACKED" : "System message needing acknowledgment was not acknowledged. ", - "ALARM_ID_OCCLUSION_BLOOD_PUMP" : "Blood pump occlusion detected. ", - "ALARM_ID_OCCLUSION_DIAL_IN_PUMP" : "Dialysate inlet pump occlusion detected. ", - "ALARM_ID_OCCLUSION_DIAL_OUT_PUMP" : "Dialysate outlet pump occlusion detected. ", - "ALARM_ID_ARTERIAL_PRESSURE_LOW" : "Arterial pressure too low during treatment. ", - "ALARM_ID_ARTERIAL_PRESSURE_HIGH" : "Arterial pressure too high during treatment. ", - "ALARM_ID_VENOUS_PRESSURE_LOW" : "Venous pressure too low during treatment. ", - "ALARM_ID_VENOUS_PRESSURE_HIGH" : "Venous pressure too high during treatment.", - "ALARM_ID_UF_RATE_TOO_HIGH_ERROR" : "Ultrafiltration rate is too high error during treatment. ", - "ALARM_ID_UF_VOLUME_ACCURACY_ERROR" : "Ultrafiltration volume accuracy error during treatment. ", - "ALARM_ID_RTC_BATTERY_LOW" : "RTC battery low. ", - "ALARM_ID_RTC_OR_TIMER_ACCURACY_FAILURE" : "RTC or MCU timer inaccurate. ", - "ALARM_ID_RTC_RAM_OPS_ERROR" : "RTC or RAM operations failure (read or write). ", - "ALARM_ID_NVDATA_EEPROM_OPS_FAILURE" : "EEPRON operations (read, write, erase) failure. ", - "ALARM_ID_NVDATA_MFG_RECORD_CRC_ERROR" : "Manufacturing record CRC failure. ", - "ALARM_ID_NVDATA_SRVC_RECORD_CRC_ERROR" : "Service record CRC failure. ", - "ALARM_ID_NVDATA_CAL_RECORD_CRC_ERROR" : "Calibration record CRC failure. ", - "ALARM_ID_NVDATA_HW_USAGE_DATA_CRC_ERROR" : "HW usage data failure. ", - "AlARM_ID_NVDATA_DISINFECTION_DATE_CRC_ERROR": "Last disinfection date CRC error ", - "ALARM_ID_RO_PUMP_OUT_PRESSURE_OUT_OF_RANGE" : "Pressure at outlet of RO pump is out of range. ", - "ALARM_ID_TEMPERATURE_SENSORS_OUT_OF_RANGE" : "DG temperature sensors ADC read out of range. ", - "ALARM_ID_TEMPERATURE_SENSORS_INCONSISTENT" : "DG temperature sensors values are inconsistent ", - "ALARM_ID_HD_COMM_TIMEOUT" : "HD communication timeout. ", - "Other" : "Alarm Not Recognized" -} - def main(): + utils.tstStart() startApplication("denaliSquish") + utils.waitForGUI(1) - - hd = HD() - - alarm_faults = [ - 'ALARM_ID_NO_ALARM', - 'ALARM_ID_SOFTWARE_FAULT', - 'ALARM_ID_STUCK_BUTTON_TEST_FAILED', - 'ALARM_ID_FPGA_POST_TEST_FAILED', - 'ALARM_ID_WATCHDOG_POST_TEST_FAILED', - 'ALARM_ID_UI_COMM_POST_FAILED', - 'ALARM_ID_WATCHDOG_EXPIRED', - 'ALARM_ID_RTC_COMM_ERROR', - 'ALARM_ID_DG_COMM_TIMEOUT', - 'ALARM_ID_UI_COMM_TIMEOUT', - 'ALARM_ID_COMM_TOO_MANY_BAD_CRCS', - 'ALARM_ID_CAN_MESSAGE_NOT_ACKED', - 'ALARM_ID_UF_RATE_TOO_HIGH_ERROR', - 'ALARM_ID_UF_VOLUME_ACCURACY_ERROR', - 'ALARM_ID_RTC_OR_TIMER_ACCURACY_FAILURE', - 'ALARM_ID_NVDATA_CAL_RECORD_CRC_ERROR', - 'AlARM_ID_NVDATA_DISINFECTION_DATE_CRC_ERROR', - 'ALARM_ID_NVDATA_MFG_RECORD_CRC_ERROR', - 'ALARM_ID_RO_PUMP_OUT_PRESSURE_OUT_OF_RANGE', - 'ALARM_ID_TEMPERATURE_SENSORS_OUT_OF_RANGE', - 'ALARM_ID_TEMPERATURE_SENSORS_INCONSISTENT', - 'ALARM_ID_VALVE_CONTROL_FAILURE' - ] - - - if not yes_or_no("Did you reset the HD?"): - test.fatal("The test could not start", "The HD was not reset.") - sys.exit() - - if hd.cmd_log_in_to_hd(): - hd.ui.cmd_ui_request_hd_version() - time.sleep(0.5) - print("Current HD version: {0}".format(hd.ui.hd_version)) - for desc, val in hd.alarms.ids.items(): - if desc in alarm_faults: - continue - success = hd.alarms.cmd_alarm_state_override(1, val) - - if not success: - raise Exception("Failed to activate alarm {0} = {1}".format(desc, val)) - - alarm_displayed = yes_or_no("Did the following alarm display? \n{0}".format(alarms_text[desc])) - if alarm_displayed: - test.passes(desc,"Confirmed the alarm displayed properly.") - else: - test.fail(desc, "Cannot confirm the alarm displayed properly.") - - success = hd.alarms.cmd_alarm_state_override(0, val) - if not success: - raise Exception("Failed to deactivate alarm {0} = {1}".format(desc, val)) - time.sleep(2) - + denaliMessages.sendAlarm(3, 26, 2, 0, 0) + test.compare(waitForObjectExists(names.o_ALARM_ID_MESSAGE).level, 3) + test.compare(waitForObjectExists(names.o_ALARM_ID_MESSAGE).color.name, "#c53b33") + utils.waitForGUI() # visual delay + denaliMessages.sendAlarm(3, 26, 2, 0, 65535) + test.compare(waitForObjectExists(names.o_ALARM_ID_MESSAGE).level, 3) + test.compare(waitForObjectExists(names.o_ALARM_ID_MESSAGE).color.name, "#c53b33") + utils.waitForGUI() # visual delay + + denaliMessages.sendAlarm(2, 2, 0, 10, 100) + test.compare(waitForObjectExists(names.o_ALARM_ID_MESSAGE).level, 2) + test.compare(waitForObjectExists(names.o_ALARM_ID_MESSAGE).color.name, "#ffa500") + utils.waitForGUI() # visual delay + + denaliMessages.sendAlarm(1, 3, 0, 0, 54) + test.compare(waitForObjectExists(names.o_ALARM_ID_MESSAGE).level, 1) + test.compare(waitForObjectExists(names.o_ALARM_ID_MESSAGE).color.name, "#008000") + utils.waitForGUI() # visual delay + + denaliMessages.sendAlarm(0, 4, 0, 0, 91) + test.compare(waitForObjectExists(names.o_ALARM_ID_MESSAGE).level, 0) + test.compare(waitForObjectExists(names.o_ALARM_ID_MESSAGE).color.name, "#ffffff") + utils.waitForGUI() # visual delay + + denaliMessages.sendAlarm(3, 255, 0, 0, 0) + test.compare(waitForObjectExists(names.o_ALARM_ID_MESSAGE).level, 3) + test.compare(waitForObjectExists(names.o_ALARM_ID_MESSAGE).color.name, "#c53b33") + utils.waitForGUI() # visual delay + + denaliMessages.sendAlarm(0, 0, 0, 0, 0) + try: # Notification Bar should be hidden + waitForObjectExists(names.o_ALARM_ID_MESSAGE,0) + test.compare(False, True) + except LookupError: + test.compare(False, False) + + # Coverage : These messages have not been implemented completely yet. + # but as long as the coverage is 100% it means the portion of the implementation for them are working fine. + denaliMessages.setAlarmTriggered(1) + denaliMessages.send_acknowledge_UI() + denaliMessages.setAlarmCleared (1) + denaliMessages.send_acknowledge_UI() + denaliMessages.sendUnknown_HD() + denaliMessages.sendUnknown_DG() + + utils.tstDone() \ No newline at end of file