KiCad PCB EDA Suite
erc.h File Reference

Go to the source code of this file.

Macros

#define ERCE_UNSPECIFIED   0
 DRC error codes: More...
 
#define ERCE_DUPLICATE_SHEET_NAME   1
 
#define ERCE_PIN_NOT_CONNECTED   2
 
#define ERCE_PIN_NOT_DRIVEN   3
 
#define ERCE_PIN_TO_PIN_WARNING   4
 
#define ERCE_PIN_TO_PIN_ERROR   5
 
#define ERCE_HIERACHICAL_LABEL   6
 
#define ERCE_NOCONNECT_CONNECTED   7
 
#define ERCE_GLOBLABEL   8
 
#define ERCE_SIMILAR_LABELS   9
 
#define ERCE_SIMILAR_GLBL_LABELS   10
 
#define NPI   4
 
#define DRV   3
 
#define NET_NC   2
 
#define NOD   1
 
#define NOC   0
 

Enumerations

enum  errortype { OK = 0, WAR, ERR, UNC }
 

Functions

bool WriteDiagnosticERC (const wxString &aFullFileName)
 Function WriteDiagnosticERC save the ERC errors to aFullFileName. More...
 
void Diagnose (NETLIST_OBJECT *NetItemRef, NETLIST_OBJECT *NetItemTst, int MinConnexion, int Diag)
 Performs ERC testing and creates an ERC marker to show the ERC problem for aNetItemRef or between aNetItemRef and aNetItemTst. More...
 
void TestOthersItems (NETLIST_OBJECT_LIST *aList, unsigned aNetItemRef, unsigned aNetStart, int *aMinConnexion)
 Perform ERC testing for electrical conflicts between NetItemRef and other items (mainly pin) on the same net. More...
 
int TestDuplicateSheetNames (bool aCreateMarker)
 Function TestDuplicateSheetNames( ) inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated). More...
 

Variables

const wxString CommentERC_H []
 
const wxString CommentERC_V []
 

Macro Definition Documentation

#define DRV   3

Definition at line 66 of file erc.h.

Referenced by TestOthersItems().

#define ERCE_DUPLICATE_SHEET_NAME   1

Definition at line 53 of file erc.h.

Referenced by TestDuplicateSheetNames().

#define ERCE_GLOBLABEL   8

Definition at line 60 of file erc.h.

Referenced by Diagnose().

#define ERCE_HIERACHICAL_LABEL   6

Definition at line 58 of file erc.h.

Referenced by Diagnose().

#define ERCE_NOCONNECT_CONNECTED   7

Definition at line 59 of file erc.h.

Referenced by Diagnose().

#define ERCE_PIN_NOT_CONNECTED   2

Definition at line 54 of file erc.h.

Referenced by Diagnose().

#define ERCE_PIN_NOT_DRIVEN   3

Definition at line 55 of file erc.h.

Referenced by Diagnose().

#define ERCE_PIN_TO_PIN_ERROR   5

Definition at line 57 of file erc.h.

Referenced by Diagnose().

#define ERCE_PIN_TO_PIN_WARNING   4

Definition at line 56 of file erc.h.

Referenced by Diagnose().

#define ERCE_SIMILAR_GLBL_LABELS   10

Definition at line 62 of file erc.h.

Referenced by SimilarLabelsDiagnose().

#define ERCE_SIMILAR_LABELS   9

Definition at line 61 of file erc.h.

Referenced by SimilarLabelsDiagnose().

#define ERCE_UNSPECIFIED   0

DRC error codes:

Definition at line 52 of file erc.h.

#define NET_NC   2

Definition at line 67 of file erc.h.

Referenced by DIALOG_ERC::TestErc(), and TestOthersItems().

#define NOC   0

Definition at line 69 of file erc.h.

Referenced by Diagnose(), DIALOG_ERC::TestErc(), and TestOthersItems().

#define NOD   1

Definition at line 68 of file erc.h.

Referenced by Diagnose().

#define NPI   4

Definition at line 65 of file erc.h.

Referenced by TestOthersItems().

Enumeration Type Documentation

enum errortype
Enumerator
OK 
WAR 
ERR 
UNC 

Definition at line 40 of file erc.h.

41 {
42  OK = 0,
43  WAR, // Error: severity = warning
44  ERR, // Error: severity = error
45  UNC // Error: unconnected pin
46 };
Definition: erc.h:43
Definition: erc.h:42
Definition: erc.h:44
Definition: erc.h:45

Function Documentation

void Diagnose ( NETLIST_OBJECT NetItemRef,
NETLIST_OBJECT NetItemTst,
int  MinConnexion,
int  Diag 
)

Performs ERC testing and creates an ERC marker to show the ERC problem for aNetItemRef or between aNetItemRef and aNetItemTst.

if MinConn < 0: this is an error on labels

Definition at line 228 of file erc.cpp.

References SCH_SCREEN::Append(), ERCE_GLOBLABEL, ERCE_HIERACHICAL_LABEL, ERCE_NOCONNECT_CONNECTED, ERCE_PIN_NOT_CONNECTED, ERCE_PIN_NOT_DRIVEN, ERCE_PIN_TO_PIN_ERROR, ERCE_PIN_TO_PIN_WARNING, ERR, FROM_UTF8(), GetChars(), NETLIST_OBJECT::GetComponentParent(), NETLIST_OBJECT::GetNet(), GetNewTimeStamp(), SCH_COMPONENT::GetRef(), GetText(), SCH_SHEET_PATH::LastScreen(), NETLIST_OBJECT::m_ElectricalPinType, NETLIST_OBJECT::m_Label, NETLIST_OBJECT::m_Link, NETLIST_OBJECT::m_PinNum, NETLIST_OBJECT::m_SheetPath, NETLIST_OBJECT::m_Start, NETLIST_OBJECT::m_Type, MARKER_BASE::MARKER_ERC, MARKER_BASE::MARKER_SEVERITY_ERROR, MARKER_BASE::MARKER_SEVERITY_WARNING, NET_GLOBLABEL, NET_HIERBUSLABELMEMBER, NET_HIERLABEL, NET_PIN, NOC, NOD, OK, MARKER_BASE::SetAuxiliaryData(), MARKER_BASE::SetData(), MARKER_BASE::SetErrorLevel(), MARKER_BASE::SetMarkerType(), EDA_ITEM::SetTimeStamp(), and UNC.

Referenced by DIALOG_ERC::TestErc(), NETLIST_OBJECT_LIST::TestforNonOrphanLabel(), and TestOthersItems().

230 {
231  SCH_MARKER* marker = NULL;
232  SCH_SCREEN* screen;
233  ELECTRICAL_PINTYPE ii, jj;
234 
235  if( aDiag == OK )
236  return;
237 
238  /* Create new marker for ERC error. */
239  marker = new SCH_MARKER();
240  marker->SetTimeStamp( GetNewTimeStamp() );
241 
244  screen = aNetItemRef->m_SheetPath.LastScreen();
245  screen->Append( marker );
246 
247  wxString msg;
248 
249  if( aMinConn < 0 )
250  {
251  if( aNetItemRef->m_Type == NET_HIERLABEL || aNetItemRef->m_Type == NET_HIERBUSLABELMEMBER )
252  {
253  msg.Printf( _( "Hierarchical label %s is not connected to a sheet label." ),
254  GetChars( aNetItemRef->m_Label ) );
256  aNetItemRef->m_Start,
257  msg,
258  aNetItemRef->m_Start );
259  }
260  else if( aNetItemRef->m_Type == NET_GLOBLABEL )
261  {
262  msg.Printf( _( "Global label %s is not connected to any other global label." ),
263  GetChars( aNetItemRef->m_Label ) );
264  marker->SetData( ERCE_GLOBLABEL,
265  aNetItemRef->m_Start,
266  msg,
267  aNetItemRef->m_Start );
268  }
269  else
270  {
271  msg.Printf( _( "Sheet label %s is not connected to a hierarchical label." ),
272  GetChars( aNetItemRef->m_Label ) );
274  aNetItemRef->m_Start,
275  msg,
276  aNetItemRef->m_Start );
277  }
278 
279  return;
280  }
281 
282  ii = aNetItemRef->m_ElectricalPinType;
283 
284  wxString string_pinnum, cmp_ref;
285  char ascii_buf[5];
286  ascii_buf[4] = 0;
287  memcpy( ascii_buf, &aNetItemRef->m_PinNum, 4 );
288  string_pinnum = FROM_UTF8( ascii_buf );
289  cmp_ref = wxT( "?" );
290 
291  if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link )
292  cmp_ref = aNetItemRef->GetComponentParent()->GetRef( &aNetItemRef->m_SheetPath );
293 
294  if( aNetItemTst == NULL )
295  {
296  if( aMinConn == NOC ) /* Only 1 element in the net. */
297  {
298  msg.Printf( _( "Pin %s (%s) of component %s is unconnected." ),
299  GetChars( string_pinnum ),
300  GetChars( GetText( ii ) ),
301  GetChars( cmp_ref ) );
303  aNetItemRef->m_Start,
304  msg,
305  aNetItemRef->m_Start );
306  return;
307  }
308 
309  if( aMinConn == NOD ) /* Nothing driving the net. */
310  {
311  if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link )
312  cmp_ref = aNetItemRef->GetComponentParent()->GetRef(
313  &aNetItemRef->m_SheetPath );
314 
315  msg.Printf( _( "Pin %s (%s) of component %s is not driven (Net %d)." ),
316  GetChars( string_pinnum ),
317  GetChars( GetText( ii ) ),
318  GetChars( cmp_ref ),
319  aNetItemRef->GetNet() );
320  marker->SetData( ERCE_PIN_NOT_DRIVEN,
321  aNetItemRef->m_Start,
322  msg,
323  aNetItemRef->m_Start );
324  return;
325  }
326 
327  if( aDiag == UNC )
328  {
329  msg.Printf( _( "More than 1 pin connected to an UnConnect symbol." ) );
331  aNetItemRef->m_Start,
332  msg,
333  aNetItemRef->m_Start );
334  return;
335  }
336  }
337 
338  if( aNetItemTst ) /* Error between 2 pins */
339  {
340  jj = aNetItemTst->m_ElectricalPinType;
342 
343  if( aDiag == ERR )
344  {
346  errortype = ERCE_PIN_TO_PIN_ERROR;
347  }
348 
349  wxString alt_string_pinnum, alt_cmp;
350  memcpy( ascii_buf, &aNetItemTst->m_PinNum, 4 );
351  alt_string_pinnum = FROM_UTF8( ascii_buf );
352  alt_cmp = wxT( "?" );
353 
354  if( aNetItemTst->m_Type == NET_PIN && aNetItemTst->m_Link )
355  alt_cmp = aNetItemTst->GetComponentParent()->GetRef( &aNetItemTst->m_SheetPath );
356 
357  msg.Printf( _( "Pin %s (%s) of component %s is connected to " ),
358  GetChars( string_pinnum ),
359  GetChars( GetText( ii ) ),
360  GetChars( cmp_ref ) );
361  marker->SetData( errortype, aNetItemRef->m_Start, msg, aNetItemRef->m_Start );
362  msg.Printf( _( "pin %s (%s) of component %s (net %d)." ),
363  GetChars( alt_string_pinnum ),
364  GetChars( GetText( jj ) ),
365  GetChars( alt_cmp ),
366  aNetItemRef->GetNet() );
367  marker->SetAuxiliaryData( msg, aNetItemTst->m_Start );
368  }
369 }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
#define ERCE_HIERACHICAL_LABEL
Definition: erc.h:58
#define ERCE_PIN_NOT_DRIVEN
Definition: erc.h:55
time_t GetNewTimeStamp()
Definition: common.cpp:166
#define ERCE_PIN_NOT_CONNECTED
Definition: erc.h:54
void SetData(int aErrorCode, const wxPoint &aMarkerPos, const wxString &aText, const wxPoint &aPos, const wxString &bText, const wxPoint &bPos)
Function SetData fills in all the reportable data associated with a MARKER.
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:217
Definition: erc.h:42
Definition: erc.h:44
#define ERCE_GLOBLABEL
Definition: erc.h:60
wxString GetText(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:33
Definition: erc.h:45
#define ERCE_PIN_TO_PIN_ERROR
Definition: erc.h:57
void SetMarkerType(enum TYPEMARKER aMarkerType)
accessors to set/get marker type (DRC, ERC, or other)
#define NOC
Definition: erc.h:69
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
ELECTRICAL_PINTYPE
The component library pin object electrical types used in ERC tests.
Definition: pin_type.h:37
void Append(SCH_ITEM *aItem)
void SetErrorLevel(MARKER_SEVERITY aErrorLevel)
accessors to set/get error levels (warning, error, fatal error..)
errortype
Definition: erc.h:40
#define ERCE_NOCONNECT_CONNECTED
Definition: erc.h:59
#define ERCE_PIN_TO_PIN_WARNING
Definition: erc.h:56
void SetAuxiliaryData(const wxString &aAuxiliaryText, const wxPoint &aAuxiliaryPos)
Function SetAuxiliaryData initialize data for the second (auxiliary) item.
#define NOD
Definition: erc.h:68
int TestDuplicateSheetNames ( bool  aCreateMarker)

Function TestDuplicateSheetNames( ) inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated).

