KiCad PCB EDA Suite
eeschema/erc.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2011-2016 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
31 #include <fctsys.h>
32 #include <sch_draw_panel.h>
33 #include <kicad_string.h>
34 #include <sch_edit_frame.h>
35 #include <netlist_object.h>
36 #include <lib_pin.h>
37 #include <erc.h>
38 #include <sch_marker.h>
39 #include <sch_sheet.h>
40 #include <sch_reference_list.h>
41 #include <wx/ffile.h>
42 
43 
44 /* ERC tests :
45  * 1 - conflicts between connected pins ( example: 2 connected outputs )
46  * 2 - minimal connections requirements ( 1 input *must* be connected to an
47  * output, or a passive pin )
48  */
49 
50 
51 /*
52  * Minimal ERC requirements:
53  * All pins *must* be connected (except ELECTRICAL_PINTYPE::PT_NC).
54  * When a pin is not connected in schematic, the user must place a "non
55  * connected" symbol to this pin.
56  * This ensures a forgotten connection will be detected.
57  */
58 
59 /* Messages for conflicts :
60  * ELECTRICAL_PINTYPE::PT_INPUT, ELECTRICAL_PINTYPE::PT_OUTPUT, ELECTRICAL_PINTYPE:PT_:BIDI, ELECTRICAL_PINTYPE::PT_TRISTATE, ELECTRICAL_PINTYPE::PT_PASSIVE,
61  * ELECTRICAL_PINTYPE::PT_UNSPECIFIED, ELECTRICAL_PINTYPE::PT_POWER_IN, ELECTRICAL_PINTYPE::PT_POWER_OUT, ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR,
62  * ELECTRICAL_PINTYPE::PT_OPENEMITTER, ELECTRICAL_PINTYPE::PT_NC
63  * These messages are used to show the ERC matrix in ERC dialog
64  */
65 
66 // Messages for matrix rows:
67 const wxString CommentERC_H[] =
68 {
69  _( "Input Pin" ),
70  _( "Output Pin" ),
71  _( "Bidirectional Pin" ),
72  _( "Tri-State Pin" ),
73  _( "Passive Pin" ),
74  _( "Unspecified Pin" ),
75  _( "Power Input Pin" ),
76  _( "Power Output Pin" ),
77  _( "Open Collector" ),
78  _( "Open Emitter" ),
79  _( "No Connection" )
80 };
81 
82 // Messages for matrix columns
83 const wxString CommentERC_V[] =
84 {
85  _( "Input Pin" ),
86  _( "Output Pin" ),
87  _( "Bidirectional Pin" ),
88  _( "Tri-State Pin" ),
89  _( "Passive Pin" ),
90  _( "Unspecified Pin" ),
91  _( "Power Input Pin" ),
92  _( "Power Output Pin" ),
93  _( "Open Collector" ),
94  _( "Open Emitter" ),
95  _( "No Connection" )
96 };
97 
98 
99 /* Look up table which gives the diag for a pair of connected pins
100  * Can be modified by ERC options.
101  * at start up: must be loaded by DefaultDiagErc
102  * Can be modified in dialog ERC
103  */
105 
114 {
115 /* I, O, Bi, 3S, Pas, UnS, PwrI, PwrO, OC, OE, NC */
116 /* I */ { OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, ERR },
117 /* O */ { OK, ERR, OK, WAR, OK, WAR, OK, ERR, ERR, ERR, ERR },
118 /* Bi*/ { OK, OK, OK, OK, OK, WAR, OK, WAR, OK, WAR, ERR },
119 /* 3S*/ { OK, WAR, OK, OK, OK, WAR, WAR, ERR, WAR, WAR, ERR },
120 /*Pas*/ { OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, ERR },
121 /*UnS */ { WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, ERR },
122 /*PwrI*/ { OK, OK, OK, WAR, OK, WAR, OK, OK, OK, OK, ERR },
123 /*PwrO*/ { OK, ERR, WAR, ERR, OK, WAR, OK, ERR, ERR, ERR, ERR },
124 /* OC */ { OK, ERR, OK, WAR, OK, WAR, OK, ERR, OK, OK, ERR },
125 /* OE */ { OK, ERR, WAR, WAR, OK, WAR, OK, ERR, OK, OK, ERR },
126 /* NC */ { ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR }
127 };
128 
129 
141 {
142 /* In Out, Bi, 3S, Pas, UnS, PwrI,PwrO,OC, OE, NC */
143 /* In*/ { NOD, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NPI },
144 /*Out*/ { DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, NPI },
145 /* Bi*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NPI },
146 /* 3S*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NPI },
147 /*Pas*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NPI },
148 /*UnS*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NPI },
149 /*PwrI*/ { NOD, DRV, NOD, NOD, NOD, NOD, NOD, DRV, NOD, NOD, NPI },
150 /*PwrO*/ { DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, NPI },
151 /* OC*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NPI },
152 /* OE*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NPI },
153 /* NC*/ { NPI, NPI, NPI, NPI, NPI, NPI, NPI, NPI, NPI, NPI, NPI }
154 };
155 
156 
157 int TestDuplicateSheetNames( bool aCreateMarker )
158 {
159  SCH_SCREEN* screen;
160  int err_count = 0;
161  SCH_SCREENS screenList; // Created the list of screen
162 
163  for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() )
164  {
165  std::vector<SCH_SHEET*> list;
166 
167  for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
168  list.push_back( static_cast<SCH_SHEET*>( item ) );
169 
170  for( size_t i = 0; i < list.size(); i++ )
171  {
172  SCH_SHEET* item = list[i];
173 
174  for( size_t j = i + 1; j < list.size(); j++ )
175  {
176  SCH_SHEET* test_item = list[j];
177 
178  // We have found a second sheet: compare names
179  // we are using case insensitive comparison to avoid mistakes between
180  // similar names like Mysheet and mysheet
181  if( item->GetName().CmpNoCase( test_item->GetName() ) == 0 )
182  {
183  if( aCreateMarker )
184  {
187  item->GetPosition(), item, test_item );
188  screen->Append( marker );
189  }
190 
191  err_count++;
192  }
193  }
194  }
195  }
196 
197  return err_count;
198 }
199 
200 
202 {
203  wxString msg;
204  int err_count = 0;
205  SCH_SCREENS screens;
206  std::vector< std::shared_ptr<BUS_ALIAS> > aliases;
207 
208  for( auto screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
209  {
210  std::unordered_set< std::shared_ptr<BUS_ALIAS> > screen_aliases = screen->GetBusAliases();
211 
212  for( const std::shared_ptr<BUS_ALIAS>& alias : screen_aliases )
213  {
214  for( const std::shared_ptr<BUS_ALIAS>& test : aliases )
215  {
216  if( alias->GetName() == test->GetName() && alias->Members() != test->Members() )
217  {
218  msg.Printf( _( "Bus alias %s has conflicting definitions on %s and %s" ),
219  alias->GetName(),
220  alias->GetParent()->GetFileName(),
221  test->GetParent()->GetFileName() );
222 
224  marker->SetData( ERCE_BUS_ALIAS_CONFLICT, wxPoint(), msg );
225  test->GetParent()->Append( marker );
226 
227  ++err_count;
228  }
229  }
230  }
231 
232  aliases.insert( aliases.end(), screen_aliases.begin(), screen_aliases.end() );
233  }
234 
235  return err_count;
236 }
237 
238 
240 {
241  int errors = 0;
242  std::map<wxString, LIB_ID> footprints;
244  aSheetList.GetMultiUnitComponents( refMap, true );
245 
246  for( auto& component : refMap )
247  {
248  auto& refList = component.second;
249 
250  if( refList.GetCount() == 0 )
251  {
252  wxFAIL; // it should not happen
253  continue;
254  }
255 
256  // Reference footprint
257  wxString fp;
258  wxString unitName;
259  KIID unitID;
260 
261  for( unsigned i = 0; i < component.second.GetCount(); ++i )
262  {
263  SCH_COMPONENT* unit = refList.GetItem( i ).GetComp();
264  SCH_SHEET_PATH sheetPath = refList.GetItem( i ).GetSheetPath();
265  fp = unit->GetField( FOOTPRINT )->GetText();
266 
267  if( !fp.IsEmpty() )
268  {
269  unitName = unit->GetRef( &sheetPath, true );
270  unitID = unit->m_Uuid;
271  break;
272  }
273  }
274 
275  for( unsigned i = 0; i < component.second.GetCount(); ++i )
276  {
277  SCH_REFERENCE& secondRef = refList.GetItem( i );
278  SCH_COMPONENT* secondUnit = secondRef.GetComp();
279  SCH_SHEET_PATH sheetPath = secondRef.GetSheetPath();
280 
281  const wxString secondFp = secondUnit->GetField( FOOTPRINT )->GetText();
282  wxString secondName = secondUnit->GetRef( &sheetPath, true );
283  KIID secondID = secondUnit->m_Uuid;
284 
285  if( !secondFp.IsEmpty() && fp != secondFp )
286  {
287  wxString description = _( "%s has '%s' assigned" );
288 
290  marker->SetData( ERCE_DIFFERENT_UNIT_FP, secondUnit->GetPosition(),
291  wxString::Format( description, unitName, fp ), unitID,
292  wxString::Format( description, secondName, secondFp ), secondID );
293  secondRef.GetSheetPath().LastScreen()->Append( marker );
294 
295  ++errors;
296  }
297  }
298  }
299 
300  return errors;
301 }
302 
303 
304 void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst, int aMinConn, int aDiag )
305 {
306  if( aDiag == OK || aMinConn < 1 || aNetItemRef->m_Type != NETLIST_ITEM::PIN )
307  return;
308 
309  SCH_PIN* pin = static_cast<SCH_PIN*>( aNetItemRef->m_Comp );
310 
311  /* Create new marker for ERC error. */
313  aNetItemRef->m_SheetPath.LastScreen()->Append( marker );
314 
315  if( aNetItemTst == NULL)
316  {
317  if( aMinConn == NOD ) /* Nothing driving the net. */
318  {
319  marker->SetData( ERCE_PIN_NOT_DRIVEN, aNetItemRef->m_Start,
320  pin->GetDescription( &aNetItemRef->m_SheetPath ), pin->m_Uuid );
321  return;
322  }
323  }
324 
325  if( aNetItemTst && aNetItemTst->m_Type == NETLIST_ITEM::PIN ) /* Error between 2 pins */
326  {
327  SCH_PIN* pinB = static_cast<SCH_PIN*>( aNetItemTst->m_Comp );
328 
330  aNetItemRef->m_Start,
331  pin->GetDescription( &aNetItemRef->m_SheetPath ), pin->m_Uuid,
332  pinB->GetDescription( &aNetItemTst->m_SheetPath ), pinB->m_Uuid );
333  }
334 }
335 
336 
337 void TestOthersItems( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef, unsigned aNetStart,
338  int* aMinConnexion )
339 {
340  unsigned netItemTst = aNetStart;
342  int erc = OK;
343 
344  /* Analysis of the table of connections. */
345  ELECTRICAL_PINTYPE ref_elect_type = aList->GetItem( aNetItemRef )->m_ElectricalPinType;
346  int local_minconn = NOC;
347 
348  if( ref_elect_type == ELECTRICAL_PINTYPE::PT_NC )
349  local_minconn = NPI;
350 
351  /* Test pins connected to NetItemRef */
352  for( ; ; netItemTst++ )
353  {
354  if( aNetItemRef == netItemTst )
355  continue;
356 
357  // We examine only a given net. We stop the search if the net changes
358  if( ( netItemTst >= aList->size() ) // End of list
359  || ( aList->GetItemNet( aNetItemRef ) !=
360  aList->GetItemNet( netItemTst ) ) ) // End of net
361  {
362  /* End net code found: minimum connection test. */
363  if( ( *aMinConnexion < NET_NC ) && ( local_minconn < NET_NC ) )
364  {
365  /* Not connected or not driven pin. */
366  bool seterr = true;
367 
368  if( local_minconn == NOC && aList->GetItemType( aNetItemRef ) == NETLIST_ITEM::PIN )
369  {
370  /* This pin is not connected: for multiple part per
371  * package, and duplicated pin,
372  * search for another instance of this pin
373  * this will be flagged only if all instances of this pin
374  * are not connected
375  * TODO test also if instances connected are connected to
376  * the same net
377  */
378  for( unsigned duplicate = 0; duplicate < aList->size(); duplicate++ )
379  {
380  if( aList->GetItemType( duplicate ) != NETLIST_ITEM::PIN )
381  continue;
382 
383  if( duplicate == aNetItemRef )
384  continue;
385 
386  if( aList->GetItem( aNetItemRef )->m_PinNum !=
387  aList->GetItem( duplicate )->m_PinNum )
388  continue;
389 
390  if( ( (SCH_COMPONENT*) aList->GetItem( aNetItemRef )->
391  m_Link )->GetRef( &aList->GetItem( aNetItemRef )-> m_SheetPath ) !=
392  ( (SCH_COMPONENT*) aList->GetItem( duplicate )->m_Link )
393  ->GetRef( &aList->GetItem( duplicate )->m_SheetPath ) )
394  continue;
395 
396  // Same component and same pin. Do dot create error for this pin
397  // if the other pin is connected (i.e. if duplicate net has another
398  // item)
399  if( (duplicate > 0)
400  && ( aList->GetItemNet( duplicate ) ==
401  aList->GetItemNet( duplicate - 1 ) ) )
402  seterr = false;
403 
404  if( (duplicate < aList->size() - 1)
405  && ( aList->GetItemNet( duplicate ) ==
406  aList->GetItemNet( duplicate + 1 ) ) )
407  seterr = false;
408  }
409  }
410 
411  if( seterr )
412  Diagnose( aList->GetItem( aNetItemRef ), NULL, local_minconn, WAR );
413 
414  *aMinConnexion = DRV; // inhibiting other messages of this
415  // type for the net.
416  }
417  return;
418  }
419 
420  switch( aList->GetItemType( netItemTst ) )
421  {
424  case NETLIST_ITEM::BUS:
426  case NETLIST_ITEM::LABEL:
435  break;
436 
438  local_minconn = std::max( NET_NC, local_minconn );
439  break;
440 
441  case NETLIST_ITEM::PIN:
442  jj = aList->GetItem( netItemTst )->m_ElectricalPinType;
443  local_minconn = std::max(
444  MinimalReq[static_cast<int>( ref_elect_type )][static_cast<int>( jj )],
445  local_minconn );
446 
447  if( netItemTst <= aNetItemRef )
448  break;
449 
450  if( erc == OK )
451  {
452  erc = PinMap[static_cast<int>( ref_elect_type )][static_cast<int>( jj )];
453 
454  if( erc != OK )
455  {
456  if( aList->GetConnectionType( netItemTst ) == NET_CONNECTION::UNCONNECTED )
457  {
458  Diagnose( aList->GetItem( aNetItemRef ), aList->GetItem( netItemTst ),
459  0, erc );
460  aList->SetConnectionType( netItemTst,
462  }
463  }
464  }
465 
466  break;
467  }
468  }
469 }
470 
471 // this code try to detect similar labels, i.e. labels which are identical
472 // when they are compared using case insensitive coparisons.
473 
474 
475 // A helper struct to compare NETLIST_OBJECT items by sheetpath and label texts
476 // for a std::set<NETLIST_OBJECT*> container
477 // the full text is "sheetpath+label" for local labels and "label" for global labels
479 {
480  bool operator() ( const NETLIST_OBJECT* lab1, const NETLIST_OBJECT* lab2 ) const
481  {
482  wxString str1 = lab1->m_SheetPath.PathAsString() + lab1->m_Label;
483  wxString str2 = lab2->m_SheetPath.PathAsString() + lab2->m_Label;
484 
485  return str1.Cmp( str2 ) < 0;
486  }
487 };
488 
490 {
491  bool operator() ( const NETLIST_OBJECT* lab1, const NETLIST_OBJECT* lab2 ) const
492  {
493  return lab1->m_Label.Cmp( lab2->m_Label ) < 0;
494  }
495 };
496 
498 {
499  bool operator() ( const NETLIST_OBJECT* lab1, const NETLIST_OBJECT* lab2 ) const
500  {
501  return lab1->m_SheetPath.Path() < lab2->m_SheetPath.Path();
502  }
503 };
504 
505 // Helper functions to build the warning messages about Similar Labels:
506 static int countIndenticalLabels( std::vector<NETLIST_OBJECT*>& aList, NETLIST_OBJECT* aRef );
507 static void SimilarLabelsDiagnose( NETLIST_OBJECT* aItemA, NETLIST_OBJECT* aItemB );
508 
509 
511 {
512  // Similar labels which are different when using case sensitive comparisons
513  // but are equal when using case insensitive comparisons
514 
515  // list of all labels (used the better item to build diag messages)
516  std::vector<NETLIST_OBJECT*> fullLabelList;
517  // list of all labels , each label appears only once (used to to detect similar labels)
518  std::set<NETLIST_OBJECT*, compare_labels> uniqueLabelList;
519  wxString msg;
520 
521  // Build a list of differents labels. If inside a given sheet there are
522  // more than one given label, only one label is stored.
523  // not also the sheet labels are not taken in account for 2 reasons:
524  // * they are in the root sheet but they are seen only from the child sheet
525  // * any mismatch between child sheet hierarchical labels and the sheet label
526  // already detected by ERC
527  for( unsigned netItem = 0; netItem < size(); ++netItem )
528  {
529  switch( GetItemType( netItem ) )
530  {
531  case NETLIST_ITEM::LABEL:
538  // add this label in lists
539  uniqueLabelList.insert( GetItem( netItem ) );
540  fullLabelList.push_back( GetItem( netItem ) );
541  break;
542 
545  default:
546  break;
547  }
548  }
549 
550  // build global labels and compare
551  std::set<NETLIST_OBJECT*, compare_label_names> loc_labelList;
552 
553  for( auto it = uniqueLabelList.begin(); it != uniqueLabelList.end(); ++it )
554  {
555  if( (*it)->IsLabelGlobal() )
556  loc_labelList.insert( *it );
557  }
558 
559  // compare global labels (same label names appears only once in list)
560  for( auto it = loc_labelList.begin(); it != loc_labelList.end(); ++it )
561  {
562  auto it_aux = it;
563 
564  for( ++it_aux; it_aux != loc_labelList.end(); ++it_aux )
565  {
566  if( (*it)->m_Label.CmpNoCase( (*it_aux)->m_Label ) == 0 )
567  {
568  // Create new marker for ERC.
569  int cntA = countIndenticalLabels( fullLabelList, *it );
570  int cntB = countIndenticalLabels( fullLabelList, *it_aux );
571 
572  if( cntA <= cntB )
573  SimilarLabelsDiagnose( (*it), (*it_aux) );
574  else
575  SimilarLabelsDiagnose( (*it_aux), (*it) );
576  }
577  }
578  }
579 
580  // Build paths list
581  std::set<NETLIST_OBJECT*, compare_paths> pathsList;
582 
583  for( NETLIST_OBJECT* label : uniqueLabelList )
584  pathsList.insert( label );
585 
586  // Examine each label inside a sheet path:
587  for( NETLIST_OBJECT* candidate : pathsList )
588  {
589  loc_labelList.clear();
590 
591  for( NETLIST_OBJECT* uniqueLabel : uniqueLabelList)
592  {
593  if( candidate->m_SheetPath.Path() == uniqueLabel->m_SheetPath.Path() )
594  loc_labelList.insert( uniqueLabel );
595  }
596 
597  // at this point, loc_labelList contains labels of the current sheet path.
598  // Detect similar labels (same label names appears only once in list)
599 
600  for( auto ref_it = loc_labelList.begin(); ref_it != loc_labelList.end(); ++ref_it )
601  {
602  NETLIST_OBJECT* ref_item = *ref_it;
603  auto it_aux = ref_it;
604 
605  for( ++it_aux; it_aux != loc_labelList.end(); ++it_aux )
606  {
607  // global label versus global label was already examined.
608  // here, at least one label must be local
609  if( ref_item->IsLabelGlobal() && ( *it_aux )->IsLabelGlobal() )
610  continue;
611 
612  if( ref_item->m_Label.CmpNoCase( ( *it_aux )->m_Label ) == 0 )
613  {
614  // Create new marker for ERC.
615  int cntA = countIndenticalLabels( fullLabelList, ref_item );
616  int cntB = countIndenticalLabels( fullLabelList, *it_aux );
617 
618  if( cntA <= cntB )
619  SimilarLabelsDiagnose( ref_item, ( *it_aux ) );
620  else
621  SimilarLabelsDiagnose( ( *it_aux ), ref_item );
622  }
623  }
624  }
625  }
626 }
627 
628 
629 // Helper function: count the number of labels identical to aLabel
630 // for global label: global labels in the full project
631 // for local label: all labels in the current sheet
632 static int countIndenticalLabels( std::vector<NETLIST_OBJECT*>& aList, NETLIST_OBJECT* aRef )
633 {
634  int count = 0;
635 
636  if( aRef->IsLabelGlobal() )
637  {
638  for( auto i : aList)
639  {
640  if( i->IsLabelGlobal() && i->m_Label == aRef->m_Label )
641  count++;
642  }
643  }
644  else
645  {
646  for( auto i : aList)
647  {
648  if( i->m_Label == aRef->m_Label && i->m_SheetPath.Path() == aRef->m_SheetPath.Path() )
649  count++;
650  }
651  }
652 
653  return count;
654 }
655 
656 
657 // Helper function: creates a marker for similar labels ERC warning
658 static void SimilarLabelsDiagnose( NETLIST_OBJECT* aItemA, NETLIST_OBJECT* aItemB )
659 {
660  // Create new marker for ERC.
663  aItemA->m_Comp, aItemB->m_Comp );
664  aItemA->m_SheetPath.LastScreen()->Append( marker );
665 }
SCH_SHEET_LIST.
static int countIndenticalLabels(std::vector< NETLIST_OBJECT * > &aList, NETLIST_OBJECT *aRef)
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
Definition: erc.h:43
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...
const SCH_SHEET_PATH & GetSheetPath() const
const wxString CommentERC_V[]
const wxString CommentERC_H[]
int DefaultPinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
Default Look up table which gives the ERC error level for a pair of connected pins Same as DiagErc,...
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCH_COMPONENT * GetComp() const
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
wxString GetDescription(const SCH_SHEET_PATH *aSheet)
Definition: sch_pin.cpp:84
wxString PathAsString() const
Function PathAsString the path uses the time stamps which do not changes even when editing sheet para...
SCH_SHEET_PATH m_SheetPath
ELECTRICAL_PINTYPE m_ElectricalPinType
int GetItemNet(unsigned aIdx) const
Acces to an item net code.
EDA_ITEM * m_Comp
Field Name Module PCB, i.e. "16DIP300".
bool IsLabelGlobal() const
Function IsLabelGlobal.
NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected items in a...
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
#define DRV
Definition: erc.h:80
Definition: erc.h:42
int TestConflictingBusAliases()
Checks that there are not conflicting bus alias definitions in the schematic.
Definition: common.h:65
bool operator()(const NETLIST_OBJECT *lab1, const NETLIST_OBJECT *lab2) const
Definition: erc.h:44
bool operator()(const NETLIST_OBJECT *lab1, const NETLIST_OBJECT *lab2) const
void TestforSimilarLabels()
Function TestforSimilarLabels detects labels which are different when using case sensitive comparison...
wxString GetName() const
Definition: sch_sheet.h:280
#define NULL
int TestDuplicateSheetNames(bool aCreateMarker)
Function TestDuplicateSheetNames( ) inside a given sheet, one cannot have sheets with duplicate names...
SCH_SHEET_PATH.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false)
Return the reference for the given sheet path.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:565
NETLIST_ITEM GetItemType(unsigned aIdx) const
Acces to an item type.
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Type SCH_MULTI_UNIT_REFERENCE_MAP is used to create a map of reference designators for multi-unit par...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:215
void GetMultiUnitComponents(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true)
Function GetMultiUnitComponents adds a SCH_REFERENCE_LIST object to aRefList for each same-reference ...
const KIID m_Uuid
Definition: base_struct.h:169
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
#define NOC
Definition: erc.h:83
SCH_SCREEN * LastScreen()
Function LastScreen.
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
ELECTRICAL_PINTYPE
The component library pin object electrical types used in ERC tests.
Definition: pin_type.h:37
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:175
#define _(s)
Definition: 3d_actions.cpp:33
#define NPI
Definition: erc.h:79
EE_RTREE & Items()
Definition: sch_screen.h:127
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
wxPoint GetPosition() const override
Function GetPosition.
void SetConnectionType(unsigned aIdx, NET_CONNECTION aFlg=NET_CONNECTION::UNCONNECTED)
Set the item connection type: UNCONNECTED Pin or Label not connected (error) NOCONNECT_SYMBOL_PRESENT...
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 s...
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959
NET_CONNECTION GetConnectionType(unsigned aIdx)
#define NET_NC
Definition: erc.h:81
#define ELECTRICAL_PINTYPES_TOTAL
Definition: pin_type.h:54
void SetData(EDA_UNITS aUnits, int aErrorCode, const wxPoint &aMarkerPos, EDA_ITEM *aItem, const wxPoint &aPos, EDA_ITEM *bItem=nullptr, const wxPoint &bPos=wxPoint())
Function SetData fills in all the reportable data associated with a MARKER.
Definition: marker_base.cpp:91
not connected (must be left open)
Definition of the NETLIST_OBJECT class.
NETLIST_ITEM m_Type
int TestMultiunitFootprints(SCH_SHEET_LIST &aSheetList)
Test if all units of each multiunit component have the same footprint assigned.
SCH_ITEM * m_Link
bool operator()(const NETLIST_OBJECT *lab1, const NETLIST_OBJECT *lab2) const
int PinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
static int MinimalReq[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
Look up table which gives the minimal drive for a pair of connected pins on a net.
SCH_REFERENCE is used as a helper to define a component's reference designator in a schematic.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491
#define NOD
Definition: erc.h:82
static void SimilarLabelsDiagnose(NETLIST_OBJECT *aItemA, NETLIST_OBJECT *aItemB)