2009-11-03 13:26:31 +00:00
|
|
|
/**************************************/
|
|
|
|
/* erc.cpp - Electrical Rules Check */
|
|
|
|
/**************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "kicad_string.h"
|
|
|
|
#include "gestfich.h"
|
2009-04-05 20:49:15 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "bitmaps.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "netlist.h"
|
2009-07-07 17:50:02 +00:00
|
|
|
#include "class_marker_sch.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "protos.h"
|
|
|
|
#include "erc.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "dialog_erc.h"
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
/* ERC tests :
|
|
|
|
* 1 - conflicts between connected pins ( example: 2 connected outputs )
|
2009-11-03 13:26:31 +00:00
|
|
|
* 2 - minimal connections requirements ( 1 input *must* be connected to an
|
|
|
|
* output, or a passive pin )
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
static bool WriteDiagnosticERC( const wxString& FullFileName );
|
2009-07-03 18:25:06 +00:00
|
|
|
static void Diagnose( WinEDA_DrawPanel* panel,
|
2009-07-12 15:29:42 +00:00
|
|
|
NETLIST_OBJECT* NetItemRef,
|
|
|
|
NETLIST_OBJECT* NetItemTst, int MinConnexion, int Diag );
|
2007-09-20 21:06:49 +00:00
|
|
|
static void TestOthersItems( WinEDA_DrawPanel* panel,
|
2009-07-12 15:29:42 +00:00
|
|
|
unsigned NetItemRef,
|
|
|
|
unsigned NetStart,
|
2007-09-20 21:06:49 +00:00
|
|
|
int* NetNbItems, int* MinConnexion );
|
2009-11-03 13:26:31 +00:00
|
|
|
static void TestLabel( WinEDA_DrawPanel* panel,
|
|
|
|
unsigned NetItemRef,
|
|
|
|
unsigned StartNet );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
/* Local variables */
|
2007-05-06 16:03:28 +00:00
|
|
|
int WriteFichierERC = FALSE;
|
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
/*
|
|
|
|
* Electrical type of pins:
|
|
|
|
* PIN_INPUT = usual pin input: must be connected
|
|
|
|
* PIN_OUTPUT = usual output
|
|
|
|
* PIN_BIDI = input or output (like port for a microprocessor)
|
|
|
|
* PIN_TRISTATE = tris state bus pin
|
2009-11-03 13:26:31 +00:00
|
|
|
* PIN_PASSIVE = pin for passive components: must be connected, and can be
|
|
|
|
* connected to any pin
|
|
|
|
* PIN_UNSPECIFIED = unknown electrical properties: creates always a warning
|
|
|
|
* when connected
|
|
|
|
* PIN_POWER_IN = power input (GND, VCC for ICs). Must be connected to a power
|
|
|
|
* output.
|
|
|
|
* PIN_POWER_OUT = output of a regulator: intended to be connected to power
|
|
|
|
* input pins
|
2009-07-07 17:50:02 +00:00
|
|
|
* PIN_OPENCOLLECTOR = pin type open collector
|
|
|
|
* PIN_OPENEMITTER = pin type open emitter
|
|
|
|
* PIN_NC = not connected (must be left open)
|
|
|
|
*
|
|
|
|
* Minimal requirements:
|
|
|
|
* All pins *must* be connected (except PIN_NC).
|
2009-11-03 13:26:31 +00:00
|
|
|
* When a pin is not connected in schematic, the user must place a "non
|
|
|
|
* connected" symbol to this pin.
|
2009-07-07 17:50:02 +00:00
|
|
|
* This ensures a forgotten connection will be detected.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Messages for conflicts :
|
2007-09-20 21:06:49 +00:00
|
|
|
* PIN_INPUT, PIN_OUTPUT, PIN_BIDI, PIN_TRISTATE, PIN_PASSIVE,
|
|
|
|
* PIN_UNSPECIFIED, PIN_POWER_IN, PIN_POWER_OUT, PIN_OPENCOLLECTOR,
|
|
|
|
* PIN_OPENEMITTER, PIN_NC
|
2009-07-07 17:50:02 +00:00
|
|
|
* These messages are used to show the ERC matrix in ERC dialog
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
// Messages for matrix rows:
|
2009-07-03 18:25:06 +00:00
|
|
|
const wxChar* CommentERC_H[] =
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
wxT( "Input Pin...." ),
|
|
|
|
wxT( "Output Pin..." ),
|
|
|
|
wxT( "BiDi Pin....." ),
|
|
|
|
wxT( "3 State Pin.." ),
|
|
|
|
wxT( "Passive Pin.." ),
|
|
|
|
wxT( "Unspec Pin..." ),
|
|
|
|
wxT( "Power IN Pin." ),
|
|
|
|
wxT( "PowerOUT Pin." ),
|
|
|
|
wxT( "Open Coll...." ),
|
|
|
|
wxT( "Open Emit...." ),
|
|
|
|
wxT( "No Conn......" ),
|
|
|
|
NULL
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
2009-07-07 17:50:02 +00:00
|
|
|
|
|
|
|
// Messages for matrix columns
|
2009-07-03 18:25:06 +00:00
|
|
|
const wxChar* CommentERC_V[] =
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
wxT( "Input Pin" ),
|
|
|
|
wxT( "Output Pin" ),
|
|
|
|
wxT( "BiDi Pin" ),
|
|
|
|
wxT( "3 State Pin" ),
|
|
|
|
wxT( "Passive Pin" ),
|
|
|
|
wxT( "Unspec Pin" ),
|
|
|
|
wxT( "Power IN Pin" ),
|
|
|
|
wxT( "PowerOUT Pin" ),
|
|
|
|
wxT( "Open Coll" ),
|
|
|
|
wxT( "Open Emit" ),
|
|
|
|
wxT( "No Conn" ),
|
|
|
|
NULL
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Look up table which gives the diag for a pair of connected pins
|
2007-09-20 21:06:49 +00:00
|
|
|
* Can be modified by ERC options.
|
|
|
|
* at start up: must be loaded by DefaultDiagErc
|
|
|
|
*/
|
2009-07-07 17:50:02 +00:00
|
|
|
int DiagErc[PIN_NMAX][PIN_NMAX];
|
|
|
|
bool DiagErcTableInit; // go to TRUE after DiagErc init
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
/* Default Look up table which gives the diag for a pair of connected pins
|
2007-09-20 21:06:49 +00:00
|
|
|
* Same as DiagErc, but cannot be modified
|
|
|
|
* Used to init or reset DiagErc
|
|
|
|
*/
|
2009-07-03 18:25:06 +00:00
|
|
|
int DefaultDiagErc[PIN_NMAX][PIN_NMAX] =
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/* I, O, Bi, 3S, Pas, UnS, PwrI, PwrO, OC, OE, NC */
|
|
|
|
/* I */ { OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, WAR },
|
|
|
|
/* O */ { OK, ERR, OK, WAR, OK, WAR, OK, ERR, ERR, ERR, WAR },
|
|
|
|
/* Bi*/ { OK, OK, OK, OK, OK, WAR, OK, WAR, OK, WAR, WAR },
|
|
|
|
/* 3S*/ { OK, WAR, OK, OK, OK, WAR, WAR, ERR, WAR, WAR, WAR },
|
|
|
|
/*Pas*/ { OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, WAR },
|
|
|
|
/*UnS */ { WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR },
|
|
|
|
/*PwrI*/ { OK, OK, OK, WAR, OK, WAR, OK, OK, OK, OK, ERR },
|
|
|
|
/*PwrO*/ { OK, ERR, WAR, ERR, OK, WAR, OK, ERR, ERR, ERR, WAR },
|
|
|
|
/* OC */ { OK, ERR, OK, WAR, OK, WAR, OK, ERR, OK, OK, WAR },
|
|
|
|
/* OE */ { OK, ERR, WAR, WAR, OK, WAR, OK, ERR, OK, OK, WAR },
|
|
|
|
/* NC */ { WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR }
|
2007-09-20 21:06:49 +00:00
|
|
|
};
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Minimal connection table */
|
2007-09-20 21:06:49 +00:00
|
|
|
#define DRV 3 /* Net driven by a signal (a pin output for instance) */
|
|
|
|
#define NET_NC 2 /* Net "connected" to a "NoConnect symbol" */
|
|
|
|
#define NOD 1 /* Net not driven ( Such as 2 or more connected inputs )*/
|
2009-11-03 13:26:31 +00:00
|
|
|
#define NOC 0 /* Pin isolated, no connection */
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Look up table which gives the minimal drive for a pair of connected pins on
|
|
|
|
* a net
|
2007-09-20 21:06:49 +00:00
|
|
|
* Initial state of a net is NOC (No Connection)
|
|
|
|
* Can be updated to NET_NC, or NOD (Not Driven) or DRV (DRIven)
|
2008-03-13 05:04:59 +00:00
|
|
|
*
|
2007-09-20 21:06:49 +00:00
|
|
|
* Can be updated to NET_NC only if the previous state is NOC
|
2008-03-13 05:04:59 +00:00
|
|
|
*
|
2007-09-20 21:06:49 +00:00
|
|
|
* Nets are OK when their final state is NET_NC or DRV
|
|
|
|
* Nets with the state NOD have no source signal
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
static int MinimalReq[PIN_NMAX][PIN_NMAX] =
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/* In Out, Bi, 3S, Pas, UnS, PwrI,PwrO,OC, OE, NC */
|
|
|
|
/* In*/ { NOD, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
|
|
|
|
/*Out*/ { DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, NOC },
|
|
|
|
/* Bi*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
|
|
|
|
/* 3S*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
|
|
|
|
/*Pas*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
|
|
|
|
/*UnS*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
|
|
|
|
/*PwrI*/ { NOD, DRV, NOD, NOD, NOD, NOD, NOD, DRV, NOD, NOD, NOC },
|
|
|
|
/*PwrO*/ { DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, NOC },
|
|
|
|
/* OC*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
|
|
|
|
/* OE*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
|
|
|
|
/* NC*/ { NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC }
|
2007-09-20 21:06:49 +00:00
|
|
|
};
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
/** Function TestDuplicateSheetNames( )
|
2009-11-03 13:26:31 +00:00
|
|
|
* inside a given sheet, one cannot have sheets with duplicate names (file
|
|
|
|
* names can be duplicated).
|
2009-07-09 17:02:15 +00:00
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
int TestDuplicateSheetNames()
|
2009-07-09 17:02:15 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
int err_count = 0;
|
2009-07-09 17:02:15 +00:00
|
|
|
EDA_ScreenList ScreenList; // Created the list of screen
|
2009-11-03 13:26:31 +00:00
|
|
|
|
|
|
|
for( SCH_SCREEN* Screen = ScreenList.GetFirst();
|
|
|
|
Screen != NULL;
|
|
|
|
Screen = ScreenList.GetNext() )
|
2009-07-09 17:02:15 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
for( SCH_ITEM* ref_item = Screen->EEDrawList;
|
|
|
|
ref_item != NULL;
|
|
|
|
ref_item = ref_item->Next() )
|
2009-07-09 17:02:15 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
// search for a sheet;
|
2009-07-09 17:02:15 +00:00
|
|
|
if( ref_item->Type() != DRAW_SHEET_STRUCT_TYPE )
|
|
|
|
continue;
|
|
|
|
for( SCH_ITEM* item_to_test = ref_item->Next();
|
2009-11-03 13:26:31 +00:00
|
|
|
item_to_test != NULL;
|
|
|
|
item_to_test = item_to_test->Next() )
|
2009-07-09 17:02:15 +00:00
|
|
|
{
|
|
|
|
if( item_to_test->Type() != DRAW_SHEET_STRUCT_TYPE )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// We have found a second sheet: compare names
|
2009-11-04 20:46:53 +00:00
|
|
|
if( ( (SCH_SHEET*) ref_item )->m_SheetName.CmpNoCase(
|
|
|
|
( ( SCH_SHEET* ) item_to_test )-> m_SheetName )
|
2009-11-03 13:26:31 +00:00
|
|
|
== 0 )
|
2009-07-09 17:02:15 +00:00
|
|
|
{
|
|
|
|
/* Create a new marker type ERC error*/
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_MARKER* Marker = new SCH_MARKER();
|
2009-07-09 17:02:15 +00:00
|
|
|
Marker->m_TimeStamp = GetTimeStamp();
|
|
|
|
Marker->SetData( ERCE_DUPLICATE_SHEET_NAME,
|
2009-11-04 20:46:53 +00:00
|
|
|
( (SCH_SHEET*) item_to_test )->m_Pos,
|
2009-07-09 17:02:15 +00:00
|
|
|
_( "Duplicate Sheet name" ),
|
2009-11-04 20:46:53 +00:00
|
|
|
( (SCH_SHEET*) item_to_test )->m_Pos );
|
2009-07-09 17:02:15 +00:00
|
|
|
Marker->SetMarkerType( MARK_ERC );
|
|
|
|
Marker->SetErrorLevel( ERR );
|
|
|
|
Marker->SetNext( Screen->EEDrawList );
|
|
|
|
Screen->EEDrawList = Marker;
|
|
|
|
err_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err_count;
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
wxFileName fn;
|
|
|
|
unsigned NetItemRef;
|
|
|
|
unsigned OldItem;
|
|
|
|
unsigned StartNet;
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
int NetNbItems, MinConn;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
if( !DiagErcTableInit )
|
|
|
|
{
|
|
|
|
memcpy( DiagErc, DefaultDiagErc, sizeof(DefaultDiagErc) );
|
|
|
|
DiagErcTableInit = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
WriteFichierERC = m_WriteResultOpt->GetValue();
|
|
|
|
|
|
|
|
ReAnnotatePowerSymbolsOnly();
|
2009-07-05 12:09:41 +00:00
|
|
|
if( m_Parent->CheckAnnotate( aMessagesList, false ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-07 17:50:02 +00:00
|
|
|
if( aMessagesList )
|
2009-07-03 18:25:06 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
wxString msg = _( "Annotation required!" );
|
2009-07-08 15:42:45 +00:00
|
|
|
msg += wxT( "\n" );
|
|
|
|
aMessagesList->Add( msg );
|
2009-07-03 18:25:06 +00:00
|
|
|
}
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
/* Erase all DRC markers */
|
2009-07-07 17:50:02 +00:00
|
|
|
DeleteAllMarkers( MARK_ERC );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
g_EESchemaVar.NbErrorErc = 0;
|
|
|
|
g_EESchemaVar.NbWarningErc = 0;
|
|
|
|
|
|
|
|
/* Cleanup the entire hierarchy */
|
2008-02-12 21:12:46 +00:00
|
|
|
EDA_ScreenList ScreenList;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
for( SCH_SCREEN* Screen = ScreenList.GetFirst();
|
|
|
|
Screen != NULL;
|
|
|
|
Screen = ScreenList.GetNext() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
|
|
|
bool ModifyWires;
|
|
|
|
ModifyWires = Screen->SchematicCleanUp( NULL );
|
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
/* if wire list has changed, delete Undo Redo list to avoid
|
2007-09-20 21:06:49 +00:00
|
|
|
* pointers on deleted data problems */
|
|
|
|
if( ModifyWires )
|
|
|
|
Screen->ClearUndoRedoList();
|
|
|
|
}
|
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
/* Test duplicate sheet names
|
2009-11-03 13:26:31 +00:00
|
|
|
* inside a given sheet, one cannot have sheets with duplicate names (file
|
|
|
|
* names can be duplicated).
|
2009-07-03 18:25:06 +00:00
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
int errcnt = TestDuplicateSheetNames();
|
|
|
|
g_EESchemaVar.NbErrorErc += errcnt;
|
2009-07-09 17:02:15 +00:00
|
|
|
g_EESchemaVar.NbWarningErc += errcnt;
|
2009-07-03 18:25:06 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
m_Parent->BuildNetListBase();
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* 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;
|
2009-07-12 15:29:42 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
StartNet = OldItem = 0;
|
2008-03-13 05:04:59 +00:00
|
|
|
NetNbItems = 0;
|
|
|
|
MinConn = NOC;
|
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
for( NetItemRef = 0; NetItemRef < g_NetObjectslist.size(); NetItemRef++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
if( g_NetObjectslist[OldItem]->GetNet() !=
|
|
|
|
g_NetObjectslist[NetItemRef]->GetNet() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-03-13 05:04:59 +00:00
|
|
|
MinConn = NOC;
|
|
|
|
NetNbItems = 0;
|
|
|
|
StartNet = NetItemRef;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
switch( g_NetObjectslist[NetItemRef]->m_Type )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
case NET_ITEM_UNSPECIFIED:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_SEGMENT:
|
|
|
|
case NET_BUS:
|
|
|
|
case NET_JONCTION:
|
|
|
|
case NET_LABEL:
|
|
|
|
case NET_BUSLABELMEMBER:
|
|
|
|
case NET_PINLABEL:
|
2009-07-05 12:09:41 +00:00
|
|
|
case NET_GLOBLABEL:
|
2008-03-13 05:04:59 +00:00
|
|
|
case NET_GLOBBUSLABELMEMBER:
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
// These items do not create erc problems
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERLABEL:
|
|
|
|
case NET_HIERBUSLABELMEMBER:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_SHEETLABEL:
|
|
|
|
case NET_SHEETBUSLABELMEMBER:
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
// ERC problems when pin sheets do not match hierarchical labels.
|
|
|
|
// Each pin sheet must match a hierarchical label
|
|
|
|
// Each hierarchical label must match a pin sheet
|
2009-07-03 18:25:06 +00:00
|
|
|
TestLabel( m_Parent->DrawPanel, NetItemRef, StartNet );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_NOCONNECT:
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
// ERC problems when a noconnect symbol is connected to more than
|
|
|
|
// one pin.
|
2007-09-20 21:06:49 +00:00
|
|
|
MinConn = NET_NC;
|
|
|
|
if( NetNbItems != 0 )
|
2009-07-12 15:29:42 +00:00
|
|
|
Diagnose( m_Parent->DrawPanel,
|
2009-11-03 13:26:31 +00:00
|
|
|
g_NetObjectslist[NetItemRef], NULL, MinConn, UNC );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_PIN:
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
// Look for ERC problems between pins:
|
2009-07-03 18:25:06 +00:00
|
|
|
TestOthersItems( m_Parent->DrawPanel,
|
|
|
|
NetItemRef, StartNet, &NetNbItems, &MinConn );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
OldItem = NetItemRef;
|
|
|
|
}
|
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
// Displays global results:
|
2007-09-20 21:06:49 +00:00
|
|
|
wxString num;
|
|
|
|
num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc );
|
|
|
|
m_TotalErrCount->SetLabel( num );
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
num.Printf( wxT(
|
|
|
|
"%d" ), g_EESchemaVar.NbErrorErc -
|
|
|
|
g_EESchemaVar.NbWarningErc );
|
2007-09-20 21:06:49 +00:00
|
|
|
m_LastErrCount->SetLabel( num );
|
|
|
|
|
|
|
|
num.Printf( wxT( "%d" ), g_EESchemaVar.NbWarningErc );
|
|
|
|
m_LastWarningCount->SetLabel( num );
|
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
// Display diags:
|
2009-07-07 17:50:02 +00:00
|
|
|
DisplayERC_MarkersList();
|
2009-07-03 18:25:06 +00:00
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
// Display new markers:
|
2009-07-03 18:25:06 +00:00
|
|
|
m_Parent->DrawPanel->Refresh();
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
if( WriteFichierERC == TRUE )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
|
|
|
fn.SetExt( wxT( "erc" ) );
|
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "ERC File" ), fn.GetPath(), fn.GetFullName(),
|
|
|
|
_( "Electronic rule check file (.erc)|*.erc" ),
|
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( WriteDiagnosticERC( dlg.GetPath() ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
|
|
|
Close( TRUE );
|
2009-04-05 20:49:15 +00:00
|
|
|
ExecuteFile( this, wxGetApp().GetEditorName(),
|
2009-11-03 13:26:31 +00:00
|
|
|
QuoteFullPath( fn ) );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/* Creates an ERC marker to show the ERC problem about aNetItemRef
|
|
|
|
* or between aNetItemRef and aNetItemTst
|
|
|
|
* if MinConn < 0: this is an error on labels
|
|
|
|
*/
|
2009-07-05 12:09:41 +00:00
|
|
|
static void Diagnose( WinEDA_DrawPanel* aPanel,
|
2009-07-12 15:29:42 +00:00
|
|
|
NETLIST_OBJECT* aNetItemRef,
|
|
|
|
NETLIST_OBJECT* aNetItemTst,
|
2009-07-05 12:09:41 +00:00
|
|
|
int aMinConn, int aDiag )
|
2009-11-03 13:26:31 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_MARKER* Marker = NULL;
|
2009-07-07 17:50:02 +00:00
|
|
|
SCH_SCREEN* screen;
|
|
|
|
int ii, jj;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
if( aDiag == OK )
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Create new marker for ERC error. */
|
2009-12-02 21:44:03 +00:00
|
|
|
Marker = new SCH_MARKER();
|
2009-07-09 17:02:15 +00:00
|
|
|
Marker->m_TimeStamp = GetTimeStamp();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
Marker->SetMarkerType( MARK_ERC );
|
2009-07-06 18:02:26 +00:00
|
|
|
Marker->SetErrorLevel( WAR );
|
2009-07-05 12:09:41 +00:00
|
|
|
screen = aNetItemRef->m_SheetList.LastScreen();
|
2008-11-24 06:53:43 +00:00
|
|
|
Marker->SetNext( screen->EEDrawList );
|
2007-09-20 21:06:49 +00:00
|
|
|
screen->EEDrawList = Marker;
|
|
|
|
g_EESchemaVar.NbErrorErc++;
|
|
|
|
g_EESchemaVar.NbWarningErc++;
|
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
wxString msg;
|
2009-11-03 13:26:31 +00:00
|
|
|
if( aMinConn < 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-05 12:09:41 +00:00
|
|
|
if( (aNetItemRef->m_Type == NET_HIERLABEL)
|
|
|
|
|| (aNetItemRef->m_Type == NET_HIERBUSLABELMEMBER) )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-07 17:50:02 +00:00
|
|
|
msg.Printf( _( "HLabel %s not connected to SheetLabel" ),
|
2009-11-03 13:26:31 +00:00
|
|
|
aNetItemRef->m_Label->GetData() );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
else
|
2009-07-07 17:50:02 +00:00
|
|
|
msg.Printf( _( "SheetLabel %s not connected to HLabel" ),
|
2009-11-03 13:26:31 +00:00
|
|
|
aNetItemRef->m_Label->GetData() );
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
Marker->SetData( ERCE_HIERACHICAL_LABEL,
|
|
|
|
aNetItemRef->m_Start,
|
|
|
|
msg,
|
|
|
|
aNetItemRef->m_Start );
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
ii = aNetItemRef->m_ElectricalType;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
wxString string_pinnum, cmp_ref;
|
2009-07-07 17:50:02 +00:00
|
|
|
char ascii_buf[5];
|
2009-07-03 18:25:06 +00:00
|
|
|
ascii_buf[4] = 0;
|
2009-07-05 12:09:41 +00:00
|
|
|
memcpy( ascii_buf, &aNetItemRef->m_PinNum, 4 );
|
2009-07-03 18:25:06 +00:00
|
|
|
string_pinnum = CONV_FROM_UTF8( ascii_buf );
|
2009-07-07 17:50:02 +00:00
|
|
|
cmp_ref = wxT( "?" );
|
|
|
|
if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link )
|
2009-11-03 13:26:31 +00:00
|
|
|
cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef(
|
|
|
|
&aNetItemRef->m_SheetList );
|
2009-07-03 18:25:06 +00:00
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
if( aNetItemTst == NULL )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
if( aMinConn == NOC ) /* Only 1 element in the net. */
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-07 17:50:02 +00:00
|
|
|
msg.Printf( _( "Cmp %s, Pin %s (%s) Unconnected" ),
|
2009-07-09 17:02:15 +00:00
|
|
|
cmp_ref.GetData(), string_pinnum.GetData(),
|
|
|
|
MsgPinElectricType[ii] );
|
2009-07-07 17:50:02 +00:00
|
|
|
Marker->SetData( ERCE_PIN_NOT_CONNECTED,
|
|
|
|
aNetItemRef->m_Start,
|
|
|
|
msg,
|
|
|
|
aNetItemRef->m_Start );
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
if( aMinConn == NOD ) /* Nothing driving the net. */
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-07 17:50:02 +00:00
|
|
|
if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link )
|
|
|
|
cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef(
|
|
|
|
&aNetItemRef->m_SheetList );
|
2009-11-03 13:26:31 +00:00
|
|
|
msg.Printf( _( "Cmp %s, Pin %s (%s) not driven (Net %d)" ),
|
|
|
|
cmp_ref.GetData(), string_pinnum.GetData(),
|
|
|
|
MsgPinElectricType[ii], aNetItemRef->GetNet() );
|
2009-07-07 17:50:02 +00:00
|
|
|
Marker->SetData( ERCE_PIN_NOT_DRIVEN,
|
|
|
|
aNetItemRef->m_Start,
|
|
|
|
msg,
|
|
|
|
aNetItemRef->m_Start );
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
if( aDiag == UNC )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-06 18:02:26 +00:00
|
|
|
msg.Printf(
|
2009-07-07 17:50:02 +00:00
|
|
|
_( "More than 1 Pin connected to UnConnect symbol" ) );
|
|
|
|
Marker->SetData( ERCE_NOCONNECT_CONNECTED,
|
|
|
|
aNetItemRef->m_Start,
|
|
|
|
msg,
|
|
|
|
aNetItemRef->m_Start );
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
if( aNetItemTst ) /* Error between 2 pins */
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-05 12:09:41 +00:00
|
|
|
jj = aNetItemTst->m_ElectricalType;
|
2009-07-08 15:42:45 +00:00
|
|
|
int errortype = ERCE_PIN_TO_PIN_WARNING;
|
2009-07-05 12:09:41 +00:00
|
|
|
if( aDiag == ERR )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-06 18:02:26 +00:00
|
|
|
Marker->SetErrorLevel( ERR );
|
2007-09-20 21:06:49 +00:00
|
|
|
g_EESchemaVar.NbWarningErc--;
|
2009-07-08 15:42:45 +00:00
|
|
|
errortype = ERCE_PIN_TO_PIN_ERROR;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
wxString alt_string_pinnum, alt_cmp;
|
2009-07-05 12:09:41 +00:00
|
|
|
memcpy( ascii_buf, &aNetItemTst->m_PinNum, 4 );
|
2009-07-03 18:25:06 +00:00
|
|
|
alt_string_pinnum = CONV_FROM_UTF8( ascii_buf );
|
2009-07-07 17:50:02 +00:00
|
|
|
alt_cmp = wxT( "?" );
|
|
|
|
if( aNetItemTst->m_Type == NET_PIN && aNetItemTst->m_Link )
|
2009-11-03 13:26:31 +00:00
|
|
|
alt_cmp = ( (SCH_COMPONENT*) aNetItemTst->m_Link )->GetRef(
|
|
|
|
&aNetItemTst->m_SheetList );
|
|
|
|
msg.Printf( _( "Cmp %s, Pin %s (%s) connected to " ),
|
|
|
|
cmp_ref.GetData(),
|
|
|
|
string_pinnum.GetData(), MsgPinElectricType[ii] );
|
2009-07-08 15:42:45 +00:00
|
|
|
Marker->SetData( errortype,
|
2009-07-07 17:50:02 +00:00
|
|
|
aNetItemRef->m_Start,
|
|
|
|
msg,
|
|
|
|
aNetItemRef->m_Start );
|
2009-11-03 13:26:31 +00:00
|
|
|
msg.Printf( _( "Cmp %s, Pin %s (%s) (net %d)" ),
|
|
|
|
alt_cmp.GetData(),
|
|
|
|
alt_string_pinnum.GetData(), MsgPinElectricType[jj],
|
|
|
|
aNetItemRef->GetNet() );
|
2009-07-08 15:42:45 +00:00
|
|
|
Marker->SetAuxiliaryData( msg, aNetItemTst->m_Start );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/* Routine testing electrical conflicts between NetItemRef and other items
|
|
|
|
* of the same net
|
|
|
|
*/
|
2009-07-03 18:25:06 +00:00
|
|
|
static void TestOthersItems( WinEDA_DrawPanel* panel,
|
2009-07-12 15:29:42 +00:00
|
|
|
unsigned NetItemRef,
|
|
|
|
unsigned netstart,
|
2007-09-20 21:06:49 +00:00
|
|
|
int* NetNbItems, int* MinConnexion )
|
2009-11-03 13:26:31 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
unsigned NetItemTst;
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
int ref_elect_type, jj, erc = OK, local_minconn;
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Analysis of the table of connections. */
|
2009-07-12 15:29:42 +00:00
|
|
|
ref_elect_type = g_NetObjectslist[NetItemRef]->m_ElectricalType;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
NetItemTst = netstart;
|
|
|
|
local_minconn = NOC;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Test pins connected to NetItemRef */
|
2007-09-20 21:06:49 +00:00
|
|
|
for( ; ; NetItemTst++ )
|
|
|
|
{
|
|
|
|
if( NetItemRef == NetItemTst )
|
|
|
|
continue;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* We examine only a given net. We stop the search if the net changes
|
|
|
|
**/
|
|
|
|
if( ( NetItemTst >= g_NetObjectslist.size() ) // End of list
|
|
|
|
|| ( g_NetObjectslist[NetItemRef]->GetNet() !=
|
|
|
|
g_NetObjectslist[NetItemTst]->GetNet() ) ) // End of net
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/* End net code found: minimum connection test. */
|
|
|
|
if( (*MinConnexion < NET_NC ) && (local_minconn < NET_NC ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Not connected or not driven pin. */
|
2009-07-10 12:29:31 +00:00
|
|
|
bool seterr = true;
|
2009-11-03 13:26:31 +00:00
|
|
|
if( local_minconn == NOC
|
|
|
|
&& g_NetObjectslist[NetItemRef]->m_Type == NET_PIN )
|
2009-07-10 12:29:31 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/* This pin is not connected: for multiple part per
|
|
|
|
* package, and duplicated pin,
|
|
|
|
* search for an other instance of this pin
|
|
|
|
* this will be flagged only is all instances of this pin
|
|
|
|
* are not connected
|
|
|
|
* TODO test also if instances connected are connected to
|
|
|
|
* the same net
|
|
|
|
*/
|
|
|
|
for( unsigned duppin = 0;
|
|
|
|
duppin < g_NetObjectslist.size();
|
|
|
|
duppin++ )
|
2009-07-10 12:29:31 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
if( g_NetObjectslist[duppin]->m_Type != NET_PIN )
|
2009-07-10 12:29:31 +00:00
|
|
|
continue;
|
|
|
|
if( duppin == NetItemRef )
|
|
|
|
continue;
|
2009-11-03 13:26:31 +00:00
|
|
|
if( g_NetObjectslist[NetItemRef]->m_PinNum !=
|
|
|
|
g_NetObjectslist[duppin]->m_PinNum )
|
2009-07-10 12:29:31 +00:00
|
|
|
continue;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
if( ( (SCH_COMPONENT*) g_NetObjectslist[NetItemRef]->
|
|
|
|
m_Link )->GetRef( &g_NetObjectslist[NetItemRef]->
|
|
|
|
m_SheetList ) !=
|
|
|
|
( (SCH_COMPONENT*) g_NetObjectslist[duppin]->m_Link )
|
|
|
|
->GetRef( &g_NetObjectslist[duppin]->m_SheetList ) )
|
2009-07-10 12:29:31 +00:00
|
|
|
continue;
|
2009-11-03 13:26:31 +00:00
|
|
|
|
|
|
|
// Same component and same pin. Do dot create error for
|
|
|
|
// this pin
|
|
|
|
// if the other pin is connected (i.e. if duppin net
|
|
|
|
// has an other item)
|
|
|
|
if( (duppin > 0)
|
|
|
|
&& ( g_NetObjectslist[duppin]->GetNet() ==
|
|
|
|
g_NetObjectslist[duppin - 1]->GetNet() ) )
|
2009-07-10 12:29:31 +00:00
|
|
|
seterr = false;
|
2009-11-03 13:26:31 +00:00
|
|
|
if( (duppin < g_NetObjectslist.size() - 1)
|
|
|
|
&& ( g_NetObjectslist[duppin]->GetNet() ==
|
|
|
|
g_NetObjectslist[duppin + 1]->GetNet() ) )
|
2009-07-10 12:29:31 +00:00
|
|
|
seterr = false;
|
|
|
|
}
|
|
|
|
}
|
2009-11-03 13:26:31 +00:00
|
|
|
if( seterr )
|
|
|
|
Diagnose( panel,
|
|
|
|
g_NetObjectslist[NetItemRef],
|
|
|
|
NULL,
|
|
|
|
local_minconn,
|
|
|
|
WAR );
|
|
|
|
*MinConnexion = DRV; // inhibiting other messages of this
|
|
|
|
// type for the net.
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
switch( g_NetObjectslist[NetItemTst]->m_Type )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
case NET_ITEM_UNSPECIFIED:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_SEGMENT:
|
|
|
|
case NET_BUS:
|
|
|
|
case NET_JONCTION:
|
|
|
|
case NET_LABEL:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERLABEL:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_BUSLABELMEMBER:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERBUSLABELMEMBER:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_SHEETBUSLABELMEMBER:
|
|
|
|
case NET_SHEETLABEL:
|
2008-03-13 05:04:59 +00:00
|
|
|
case NET_GLOBLABEL:
|
|
|
|
case NET_GLOBBUSLABELMEMBER:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_PINLABEL:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_NOCONNECT:
|
|
|
|
local_minconn = MAX( NET_NC, local_minconn );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_PIN:
|
2009-07-12 15:29:42 +00:00
|
|
|
jj = g_NetObjectslist[NetItemTst]->m_ElectricalType;
|
2007-09-20 21:06:49 +00:00
|
|
|
local_minconn = MAX( MinimalReq[ref_elect_type][jj], local_minconn );
|
|
|
|
|
|
|
|
if( NetItemTst <= NetItemRef )
|
|
|
|
break;
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
*NetNbItems += 1;
|
2009-11-03 13:26:31 +00:00
|
|
|
if( erc == OK )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
|
|
|
erc = DiagErc[ref_elect_type][jj];
|
|
|
|
if( erc != OK )
|
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
if( g_NetObjectslist[NetItemTst]->m_FlagOfConnection == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
Diagnose( panel,
|
|
|
|
g_NetObjectslist[NetItemRef],
|
|
|
|
g_NetObjectslist[NetItemTst],
|
|
|
|
0,
|
|
|
|
erc );
|
|
|
|
g_NetObjectslist[NetItemTst]->m_FlagOfConnection =
|
|
|
|
NOCONNECT_SYMBOL_PRESENT;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-13 15:35:40 +00:00
|
|
|
/* Create the Diagnostic file (<xxx>.erc file)
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
static bool WriteDiagnosticERC( const wxString& FullFileName )
|
|
|
|
{
|
|
|
|
SCH_ITEM* DrawStruct;
|
|
|
|
SCH_MARKER* Marker;
|
|
|
|
char Line[1024];
|
|
|
|
static FILE* OutErc;
|
|
|
|
SCH_SHEET_PATH* Sheet;
|
|
|
|
wxString msg;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
if( ( OutErc = wxFopen( FullFileName, wxT( "wt" ) ) ) == NULL )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
DateAndTime( Line );
|
2009-07-08 15:42:45 +00:00
|
|
|
msg = _( "ERC report" );
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
fprintf( OutErc, "%s (%s)\n", CONV_TO_UTF8( msg ), Line );
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_LIST SheetList;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
for( Sheet = SheetList.GetFirst();
|
|
|
|
Sheet != NULL;
|
|
|
|
Sheet = SheetList.GetNext() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-03-13 05:04:59 +00:00
|
|
|
if( Sheet->Last() == g_RootSheet )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "\n***** Sheet / (Root) \n" ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxString str = Sheet->PathHumanReadable();
|
|
|
|
msg.Printf( _( "\n***** Sheet %s\n" ), str.GetData() );
|
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
fprintf( OutErc, "%s", CONV_TO_UTF8( msg ) );
|
|
|
|
|
2008-03-13 05:04:59 +00:00
|
|
|
DrawStruct = Sheet->LastDrawList();
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
if( DrawStruct->Type() != TYPE_SCH_MARKER )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
Marker = (SCH_MARKER*) DrawStruct;
|
2009-07-07 17:50:02 +00:00
|
|
|
if( Marker->GetMarkerType() != MARK_ERC )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2009-07-08 15:42:45 +00:00
|
|
|
msg = Marker->GetReporter().ShowReport();
|
2007-09-20 21:06:49 +00:00
|
|
|
fprintf( OutErc, "%s", CONV_TO_UTF8( msg ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.Printf( _( "\n >> Errors ERC: %d\n" ), g_EESchemaVar.NbErrorErc );
|
|
|
|
fprintf( OutErc, "%s", CONV_TO_UTF8( msg ) );
|
|
|
|
fclose( OutErc );
|
|
|
|
|
|
|
|
return TRUE;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
static bool IsLabelsConnected( NETLIST_OBJECT* a, NETLIST_OBJECT* b )
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2008-03-13 05:04:59 +00:00
|
|
|
int at = a->m_Type;
|
|
|
|
int bt = b->m_Type;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
if( ( at == NET_HIERLABEL || at == NET_HIERBUSLABELMEMBER )
|
|
|
|
&& ( bt == NET_SHEETLABEL || bt == NET_SHEETBUSLABELMEMBER ) )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
|
|
|
if( a->m_SheetList == b->m_SheetListInclude )
|
|
|
|
{
|
|
|
|
return true; //connected!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false; //these two are unconnected
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-03-13 05:04:59 +00:00
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/* Routine to perform erc on a sheetLabel that is connected to a corresponding
|
|
|
|
* sub sheet Glabel
|
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
void TestLabel( WinEDA_DrawPanel* panel,
|
|
|
|
unsigned NetItemRef,
|
|
|
|
unsigned StartNet )
|
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
unsigned NetItemTst;
|
2009-11-03 13:26:31 +00:00
|
|
|
int erc = 1;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
NetItemTst = StartNet;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Review the list of labels connected to NetItemRef. */
|
2007-09-20 21:06:49 +00:00
|
|
|
for( ; ; NetItemTst++ )
|
|
|
|
{
|
|
|
|
if( NetItemTst == NetItemRef )
|
|
|
|
continue;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Is always in the same net? */
|
2009-07-12 15:29:42 +00:00
|
|
|
if( ( NetItemTst == g_NetObjectslist.size() )
|
2009-11-03 13:26:31 +00:00
|
|
|
|| ( g_NetObjectslist[NetItemRef]->GetNet() !=
|
|
|
|
g_NetObjectslist[NetItemTst]->GetNet() ) )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/* End Netcode found. */
|
2008-03-13 05:04:59 +00:00
|
|
|
if( erc )
|
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Glabel or SheetLabel orphaned. */
|
2009-07-12 15:29:42 +00:00
|
|
|
Diagnose( panel, g_NetObjectslist[NetItemRef], NULL, -1, WAR );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2009-11-03 13:26:31 +00:00
|
|
|
if( IsLabelsConnected( g_NetObjectslist[NetItemRef],
|
|
|
|
g_NetObjectslist[NetItemTst] ) )
|
2008-03-13 05:04:59 +00:00
|
|
|
erc = 0;
|
|
|
|
|
|
|
|
//same thing, different order.
|
2009-11-03 13:26:31 +00:00
|
|
|
if( IsLabelsConnected( g_NetObjectslist[NetItemTst],
|
|
|
|
g_NetObjectslist[NetItemRef] ) )
|
2008-03-13 05:04:59 +00:00
|
|
|
erc = 0;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|