bool SCH_EDIT_FRAME::prepareForNetlist() { SCH_SHEET_LIST sheets( g_RootSheet ); sheets.AnnotatePowerSymbols( Prj().SchLibs() ); // Performs some controls: if( CheckAnnotate( NULL, 0 ) ) { // Schematic must be annotated: call Annotate dialog and tell // the user why that is. InvokeDialogAnnotate( this, _( "Exporting the netlist requires a " "completely\nannotated schematic." ) ); if( CheckAnnotate( NULL, 0 ) ) return false; } // Test duplicate sheet names: if( TestDuplicateSheetNames( false ) > 0 ) { if( !IsOK( NULL, _( "Error: duplicate sheet names. Continue?" ) ) ) return false; } // Cleanup the entire hierarchy SCH_SCREENS screens; screens.SchematicCleanUp(); return true; }
/* Function CreateNetlist * > test for some issues (missing or duplicate references and sheet names) * > build netlist info * > create the netlist file * param aFormat = netlist format (NET_TYPE_PCBNEW ...) * param aFullFileName = full netlist file name * param aNetlistOptions = netlist options using OR'ed bits (see WriteNetListFile). * return true if success. */ bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName, unsigned aNetlistOptions ) { SCH_SHEET_LIST sheets; sheets.AnnotatePowerSymbols(); // Performs some controls: if( CheckAnnotate( NULL, 0 ) ) { if( !IsOK( NULL, _( "Some items are not annotated\n\ Do you want to annotate schematic?" ) ) ) return false; // Schematic must be annotated: call Annotate dialog: wxCommandEvent event; OnAnnotate( event ); if( CheckAnnotate( NULL, 0 ) ) return false; } // Test duplicate sheet names: if( TestDuplicateSheetNames( false ) > 0 ) { if( !IsOK( NULL, _( "Error: duplicate sheet names. Continue?" ) ) ) return false; } /* Cleanup the entire hierarchy */ SCH_SCREENS screens; screens.SchematicCleanUp(); BuildNetListBase(); bool success = WriteNetListFile( aFormat, aFullFileName, aNetlistOptions ); return success; }
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 ) ); } } }