import __init__ import signal import time,sys,os import logging from leo_grifo_common import * from test_common_function import * from leo_grifo_test_report import testReport from leo_grifo_1553 import theGrifo1553 #import leo_grifo_serial_maintnance from logger import logger_setup import leo_grifo_terminal import pdb import traceback NUMBER_OF_REPETITIONS = 10 PBIT_SEC_TIME = 180 interruptRequest = False def signal_handler(sig, frame): global interruptRequest logging.info("Ctrl-C detected, exiting gracefully...") interruptRequest = True def tgt_gen(interface): logging.info('tgt_gen()') #time.sleep(5) period=10 #ms expeced_range=1000 pcnt=0 for i in range(500): time.sleep(0.010) cnt = interface.getSingleMessageReceivedSz("B9") t_num=interface.getMessageFieldValue("B9", "b9_t_num") t_rng=interface.getMessageFieldValue("B9", "b9_t1_rng") if (i % 10)==0: dcnt=cnt-pcnt pcnt=cnt logging.info(f'TgtMsg: {cnt} {dcnt}') if t_num>0: logging.info(f'Tgt: {t_num} @ {t_rng}') ret_proc_sts, err= check(theGrifo1553,(1,2), "B9", "b9_t_num") check(theGrifo1553,(1179, 1186), "B9", "b9_t1_rng") break if interruptRequest is True: break def tgt_gen_alone(interface): interface.logStart(3,os.path.dirname(sys.argv[0])) for n in range(10*1000): logging.info(f'tgt_gen_alone(): {n}') tgt_gen(interface) if interruptRequest is True: break interface.logStop() return True def test_proc(): global report bit_fields = ("failure_location_processor_FailureLocationProcessor_sru14_rx_module", "failure_location_processor_FailureLocationProcessor_sru13_det_exp", "failure_location_processor_FailureLocationProcessor_sru12_power_supply", "failure_location_processor_FailureLocationProcessor_sru11_graphic_computer", "failure_location_processor_FailureLocationProcessor_sru10_main_computer", "failure_location_processor_FailureLocationProcessor_sru9_esa_if", "failure_location_processor_FailureLocationProcessor_sru8_agc", "failure_location_processor_FailureLocationProcessor_sru7_post_processor", "failure_location_processor_FailureLocationProcessor_sru6_timer", "failure_location_processor_FailureLocationProcessor_sru5_cfar_px_ctrl", "failure_location_processor_FailureLocationProcessor_sru4_dsp1", "failure_location_processor_FailureLocationProcessor_sru3_dsp0", "failure_location_processor_FailureLocationProcessor_sru2_mti_fft", "failure_location_processor_FailureLocationProcessor_sru1_motherboard_chassis", "signal_processor_test_results_SignalProcessorTestResults_test_sp16_bcn", "signal_processor_test_results_SignalProcessorTestResults_test_sp14_external_sp_if", "signal_processor_test_results_SignalProcessorTestResults_test_sp11_attenuatori_antenna", "signal_processor_test_results_SignalProcessorTestResults_test_sp10_board_overall", "signal_processor_test_results_SignalProcessorTestResults_test_sp9b_wideband_expander", "signal_processor_test_results_SignalProcessorTestResults_test_sp9_ad_da", "signal_processor_test_results_SignalProcessorTestResults_test_sp8_video2_timer_sync", "signal_processor_test_results_SignalProcessorTestResults_test_sp7_video2_ad_sync", "signal_processor_test_results_SignalProcessorTestResults_test_sp6_video1_with_ad", "signal_processor_test_results_SignalProcessorTestResults_test_sp5_video1_without_ad", "signal_processor_test_results_SignalProcessorTestResults_test_sp4_px_ctrl_comm", "signal_processor_test_results_SignalProcessorTestResults_test_sp3_timer_internal", "signal_processor_test_results_SignalProcessorTestResults_test_sp2_timer_dma_pxc_if", "signal_processor_test_results_SignalProcessorTestResults_test_sp1_timer1_up") logger_setup('GRIFO_M_PBIT.log') report = testReport(sys.argv[0]) interface = theGrifo1553.getInterface() terminal = leo_grifo_terminal.GrifoSerialTerminal() terminal.connect() test_return = True try: #report.open_session('Pre Conditions') #power_grifo_off() #report.close_session() ############ Test Execution ############ #report.open_session('Test Execution') report.add_comment("The Test Operator check if the failure BIT in B6_MsgRdrSettingsAndParametersTellback changes ...") if tgt_gen_alone(interface) is False: return for repetition in range(NUMBER_OF_REPETITIONS): info = f'Repetition {1 + repetition} of {NUMBER_OF_REPETITIONS}' logging.info(info) report.open_session(info) report.add_comment("The test operator is required to switch off the target and wait 3 seconds.") power_grifo_off(3) report.add_comment("The test operator is required to switch on the target.") power_grifo_on() remaining_time = PBIT_SEC_TIME max_counter_1553_msg = 20 while remaining_time > 0: start = time.perf_counter() ret_rep_is_avail = False msg_cnt = 0 mil1553_error_flag = max_counter_1553_msg for i in range(100): cnt = interface.getSingleMessageReceivedSz("B6_MsgRdrSettingsAndParametersTellback") value = interface.getMessageFieldValue("B6_MsgRdrSettingsAndParametersTellback", "radar_health_status_and_bit_report_valid_RdrHealthStatusAndBitReport_bit_report_available") ret_rep_is_avail = value == "true" if ret_rep_is_avail is True: break time.sleep(0.05) #logging.critical(f"1553 messag count {cnt} {mil1553_error_flag}") if cnt > msg_cnt: mil1553_error_flag = max_counter_1553_msg else : mil1553_error_flag -=1 msg_cnt = cnt if mil1553_error_flag == 0: logging.critical("1553 communication lost") return False if ret_rep_is_avail is True: time.sleep(0.02) report.add_comment("bit report avail occurred..") ret_proc_sts, err= check(theGrifo1553,"false", "B6_MsgRdrSettingsAndParametersTellback", "radar_health_status_and_bit_report_valid_RdrHealthStatusAndBitReport_processor_status") if ret_proc_sts is False: for f in bit_fields: ret_error_field, err = check(theGrifo1553,"false","B8_MsgBitReport",f) test_return = (test_return and ret_error_field) time_passed = time.perf_counter() - start remaining_time -= time_passed if ret_rep_is_avail is True: remaining_time = 0 logging.info(f'{remaining_time:.1f}s remaining ...') report.close_session() if interruptRequest is True: report.add_comment("Test interrupted by user (Ctrl-C)") break tgt_gen(interface) report.add_comment("Repetitions terminated.") ############ END STEPS ############ #report.open_session('Post Conditions') power_grifo_off() #report.close_session() if terminal is not None: terminal.disconnect() return test_return except Exception as e: report.add_comment(f"Test terminated unexpectedly :{e}") return False finally: report.generate_pdf() #-- --------------------------------------------------------------- if __name__ == '__main__': signal.signal(signal.SIGINT, signal_handler) test_proc()