From d583b1ff983fc2e36360144ec96a57c3816c5fdf Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 9 Jun 2015 12:40:34 +0200 Subject: [PATCH] Fix Bug #1462876 (Eeschema ERC NoConnect not reliable.) --- eeschema/dialogs/dialog_erc.cpp | 6 ++---- eeschema/erc.cpp | 24 +++++++++++++++++++++--- eeschema/erc.h | 19 +++++++++++++++++-- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 5674673a4f..7f3e315784 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -473,7 +473,6 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) unsigned lastNet; unsigned nextNet = lastNet = 0; - int NetNbItems = 0; int MinConn = NOC; for( unsigned net = 0; net < objectsConnectedList->size(); net++ ) @@ -483,7 +482,6 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) { // New net found: MinConn = NOC; - NetNbItems = 0; nextNet = net; } @@ -517,7 +515,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) // ERC problems when a noconnect symbol is connected to more than one pin. MinConn = NET_NC; - if( NetNbItems != 0 ) + if( CountPinsInNet( objectsConnectedList.get(), nextNet ) > 1 ) Diagnose( objectsConnectedList->GetItem( net ), NULL, MinConn, UNC ); break; @@ -525,7 +523,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) case NET_PIN: // Look for ERC problems between pins: - TestOthersItems( objectsConnectedList.get(), net, nextNet, &NetNbItems, &MinConn ); + TestOthersItems( objectsConnectedList.get(), net, nextNet, &MinConn ); break; } diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index c93a9b1154..699523139a 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -356,7 +356,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst, void TestOthersItems( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef, unsigned aNetStart, - int* aNetNbItems, int* aMinConnexion ) + int* aMinConnexion ) { unsigned netItemTst = aNetStart; int jj; @@ -467,8 +467,6 @@ void TestOthersItems( NETLIST_OBJECT_LIST* aList, if( netItemTst <= aNetItemRef ) break; - *aNetNbItems += 1; - if( erc == OK ) { erc = DiagErc[ref_elect_type][jj]; @@ -491,6 +489,26 @@ void TestOthersItems( NETLIST_OBJECT_LIST* aList, } +int CountPinsInNet( NETLIST_OBJECT_LIST* aList, unsigned aNetStart ) +{ + int count = 0; + int curr_net = aList->GetItemNet( aNetStart ); + + /* Test pins connected to NetItemRef */ + for( unsigned item = aNetStart; item < aList->size(); item++ ) + { + // We examine only a given net. We stop the search if the net changes + if( curr_net != aList->GetItemNet( item ) ) // End of net + break; + + if( aList->GetItemType( item ) == NET_PIN ) + count++; + } + + return count; +} + + bool WriteDiagnosticERC( const wxString& aFullFileName ) { SCH_ITEM* item; diff --git a/eeschema/erc.h b/eeschema/erc.h index 5072ed7dbc..1e015155c6 100644 --- a/eeschema/erc.h +++ b/eeschema/erc.h @@ -84,11 +84,26 @@ extern void Diagnose( NETLIST_OBJECT* NetItemRef, NETLIST_OBJECT* NetItemTst, /** * Perform ERC testing for electrical conflicts between \a NetItemRef and other items - * on the same net. + * (mainly pin) on the same net. + * @param aList = a reference to the list of connected objects + * @param aNetItemRef = index in list of the current object + * @param aNetStart = index in list of net objects of the first item + * @param aMinConnexion = a pointer to a variable to store the minimal connection + * found( NOD, DRV, NPI, NET_NC) */ extern void TestOthersItems( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef, unsigned aNetStart, - int* aNetNbItems, int* aMinConnexion ); + int* aMinConnexion ); + +/** + * Counts number of pins connected on the same net. + * Used to find all pins conected to a no connect symbol + * @return the pin count of the net starting at aNetStart + * @param aNetStart = index in list of net objects of the first item + * @param aList = a reference to the list of connected objects + */ +int CountPinsInNet( NETLIST_OBJECT_LIST* aList, unsigned aNetStart ); + /** * Function TestLabel