Returns
the error count
Parameters
aCreateMarkertrue = create error markers in schematic, false = calculate error count only

Definition at line 177 of file erc.cpp.

178 {
179  SCH_SCREEN* screen;
180  SCH_ITEM* item;
181  SCH_ITEM* test_item;
182  int err_count = 0;
183  SCH_SCREENS screenList; // Created the list of screen
184 
185  for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() )
186  {
187  for( item = screen->GetDrawItems(); item != NULL; item = item->Next() )
188  {
189  // search for a sheet;
190  if( item->Type() != SCH_SHEET_T )
191  continue;
192 
193  for( test_item = item->Next(); test_item != NULL; test_item = test_item->Next() )
194  {
195  if( test_item->Type() != SCH_SHEET_T )
196  continue;
197 
198  // We have found a second sheet: compare names
199  // we are using case insensitive comparison to avoid mistakes between
200  // similar names like Mysheet and mysheet
201  if( ( (SCH_SHEET*) item )->GetName().CmpNoCase(
202  ( ( SCH_SHEET* ) test_item )->GetName() ) == 0 )
203  {
204  if( aCreateMarker )
205  {
206  /* Create a new marker type ERC error*/
207  SCH_MARKER* marker = new SCH_MARKER();
208  marker->SetTimeStamp( GetNewTimeStamp() );
210  ( (SCH_SHEET*) test_item )->GetPosition(),
211  _( "Duplicate sheet name" ),
212  ( (SCH_SHEET*) test_item )->GetPosition() );
215  screen->Append( marker );
216  }
217 
218  err_count++;
219  }
220  }
221  }
222  }
223 
224  return err_count;
225 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
SCH_SCREEN * GetNext()
time_t GetNewTimeStamp()
Definition: common.cpp:166
SCH_ITEM * Next() const
void SetData(int aErrorCode, const wxPoint &aMarkerPos, const wxString &aText, const wxPoint &aPos, const wxString &bText, const wxPoint &bPos)
Function SetData fills in all the reportable data associated with a MARKER.
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:217
#define ERCE_DUPLICATE_SHEET_NAME
Definition: erc.h:53
void SetMarkerType(enum TYPEMARKER aMarkerType)
accessors to set/get marker type (DRC, ERC, or other)
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
SCH_ITEM * GetDrawItems() const
Function GetDrawItems().
void Append(SCH_ITEM *aItem)
void SetErrorLevel(MARKER_SEVERITY aErrorLevel)
accessors to set/get error levels (warning, error, fatal error..)
SCH_SCREEN * GetFirst()
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Class SCH_SCREENS is a container class that holds multiple SCH_SCREENs in a hierarchy.
void TestOthersItems ( NETLIST_OBJECT_LIST aList,
unsigned  aNetItemRef,
unsigned  aNetStart,
int *  aMinConnexion 
)

