New ERC rule verifying if all units of a component use the same footprint
This commit is contained in:
parent
89a5a84af9
commit
8e18aea11d
|
@ -58,8 +58,11 @@ wxString DRC_ITEM::GetErrorText() const
|
|||
return wxString( _("Labels are similar (lower/upper case difference only)") );
|
||||
case ERCE_SIMILAR_GLBL_LABELS:
|
||||
return wxString( _("Global labels are similar (lower/upper case difference only)") );
|
||||
case ERCE_DIFFERENT_UNIT_FP:
|
||||
return wxString( _("Different footprint assigned in another unit of the same component") );
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( "Missing ERC error description" );
|
||||
return wxString( wxT("Unkown.") );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -483,6 +483,10 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
|
|||
*/
|
||||
TestDuplicateSheetNames( true );
|
||||
|
||||
/* Test is all units of each multiunit component have the same footprint assigned.
|
||||
*/
|
||||
TestMultiunitFootprints( sheets );
|
||||
|
||||
std::unique_ptr<NETLIST_OBJECT_LIST> objectsConnectedList( m_parent->BuildNetListBase() );
|
||||
|
||||
// Reset the connection type indicator
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
#include <lib_pin.h>
|
||||
#include <erc.h>
|
||||
#include <sch_marker.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_reference_list.h>
|
||||
|
||||
#include <wx/ffile.h>
|
||||
|
||||
|
@ -225,6 +225,72 @@ int TestDuplicateSheetNames( bool aCreateMarker )
|
|||
}
|
||||
|
||||
|
||||
int TestMultiunitFootprints( SCH_SHEET_LIST& aSheetList )
|
||||
{
|
||||
int errors = 0;
|
||||
std::map<wxString, LIB_ID> footprints;
|
||||
SCH_MULTI_UNIT_REFERENCE_MAP refMap;
|
||||
aSheetList.GetMultiUnitComponents( refMap, true );
|
||||
|
||||
for( auto& component : refMap )
|
||||
{
|
||||
auto& refList = component.second;
|
||||
|
||||
if( refList.GetCount() == 0 )
|
||||
{
|
||||
wxFAIL; // it should not happen
|
||||
continue;
|
||||
}
|
||||
|
||||
// Reference footprint
|
||||
wxString fp;
|
||||
wxString unitName;
|
||||
|
||||
for( int i = 0; i < component.second.GetCount(); ++i )
|
||||
{
|
||||
SCH_COMPONENT* cmp = refList.GetItem( i ).GetComp();
|
||||
SCH_SHEET_PATH sheetPath = refList.GetItem( i ).GetSheetPath();
|
||||
fp = cmp->GetField( FOOTPRINT )->GetText();
|
||||
|
||||
if( !fp.IsEmpty() )
|
||||
{
|
||||
unitName = cmp->GetRef( &sheetPath )
|
||||
+ LIB_PART::SubReference( cmp->GetUnit(), false );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for( int i = 0; i < component.second.GetCount(); ++i )
|
||||
{
|
||||
SCH_REFERENCE& ref = refList.GetItem( i );
|
||||
SCH_COMPONENT* unit = ref.GetComp();
|
||||
SCH_SHEET_PATH sheetPath = refList.GetItem( i ).GetSheetPath();
|
||||
const wxString& curFp = unit->GetField( FOOTPRINT )->GetText();
|
||||
|
||||
if( !curFp.IsEmpty() && fp != curFp )
|
||||
{
|
||||
wxString curUnitName = unit->GetRef( &sheetPath )
|
||||
+ LIB_PART::SubReference( unit->GetUnit(), false );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER();
|
||||
marker->SetTimeStamp( GetNewTimeStamp() );
|
||||
marker->SetData( ERCE_DIFFERENT_UNIT_FP, unit->GetPosition(),
|
||||
wxString::Format( _( "Unit %s has '%s' assigned, "
|
||||
"whereas unit %s has '%s' assigned" ), unitName, fp, curUnitName, curFp ),
|
||||
unit->GetPosition() );
|
||||
marker->SetMarkerType( MARKER_BASE::MARKER_ERC );
|
||||
marker->SetErrorLevel( MARKER_BASE::MARKER_SEVERITY_WARNING );
|
||||
ref.GetSheetPath().LastScreen()->Append( marker );
|
||||
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
|
||||
void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
|
||||
int aMinConn, int aDiag )
|
||||
{
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
#define _ERC_H
|
||||
|
||||
|
||||
//class EDA_DRAW_PANEL;
|
||||
class NETLIST_OBJECT;
|
||||
class NETLIST_OBJECT_LIST;
|
||||
class SCH_SHEET_LIST;
|
||||
|
||||
/* For ERC markers: error types (used in diags, and to set the color):
|
||||
*/
|
||||
|
@ -60,6 +60,8 @@ extern const wxString CommentERC_V[];
|
|||
#define ERCE_GLOBLABEL 8 // global label not connected to any other global label
|
||||
#define ERCE_SIMILAR_LABELS 9 // 2 labels are equal fir case insensitive comparisons
|
||||
#define ERCE_SIMILAR_GLBL_LABELS 10 // 2 labels are equal fir case insensitive comparisons
|
||||
#define ERCE_DIFFERENT_UNIT_FP 11 // different units of the same component have different
|
||||
// footprints assigned
|
||||
|
||||
/* Minimal connection table */
|
||||
#define NPI 4 // Net with Pin isolated, this pin has type Not Connected and must be left N.C.
|
||||
|
@ -108,5 +110,12 @@ void TestOthersItems( NETLIST_OBJECT_LIST* aList,
|
|||
*/
|
||||
int TestDuplicateSheetNames( bool aCreateMarker );
|
||||
|
||||
/**
|
||||
* Test if all units of each multiunit component have the same footprint assigned.
|
||||
* @param aSheetList contains components to be validated.
|
||||
* @return The error count.
|
||||
*/
|
||||
int TestMultiunitFootprints( SCH_SHEET_LIST& aSheetList );
|
||||
|
||||
|
||||
#endif // _ERC_H
|
||||
|
|
Loading…
Reference in New Issue