void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) { wxFileName fn; if( !DiagErcTableInit ) { memcpy( DiagErc, DefaultDiagErc, sizeof( DefaultDiagErc ) ); DiagErcTableInit = true; } m_writeErcFile = m_WriteResultOpt->GetValue(); // Build the whole sheet list in hierarchy (sheet, not screen) SCH_SHEET_LIST sheets; sheets.AnnotatePowerSymbols( Prj().SchLibs() ); if( m_parent->CheckAnnotate( aMessagesList, false ) ) { if( aMessagesList ) { wxString msg = _( "Annotation required!" ); msg += wxT( "\n" ); aMessagesList->Add( msg ); } return; } SCH_SCREENS screens; // Erase all previous DRC markers. screens.DeleteAllMarkers( MARKER_BASE::MARKER_ERC ); for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() ) { /* Ff wire list has changed, delete Undo Redo list to avoid pointers on deleted * data problems. */ if( screen->SchematicCleanUp( NULL ) ) screen->ClearUndoRedoList(); } /* Test duplicate sheet names inside a given sheet, one cannot have sheets with * duplicate names (file names can be duplicated). */ TestDuplicateSheetNames( true ); std::auto_ptr<NETLIST_OBJECT_LIST> objectsConnectedList( m_parent->BuildNetListBase() ); // Reset the connection type indicator objectsConnectedList->ResetConnectionsType(); unsigned lastNet; unsigned nextNet = lastNet = 0; int MinConn = NOC; for( unsigned net = 0; net < objectsConnectedList->size(); net++ ) { if( objectsConnectedList->GetItemNet( lastNet ) != objectsConnectedList->GetItemNet( net ) ) { // New net found: MinConn = NOC; nextNet = net; } switch( objectsConnectedList->GetItemType( net ) ) { // These items do not create erc problems case NET_ITEM_UNSPECIFIED: case NET_SEGMENT: case NET_BUS: case NET_JUNCTION: case NET_LABEL: case NET_BUSLABELMEMBER: case NET_PINLABEL: case NET_GLOBBUSLABELMEMBER: break; case NET_HIERLABEL: case NET_HIERBUSLABELMEMBER: case NET_SHEETLABEL: case NET_SHEETBUSLABELMEMBER: case NET_GLOBLABEL: // ERC problems when pin sheets do not match hierarchical labels. // Each pin sheet must match a hierarchical label // Each hierarchical label must match a pin sheet TestLabel( objectsConnectedList.get(), net, nextNet ); break; case NET_NOCONNECT: // ERC problems when a noconnect symbol is connected to more than one pin. MinConn = NET_NC; if( CountPinsInNet( objectsConnectedList.get(), nextNet ) > 1 ) Diagnose( objectsConnectedList->GetItem( net ), NULL, MinConn, UNC ); break; case NET_PIN: // Look for ERC problems between pins: TestOthersItems( objectsConnectedList.get(), net, nextNet, &MinConn ); break; } lastNet = net; } // Displays global results: updateMarkerCounts( &screens ); // Display diags: DisplayERC_MarkersList(); // Display new markers: m_parent->GetCanvas()->Refresh(); if( m_writeErcFile ) { fn = g_RootSheet->GetScreen()->GetFileName(); fn.SetExt( wxT( "erc" ) ); wxFileDialog dlg( this, _( "ERC File" ), fn.GetPath(), fn.GetFullName(), _( "Electronic rule check file (.erc)|*.erc" ), wxFD_SAVE ); if( dlg.ShowModal() == wxID_CANCEL ) return; if( WriteDiagnosticERC( dlg.GetPath() ) ) { Close( true ); ExecuteFile( this, Pgm().GetEditorName(), QuoteFullPath( fn ) ); } } }
void WinEDA_ErcFrame::TestErc(wxCommandEvent& event) /**************************************************/ { ObjetNetListStruct * NetItemRef, * OldItem, * StartNet, * Lim; int NetNbItems, MinConn; if ( ! DiagErcTableInit ) { memcpy(DiagErc, DefaultDiagErc, sizeof (DefaultDiagErc)); DiagErcTableInit = TRUE; } WriteFichierERC = m_WriteResultOpt->GetValue(); if( CheckAnnotate(m_Parent, 0) ) { DisplayError(this, _("Annotation Required!") ); return; } /* Effacement des anciens marqueurs DRC */ DelERCMarkers(event); wxClientDC dc(m_Parent->DrawPanel); m_Parent->DrawPanel->PrepareGraphicContext(&dc); g_EESchemaVar.NbErrorErc = 0; g_EESchemaVar.NbWarningErc = 0; SchematicCleanUp(&dc); BuildNetList(m_Parent, ScreenSch); /* Analyse de la table des connexions : */ Lim = g_TabObjNet + g_NbrObjNet; /* Reset du flag m_FlagOfConnection, utilise par la suite */ for (NetItemRef = g_TabObjNet; NetItemRef < Lim; NetItemRef ++ ) NetItemRef->m_FlagOfConnection = (IsConnectType) 0; NetNbItems = 0; MinConn = NOC; StartNet = OldItem = NetItemRef = g_TabObjNet; for ( ; NetItemRef < Lim; NetItemRef ++ ) { /* Tst changement de net */ if( OldItem->m_NetCode != NetItemRef->m_NetCode) { MinConn = NOC; NetNbItems = 0; StartNet = NetItemRef; } switch ( NetItemRef->m_Type ) { case NET_SEGMENT: case NET_BUS: case NET_JONCTION: case NET_LABEL: case NET_BUSLABELMEMBER: case NET_PINLABEL: break; case NET_GLOBLABEL: case NET_GLOBBUSLABELMEMBER: case NET_SHEETLABEL: case NET_SHEETBUSLABELMEMBER: TestLabel(m_Parent->DrawPanel, &dc, NetItemRef, StartNet); break; case NET_NOCONNECT: MinConn = NET_NC; if( NetNbItems != 0 ) Diagnose(m_Parent->DrawPanel, &dc, NetItemRef, NULL, MinConn, UNC); break; case NET_PIN: TestOthersItems(m_Parent->DrawPanel, &dc, NetItemRef, StartNet, &NetNbItems , &MinConn); break; } OldItem = NetItemRef; } FreeTabNetList(g_TabObjNet, g_NbrObjNet ); wxString num; num.Printf(wxT("%d"), g_EESchemaVar.NbErrorErc); m_TotalErrCount->SetLabel(num); num.Printf(wxT("%d"), g_EESchemaVar.NbErrorErc-g_EESchemaVar.NbWarningErc); m_LastErrCount->SetLabel(num); num.Printf(wxT("%d"), g_EESchemaVar.NbWarningErc); m_LastWarningCount->SetLabel(num); /* Generation ouverture fichier diag */ if( WriteFichierERC == TRUE ) { wxString ErcFullFileName; ErcFullFileName = ScreenSch->m_FileName; ChangeFileNameExt(ErcFullFileName, wxT(".erc")); ErcFullFileName = EDA_FileSelector(_("ERC file:"), wxEmptyString, /* Chemin par defaut */ ErcFullFileName, /* nom fichier par defaut */ wxT(".erc"), /* extension par defaut */ wxT("*.erc"), /* Masque d'affichage */ this, wxSAVE, TRUE ); if ( ErcFullFileName.IsEmpty()) return; if ( WriteDiagnosticERC(ErcFullFileName) ) { Close(TRUE); wxString editorname = GetEditorName(); AddDelimiterString(ErcFullFileName); ExecuteFile(this, editorname, ErcFullFileName); } } }