Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
home:rehar:kicad
kicad-svn
streamline-and-erc-exception.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File streamline-and-erc-exception.patch of Package kicad-svn
diff -Naur kicad.old/eeschema/erc.cpp kicad/eeschema/erc.cpp --- kicad.old/eeschema/erc.cpp 2009-08-23 20:24:11.000000000 -0500 +++ kicad/eeschema/erc.cpp 2009-08-23 23:43:27.000000000 -0500 @@ -4,6 +4,7 @@ #include "fctsys.h" #include "common.h" +#include "confirm.h" #include "class_drawpanel.h" #include "kicad_string.h" #include "gestfich.h" @@ -212,6 +213,187 @@ return err_count; } +static struct exception +{ + char* a_ref; + char* a_pin; + char* b_ref; + char* b_pin; + char* line; /* pointer to the memory object we've allocated */ + struct exception* next; +}* exceptions; + + + +/********************************************************************/ +static void FreeExceptions( void ) +/********************************************************************/ +{ + struct exception* next; + + while( exceptions ) + { + next = exceptions->next; + MyFree( exceptions->line ); + MyFree( exceptions ); + exceptions = next; + } +} + + +/********************************************************************/ +static bool ParseField( char **s, char **field ) +/********************************************************************/ +{ + *field = *s; + if( ! **s ) + return FALSE; + while( **s && ! isspace( **s ) ) + (*s)++; + if( ! **s ) + return TRUE; + *(*s)++ = 0; + while( **s && isspace( **s ) ) + (*s)++; + return TRUE; +} + + +/********************************************************************/ +static bool ParseException( char *s ) +/********************************************************************/ +{ + struct exception tmp; + struct exception* e; + + tmp.line = s; + + if( ! ParseField( &s, &tmp.a_ref)) + return FALSE; + if( ! ParseField( &s, &tmp.a_pin )) + return FALSE; + if( ! ParseField( &s, &tmp.b_ref)) + return FALSE; + if( ! ParseField( &s, &tmp.b_pin )) + return FALSE; + + e = (struct exception*) MyMalloc( sizeof( *e )); + *e = tmp; + e->next = exceptions; + exceptions = e; + + return TRUE; +} + + +/********************************************************************/ +static bool LoadExceptionsByName( const wxString &file_name ) +/********************************************************************/ +{ + FILE* file; + char buf[200]; /* enough room for chatty comments */ + char* s; + char* tmp; + char* hash; + int n = 0; + + FreeExceptions(); + file = wxFopen( file_name, wxT( "r" ) ); + if( ! file ) + return FALSE; + + while( 1 ) + { + s = fgets( buf, sizeof( buf ), file ); + if( ! s ) + break; + + n++; + + // remove comments + hash = strchr( s, '#' ); + if( hash ) + *hash = 0; + + // skip leading whitespace + while( *s && isspace( *s ) ) + s++; + if( ! *s ) + continue; + + tmp = (char*) MyMalloc( strlen( s ) + 1 ); + strcpy( tmp, s ); + + if( ! ParseException( tmp ) ) + { + wxString msg; + + msg.Printf( wxT( "Parse error at %s:%d" ), CONV_TO_UTF8(file_name), n ); + DisplayError( NULL, msg ); + MyFree( tmp ); + break; + } + } + + fclose( file ); + + return TRUE; +} + + +/********************************************************************/ +static void LoadExceptions( void ) +/********************************************************************/ +{ + wxFileName fn; + + fn = g_RootSheet->m_AssociatedScreen->m_FileName; + fn.SetExt( wxT( "erx" ) ); + if ( LoadExceptionsByName( fn.GetFullPath() ) ) + g_EESchemaVar.NbExceptionErc = 0; +} + + +/********************************************************************/ +static bool FindException( NETLIST_OBJECT* a, NETLIST_OBJECT* b ) +/********************************************************************/ +{ + SCH_COMPONENT* a_comp = (SCH_COMPONENT*) a->m_Link; + SCH_COMPONENT* b_comp = (SCH_COMPONENT*) b->m_Link; + const char* a_ref = CONV_TO_UTF8( a_comp->GetRef( &a->m_SheetList ) ); + const char* b_ref = CONV_TO_UTF8( b_comp->GetRef( &b->m_SheetList ) ); + const char* a_pin = (char *) &a->m_PinNum; + const char* b_pin = (char *) &b->m_PinNum; + struct exception* e = exceptions; + + for( e = exceptions; e; e = e->next ) + { +#if 0 +fprintf(stderr, "a) %s %4.4s =? %s %4.4s\n", e->a_ref, e->a_pin, a_ref, a_pin); +fprintf(stderr, "b) %s %4.4s =? %s %4.4s\n", e->b_ref, e->b_pin, b_ref, b_pin); +#endif + if( strcmp( e->a_ref, a_ref ) ) + continue; + if( strncmp( e->a_pin, a_pin, 4 ) ) + continue; + if( strcmp( e->b_ref, b_ref ) ) + continue; + if( strncmp( e->b_pin, b_pin, 4 ) ) + continue; + return TRUE; + } + return FALSE; +} + + +/********************************************************************/ +static bool IsException( NETLIST_OBJECT* a, NETLIST_OBJECT* b ) +/********************************************************************/ +{ + return FindException( a, b ) || FindException( b, a); +} + + /**************************************************/ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) /**************************************************/ @@ -248,6 +430,7 @@ g_EESchemaVar.NbErrorErc = 0; g_EESchemaVar.NbWarningErc = 0; + g_EESchemaVar.NbExceptionErc = -1; /* -1 means "no file" */ /* Cleanup the entire hierarchy */ EDA_ScreenList ScreenList; @@ -272,6 +455,8 @@ m_Parent->BuildNetListBase(); + LoadExceptions(); + /* Reset the flag m_FlagOfConnection, that will be used next, in calculations */ for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ ) g_NetObjectslist[ii]->m_FlagOfConnection = UNCONNECTED; @@ -339,7 +524,13 @@ // Displays global results: wxString num; - num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc ); + + if( g_EESchemaVar.NbExceptionErc >= 0) + num.Printf( wxT( "%d (%d exception%s)" ), g_EESchemaVar.NbErrorErc, + g_EESchemaVar.NbExceptionErc, + g_EESchemaVar.NbExceptionErc == 1 ? wxT( "" ) : wxT( "s" ) ); + else + num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc ); m_TotalErrCount->SetLabel( num ); num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc - g_EESchemaVar.NbWarningErc ); @@ -609,18 +800,24 @@ break; *NetNbItems += 1; - if( erc == OK ) // 1 marqueur par pin maxi + if( erc != OK ) // 1 marqueur par pin maxi + break; + + erc = DiagErc[ref_elect_type][jj]; + if( erc == OK ) + break; + + if( g_NetObjectslist[NetItemTst]->m_FlagOfConnection > 0 ) + break; + + if( IsException( g_NetObjectslist[NetItemRef], g_NetObjectslist[NetItemTst] ) ) { - erc = DiagErc[ref_elect_type][jj]; - if( erc != OK ) - { - if( g_NetObjectslist[NetItemTst]->m_FlagOfConnection == 0 ) - { - Diagnose( panel, g_NetObjectslist[NetItemRef], g_NetObjectslist[NetItemTst], 0, erc ); - g_NetObjectslist[NetItemTst]->m_FlagOfConnection = NOCONNECT_SYMBOL_PRESENT; - } - } + g_EESchemaVar.NbExceptionErc++; + break; } + + Diagnose( panel, g_NetObjectslist[NetItemRef], g_NetObjectslist[NetItemTst], 0, erc ); + g_NetObjectslist[NetItemTst]->m_FlagOfConnection = NOCONNECT_SYMBOL_PRESENT; break; } } diff -Naur kicad.old/eeschema/general.h kicad/eeschema/general.h --- kicad.old/eeschema/general.h 2009-08-23 20:24:11.000000000 -0500 +++ kicad/eeschema/general.h 2009-08-23 23:43:27.000000000 -0500 @@ -123,6 +123,7 @@ { int NbErrorErc; int NbWarningErc; + int NbExceptionErc; }; extern struct EESchemaVariables g_EESchemaVar;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor