Add test for duplicate footprints to Update from PCB.

This commit is contained in:
Jeff Young 2018-09-15 19:37:57 +01:00
parent 02a3f83040
commit ae5183f614
1 changed files with 51 additions and 22 deletions

View File

@ -619,6 +619,7 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
wxString msg; wxString msg;
m_errorCount = 0; m_errorCount = 0;
m_warningCount = 0; m_warningCount = 0;
MODULE* lastPreexistingFootprint = m_board->m_Modules.GetLast();
cacheCopperZoneConnections(); cacheCopperZoneConnections();
@ -627,10 +628,10 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
m_board->SetStatus( 0 ); m_board->SetStatus( 0 );
} }
for( int i = 0; i < (int) aNetlist.GetCount(); i++ ) for( unsigned i = 0; i < aNetlist.GetCount(); i++ )
{ {
COMPONENT* component = aNetlist.GetComponent( i ); COMPONENT* component = aNetlist.GetComponent( i );
MODULE* footprint = NULL; int matchCount = 0;
msg.Printf( _( "Processing component \"%s:%s:%s\"." ), msg.Printf( _( "Processing component \"%s:%s:%s\"." ),
component->GetReference(), component->GetReference(),
@ -638,25 +639,57 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
component->GetFPID().Format().wx_str() ); component->GetFPID().Format().wx_str() );
m_reporter->Report( msg, REPORTER::RPT_INFO ); m_reporter->Report( msg, REPORTER::RPT_INFO );
if( aNetlist.IsFindByTimeStamp() ) for( MODULE* footprint = m_board->m_Modules; footprint; footprint = footprint->Next() )
footprint = m_board->FindModule( component->GetTimeStamp(), true ); {
else bool match;
footprint = m_board->FindModule( component->GetReference() ); MODULE* tmp;
if( footprint ) // An existing footprint. if( aNetlist.IsFindByTimeStamp() )
{ match = footprint->GetPath() == component->GetTimeStamp();
if( m_replaceFootprints && component->GetFPID() != footprint->GetFPID() ) else
footprint = replaceComponent( aNetlist, footprint, component ); match = footprint->GetReference().CmpNoCase( component->GetReference() );
}
else if( match )
{ {
footprint = addNewComponent( component ); tmp = footprint;
if( m_replaceFootprints && component->GetFPID() != footprint->GetFPID() )
tmp = replaceComponent( aNetlist, footprint, component );
if( tmp )
{
updateComponentParameters( tmp, component );
updateComponentPadConnections( tmp, component );
}
matchCount++;
}
if( footprint == lastPreexistingFootprint )
{
if( matchCount == 0 )
{
tmp = addNewComponent( component );
if( tmp )
{
updateComponentParameters( tmp, component );
updateComponentPadConnections( tmp, component );
}
matchCount++;
}
// No sense going through the newly-created footprints
break;
}
} }
if( footprint ) if( matchCount > 1 )
{ {
updateComponentParameters( footprint, component ); msg.Printf( _( "Multiple footprints found for \"%s\"." ),
updateComponentPadConnections( footprint, component ); component->GetReference() );
m_reporter->Report( msg, REPORTER::RPT_ERROR );
} }
} }
@ -687,14 +720,10 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
m_reporter->ReportTail( _( "Errors occurred during the netlist update. Unless you fix them " m_reporter->ReportTail( _( "Errors occurred during the netlist update. Unless you fix them "
"your board will not be consistent with the schematics." ), "your board will not be consistent with the schematics." ),
REPORTER::RPT_ERROR ); REPORTER::RPT_ERROR );
return false; return false;
} }
else
{
m_reporter->ReportTail( _( "Netlist update successful!" ), REPORTER::RPT_ACTION );
}
m_reporter->ReportTail( _( "Netlist update successful!" ), REPORTER::RPT_ACTION );
return true; return true;
} }