void DIALOG_ERC::Init() { m_initialized = false; for( int ii = 0; ii < PIN_NMAX; ii++ ) { for( int jj = 0; jj < PIN_NMAX; jj++ ) m_buttonList[ii][jj] = NULL; } m_WriteResultOpt->SetValue( m_writeErcFile ); m_cbTestSimilarLabels->SetValue( m_TestSimilarLabels ); m_cbTestUniqueGlbLabels->SetValue( m_tstUniqueGlobalLabels ); SCH_SCREENS screens; updateMarkerCounts( &screens ); DisplayERC_MarkersList(); // Init Panel Matrix ReBuildMatrixPanel(); // Set the run ERC button as the default button. m_buttonERC->SetDefault(); }
void DIALOG_ERC::Init() { m_initialized = false; for( int ii = 0; ii < PIN_NMAX; ii++ ) for( int jj = 0; jj < PIN_NMAX; jj++ ) m_buttonList[ii][jj] = NULL; m_WriteResultOpt->SetValue( m_writeErcFile ); SCH_SCREENS screens; int markers = screens.GetMarkerCount(); int warnings = screens.GetMarkerCount( WAR ); wxString num; num.Printf( wxT( "%d" ), markers ); m_TotalErrCount->SetLabel( num ); num.Printf( wxT( "%d" ), markers - warnings ); m_LastErrCount->SetLabel( num ); num.Printf( wxT( "%d" ), warnings ); m_LastWarningCount->SetLabel( num ); DisplayERC_MarkersList(); // Init Panel Matrix ReBuildMatrixPanel(); // Set the run ERC button as the default button. m_buttonERC->SetDefault(); }
void DIALOG_ERC::OnLeftClickMarkersList( wxHtmlLinkEvent& event ) { wxString link = event.GetLinkInfo().GetHref(); m_lastMarkerFound = NULL; long index; if( !link.ToLong( &index ) ) return; const SCH_MARKER* marker = m_MarkersList->GetItem( index ); if( marker == NULL ) return; // Search for the selected marker SCH_SHEET_PATH* sheet; SCH_SHEET_LIST SheetList; bool notFound = true; for( sheet = SheetList.GetFirst(); sheet; sheet = SheetList.GetNext() ) { SCH_ITEM* item = (SCH_ITEM*) sheet->LastDrawList(); for( ; item; item = item->Next() ) { if( item == marker ) { notFound = false; break; } } if( notFound == false ) break; } if( notFound ) // Error { wxMessageBox( _( "Marker not found" ) ); // The marker was deleted, so rebuild marker list DisplayERC_MarkersList(); return; } if( *sheet != m_parent->GetCurrentSheet() ) { sheet->LastScreen()->SetZoom( m_parent->GetScreen()->GetZoom() ); m_parent->SetCurrentSheet( *sheet ); m_parent->GetCurrentSheet().UpdateAllScreenReferences(); } m_lastMarkerFound = marker; m_parent->SetCrossHairPosition( marker->m_Pos ); m_parent->RedrawScreen( marker->m_Pos, false); }
void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) { wxFileName fn; m_writeErcFile = m_WriteResultOpt->GetValue(); m_TestSimilarLabels = m_cbTestSimilarLabels->GetValue(); m_tstUniqueGlobalLabels = m_cbTestUniqueGlbLabels->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: // 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 objectsConnectedList->TestforNonOrphanLabel( net, nextNet ); break; case NET_GLOBLABEL: if( m_tstUniqueGlobalLabels ) objectsConnectedList->TestforNonOrphanLabel( net, nextNet ); break; case NET_NOCONNECT: // ERC problems when a noconnect symbol is connected to more than one pin. MinConn = NET_NC; if( objectsConnectedList->CountPinsInNet( 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; } // Test similar labels (i;e. labels which are identical when // using case insensitive comparisons) if( m_TestSimilarLabels ) objectsConnectedList->TestforSimilarLabels(); // 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 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(); 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( MARK_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 ); NETLIST_OBJECT_LIST* objectsConnectedList = m_parent->BuildNetListBase(); // Reset the connection type indicator objectsConnectedList->ResetConnectionsType(); unsigned lastNet; unsigned nextNet = lastNet = 0; int NetNbItems = 0; int MinConn = NOC; for( unsigned net = 0; net < objectsConnectedList->size(); net++ ) { if( objectsConnectedList->GetItemNet( lastNet ) != objectsConnectedList->GetItemNet( net ) ) { // New net found: MinConn = NOC; NetNbItems = 0; 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_GLOBLABEL: case NET_GLOBBUSLABELMEMBER: break; case NET_HIERLABEL: case NET_HIERBUSLABELMEMBER: case NET_SHEETLABEL: case NET_SHEETBUSLABELMEMBER: // 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, net, nextNet ); break; case NET_NOCONNECT: // ERC problems when a noconnect symbol is connected to more than one pin. MinConn = NET_NC; if( NetNbItems != 0 ) Diagnose( objectsConnectedList->GetItem( net ), NULL, MinConn, UNC ); break; case NET_PIN: // Look for ERC problems between pins: TestOthersItems( objectsConnectedList, net, nextNet, &NetNbItems, &MinConn ); break; } lastNet = net; } // Displays global results: wxString num; int markers = screens.GetMarkerCount(); int warnings = screens.GetMarkerCount( WAR ); num.Printf( wxT( "%d" ), markers ); m_TotalErrCount->SetLabel( num ); num.Printf( wxT( "%d" ), markers - warnings ); m_LastErrCount->SetLabel( num ); num.Printf( wxT( "%d" ), warnings ); m_LastWarningCount->SetLabel( num ); // 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 | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() == wxID_CANCEL ) return; if( WriteDiagnosticERC( dlg.GetPath() ) ) { Close( true ); ExecuteFile( this, wxGetApp().GetEditorName(), QuoteFullPath( fn ) ); } } }