def test_sterowan_4p(con_m, con_s, txt_frame, grafic_frame): printing(txt_frame, "**********TEST STEROWAN**********") logging.info("**********TEST STEROWAN**********") con_s.write(str.encode('x' + '\r\n')) time.sleep(0.1) con_s.write(str.encode('x' + '\r\n')) #Ustawienie sterownika w tryb testowy time.sleep(0.1) con_s.write(str.encode('x' + '\r\n')) #Ustawienie sterowania w tryb testowy time.sleep(0.1) con_s.write(str.encode('x' + '\r\n')) # Ustawienie sterowania w tryb testowy time.sleep(0.1) read_bi(con_m, "Io7") time.sleep(0.1) counter = 0 for i in range(0, 9): if i < 7: set_bo(con_s, "IO3", i, txt_frame) ans = read_bi(con_m, "Io7") del_bo(con_s, "IO3", i) check_sygn(ans, EOP_OUT, i, txt_frame, grafic_frame) else: set_bo(con_s, "IO6", counter, txt_frame) ans = read_bi(con_m, "Io7") del_bo(con_s, "IO6", counter) check_sygn(ans, EOP_OUT, i, txt_frame, grafic_frame) counter += 1
def set_bo(console, module, bo, txt_frame): console.write(str.encode('x' + '\r\n')) time.sleep(0.15) for key, value in MODULE.items(): if module == key: printing(txt_frame, f'Zalaczenie sterowania {bo}') print(f'Zalaczenie sterowania {bo}') logging.info(f'Zalaczenie sterowania {bo}') console.write(str.encode(f'x({value})x {bo}x' + '\r\n')) time.sleep(0.3)
def result(serial_number, txt_frame, sn_zespol): if error_counter == 0: print( f"Zespół SN:{sn_zespol} ze sterownikiem {serial_number} przeszedł POZYTYWNIE test sterowan i sygnalizacji\nLiczba bledow {error_counter}" ) logging.info( f"Zespół SN:{sn_zespol} ze sterownikiem {serial_number} przeszedł POZYTYWNIE test sterowan i sygnalizacji\nLiczba bledow {error_counter}" ) printing( txt_frame, f"Zespół SN:{sn_zespol} ze sterownikiem {serial_number} przeszedł POZYTYWNIE test sterowan i sygnalizacji\nLiczba bledow {error_counter}" ) else: printing( txt_frame, f"Zespół SN:{sn_zespol} ze sterownikiem {serial_number} wynik testu NEGATYWNY\nLiczba bledow {error_counter}" ) print( f"Zespół SN:{sn_zespol} ze sterownikiem {serial_number} wynik testu NEGATYWNY\nLiczba bledow {error_counter}" ) logging.info( f"Sterownik Zespół SN:{sn_zespol} ze sterownikiem {serial_number} wynik testu NEGATYWNY\nLiczba bledow {error_counter}" ) for x in error_names_sygn: printing(txt_frame, f"AWARIA Sygnalizacji {x[0]} - ({x[1]})") print(f"AWARIA Sygnalizacji {x[0]} - ({x[1]})") logging.info(f"AWARIA Sygnalizacji {x[0]} - ({x[1]})") for error in error_names_out: printing(txt_frame, f"AWARIA sterowania {error[0]} - ({error[1]})") print(f"AWARIA sterowania {error[0]} - ({error[1]})") logging.info(f"AWARIA sterowania {error[0]} - ({error[1]})")
def check_sygn(sygn, db, nr_sygn, txt_frame, grafic_frame): if sygn == db[nr_sygn]: if db == EOP_4P or db == EOP_5P: printing(txt_frame, f"Numer sygnalizacji {nr_sygn} : {sygn} OK") grafic_sygn_connection(grafic_frame, nr_sygn, 1) print(f"Numer sygnalizacji {nr_sygn} : {sygn} OK") logging.info(f"Numer sygnalizacji {nr_sygn} : {sygn} OK") if db == EOP_OUT: printing(txt_frame, f"Numer sterowania {nr_sygn} : {sygn} OK") grafic_out_connection(grafic_frame, nr_sygn, 1) print(f"Numer sterowania {nr_sygn} : {sygn} OK") logging.info(f"Numer sterowania {nr_sygn} : {sygn} OK") else: global error_counter if db == EOP_4P or db == EOP_5P: printing(txt_frame, f"Numer sygnalizacji {nr_sygn} : {sygn} ZLE") grafic_sygn_connection(grafic_frame, nr_sygn, 0) print(f"Numer sygnalizacji {nr_sygn} : {sygn} ZLE") logging.info(f"Numer sygnalizacji {nr_sygn} : {sygn} ZLE") global error_names_sygn error_counter += 1 error_names_sygn.append((nr_sygn, SYGN_NAME[nr_sygn])) if db == EOP_OUT: global error_names_out printing(txt_frame, f"Numer sterowania {nr_sygn} : {sygn} ZLE") grafic_out_connection(grafic_frame, nr_sygn, 0) print(f"Numer sterowania {nr_sygn} : {sygn} ZLE") logging.info(f"Numer sterownia {nr_sygn} : {sygn} ZLE") error_counter += 1 error_names_out.append((nr_sygn, OUT_NAME[nr_sygn]))
def test_bi_4p(con_m, con_s, txt_frame, grafic_frame): printing(txt_frame, "**********TEST SYGNALIZACJI**********") logging.info("**********TEST SYGNALIZACJI**********") counter = 0 for i in range(0, 45): if counter == 8: counter = 0 if i < 6: set_bo(con_m, "IO2", i, txt_frame) ans = read_bi(con_s, "Io4") del_bo(con_m, "IO2", i) check_sygn(ans, EOP_4P, i, txt_frame, grafic_frame) elif i == 6: set_bo(con_m, "IO3", counter, txt_frame) ans = read_bi(con_s, "Io4") del_bo(con_m, "IO3", counter) check_sygn(ans, EOP_4P, i, txt_frame, grafic_frame) elif i < 15: set_bo(con_m, "IO2", counter, txt_frame) ans = read_bi(con_s, "Io4") del_bo(con_m, "IO2", counter) check_sygn(ans, EOP_4P, i, txt_frame, grafic_frame) counter += 1 elif i < 23: set_bo(con_m, "IO3", counter, txt_frame) ans = read_bi(con_s, "Io4") del_bo(con_m, "IO3", counter) check_sygn(ans, EOP_4P, i, txt_frame, grafic_frame) counter += 1 elif i < 31: set_bo(con_m, "IO4", counter, txt_frame) ans = read_bi(con_s, "Io7") del_bo(con_m, "IO4", counter) check_sygn(ans, EOP_4P, i, txt_frame, grafic_frame) counter += 1 elif i < 39: set_bo(con_m, "IO5", counter, txt_frame) ans = read_bi(con_s, "Io7") del_bo(con_m, "IO5", counter) check_sygn(ans, EOP_4P, i, txt_frame, grafic_frame) counter += 1 elif i < 45: set_bo(con_m, "IO6", counter, txt_frame) ans = read_bi(con_s, "Io7") del_bo(con_m, "IO6", counter) check_sygn(ans, EOP_4P, i, txt_frame, grafic_frame) counter += 1
def test_sterowan_5p(con_m, con_s, txt_frame, grafic_frame): printing(txt_frame, "**********TEST STEROWAN**********") logging.info("**********TEST STEROWAN**********") time.sleep(0.1) read_bi(con_m, "Io7") time.sleep(0.1) control = 1 for i in range(1, 12): if i >= 8: set_signal(con_s, control + 1, txt_frame) ans = read_bi(con_m, "Io7") check_sygn(ans, EOP_OUT, control - 1, txt_frame, grafic_frame) control += 1 time.sleep(0.8) else: set_signal(con_s, control, txt_frame) ans = read_bi(con_m, "Io7") check_sygn(ans, EOP_OUT, control - 1, txt_frame, grafic_frame) control += 1 time.sleep(0.8)
def test_bi_5p(con_m, con_s, txt_frame, grafic_frame): logging.info("**********TEST SYGNALIZACJI**********") printing(txt_frame, "**********TEST SYGNALIZACJI**********") counter = 0 for i in range(0, 54): if counter == 8: counter = 0 if i < 6: set_bo(con_m, "IO2", i, txt_frame) ans = read_bi(con_s, "Io5") del_bo(con_m, "IO2", i) check_sygn(ans, EOP_4P, i, txt_frame, grafic_frame) elif i == 6: set_bo(con_m, "IO3", counter, txt_frame) ans = read_bi(con_s, "Io5") del_bo(con_m, "IO3", counter) check_sygn(ans, EOP_4P, i, txt_frame, grafic_frame) elif i < 15: set_bo(con_m, "IO2", counter, txt_frame) ans = read_bi(con_s, "Io5") del_bo(con_m, "IO2", counter) check_sygn(ans, EOP_4P, i, txt_frame, grafic_frame) counter += 1 elif i < 23: set_bo(con_m, "IO3", counter, txt_frame) ans = read_bi(con_s, "Io5") del_bo(con_m, "IO3", counter) check_sygn(ans, EOP_4P, i, txt_frame, grafic_frame) counter += 1 elif i < 31: set_bo(con_m, "IO4", counter, txt_frame) ans = read_bi(con_s, "Io6") del_bo(con_m, "IO4", counter) check_sygn(ans, EOP_5P, i, txt_frame, grafic_frame) counter += 1 elif i < 39: set_bo(con_m, "IO5", counter, txt_frame) ans = read_bi(con_s, "Io6") del_bo(con_m, "IO5", counter) check_sygn(ans, EOP_5P, i, txt_frame, grafic_frame) counter += 1 elif i < 47: set_bo(con_m, "IO6", counter, txt_frame) ans = read_bi(con_s, "Io6") del_bo(con_m, "IO6", counter) check_sygn(ans, EOP_5P, i, txt_frame, grafic_frame) counter += 1 elif i == 47: set_bo(con_m, "IO4", 6, txt_frame) ans = read_bi(con_s, "Io6") del_bo(con_m, "IO4", 6) check_sygn(ans, EOP_5P, i, txt_frame, grafic_frame) elif i == 48: set_bo(con_m, "IO4", 7, txt_frame) ans = read_bi(con_s, "Io6") del_bo(con_m, "IO4", 7) check_sygn(ans, EOP_5P, i, txt_frame, grafic_frame) elif i < 54: set_bo(con_m, "IO5", counter, txt_frame) ans = read_bi(con_s, "Io7") del_bo(con_m, "IO5", counter) check_sygn(ans, EOP_5P, i, txt_frame, grafic_frame) counter += 1
def set_signal(console, bo, txt_frame): printing(txt_frame, f'Zalaczenie sterowania {bo}') logging.info(f'Zalaczenie sterowania {bo}') console.write(str.encode(f'x {bo} x' + '\r\n')) time.sleep(0.3)