Begin refactoring netlist creation

This commit is contained in:
Jon Evans 2019-03-17 15:15:08 -04:00 committed by Wayne Stambaugh
parent c8c0b89eef
commit 5cf82f1a9e
5 changed files with 33 additions and 51 deletions

View File

@ -472,7 +472,10 @@ void DIALOG_BOM::OnRunPlugin( wxCommandEvent& event )
m_parent->SetExecFlags( wxEXEC_SHOW_CONSOLE );
#endif
m_parent->CreateNetlist( -1, fullfilename, 0, &reporter, false );
auto netlist = m_parent->CreateNetlist( false, false );
m_parent->WriteNetListFile( netlist, -1,
fullfilename, 0, &reporter );
m_Messages->SetValue( reportmsg );
}

View File

@ -597,7 +597,10 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event )
else
m_Parent->SetNetListerCommand( wxEmptyString );
m_Parent->CreateNetlist( currPage->m_IdNetType, fullpath, netlist_opt, NULL, false );
auto netlist = m_Parent->CreateNetlist( false, false );
m_Parent->WriteNetListFile( netlist, currPage->m_IdNetType,
fullpath, netlist_opt, NULL );
WriteCurrentNetlistSetup();
@ -674,8 +677,10 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event )
if( currPage->m_SpiceAjustPassiveValues && currPage->m_SpiceAjustPassiveValues->GetValue() )
netlist_opt |= NET_ADJUST_PASSIVE_VALS;
if( ! m_Parent->CreateNetlist( currPage->m_IdNetType, fn.GetFullPath(),
netlist_opt, NULL, false ) )
auto netlist = m_Parent->CreateNetlist( false, false );
if( ! m_Parent->WriteNetListFile( netlist, currPage->m_IdNetType,
fn.GetFullPath(), netlist_opt, NULL ) )
return;
ExecuteFile( this, ExecFile, CommandLine );

View File

@ -191,11 +191,11 @@ bool SCH_EDIT_FRAME::prepareForNetlist()
}
void SCH_EDIT_FRAME::sendNetlist()
void SCH_EDIT_FRAME::sendNetlistToCvpcb()
{
NETLIST_OBJECT_LIST* net_atoms = BuildNetListBase();
NETLIST_EXPORTER_KICAD exporter( this, net_atoms );
NETLIST_EXPORTER_KICAD exporter( this, net_atoms, g_ConnectionGraph );
STRING_FORMATTER formatter;
@ -210,13 +210,13 @@ void SCH_EDIT_FRAME::sendNetlist()
}
bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName,
unsigned aNetlistOptions, REPORTER* aReporter, bool aSilent )
NETLIST_OBJECT_LIST* SCH_EDIT_FRAME::CreateNetlist( bool aSilent,
bool aSilentAnnotate )
{
if( !aSilent ) // checks for errors and invokes annotation dialog as neccessary
{
if( !prepareForNetlist() )
return false;
return nullptr;
}
else // performs similar function as prepareForNetlist but without a dialog.
{
@ -224,14 +224,16 @@ bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName,
schematic.UpdateSymbolLinks();
SCH_SHEET_LIST sheets( g_RootSheet );
sheets.AnnotatePowerSymbols();
if( aSilentAnnotate )
AnnotateComponents( true, UNSORTED, INCREMENTAL_BY_REF, 0, false, false, true,
NULL_REPORTER::GetInstance() );
}
std::unique_ptr<NETLIST_OBJECT_LIST> connectedItemsList( BuildNetListBase() );
// TODO(JE) This is really going to turn into "PrepareForNetlist"
// when the old netlister (BuildNetListBase) is removed
bool success = WriteNetListFile( connectedItemsList.release(), aFormat,
aFullFileName, aNetlistOptions, aReporter );
return success;
return BuildNetListBase();
}

View File

@ -907,25 +907,9 @@ void SCH_EDIT_FRAME::doUpdatePcb( const wxString& aUpdateOptions )
frame->Raise();
}
if( aUpdateOptions.Contains( "quiet-annotate" ) )
{
SCH_SCREENS schematic;
schematic.UpdateSymbolLinks();
SCH_SHEET_LIST sheets( g_RootSheet );
sheets.AnnotatePowerSymbols();
AnnotateComponents( true, UNSORTED, INCREMENTAL_BY_REF, 0, false, false, true,
NULL_REPORTER::GetInstance() );
}
auto net_atoms = CreateNetlist( aUpdateOptions.Contains( "no-annotate" ),
aUpdateOptions.Contains( "quiet-annotate" ) );
if( !aUpdateOptions.Contains( "no-annotate" ) )
{
// Ensure the schematic is OK for a netlist creation
// (especially all components are annotated):
if( !prepareForNetlist() )
return;
}
NETLIST_OBJECT_LIST* net_atoms = BuildNetListBase();
NETLIST_EXPORTER_KICAD exporter( this, net_atoms, g_ConnectionGraph );
STRING_FORMATTER formatter;
@ -1173,7 +1157,7 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
// player->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
}
sendNetlist();
sendNetlistToCvpcb();
player->Raise();
}

View File

@ -241,7 +241,7 @@ protected:
/**
* Send the kicad netlist over to CVPCB.
*/
void sendNetlist();
void sendNetlistToCvpcb();
public:
SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent );
@ -562,24 +562,12 @@ public:
* - Build netlist info
* - Create the netlist file (different formats)
*
* @param aFormat = netlist format (NET_TYPE_PCBNEW ...)
* @param aFullFileName = full netlist file name
* @param aNetlistOptions = netlist options using OR'ed bits.
* <p>
* For SPICE netlist only:
* if NET_USE_NETNAMES is set, use net names from labels in schematic
* else use net numbers (net codes)
* if NET_USE_X_PREFIX is set : change "U" and "IC" reference prefix to "X"
* </p>
* @param aReporter = a REPORTER to report error messages,
* mainly if a command line must be run (can be NULL
* @return true if success.
* @param aSilent is true if annotation error dialog should be skipped
* @param aSilentAnnotate is true if components should be reannotated silently
* @returns a unique_ptr to the netlist
*/
bool CreateNetlist( int aFormat,
const wxString& aFullFileName,
unsigned aNetlistOptions,
REPORTER* aReporter = NULL,
bool silent = false );
NETLIST_OBJECT_LIST* CreateNetlist( bool aSilent = false,
bool aSilentAnnotate = false );
/**
* Create a netlist file.