Perform ERC testing for electrical conflicts between NetItemRef and other items (mainly pin) on the same net.

Parameters
aList= a reference to the list of connected objects
aNetItemRef= index in list of the current object
aNetStart= index in list of net objects of the first item
aMinConnexion= a pointer to a variable to store the minimal connection found( NOD, DRV, NPI, NET_NC)

Definition at line 372 of file erc.cpp.

References DiagErc, Diagnose(), DRV, NETLIST_OBJECT_LIST::GetConnectionType(), NETLIST_OBJECT_LIST::GetItem(), NETLIST_OBJECT_LIST::GetItemNet(), NETLIST_OBJECT_LIST::GetItemType(), NETLIST_OBJECT::m_ElectricalPinType, NETLIST_OBJECT::m_Link, NETLIST_OBJECT::m_PinNum, NETLIST_OBJECT::m_SheetPath, max, MinimalReq, NET_BUS, NET_BUSLABELMEMBER, NET_GLOBBUSLABELMEMBER, NET_GLOBLABEL, NET_HIERBUSLABELMEMBER, NET_HIERLABEL, NET_ITEM_UNSPECIFIED, NET_JUNCTION, NET_LABEL, NET_NC, NET_NOCONNECT, NET_PIN, NET_PINLABEL, NET_SEGMENT, NET_SHEETBUSLABELMEMBER, NET_SHEETLABEL, NOC, NOCONNECT_SYMBOL_PRESENT, NPI, OK, PIN_NC, NETLIST_OBJECT_LIST::SetConnectionType(), UNCONNECTED, and WAR.

Referenced by DIALOG_ERC::TestErc().

