for module in individual_module_list: print('Iniciando medidas isoladas do ' + module + '...\n') if module == 'modulo 1': drs.TurnOn(0b0001) elif module == 'modulo 2': drs.TurnOn(0b0010) elif module == 'modulo 3': drs.TurnOn(0b0100) elif module == 'modulo 4': drs.TurnOn(0b1000) time.sleep(1) if module == 'modulo 1': drs.ClosedLoop(0b0001) elif module == 'modulo 2': drs.ClosedLoop(0b0010) elif module == 'modulo 3': drs.ClosedLoop(0b0100) elif module == 'modulo 4': drs.ClosedLoop(0b1000) dso.connect(dso_addr) time.sleep(1) dso.setup_config(dso_file) time.sleep(5) _file = open('ripple_results_iso.csv', 'a') _file.write('NS bastidor: ' + bastidor + '\n')
class DCCTTest(QThread): test_complete = pyqtSignal(bool) update_gui = pyqtSignal(str) connection_lost = pyqtSignal() def __init__(self, comport=None, baudrate=None, serial_number=None, variant=None): QThread.__init__(self) self._comport = comport self._baudarate = baudrate self._serial_number = serial_number self._variant = variant self.FBP = SerialDRS() self._load_current = [0, 0, 2, 4, 6, 8, 10, -10, -8, -6, -4, -2] @property def serial_number(self): return self._serial_number @serial_number.setter def serial_number(self, value): self._serial_number = value @property def variant(self): return self._variant @variant.setter def variant(self, value): self._variant = value @property def comport(self): return self._comport @comport.setter def comport(self, value): self._comport = value @property def baudrate(self): return self._baudarate @baudrate.setter def baudrate(self, value): self._baudrate = value def open_serial_port(self): if self._comport is None or self._baudrate is None: return False else: self.FBP.SetSlaveAdd(5) return self.FBP.Connect(self._comport, self._baudrate) def test_communication(self): result = (False, False ) # Result for communication test and aux power supply try: print('##########################') print(self.FBP.Write_sigGen_Aux(1)) time.sleep(5) test_package = self.FBP.Read_ps_Model() if (test_package[0] == 0) and (test_package[1] == 17) and ( test_package[2] == 512) and (test_package[3] == 14) and (test_package[4] == 223): result = (True, True) else: result = (False, False) self.FBP.Read_ps_SoftInterlocks() self.FBP.Read_ps_HardInterlocks() except: result = (False, False) return result def _test_sequence(self): result = False list_log = [] current_DCCT = [] current_DCCT1 = [] current_DCCT2 = [] dcct = DCCT() dcct.serial_number = self._serial_number dcct.variant = self._variant res = self._send_to_server(dcct) print(dcct.variant) if res: #TODO: Sequencia de Testes if self.FBP.Read_ps_SoftInterlocks() is not 0: if round(self.FBP.Read_iMod1()) == 0 and round(self.FBP.Read_iMod2()) == 0\ and round(self.FBP.Read_iMod3()) == 0 and round(self.FBP.Read_iMod4()) == 0: print('Resetando Interlocks...') self.FBP.ResetInterlocks() else: print( 'Jiga com problemas! Verifique os Soft interlocks ativos...' ) if self.FBP.Read_ps_HardInterlocks() is not 0: if round(self.FBP.Read_iMod1()) == 0 and round(self.FBP.Read_iMod2()) == 0\ and round(self.FBP.Read_iMod3()) == 0 and round(self.FBP.Read_iMod4()) == 0: print('Resetando Interlocks...') self.FBP.ResetInterlocks() else: print( 'Jiga com problemas! Verifique os Hard interlocks ativos...' ) print('variante ' + str(self._variant)) if self._variant == 'DCCT-CONF-A': list_log.append(DCCTLog()) list_log.append(DCCTLog()) current_DCCT1.append(self.FBP.Read_iMod3( )) # medidas de corrente com fonte desligada current_DCCT2.append(self.FBP.Read_iMod4( )) # medidas de corrente com fonte desligada time.sleep(1) self.FBP.TurnOn(0b0001) time.sleep(1) if self.FBP.Read_ps_OnOff() is not 1: print('ERRO! O MÓDULO NÃO LIGOU CORRETAMENTE!!!') self.update_gui.emit( 'O módulo da Jiga não ligou corretamente. Desligue a jiga reinicie o teste!!!' ) else: self.update_gui.emit('Fonte ligada') time.sleep(1) self.FBP.ClosedLoop(0b0001) self.update_gui.emit('Malha fechada') time.sleep(1) self.FBP.Read_ps_SoftInterlocks() self.FBP.Read_ps_HardInterlocks() for i in range(1, len(self._load_current)): self.FBP.SetISlowRef(self._load_current[i]) time.sleep(1) self.update_gui.emit( 'Testando DCCTs com corrente de ' + str(self._load_current[i]) + 'A') self.update_gui.emit( ' Corrente de saida do modulo padrao: ' + str(round(self.FBP.Read_iMod1())) + 'A') compare_mod1 = round(self.FBP.Read_iMod1()) if not self._load_current[i] == compare_mod1: self.update_gui.emit(str(self._load_current[i])) self.update_gui.emit(str(compare_mod1)) self.update_gui.emit( '\nMAU FUNCIONAMENTO NO TESTE: CIRCUITO ABERTO OU DEFEITO NO MODULO PADRAO\n' ) time.sleep(30) # Alterar para 30s self.update_gui.emit(' Corrente DCCT1: ' + str(self.FBP.Read_iMod3()) + 'A') self.update_gui.emit(' Corrente DCCT2: ' + str(self.FBP.Read_iMod4()) + 'A') print(self.FBP.Read_iMod3()) print(self.FBP.Read_iMod4()) current_DCCT1.append(self.FBP.Read_iMod3()) current_DCCT2.append(self.FBP.Read_iMod4()) self.FBP.Read_ps_SoftInterlocks() self.FBP.Read_ps_HardInterlocks() current_DCCT.append(current_DCCT1) current_DCCT.append(current_DCCT2) for j in range(0, 2): for k in range(0, len(self._load_current)): if round(current_DCCT[j] [k]) == self._load_current[k]: string_result = 'Aprovado' result = True else: string_result = 'Reprovado' result = False break list_log[j].test_result = string_result self.update_gui.emit('DCCT' + str(j + 1) + ' ' + str(list_log[j].test_result)) for l in range(2): list_log[l].iload_off = current_DCCT[l][0] list_log[l].iload0 = current_DCCT[l][1] list_log[l].iload1 = current_DCCT[l][2] list_log[l].iload2 = current_DCCT[l][3] list_log[l].iload3 = current_DCCT[l][4] list_log[l].iload4 = current_DCCT[l][5] list_log[l].iload5 = current_DCCT[l][6] list_log[l].iload6 = current_DCCT[l][7] list_log[l].iload7 = current_DCCT[l][8] list_log[l].iload8 = current_DCCT[l][9] list_log[l].iload9 = current_DCCT[l][10] list_log[l].iload10 = current_DCCT[l][11] list_log[l].id_canal_dcct = l + 1 list_log[l].serial_number_dcct = self._serial_number if self._send_to_server(list_log[0]): self.update_gui.emit('Dados enviados para o servidor') else: self.update_gui.emit( 'Erro no envio de dados para o servidor') if self._send_to_server(list_log[1]): self.update_gui.emit('Dados enviados para o servidor') else: self.update_gui.emit( 'Erro no envio de dados para o servidor') elif self._variant == 'DCCT-CONF-B': list_log.append(DCCTLog()) list_log.append(None) current_DCCT1.append(self.FBP.Read_iMod3( )) # medidas de corrente com fonte desligada time.sleep(1) self.FBP.TurnOn(0b0001) time.sleep(1) if self.FBP.Read_ps_OnOff() is not 1: print('ERRO! O MÓDULO NÃO LIGOU CORRETAMENTE!!!') self.update_gui.emit( 'O módulo da Jiga não ligou corretamente. Desligue a jiga e reinicie o teste!!!' ) else: self.update_gui.emit('Fonte ligada') time.sleep(1) self.FBP.ClosedLoop(0b0001) self.update_gui.emit('Malha fechada') time.sleep(1) self.FBP.Read_ps_SoftInterlocks() self.FBP.Read_ps_HardInterlocks() for i in range(1, len(self._load_current)): self.FBP.SetISlowRef(self._load_current[i]) time.sleep(1) self.update_gui.emit( 'Testando DCCTs com corrente de ' + str(self._load_current[i]) + 'A') self.update_gui.emit( ' Corrente de saida do modulo padrao: ' + str(round(self.FBP.Read_iMod1())) + 'A') compare_mod1 = round(self.FBP.Read_iMod1()) if not self._load_current[i] == compare_mod1: self.update_gui.emit(str(self._load_current[i])) self.update_gui.emit(str(compare_mod1)) self.update_gui.emit( '\nMAU FUNCIONAMENTO NO TESTE: CIRCUITO ABERTO OU DEFEITO NO MODULO PADRAO\n' ) time.sleep(30) # Alterar para 30s self.update_gui.emit(' Corrente DCCT1: ' + str(self.FBP.Read_iMod3()) + 'A') current_DCCT1.append(self.FBP.Read_iMod3()) for j in range(0, len(self._load_current)): if round(current_DCCT1[j]) == self._load_current[j]: string_result = 'Aprovado' result = True else: string_result = 'Reprovado' result = False break list_log[0].test_result = string_result self.update_gui.emit('DCCT1 ' + str(list_log[0].test_result)) list_log[0].iload_off = current_DCCT1[0] list_log[0].iload0 = current_DCCT1[1] list_log[0].iload1 = current_DCCT1[2] list_log[0].iload2 = current_DCCT1[3] list_log[0].iload3 = current_DCCT1[4] list_log[0].iload4 = current_DCCT1[5] list_log[0].iload5 = current_DCCT1[6] list_log[0].iload6 = current_DCCT1[7] list_log[0].iload7 = current_DCCT1[8] list_log[0].iload8 = current_DCCT1[9] list_log[0].iload9 = current_DCCT1[10] list_log[0].iload10 = current_DCCT1[11] list_log[0].id_canal_dcct = 1 list_log[0].serial_number_dcct = self._serial_number if self._send_to_server(list_log[0]): self.update_gui.emit('Dados enviados para o servidor') else: self.update_gui.emit( 'Erro no envio de dados para o servidor') self.FBP.TurnOff(0b0001) self.test_complete.emit(result) def _send_to_server(self, item): client = ElpWebClient() client_data = item.data client_method = item.method client_response = client.do_request(client_method, client_data) print(client_response) server_status = self._parse_response(client_response) return server_status def _parse_response(self, response): res_key = 'StatusCode' err_key = 'error' if res_key in response.keys() and err_key not in response.keys(): return True else: return False def run(self): self._test_sequence()
class PowerSupplyTest(QThread): test_complete = pyqtSignal(bool) update_gui = pyqtSignal(str) connection_lost = pyqtSignal() def __init__(self, comport=None, baudrate=None, serial_number=None, variant=None): QThread.__init__(self) self._comport = comport self._baudarate = baudrate self._serial_number = serial_number self._serial_port = serial.Serial() self.FBP = SerialDRS() @property def serial_number(self): return self._serial_number @serial_number.setter def serial_number(self, value): self._serial_number = value @property def comport(self): return self._comport @comport.setter def comport(self, value): self._comport = value @property def baudrate(self): return self._baudarate @baudrate.setter def baudrate(self, value): self._baudrate = value def open_serial_port(self): if self._comport is None or self._baudrate is None: return False else: self._serial_port.baudrate = self._baudrate self._serial_port.port = self._comport return self.FBP.Connect(self._comport, self._baudrate) def test_communication(self): result = (False, False ) # Result for communication test and aux power supply test = [] #TODO: Communication test for i in range(2): try: if i == 0: print('Configurando UDC da Fonte...') self.FBP.SetSlaveAdd(1) # Endereço do controlador time.sleep(0.5) self.FBP.Config_nHRADC(4) elif i == 1: print('Configurando UDC da jiga...') self.FBP.SetSlaveAdd(5) # Endereço do controlador time.sleep(0.5) self.FBP.Write_sigGen_Aux(0) # Usando 4 fontes no bastidor # em teste e 0 na jiga bastidor time.sleep(5) test_package = self.FBP.Read_ps_Model() if (test_package[0] == 0) and (test_package[1] == 17) and \ (test_package[2] == 512) and (test_package[3] == 14) and \ (test_package[4] == 223): test.append(True) else: test.append(False) except: print('ERRO!!!') test.append(False) print( '###########################################################') print('Interlocks no teste de comunicação:') self.FBP.Read_ps_SoftInterlocks() self.FBP.Read_ps_HardInterlocks() if test == [True, True]: result = (True, True) else: result = (False, False) return result def _test_sequence(self): result = True send_to_server_result = False OnOff = ['Reprovado' for i in range(4)] MeasDCLink = [[] for j in range(4)] MeasVout = [[] for k in range(4)] MeasTemp = [[] for l in range(4)] MeasCurr = [[[] for m in range(5)] for n in range(4)] compare_current = [ 4, -4, 5, 10, -10 ] # [0] e [1] alterados para adequação do novo ciclo de trabalho LimDCLink = [14, 16] # valores limite para o DC Link LimVout = [ 5, 7.5 ] # valores limite para tensão de saída alterar para LimVout[0] = 0.6 e LimVout[1] = 1 LimTemp = 60 # valor limite para temperatura # If serial connection is lost if not self._serial_port.is_open: self.connection_lost.emit() #TODO: Encerra testes ps = PowerSupply() ps.serial_number = self._serial_number res = self._send_to_server(ps) if res: self.FBP.SetSlaveAdd(1) # Bastidor em teste time.sleep(1) self.FBP.ResetInterlocks() time.sleep(5) # self.FBP.TurnOff(0b1111) # time.sleep(5) '''########################### Teste Liga/Desliga ###########################''' '''##########################################################################''' self.update_gui.emit( 'Iniciando teste liga/desliga dos módulos de potência...') for module in range(4): self.FBP.TurnOn(2**module) time.sleep(1) # self.FBP.OpenLoop(2**module) # time.sleep(1) if self.FBP.Read_ps_OnOff() == 2**module: OnOff[module] = 'OK' else: self.update_gui.emit('O módulo ' + str(module + 1) + ' não ligou corretamente') OnOff[module] = 'NOK' time.sleep(1) self.FBP.TurnOff(2**module) if self.FBP.Read_ps_OnOff() == 0: if OnOff[module] == 'OK': OnOff[module] = 'OK' else: OnOff[module] = 'NOK' self.update_gui.emit('O módulo ' + str(module + 1) + ' não desligou corretamente') time.sleep(1) '''##########################################################################''' self.FBP.Read_ps_SoftInterlocks() self.FBP.Read_ps_HardInterlocks() self.FBP.TurnOn(0b1111) # liga todos os módulos time.sleep(5) self.FBP.OpenLoop(0b1111) # todos os módulos em malha aberta if (abs(self.FBP.Read_iMod1()) > 12) or \ (abs(self.FBP.Read_iMod2()) > 12) or \ (abs(self.FBP.Read_iMod3()) > 12) or \ (abs(self.FBP.Read_iMod4()) > 12): self.update_gui.emit('ERRO! REINICIE O TESTE E AS FONTES') time.sleep(10) raise NameError('ERRO! REINICIE O TESTE E AS FONTES') time.sleep(1) '''################## Teste em Malha Aberta com 21.5% #######################''' '''##########################################################################''' self.update_gui.emit('Iniciando teste com módulos a 4A...') self.FBP.ClosedLoop(15) time.sleep(1) for module in range(4): if module == 0: self.FBP.SetISlowRefx4(4, 0, 0, 0) # ciclo de trabalho elif module == 1: # alterado para 21.5% self.FBP.SetISlowRefx4(0, 4, 0, 0) # ciclo de trabalho elif module == 2: # alterado para 21.5% self.FBP.SetISlowRefx4(0, 0, 4, 0) # ciclo de trabalho elif module == 3: # alterado para 22,575% self.FBP.SetISlowRefx4(0, 0, 0, 4) # ciclo de trabalho # alterado para 21.5% # o teste original pedia um ciclo de trabalho de 20%, contudo # foi necessário alter o teste para trabalhar em malha aberta # devido a uma alteração na carga time.sleep(2) if (abs(self.FBP.Read_iMod1()) > 12) or \ (abs(self.FBP.Read_iMod2()) > 12) or \ (abs(self.FBP.Read_iMod3()) > 12) or \ (abs(self.FBP.Read_iMod4()) > 12): self.update_gui.emit('ERRO! REINICIE O TESTE E AS FONTES') time.sleep(10) raise NameError('ERRO! REINICIE O TESTE E AS FONTES') time.sleep(1) MeasureList = self._save_CurrentMeasurement(module) for current in MeasureList: MeasCurr[module][0].append(current) time.sleep(1) self.FBP.SetSlaveAdd(1) # bastidor em teste print('mod1: ' + str(self.FBP.Read_iMod1())) time.sleep(0.1) print('mod2: ' + str(self.FBP.Read_iMod2())) time.sleep(0.1) print('mod3: ' + str(self.FBP.Read_iMod3())) time.sleep(0.1) print('mod4: ' + str(self.FBP.Read_iMod4()) + '\n') time.sleep(0.1) # self.FBP.ConfigWfmRef(module+1, 0) # ajusta 0 o ciclo de trabalho apenas para o modulo testado if module == 0 or module == 1 or module == 2 or module == 3: self.FBP.SetISlowRefx4(0, 0, 0, 0) time.sleep(2) '''##########################################################################''' self.FBP.Read_ps_SoftInterlocks() self.FBP.Read_ps_HardInterlocks() '''################## Teste em Malha Aberta com -21.5% ######################''' '''##########################################################################''' self.update_gui.emit('Iniciando teste com módulos a -4A...') self.FBP.ClosedLoop(15) time.sleep(1) for module in range(4): if module == 0: self.FBP.SetISlowRefx4(-4, 0, 0, 0) # ciclo de trabalho elif module == 1: # alterado para 21.5% self.FBP.SetISlowRefx4(0, -4, 0, 0) # ciclo de trabalho elif module == 2: # alterado para 21.5% self.FBP.SetISlowRefx4(0, 0, -4, 0) # ciclo de trabalho elif module == 3: # alterado para 22,575% self.FBP.SetISlowRefx4(0, 0, 0, -4) # ciclo de trabalho # alterado para 21.5% # o teste original pedia um ciclo de trabalho de 20%, contudo # foi necessário alter o teste para trabalhar em malha aberta # devido a uma alteração na carga time.sleep(2) MeasureList = self._save_CurrentMeasurement(module) for current in MeasureList: MeasCurr[module][1].append(current) time.sleep(1) self.FBP.SetSlaveAdd(1) # bastidor em teste print('mod1: ' + str(self.FBP.Read_iMod1())) time.sleep(0.1) print('mod2: ' + str(self.FBP.Read_iMod2())) time.sleep(0.1) print('mod3: ' + str(self.FBP.Read_iMod3())) time.sleep(0.1) print('mod4: ' + str(self.FBP.Read_iMod4()) + '\n') time.sleep(0.1) if module == 0 or module == 1 or module == 2 or module == 3: self.FBP.SetISlowRefx4(0, 0, 0, 0) time.sleep(2) '''##########################################################################''' self.FBP.Read_ps_SoftInterlocks() self.FBP.Read_ps_HardInterlocks() '''#################### Teste em Malha Fechada com 5A #######################''' '''##########################################################################''' self.update_gui.emit( 'Iniciando teste com módulos em malha fechada a 5A...') for module in range(4): self.FBP.ClosedLoop(15) time.sleep(1) if module == 0: self.FBP.SetISlowRefx4(5, 0, 0, 0) elif module == 1: self.FBP.SetISlowRefx4(0, 5, 0, 0) elif module == 2: self.FBP.SetISlowRefx4(0, 0, 5, 0) elif module == 3: self.FBP.SetISlowRefx4(0, 0, 0, 5) time.sleep(2) if (abs(self.FBP.Read_iMod1()) > 12) or \ (abs(self.FBP.Read_iMod2()) > 12) or \ (abs(self.FBP.Read_iMod3()) > 12) or \ (abs(self.FBP.Read_iMod4()) > 12): self.update_gui.emit('ERRO! REINICIE O TESTE E AS FONTES') time.sleep(10) raise NameError('ERRO! REINICIE O TESTE E AS FONTES') time.sleep(1) MeasureList = self._save_CurrentMeasurement(module) print('mod1: ' + str(self.FBP.Read_iMod1())) time.sleep(0.1) print('mod2: ' + str(self.FBP.Read_iMod2())) time.sleep(0.1) print('mod3: ' + str(self.FBP.Read_iMod3())) time.sleep(0.1) print('mod4: ' + str(self.FBP.Read_iMod4()) + '\n') time.sleep(0.1) for current in MeasureList: MeasCurr[module][2].append(current) self.FBP.SetSlaveAdd(1) if module == 0 or module == 1 or module == 2 or module == 3: self.FBP.SetISlowRefx4(0, 0, 0, 0) time.sleep(2) self.FBP.OpenLoop(15) time.sleep(2) '''##########################################################################''' self.FBP.Read_ps_SoftInterlocks() self.FBP.Read_ps_HardInterlocks() '''################### Teste em Malha Fechada com 10A #######################''' '''##########################################################################''' self.update_gui.emit( 'Iniciando teste com módulos em malha fechada a 10A...') self.FBP.ClosedLoop(0b1111) time.sleep(2) self.FBP.OpMode(0) time.sleep(2) self.FBP.SetISlowRefx4(10, 10, 10, 10) time.sleep(1) for module in range(4): time.sleep(5) MeasureList = self._save_CurrentMeasurement(module) for current in MeasureList: MeasCurr[module][3].append(current) self.FBP.SetSlaveAdd(1) print('mod1: ' + str(self.FBP.Read_iMod1())) time.sleep(0.1) print('mod2: ' + str(self.FBP.Read_iMod2())) time.sleep(0.1) print('mod3: ' + str(self.FBP.Read_iMod3())) time.sleep(0.1) print('mod4: ' + str(self.FBP.Read_iMod4()) + '\n') time.sleep(0.1) '''##########################################################################''' print('Interlocks Ativos: ') self.FBP.Read_ps_SoftInterlocks() self.FBP.Read_ps_HardInterlocks() self.update_gui.emit( 'Realizando medidas de tensão do DC-Link, tensão de saída e temperatura' ) for o in range(8): time.sleep(30) # alterar tempo para 30s MeasDCLink[0].append(self.FBP.Read_vDCMod1()) time.sleep(0.1) MeasDCLink[1].append(self.FBP.Read_vDCMod2()) time.sleep(0.1) MeasDCLink[2].append(self.FBP.Read_vDCMod3()) time.sleep(0.1) MeasDCLink[3].append(self.FBP.Read_vDCMod4()) time.sleep(0.1) MeasVout[0].append(self.FBP.Read_vOutMod1()) time.sleep(0.1) MeasVout[1].append(self.FBP.Read_vOutMod2()) time.sleep(0.1) MeasVout[2].append(self.FBP.Read_vOutMod3()) time.sleep(0.1) MeasVout[3].append(self.FBP.Read_vOutMod4()) time.sleep(0.1) MeasTemp[0].append(self.FBP.Read_temp1()) time.sleep(0.1) MeasTemp[1].append(self.FBP.Read_temp2()) time.sleep(0.1) MeasTemp[2].append(self.FBP.Read_temp3()) time.sleep(0.1) MeasTemp[3].append(self.FBP.Read_temp4()) time.sleep(0.1) self.FBP.SetSlaveAdd(1) '''################### Teste em Malha Fechada com -10A ######################''' '''##########################################################################''' self.update_gui.emit( 'Iniciando teste com módulos em malha fechada a -10A...') self.FBP.SetISlowRefx4(0, 0, 0, 0) time.sleep(0.5) self.FBP.SetISlowRefx4(-10, -10, -10, -10) for module in range(4): time.sleep(5) MeasureList = self._save_CurrentMeasurement(module) for current in MeasureList: MeasCurr[module][4].append(current) self.FBP.SetSlaveAdd(1) print('mod1: ' + str(self.FBP.Read_iMod1())) time.sleep(0.1) print('mod2: ' + str(self.FBP.Read_iMod2())) time.sleep(0.1) print('mod3: ' + str(self.FBP.Read_iMod3())) time.sleep(0.1) print('mod4: ' + str(self.FBP.Read_iMod4()) + '\n') time.sleep(0.1) '''##########################################################################''' self.FBP.Read_ps_SoftInterlocks() self.FBP.Read_ps_HardInterlocks() self.update_gui.emit( 'Realizando medidas de tensão do DC-Link, tensão de saída e temperatura' ) for p in range(8): time.sleep(30) # alterar tempo para 30s MeasDCLink[0].append(self.FBP.Read_vDCMod1()) time.sleep(0.1) MeasDCLink[1].append(self.FBP.Read_vDCMod2()) time.sleep(0.1) MeasDCLink[2].append(self.FBP.Read_vDCMod3()) time.sleep(0.1) MeasDCLink[3].append(self.FBP.Read_vDCMod4()) time.sleep(0.1) MeasVout[0].append(self.FBP.Read_vOutMod1()) time.sleep(0.1) MeasVout[1].append(self.FBP.Read_vOutMod2()) time.sleep(0.1) MeasVout[2].append(self.FBP.Read_vOutMod3()) time.sleep(0.1) MeasVout[3].append(self.FBP.Read_vOutMod4()) time.sleep(0.1) MeasTemp[0].append(self.FBP.Read_temp1()) time.sleep(0.1) MeasTemp[1].append(self.FBP.Read_temp2()) time.sleep(0.1) MeasTemp[2].append(self.FBP.Read_temp3()) time.sleep(0.1) MeasTemp[3].append(self.FBP.Read_temp4()) time.sleep(0.1) self.FBP.SetSlaveAdd(1) self.FBP.SetISlowRefx4(0, 0, 0, 0) time.sleep(1) self.FBP.TurnOff(0b1111) for module in range(4): log = PowerSupplyLog() log.id_canal_power_supply = module + 1 test = [True for p in range(9)] n = 0 temp_exceeded = 0 self.update_gui.emit('') self.update_gui.emit('Verificando resultados do módulo '\ + str(module + 1) + '...') '''-------------------------------------------------------------''' for a in compare_current: for b in MeasCurr[module][n]: if a == round(b): if test[n]: test[n] = True else: test[n] = False if test[n]: self.update_gui.emit(' Aprovado no teste ' + str(compare_current.index(a) + 1) + ' de corrente de saída') else: self.update_gui.emit(' Reprovado no teste ' + str(compare_current.index(a) + 1) + ' de corrente de saída') n = n + 1 '''-------------------------------------------------------------''' '''-------------------------------------------------------------''' for c in MeasDCLink[module]: if (LimDCLink[0] <= round(c)) and (round(c) <= LimDCLink[1]): if test[5]: test[5] = True else: test[5] = False if test[5]: self.update_gui.emit( ' Aprovado no teste de leitura da tensão do DC Link' ) else: self.update_gui.emit( ' Reprovado no teste de leitura da tensão do DC Link' ) '''-------------------------------------------------------------''' '''-------------------------------------------------------------''' for d in MeasTemp[module]: if d <= LimTemp: if test[6]: test[6] = True elif d == 127: temp_exceeded = 127 test[6] = False elif (d >= LimTemp) and (d != 127): # if d == 127: # test[6] = True # temp_exceeded = 127 test[6] = False if test[6]: self.update_gui.emit( ' Aprovado no teste de leitura da temperatura') else: if temp_exceeded == 127: self.update_gui.emit( ' Aprovado no teste de leitura da temperatura com ressalvas' ) test[6] = True else: self.update_gui.emit( ' Reprovado no teste de leitura de temperatura' ) '''-------------------------------------------------------------''' '''-------------------------------------------------------------''' for e in range(0, len(MeasVout[module]) - 8): if (LimVout[0] < MeasVout[module][e]) and ( MeasVout[module][e] < LimVout[1]): if test[7]: test[7] = True else: test[7] = False if test[7]: self.update_gui.emit( ' Aprovado no teste 1 de leitura da tensão de saída ' ) else: self.update_gui.emit( ' Reprovado no teste 1 de leitura da tensão de saída' ) '''-------------------------------------------------------------''' '''-------------------------------------------------------------''' for f in range(8, len(MeasVout[module])): if (-LimVout[1] < MeasVout[module][f]) and ( MeasVout[module][f] < -LimVout[0]): if test[8]: test[8] = True else: test[8] = False if test[8]: self.update_gui.emit( ' Aprovado no teste 2 de leitura da tensão de saída' ) else: self.update_gui.emit( ' Reprovado no teste 2 de leitura da tensão de saída' ) '''-------------------------------------------------------------''' print('\n') print(test) print('\n') if test == [True for g in range(9)]: if result: result = True log.test_result = 'Aprovado' else: log.test_result = 'Reprovado' result = False log.result_test_on_off = OnOff[module] log.serial_number_power_supply = self._serial_number log.iout0 = MeasCurr[module][3][0] log.iout1 = MeasCurr[module][4][0] log.vout0 = MeasVout[module][7] log.vout1 = MeasVout[module][15] log.vdclink0 = MeasDCLink[module][7] log.vdclink1 = MeasDCLink[module][15] log.temperatura0 = MeasTemp[module][7] log.temperatura1 = MeasTemp[module][15] log.iout_add_20_duty_cycle = MeasCurr[module][0][0] log.iout_less_20_duty_cycle = MeasCurr[module][1][0] log.details = 'SoftInterlocks ativos: ' + str(self.FBP.Read_ps_SoftInterlocks()) + \ ' HardInterlocks ativos: ' + str(self.FBP.Read_ps_HardInterlocks()) if temp_exceeded == 127: log.details = log.details + ' (false_read 127 degrees Celsius)' send_to_server_result = self._send_to_server(log) self.update_gui.emit('') self.update_gui.emit('Interlocks Ativos:') for softinterlock in self._read_SoftInterlock( self.FBP.Read_ps_SoftInterlocks()): self.update_gui.emit(softinterlock) for hardinterlock in self._read_HardInterlock( self.FBP.Read_ps_HardInterlocks()): self.update_gui.emit(hardinterlock) print('--------------------------------------------\n') self.test_complete.emit(result) def _save_CurrentMeasurement(self, module): Measurement = [] if module == 0: self.FBP.SetSlaveAdd(1) # bastidor em teste Measurement.append(self.FBP.Read_iMod1( )) # corrente de saída lida pelo bastidor testado time.sleep(0.1) self.FBP.SetSlaveAdd(5) # jiga bastidor Measurement.append(self.FBP.Read_iMod1() ) # corrente de saída lida pela jiga bastidor time.sleep(0.1) elif module == 1: self.FBP.SetSlaveAdd(1) # bastidor em teste Measurement.append(self.FBP.Read_iMod2( )) # corrente de saída lida pelo bastidor testado time.sleep(0.1) self.FBP.SetSlaveAdd(5) # jiga bastidor Measurement.append(self.FBP.Read_iMod2() ) # corrente de saída lida pela jiga bastidor time.sleep(0.1) elif module == 2: self.FBP.SetSlaveAdd(1) # bastidor em teste Measurement.append(self.FBP.Read_iMod3( )) # corrente de saída lida pelo bastidor testado time.sleep(0.1) self.FBP.SetSlaveAdd(5) # jiga bastidor Measurement.append(self.FBP.Read_iMod3() ) # corrente de saída lida pela jiga bastidor time.sleep(0.1) elif module == 3: self.FBP.SetSlaveAdd(1) # bastidor em teste Measurement.append(self.FBP.Read_iMod4( )) # corrente de saída lida pelo bastidor testado time.sleep(0.1) self.FBP.SetSlaveAdd(5) # jiga bastidor Measurement.append(self.FBP.Read_iMod4() ) # corrente de saída lida pela jiga bastidor time.sleep(0.1) return Measurement def _send_to_server(self, item): client = ElpWebClient() client_data = item.data print(client_data) client_method = item.method client_response = client.do_request(client_method, client_data) print(client_response) server_status = self._parse_response(client_response) return server_status def _parse_response(self, response): res_key = 'StatusCode' err_key = 'error' if res_key in response.keys() and err_key not in response.keys(): return True else: return False def run(self): self._test_sequence() #pass def _read_SoftInterlock(self, int_interlock): SoftInterlockList = ['N/A', 'Sobre-tensão na carga 1', 'N/A', \ 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A',\ 'Sobre-tensão na carga 2', 'N/A', \ 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A',\ 'Sobre-tensão na carga 3', 'N/A', \ 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A',\ 'Sobre-tensão na carga 4', 'N/A', \ 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A'] op_bin = 1 ActiveSoftInterlocks = [] for i in range(len('{0:b}'.format(int_interlock))): if (int_interlock & (op_bin << i)) == 2**i: ActiveSoftInterlocks.append(SoftInterlockList[i]) return ActiveSoftInterlocks def _read_HardInterlock(self, int_interlock): HardInterlockList = ['Sobre-corrente na carga 1', 'N/A', \ 'Sobre-tensão no DC-Link do módulo 1', \ 'Sub-tensão no DC-Link do módulo 1', \ 'Falha no relé de entrada do DC-Link do módulo 1', \ 'Falha no fusível de entrada do DC-Link do módulo 1', \ 'Falha nos drivers do módulo 1', \ 'Sobre-temperatura no módulo 1', \ 'Sobre-corrente na carga 2', 'N/A', \ 'Sobre-tensão no DC-Link do módulo 2', \ 'Sub-tensão no DC-Link do módulo 2', \ 'Falha no relé de entrada do DC-Link do módulo 2', \ 'Falha no fusível de entrada do DC-Link do módulo 2', \ 'Falha nos drivers do módulo 2', \ 'Sobre-temperatura no módulo 2', \ 'Sobre-corrente na carga 3', 'N\A', \ 'Sobre-tensão no DC-Link do módulo 3', \ 'Sub-tensão no DC-Link do módulo 3', \ 'Falha no relé de entrada no DC-Link do módulo 3', \ 'Falha no fusível de entrada do DC-Link do módulo 3', \ 'Falha nos drivers do módulo 3', \ 'Sobre-temperatura no módulo 3', \ 'Sobre-corrente na carga 4', 'N/A', \ 'Sobre-tensão no DC-Link do módulo 4', \ 'Sub-tensão no DC-Link do módulo 4', \ 'Falha no relé de entrada do DC-Link do módulo 4', \ 'Falha no fusível de entrada do DC-Link do módulo 4', \ 'Falha nos drivers do módulo 4', \ 'Sobre-temperatura no módulo 4'] op_bin = 1 ActiveHardInterlocks = [] for i in range(len('{0:b}'.format(int_interlock))): if (int_interlock & (op_bin << i)) == 2**i: ActiveHardInterlocks.append(HardInterlockList[i]) return ActiveHardInterlocks
# o teste dura 50 horas (em média) com um WarmUpTime de 2 horas e um StepTime de 60 min print(str(now.day) + ',' + str(now.hour) + ':' + str(now.minute)) for bastidor in BastidorList: print('\nConfigurando DRS e ligando módulos de potência do bastidor NS.:' + str(bastidor) + '...\n') drs.Connect(drs_port) time.sleep(1) drs.SetSlaveAdd(BastidorList.index(bastidor) + 1) time.sleep(1) drs.Config_nHRADC(4) time.sleep(5) drs.TurnOn(0b1111) time.sleep(1) drs.ClosedLoop(0b1111) time.sleep(1) ######################################################################### ''' Inicio do teste de Cross Talk ''' for module in module_list: for test_current in SetTestList: if module_list.index(module) == 0: for bastidor in BastidorList: drs.SetSlaveAdd(BastidorList.index(bastidor) + 1) time.sleep(1) drs.SetISlowRefx4(test_current, 0, 0, 0) time.sleep(WarmUpTime)