375 {
376  unsigned netItemTst = aNetStart;
378  int erc = OK;
379 
380  /* Analysis of the table of connections. */
381  ELECTRICAL_PINTYPE ref_elect_type = aList->GetItem( aNetItemRef )->m_ElectricalPinType;
382  int local_minconn = NOC;
383 
384  if( ref_elect_type == PIN_NC )
385  local_minconn = NPI;
386 
387  /* Test pins connected to NetItemRef */
388  for( ; ; netItemTst++ )
389  {
390  if( aNetItemRef == netItemTst )
391  continue;
392 
393  // We examine only a given net. We stop the search if the net changes
394  if( ( netItemTst >= aList->size() ) // End of list
395  || ( aList->GetItemNet( aNetItemRef ) !=
396  aList->GetItemNet( netItemTst ) ) ) // End of net
397  {
398  /* End net code found: minimum connection test. */
399  if( ( *aMinConnexion < NET_NC ) && ( local_minconn < NET_NC ) )
400  {
401  /* Not connected or not driven pin. */
402  bool seterr = true;
403 
404  if( local_minconn == NOC &&
405  aList->GetItemType( aNetItemRef ) == NET_PIN )
406  {
407  /* This pin is not connected: for multiple part per
408  * package, and duplicated pin,
409  * search for an other instance of this pin
410  * this will be flagged only if all instances of this pin
411  * are not connected
412  * TODO test also if instances connected are connected to
413  * the same net
414  */
415  for( unsigned duplicate = 0; duplicate < aList->size(); duplicate++ )
416  {
417  if( aList->GetItemType( duplicate ) != NET_PIN )
418  continue;
419 
420  if( duplicate == aNetItemRef )
421  continue;
422 
423  if( aList->GetItem( aNetItemRef )->m_PinNum !=
424  aList->GetItem( duplicate )->m_PinNum )
425  continue;
426 
427  if( ( (SCH_COMPONENT*) aList->GetItem( aNetItemRef )->
428  m_Link )->GetRef( &aList->GetItem( aNetItemRef )-> m_SheetPath ) !=
429  ( (SCH_COMPONENT*) aList->GetItem( duplicate )->m_Link )
430  ->GetRef( &aList->GetItem( duplicate )->m_SheetPath ) )
431  continue;
432 
433  // Same component and same pin. Do dot create error for this pin
434  // if the other pin is connected (i.e. if duplicate net has an other
435  // item)
436  if( (duplicate > 0)
437  && ( aList->GetItemNet( duplicate ) ==
438  aList->GetItemNet( duplicate - 1 ) ) )
439  seterr = false;
440 
441  if( (duplicate < aList->size() - 1)
442  && ( aList->GetItemNet( duplicate ) ==
443  aList->GetItemNet( duplicate + 1 ) ) )
444  seterr = false;
445  }
446  }
447 
448  if( seterr )
449  Diagnose( aList->GetItem( aNetItemRef ), NULL, local_minconn, WAR );
450 
451  *aMinConnexion = DRV; // inhibiting other messages of this
452  // type for the net.
453  }
454  return;
455  }
456 
457  switch( aList->GetItemType( netItemTst ) )
458  {
460  case NET_SEGMENT:
461  case NET_BUS:
462  case NET_JUNCTION:
463  case NET_LABEL:
464  case NET_HIERLABEL:
465  case NET_BUSLABELMEMBER:
468  case NET_SHEETLABEL:
469  case NET_GLOBLABEL:
471  case NET_PINLABEL:
472  break;
473 
474  case NET_NOCONNECT:
475  local_minconn = std::max( NET_NC, local_minconn );
476  break;
477 
478  case NET_PIN:
479  jj = aList->GetItem( netItemTst )->m_ElectricalPinType;
480  local_minconn = std::max( MinimalReq[ref_elect_type][jj], local_minconn );
481 
482  if( netItemTst <= aNetItemRef )
483  break;
484 
485  if( erc == OK )
486  {
487  erc = DiagErc[ref_elect_type][jj];
488 
489  if( erc != OK )
490  {
491  if( aList->GetConnectionType( netItemTst ) == UNCONNECTED )
492  {
493  Diagnose( aList->GetItem( aNetItemRef ),
494  aList->GetItem( netItemTst ),
495  0, erc );
496  aList->SetConnectionType( netItemTst, NOCONNECT_SYMBOL_PRESENT );
497  }
498  }
499  }
500 
501  break;
502  }
503  }
504 }
Definition: erc.h:43
NETLIST_ITEM_T GetItemType(unsigned aIdx) const
Acces to an item type.
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
int DiagErc[PINTYPE_COUNT][PINTYPE_COUNT]
Definition: erc.cpp:124
void Diagnose(NETLIST_OBJECT *aNetItemRef, NETLIST_OBJECT *aNetItemTst, int aMinConn, int aDiag)
Performs ERC testing and creates an ERC marker to show the ERC problem for aNetItemRef or between aNe...
Definition: erc.cpp:228
SCH_SHEET_PATH m_SheetPath
ELECTRICAL_PINTYPE m_ElectricalPinType
void SetConnectionType(unsigned aIdx, NET_CONNECTION_T aFlg=UNCONNECTED)
Set the item connection type: UNCONNECTED Pin or Label not connected (error) NOCONNECT_SYMBOL_PRESENT...
#define DRV
Definition: erc.h:66
Definition: erc.h:42
#define NOC
Definition: erc.h:69
NET_CONNECTION_T GetConnectionType(unsigned aIdx)
static int MinimalReq[PINTYPE_COUNT][PINTYPE_COUNT]
Look up table which gives the minimal drive for a pair of connected pins on a net.
Definition: erc.cpp:160
ELECTRICAL_PINTYPE
The component library pin object electrical types used in ERC tests.
Definition: pin_type.h:37
#define max(a, b)
Definition: auxiliary.h:86
#define NPI
Definition: erc.h:65
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
int GetItemNet(unsigned aIdx) const
Acces to an item net code.
#define NET_NC
Definition: erc.h:67
bool WriteDiagnosticERC ( const wxString &  aFullFileName)

Function WriteDiagnosticERC save the ERC errors to aFullFileName.

Parameters
aFullFileNameA wxString object containing the file name and path.

Definition at line 525 of file erc.cpp.

References DateAndTime(), Format(), g_RootSheet, GetChars(), MARKER_BASE::GetErrorLevel(), MARKER_BASE::GetMarkerType(), MARKER_BASE::GetReporter(), MARKER_BASE::MARKER_ERC, MARKER_BASE::MARKER_SEVERITY_ERROR, MARKER_BASE::MARKER_SEVERITY_WARNING, SCH_MARKER_T, and DRC_ITEM::ShowReport().

Referenced by DIALOG_ERC::TestErc().

526 {
527  wxString msg;
528 
529  wxFFile file( aFullFileName, wxT( "wt" ) );
530 
531  if( !file.IsOpened() )
532  return false;
533 
534  msg = _( "ERC report" );
535  msg << wxT(" (") << DateAndTime() << wxT( ", " )
536  << _( "Encoding UTF8" ) << wxT( " )\n" );
537 
538  int err_count = 0;
539  int warn_count = 0;
540  int total_count = 0;
541  SCH_SHEET_LIST sheetList( g_RootSheet );
542 
543  for( unsigned i = 0; i < sheetList.size(); i++ )
544  {
545  msg << wxString::Format( _( "\n***** Sheet %s\n" ),
546  GetChars( sheetList[i].PathHumanReadable() ) );
547 
548  for( SCH_ITEM* item = sheetList[i].LastDrawList(); item != NULL; item = item->Next() )
549  {
550  if( item->Type() != SCH_MARKER_T )
551  continue;
552 
553  SCH_MARKER* marker = (SCH_MARKER*) item;
554 
555  if( marker->GetMarkerType() != MARKER_BASE::MARKER_ERC )
556  continue;
557 
558  total_count++;
559 
561  err_count++;
562 
564  warn_count++;
565 
566  msg << marker->GetReporter().ShowReport();
567  }
568  }
569 
570  msg << wxString::Format( _( "\n ** ERC messages: %d Errors %d Warnings %d\n" ),
571  total_count, err_count, warn_count );
572 
573  // Currently: write report using UTF8 (as usual in Kicad).
574  // TODO: see if we can use the current encoding page (mainly for Windows users),
575  // Or other format (HTML?)
576  file.Write( msg );
577 
578  // wxFFile dtor will close the file.
579 
580  return true;
581 }
Class SCH_SHEET_LIST.
wxString ShowReport() const
Function ShowReport translates this object into a text string suitable for saving to disk in a report...
SCH_ITEM * Next() const
enum TYPEMARKER GetMarkerType() const
MARKER_SEVERITY GetErrorLevel() const
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
const DRC_ITEM & GetReporter() const
Function GetReporter returns the DRC_ITEM held within this MARKER so that its interface may be used...
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
wxString DateAndTime()
Function DateAndTime.
Definition: string.cpp:229

Variable Documentation

const wxString CommentERC_H[]

Definition at line 87 of file erc.cpp.

Referenced by DIALOG_ERC::ReBuildMatrixPanel().

const wxString CommentERC_V[]

Definition at line 103 of file erc.cpp.

Referenced by DIALOG_ERC::ReBuildMatrixPanel().