KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 Wayne Stambaugh <[email protected]>
6 * Copyright The 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
26#include <algorithm>
27#include <numeric>
28#include <set>
29
30#include "connection_graph.h"
31#include "kiface_ids.h"
32#include <advanced_config.h>
33#include <common.h> // for ExpandEnvVarSubstitutions
34#include <erc/erc.h>
37#include <string_utils.h>
38#include <sch_pin.h>
39#include <project_sch.h>
42#include <sch_bus_entry.h>
43#include <sch_edit_frame.h>
44#include <sch_marker.h>
45#include <sch_reference_list.h>
46#include <sch_rule_area.h>
47#include <sch_sheet.h>
48#include <sch_sheet_pin.h>
49#include <sch_pin.h>
50#include <sch_textbox.h>
51#include <sch_line.h>
52#include <schematic.h>
55#include <vector>
56#include <wx/ffile.h>
57#include <sim/sim_lib_mgr.h>
58#include <progress_reporter.h>
59#include <kiway.h>
60#include <pgm_base.h>
62
63
64/* ERC tests :
65 * 1 - conflicts between connected pins ( example: 2 connected outputs )
66 * 2 - minimal connections requirements ( 1 input *must* be connected to an
67 * output, or a passive pin )
68 */
69
70/*
71 * Minimal ERC requirements:
72 * All pins *must* be connected (except ELECTRICAL_PINTYPE::PT_NC).
73 * When a pin is not connected in schematic, the user must place a "non
74 * connected" symbol to this pin.
75 * This ensures a forgotten connection will be detected.
76 */
77
78// Messages for matrix rows:
79const wxString CommentERC_H[] =
80{
81 _( "Input Pin" ),
82 _( "Output Pin" ),
83 _( "Bidirectional Pin" ),
84 _( "Tri-State Pin" ),
85 _( "Passive Pin" ),
86 _( "Free Pin" ),
87 _( "Unspecified Pin" ),
88 _( "Power Input Pin" ),
89 _( "Power Output Pin" ),
90 _( "Open Collector" ),
91 _( "Open Emitter" ),
92 _( "No Connection" )
93};
94
95// Messages for matrix columns
96const wxString CommentERC_V[] =
97{
98 _( "Input Pin" ),
99 _( "Output Pin" ),
100 _( "Bidirectional Pin" ),
101 _( "Tri-State Pin" ),
102 _( "Passive Pin" ),
103 _( "Free Pin" ),
104 _( "Unspecified Pin" ),
105 _( "Power Input Pin" ),
106 _( "Power Output Pin" ),
107 _( "Open Collector" ),
108 _( "Open Emitter" ),
109 _( "No Connection" )
110};
111
112
113// List of pin types that are considered drivers for usual input pins
114// i.e. pin type = ELECTRICAL_PINTYPE::PT_INPUT, but not PT_POWER_IN
115// that need only a PT_POWER_OUT pin type to be driven
124
125// List of pin types that are considered drivers for power pins
126// In fact only a ELECTRICAL_PINTYPE::PT_POWER_OUT pin type can drive
127// power input pins
128const std::set<ELECTRICAL_PINTYPE> DrivingPowerPinTypes =
129{
131};
132
133// List of pin types that require a driver elsewhere on the net
134const std::set<ELECTRICAL_PINTYPE> DrivenPinTypes =
135{
138};
139
140extern void CheckDuplicatePins( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
141 UNITS_PROVIDER* aUnitsProvider );
142
143int ERC_TESTER::TestDuplicateSheetNames( bool aCreateMarker )
144{
145 int err_count = 0;
146
147 for( SCH_SCREEN* screen = m_screens.GetFirst(); screen; screen = m_screens.GetNext() )
148 {
149 std::vector<SCH_SHEET*> list;
150
151 for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
152 list.push_back( static_cast<SCH_SHEET*>( item ) );
153
154 for( size_t i = 0; i < list.size(); i++ )
155 {
156 SCH_SHEET* sheet = list[i];
157
158 for( size_t j = i + 1; j < list.size(); j++ )
159 {
160 SCH_SHEET* test_item = list[j];
161
162 // We have found a second sheet: compare names
163 // we are using case insensitive comparison to avoid mistakes between
164 // similar names like Mysheet and mysheet
165 if( sheet->GetShownName( false ).IsSameAs( test_item->GetShownName( false ), false ) )
166 {
167 if( aCreateMarker )
168 {
170 ercItem->SetItems( sheet, test_item );
171
172 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), sheet->GetPosition() );
173 screen->Append( marker );
174 }
175
176 err_count++;
177 }
178 }
179 }
180 }
181
182 return err_count;
183}
184
185
187{
189
190 auto unresolved =
191 [this]( wxString str )
192 {
193 str = ExpandEnvVarSubstitutions( str, &m_schematic->Project() );
194 return str.Matches( wxS( "*${*}*" ) );
195 };
196
197 auto testAssertion =
198 []( const SCH_ITEM* item, const SCH_SHEET_PATH& sheet, SCH_SCREEN* screen,
199 const wxString& text, const VECTOR2I& pos )
200 {
201 static wxRegEx warningExpr( wxS( "^\\$\\{ERC_WARNING\\s*([^}]*)\\}(.*)$" ) );
202 static wxRegEx errorExpr( wxS( "^\\$\\{ERC_ERROR\\s*([^}]*)\\}(.*)$" ) );
203
204 if( warningExpr.Matches( text ) )
205 {
206 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_GENERIC_WARNING );
207 wxString ercText = warningExpr.GetMatch( text, 1 );
208
209 if( item )
210 ercItem->SetItems( item );
211 else
212 ercText += _( " (in drawing sheet)" );
213
214 ercItem->SetSheetSpecificPath( sheet );
215 ercItem->SetErrorMessage( ercText );
216
217 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pos );
218 screen->Append( marker );
219
220 return true;
221 }
222
223 if( errorExpr.Matches( text ) )
224 {
225 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_GENERIC_ERROR );
226 wxString ercText = errorExpr.GetMatch( text, 1 );
227
228 if( item )
229 ercItem->SetItems( item );
230 else
231 ercText += _( " (in drawing sheet)" );
232
233 ercItem->SetSheetSpecificPath( sheet );
234 ercItem->SetErrorMessage( ercText );
235
236 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pos );
237 screen->Append( marker );
238
239 return true;
240 }
241
242 return false;
243 };
244
245 if( aDrawingSheet )
246 {
247 wsItems.SetPageNumber( wxS( "1" ) );
248 wsItems.SetSheetCount( 1 );
249 wsItems.SetFileName( wxS( "dummyFilename" ) );
250 wsItems.SetSheetName( wxS( "dummySheet" ) );
251 wsItems.SetSheetLayer( wxS( "dummyLayer" ) );
252 wsItems.SetProject( &m_schematic->Project() );
253 wsItems.BuildDrawItemsList( aDrawingSheet->GetPageInfo(), aDrawingSheet->GetTitleBlock() );
254 }
255
256 for( const SCH_SHEET_PATH& sheet : m_sheetList )
257 {
258 SCH_SCREEN* screen = sheet.LastScreen();
259
260 for( SCH_ITEM* item : screen->Items().OfType( SCH_LOCATE_ANY_T ) )
261 {
262 if( item->Type() == SCH_SYMBOL_T )
263 {
264 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
265
266 for( SCH_FIELD& field : symbol->GetFields() )
267 {
268 if( unresolved( field.GetShownText( &sheet, true ) ) )
269 {
271 ercItem->SetItems( symbol );
272 ercItem->SetSheetSpecificPath( sheet );
273
274 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), field.GetPosition() );
275 screen->Append( marker );
276 }
277
278 testAssertion( &field, sheet, screen, field.GetText(), field.GetPosition() );
279 }
280
281 if( symbol->GetLibSymbolRef() )
282 {
284 [&]( SCH_ITEM* child )
285 {
286 if( child->Type() == SCH_FIELD_T )
287 {
288 // test only SCH_SYMBOL fields, not LIB_SYMBOL fields
289 }
290 else if( child->Type() == SCH_TEXT_T )
291 {
292 SCH_TEXT* textItem = static_cast<SCH_TEXT*>( child );
293
294 if( unresolved( textItem->GetShownText( &sheet, true ) ) )
295 {
297 ercItem->SetItems( symbol );
298 ercItem->SetSheetSpecificPath( sheet );
299
300 BOX2I bbox = textItem->GetBoundingBox();
301 bbox = symbol->GetTransform().TransformCoordinate( bbox );
302 VECTOR2I pos = bbox.Centre() + symbol->GetPosition();
303
304 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pos );
305 screen->Append( marker );
306 }
307
308 testAssertion( symbol, sheet, screen, textItem->GetText(),
309 textItem->GetPosition() );
310 }
311 else if( child->Type() == SCH_TEXTBOX_T )
312 {
313 SCH_TEXTBOX* textboxItem = static_cast<SCH_TEXTBOX*>( child );
314
315 if( unresolved( textboxItem->GetShownText( nullptr, &sheet, true ) ) )
316 {
318 ercItem->SetItems( symbol );
319 ercItem->SetSheetSpecificPath( sheet );
320
321 BOX2I bbox = textboxItem->GetBoundingBox();
322 bbox = symbol->GetTransform().TransformCoordinate( bbox );
323 VECTOR2I pos = bbox.Centre() + symbol->GetPosition();
324
325 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pos );
326 screen->Append( marker );
327 }
328
329 testAssertion( symbol, sheet, screen, textboxItem->GetText(),
330 textboxItem->GetPosition() );
331 }
332 },
334 }
335 }
336 else if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item ) )
337 {
338 for( SCH_FIELD& field : label->GetFields() )
339 {
340 if( unresolved( field.GetShownText( &sheet, true ) ) )
341 {
343 ercItem->SetItems( label );
344 ercItem->SetSheetSpecificPath( sheet );
345
346 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), field.GetPosition() );
347 screen->Append( marker );
348 }
349
350 testAssertion( &field, sheet, screen, field.GetText(), field.GetPosition() );
351 }
352 }
353 else if( item->Type() == SCH_SHEET_T )
354 {
355 SCH_SHEET* subSheet = static_cast<SCH_SHEET*>( item );
356
357 for( SCH_FIELD& field : subSheet->GetFields() )
358 {
359 if( unresolved( field.GetShownText( &sheet, true ) ) )
360 {
362 ercItem->SetItems( subSheet );
363 ercItem->SetSheetSpecificPath( sheet );
364
365 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), field.GetPosition() );
366 screen->Append( marker );
367 }
368
369 testAssertion( &field, sheet, screen, field.GetText(), field.GetPosition() );
370 }
371
372 SCH_SHEET_PATH subSheetPath = sheet;
373 subSheetPath.push_back( subSheet );
374
375 for( SCH_SHEET_PIN* pin : subSheet->GetPins() )
376 {
377 if( pin->GetShownText( &subSheetPath, true ).Matches( wxS( "*${*}*" ) ) )
378 {
380 ercItem->SetItems( pin );
381 ercItem->SetSheetSpecificPath( sheet );
382
383 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
384 screen->Append( marker );
385 }
386 }
387 }
388 else if( SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( item ) )
389 {
390 if( text->GetShownText( &sheet, true ).Matches( wxS( "*${*}*" ) ) )
391 {
393 ercItem->SetItems( text );
394 ercItem->SetSheetSpecificPath( sheet );
395
396 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), text->GetPosition() );
397 screen->Append( marker );
398 }
399
400 testAssertion( text, sheet, screen, text->GetText(), text->GetPosition() );
401 }
402 else if( SCH_TEXTBOX* textBox = dynamic_cast<SCH_TEXTBOX*>( item ) )
403 {
404 if( textBox->GetShownText( nullptr, &sheet, true ).Matches( wxS( "*${*}*" ) ) )
405 {
407 ercItem->SetItems( textBox );
408 ercItem->SetSheetSpecificPath( sheet );
409
410 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), textBox->GetPosition() );
411 screen->Append( marker );
412 }
413
414 testAssertion( textBox, sheet, screen, textBox->GetText(), textBox->GetPosition() );
415 }
416 }
417
418 for( DS_DRAW_ITEM_BASE* item = wsItems.GetFirst(); item; item = wsItems.GetNext() )
419 {
420 if( DS_DRAW_ITEM_TEXT* text = dynamic_cast<DS_DRAW_ITEM_TEXT*>( item ) )
421 {
422 if( testAssertion( nullptr, sheet, screen, text->GetText(), text->GetPosition() ) )
423 {
424 // Don't run unresolved test
425 }
426 else if( text->GetShownText( true ).Matches( wxS( "*${*}*" ) ) )
427 {
428 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
429 ercItem->SetErrorMessage( _( "Unresolved text variable in drawing sheet" ) );
430 ercItem->SetSheetSpecificPath( sheet );
431
432 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), text->GetPosition() );
433 screen->Append( marker );
434 }
435 }
436 }
437 }
438}
439
440
442{
443 int warnings = 0;
444
445 for( const SCH_SHEET_PATH& sheet : m_sheetList )
446 {
447 SCH_SCREEN* screen = sheet.LastScreen();
448
449 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
450 {
451 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
452
453 for( SCH_FIELD& field : symbol->GetFields() )
454 {
455 wxString trimmedFieldName = field.GetName();
456 trimmedFieldName.Trim();
457 trimmedFieldName.Trim( false );
458
459 if( field.GetName() != trimmedFieldName )
460 {
462 ercItem->SetItems( symbol, &field );
463 ercItem->SetItemsSheetPaths( sheet, sheet );
464 ercItem->SetSheetSpecificPath( sheet );
465 ercItem->SetErrorMessage(
466 wxString::Format(
467 _( "Field name has leading or trailing whitespace: '%s'" ),
468 field.GetName() ) );
469
470 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), field.GetPosition() );
471 screen->Append( marker );
472 warnings++;
473 }
474 }
475 }
476
477 for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
478 {
479 SCH_SHEET* subSheet = static_cast<SCH_SHEET*>( item );
480
481 for( SCH_FIELD& field : subSheet->GetFields() )
482 {
483 wxString trimmedFieldName = field.GetName();
484 trimmedFieldName.Trim();
485 trimmedFieldName.Trim( false );
486
487 if( field.GetName() != trimmedFieldName )
488 {
490 ercItem->SetItems( subSheet, &field );
491 ercItem->SetItemsSheetPaths( sheet, sheet );
492 ercItem->SetSheetSpecificPath( sheet );
493 ercItem->SetErrorMessage(
494 wxString::Format(
495 _( "Field name has leading or trailing whitespace: '%s'" ),
496 field.GetName() ) );
497
498 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), field.GetPosition() );
499 screen->Append( marker );
500 warnings++;
501 }
502 }
503 }
504 }
505
506 return warnings;
507}
508
509
511{
512 int errors = 0;
513
514 for( std::pair<const wxString, SCH_REFERENCE_LIST>& symbol : m_refMap )
515 {
516 SCH_REFERENCE_LIST& refList = symbol.second;
517
518 if( refList.GetCount() == 0 )
519 {
520 wxFAIL; // it should not happen
521 continue;
522 }
523
524 // Reference footprint
525 SCH_SYMBOL* unit = nullptr;
526 wxString unitName;
527 wxString unitFP;
528
529 for( size_t ii = 0; ii < refList.GetCount(); ++ii )
530 {
531 SCH_SHEET_PATH sheetPath = refList.GetItem( ii ).GetSheetPath();
532 unitFP = refList.GetItem( ii ).GetFootprint();
533
534 if( !unitFP.IsEmpty() )
535 {
536 unit = refList.GetItem( ii ).GetSymbol();
537 unitName = unit->GetRef( &sheetPath, true );
538 break;
539 }
540 }
541
542 for( size_t ii = 0; ii < refList.GetCount(); ++ii )
543 {
544 SCH_REFERENCE& secondRef = refList.GetItem( ii );
545 SCH_SYMBOL* secondUnit = secondRef.GetSymbol();
546 wxString secondName = secondUnit->GetRef( &secondRef.GetSheetPath(), true );
547 const wxString secondFp = secondRef.GetFootprint();
548 wxString msg;
549
550 if( unit && !secondFp.IsEmpty() && unitFP != secondFp )
551 {
552 msg.Printf( _( "Different footprints assigned to %s and %s" ),
553 unitName, secondName );
554
555 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_FP );
556 ercItem->SetErrorMessage( msg );
557 ercItem->SetItems( unit, secondUnit );
558
559 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), secondUnit->GetPosition() );
560 secondRef.GetSheetPath().LastScreen()->Append( marker );
561
562 ++errors;
563 }
564 }
565 }
566
567 return errors;
568}
569
570
572{
573 int errors = 0;
574
575 for( std::pair<const wxString, SCH_REFERENCE_LIST>& symbol : m_refMap )
576 {
577 SCH_REFERENCE_LIST& refList = symbol.second;
578
579 wxCHECK2( refList.GetCount(), continue );
580
581 // Reference unit
582 SCH_REFERENCE& base_ref = refList.GetItem( 0 );
583 SCH_SYMBOL* unit = base_ref.GetSymbol();
584 LIB_SYMBOL* libSymbol = base_ref.GetLibPart();
585
586 if( static_cast<ssize_t>( refList.GetCount() ) == libSymbol->GetUnitCount() )
587 continue;
588
589 std::set<int> lib_units;
590 std::set<int> instance_units;
591 std::set<int> missing_units;
592
593 auto report =
594 [&]( std::set<int>& aMissingUnits, const wxString& aErrorMsg, int aErrorCode )
595 {
596 wxString msg;
597 wxString missing_pin_units = wxS( "[ " );
598 int ii = 0;
599
600 for( int missing_unit : aMissingUnits )
601 {
602 if( ii++ == 3 )
603 {
604 missing_pin_units += wxS( "..." );
605 break;
606 }
607
608 missing_pin_units += libSymbol->GetUnitDisplayName( missing_unit, false ) + ", " ;
609 }
610
611 missing_pin_units.Truncate( missing_pin_units.length() - 2 );
612 missing_pin_units += wxS( " ]" );
613
614 msg.Printf( aErrorMsg, symbol.first, missing_pin_units );
615
616 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( aErrorCode );
617 ercItem->SetErrorMessage( msg );
618 ercItem->SetItems( unit );
619 ercItem->SetSheetSpecificPath( base_ref.GetSheetPath() );
620 ercItem->SetItemsSheetPaths( base_ref.GetSheetPath() );
621
622 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), unit->GetPosition() );
623 base_ref.GetSheetPath().LastScreen()->Append( marker );
624
625 ++errors;
626 };
627
628 for( int ii = 1; ii <= libSymbol->GetUnitCount(); ++ii )
629 lib_units.insert( lib_units.end(), ii );
630
631 for( size_t ii = 0; ii < refList.GetCount(); ++ii )
632 instance_units.insert( instance_units.end(), refList.GetItem( ii ).GetUnit() );
633
634 std::set_difference( lib_units.begin(), lib_units.end(),
635 instance_units.begin(), instance_units.end(),
636 std::inserter( missing_units, missing_units.begin() ) );
637
638 if( !missing_units.empty() && m_settings.IsTestEnabled( ERCE_MISSING_UNIT ) )
639 {
640 report( missing_units, _( "Symbol %s has unplaced units %s" ), ERCE_MISSING_UNIT );
641 }
642
643 std::set<int> missing_power;
644 std::set<int> missing_input;
645 std::set<int> missing_bidi;
646
647 for( int missing_unit : missing_units )
648 {
649 int bodyStyle = 0;
650
651 for( size_t ii = 0; ii < refList.GetCount(); ++ii )
652 {
653 if( refList.GetItem( ii ).GetUnit() == missing_unit )
654 {
655 bodyStyle = refList.GetItem( ii ).GetSymbol()->GetBodyStyle();
656 break;
657 }
658 }
659
660 for( SCH_PIN* pin : libSymbol->GetGraphicalPins( missing_unit, bodyStyle ) )
661 {
662 switch( pin->GetType() )
663 {
665 missing_power.insert( missing_unit );
666 break;
667
669 missing_bidi.insert( missing_unit );
670 break;
671
673 missing_input.insert( missing_unit );
674 break;
675
676 default:
677 break;
678 }
679 }
680 }
681
682 if( !missing_power.empty() && m_settings.IsTestEnabled( ERCE_MISSING_POWER_INPUT_PIN ) )
683 {
684 report( missing_power, _( "Symbol %s has input power pins in units %s that are not placed" ),
686 }
687
688 if( !missing_input.empty() && m_settings.IsTestEnabled( ERCE_MISSING_INPUT_PIN ) )
689 {
690 report( missing_input, _( "Symbol %s has input pins in units %s that are not placed" ),
692 }
693
694 if( !missing_bidi.empty() && m_settings.IsTestEnabled( ERCE_MISSING_BIDI_PIN ) )
695 {
696 report( missing_bidi, _( "Symbol %s has bidirectional pins in units %s that are not placed" ),
698 }
699 }
700
701 return errors;
702}
703
704
706{
707 int err_count = 0;
708 std::shared_ptr<NET_SETTINGS>& settings = m_schematic->Project().GetProjectFile().NetSettings();
709 wxString defaultNetclass = settings->GetDefaultNetclass()->GetName();
710
711 auto logError =
712 [&]( const SCH_SHEET_PATH& sheet, SCH_ITEM* item, const wxString& netclass )
713 {
714 err_count++;
715
716 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNDEFINED_NETCLASS );
717
718 ercItem->SetItems( item );
719 ercItem->SetErrorMessage( wxString::Format( _( "Netclass %s is not defined" ), netclass ) );
720
721 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), item->GetPosition() );
722 sheet.LastScreen()->Append( marker );
723 };
724
725 for( const SCH_SHEET_PATH& sheet : m_sheetList )
726 {
727 for( SCH_ITEM* item : sheet.LastScreen()->Items() )
728 {
729 item->RunOnChildren(
730 [&]( SCH_ITEM* aChild )
731 {
732 if( aChild->Type() == SCH_FIELD_T )
733 {
734 SCH_FIELD* field = static_cast<SCH_FIELD*>( aChild );
735
736 if( field->GetCanonicalName() == wxT( "Netclass" ) )
737 {
738 wxString netclass = field->GetShownText( &sheet, false );
739
740 if( !netclass.empty() && !netclass.IsSameAs( defaultNetclass )
741 && !settings->HasNetclass( netclass ) )
742 {
743 logError( sheet, item, netclass );
744 }
745 }
746 }
747
748 return true;
749 },
751 }
752 }
753
754 return err_count;
755}
756
757
759{
760 int err_count = 0;
761
762 for( const SCH_SHEET_PATH& sheet : m_sheetList )
763 {
764 std::map<VECTOR2I, std::vector<SCH_ITEM*>> connMap;
765
766 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_LABEL_T ) )
767 {
768 SCH_LABEL* label = static_cast<SCH_LABEL*>( item );
769
770 for( const VECTOR2I& pt : label->GetConnectionPoints() )
771 connMap[pt].emplace_back( label );
772 }
773
774 for( const std::pair<const VECTOR2I, std::vector<SCH_ITEM*>>& pair : connMap )
775 {
776 std::vector<SCH_ITEM*> lines;
777
778 for( SCH_ITEM* item : sheet.LastScreen()->Items().Overlapping( SCH_LINE_T, pair.first ) )
779 {
780 SCH_LINE* line = static_cast<SCH_LINE*>( item );
781
782 if( line->IsGraphicLine() )
783 continue;
784
785 // If the line is connected at the endpoint, then there will be a junction
786 if( !line->IsEndPoint( pair.first ) )
787 lines.emplace_back( line );
788 }
789
790 if( lines.size() > 1 )
791 {
792 err_count++;
793 lines.resize( 3 ); // Only show the first 3 lines and if there are only two, adds a nullptr
794
795 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LABEL_MULTIPLE_WIRES );
796 wxString msg = wxString::Format( _( "Label connects more than one wire at %d, %d" ),
797 pair.first.x, pair.first.y );
798
799 ercItem->SetItems( pair.second.front(), lines[0], lines[1], lines[2] );
800 ercItem->SetErrorMessage( msg );
801 ercItem->SetSheetSpecificPath( sheet );
802
803 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pair.first );
804 sheet.LastScreen()->Append( marker );
805 }
806 }
807 }
808
809 return err_count;
810}
811
812
814{
815 int err_count = 0;
816
817 auto pinStackAlreadyRepresented =
818 []( SCH_PIN* pin, std::vector<SCH_ITEM*>& collection ) -> bool
819 {
820 for( SCH_ITEM*& item : collection )
821 {
822 if( item->Type() == SCH_PIN_T && item->GetParentSymbol() == pin->GetParentSymbol() )
823 {
824 if( pin->IsVisible() && !static_cast<SCH_PIN*>( item )->IsVisible() )
825 item = pin;
826
827 return true;
828 }
829 }
830
831 return false;
832 };
833
834 for( const SCH_SHEET_PATH& sheet : m_sheetList )
835 {
836 std::map<VECTOR2I, std::vector<SCH_ITEM*>> connMap;
837 SCH_SCREEN* screen = sheet.LastScreen();
838
839 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
840 {
841 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
842
843 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
844 {
845 std::vector<SCH_ITEM*>& entry = connMap[pin->GetPosition()];
846
847 // Only one pin per pin-stack.
848 if( pinStackAlreadyRepresented( pin, entry ) )
849 continue;
850
851 entry.emplace_back( pin );
852 }
853 }
854
855 for( SCH_ITEM* item : screen->Items().OfType( SCH_LINE_T ) )
856 {
857 SCH_LINE* line = static_cast<SCH_LINE*>( item );
858
859 if( line->IsGraphicLine() )
860 continue;
861
862 for( const VECTOR2I& pt : line->GetConnectionPoints() )
863 connMap[pt].emplace_back( line );
864 }
865
866 for( const std::pair<const VECTOR2I, std::vector<SCH_ITEM*>>& pair : connMap )
867 {
868 if( pair.second.size() >= 4 )
869 {
870 err_count++;
871
872 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOUR_WAY_JUNCTION );
873
874 ercItem->SetItems( pair.second[0], pair.second[1], pair.second[2], pair.second[3] );
875
876 wxString msg = wxString::Format( _( "Four items connected at %d, %d" ),
877 pair.first.x, pair.first.y );
878 ercItem->SetErrorMessage( msg );
879
880 ercItem->SetSheetSpecificPath( sheet );
881
882 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pair.first );
883 sheet.LastScreen()->Append( marker );
884 }
885 }
886 }
887
888 return err_count;
889}
890
891
893{
894 int err_count = 0;
895
896 for( const SCH_SHEET_PATH& sheet : m_sheetList )
897 {
898 std::map<VECTOR2I, std::vector<SCH_ITEM*>> pinMap;
899
900 auto addOther =
901 [&]( const VECTOR2I& pt, SCH_ITEM* aOther )
902 {
903 if( pinMap.count( pt ) )
904 pinMap[pt].emplace_back( aOther );
905 };
906
907 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
908 {
909 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
910
911 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
912 {
913 if( pin->GetType() == ELECTRICAL_PINTYPE::PT_NC )
914 pinMap[pin->GetPosition()].emplace_back( pin );
915 }
916 }
917
918 for( SCH_ITEM* item : sheet.LastScreen()->Items() )
919 {
920 if( item->Type() == SCH_SYMBOL_T )
921 {
922 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
923
924 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
925 {
926 if( pin->GetType() != ELECTRICAL_PINTYPE::PT_NC )
927 addOther( pin->GetPosition(), pin );
928 }
929 }
930 else if( item->IsConnectable() && item->Type() != SCH_NO_CONNECT_T )
931 {
932 for( const VECTOR2I& pt : item->GetConnectionPoints() )
933 addOther( pt, item );
934 }
935 }
936
937 for( const std::pair<const VECTOR2I, std::vector<SCH_ITEM*>>& pair : pinMap )
938 {
939 if( pair.second.size() > 1 )
940 {
941 bool all_nc = true;
942
943 for( SCH_ITEM* item : pair.second )
944 {
945 if( item->Type() != SCH_PIN_T )
946 {
947 all_nc = false;
948 break;
949 }
950
951 SCH_PIN* pin = static_cast<SCH_PIN*>( item );
952
953 if( pin->GetType() != ELECTRICAL_PINTYPE::PT_NC )
954 {
955 all_nc = false;
956 break;
957 }
958 }
959
960 if( all_nc )
961 continue;
962
963 err_count++;
964
965 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_CONNECTED );
966
967 ercItem->SetItems( pair.second[0], pair.second[1],
968 pair.second.size() > 2 ? pair.second[2] : nullptr,
969 pair.second.size() > 3 ? pair.second[3] : nullptr );
970 ercItem->SetErrorMessage( _( "Pin with 'no connection' type is connected" ) );
971 ercItem->SetSheetSpecificPath( sheet );
972
973 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pair.first );
974 sheet.LastScreen()->Append( marker );
975 }
976 }
977 }
978
979 return err_count;
980}
981
982
984{
985 int errors = 0;
986
987 for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
988 {
989 using iterator_t = std::vector<ERC_SCH_PIN_CONTEXT>::iterator;
990 std::vector<ERC_SCH_PIN_CONTEXT> pins;
991 std::unordered_map<EDA_ITEM*, SCH_SCREEN*> pinToScreenMap;
992 bool has_noconnect = false;
993
994 for( CONNECTION_SUBGRAPH* subgraph: net.second )
995 {
996 if( subgraph->GetNoConnect() )
997 has_noconnect = true;
998
999 for( SCH_ITEM* item : subgraph->GetItems() )
1000 {
1001 if( item->Type() == SCH_PIN_T )
1002 {
1003 pins.emplace_back( static_cast<SCH_PIN*>( item ), subgraph->GetSheet() );
1004 pinToScreenMap[item] = subgraph->GetSheet().LastScreen();
1005 }
1006 }
1007 }
1008
1009 std::sort( pins.begin(), pins.end(),
1010 []( const ERC_SCH_PIN_CONTEXT& lhs, const ERC_SCH_PIN_CONTEXT& rhs )
1011 {
1012 int ret = StrNumCmp( lhs.Pin()->GetParentSymbol()->GetRef( &lhs.Sheet() ),
1013 rhs.Pin()->GetParentSymbol()->GetRef( &rhs.Sheet() ) );
1014
1015 if( ret == 0 )
1016 ret = StrNumCmp( lhs.Pin()->GetNumber(), rhs.Pin()->GetNumber() );
1017
1018 if( ret == 0 )
1019 ret = lhs < rhs; // Fallback to hash to guarantee deterministic sort
1020
1021 return ret < 0;
1022 } );
1023
1024 ERC_SCH_PIN_CONTEXT needsDriver;
1026 bool hasDriver = false;
1027 std::vector<ERC_SCH_PIN_CONTEXT*> pinsNeedingDrivers;
1028 std::vector<ERC_SCH_PIN_CONTEXT*> nonPowerPinsNeedingDrivers;
1029
1030 // We need different drivers for power nets and normal nets.
1031 // A power net has at least one pin having the ELECTRICAL_PINTYPE::PT_POWER_IN
1032 // and power nets can be driven only by ELECTRICAL_PINTYPE::PT_POWER_OUT pins
1033 bool ispowerNet = false;
1034
1035 for( ERC_SCH_PIN_CONTEXT& refPin : pins )
1036 {
1037 if( refPin.Pin()->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN )
1038 {
1039 ispowerNet = true;
1040 break;
1041 }
1042 }
1043
1044 std::vector<std::tuple<iterator_t, iterator_t, PIN_ERROR>> pin_mismatches;
1045 std::map<iterator_t, int> pin_mismatch_counts;
1046
1047 for( auto refIt = pins.begin(); refIt != pins.end(); ++refIt )
1048 {
1049 ERC_SCH_PIN_CONTEXT& refPin = *refIt;
1050 ELECTRICAL_PINTYPE refType = refPin.Pin()->GetType();
1051
1052 if( DrivenPinTypes.contains( refType ) )
1053 {
1054 // needsDriver will be the pin shown in the error report eventually, so try to
1055 // upgrade to a "better" pin if possible: something visible and only a power symbol
1056 // if this net needs a power driver
1057 pinsNeedingDrivers.push_back( &refPin );
1058
1059 if( !refPin.Pin()->IsPower() )
1060 nonPowerPinsNeedingDrivers.push_back( &refPin );
1061
1062 if( !needsDriver.Pin()
1063 || ( !needsDriver.Pin()->IsVisible() && refPin.Pin()->IsVisible() )
1064 || ( ispowerNet != ( needsDriverType == ELECTRICAL_PINTYPE::PT_POWER_IN )
1065 && ispowerNet == ( refType == ELECTRICAL_PINTYPE::PT_POWER_IN ) ) )
1066 {
1067 needsDriver = refPin;
1068 needsDriverType = needsDriver.Pin()->GetType();
1069 }
1070 }
1071
1072 if( ispowerNet )
1073 hasDriver |= ( DrivingPowerPinTypes.count( refType ) != 0 );
1074 else
1075 hasDriver |= ( DrivingPinTypes.count( refType ) != 0 );
1076
1077 for( auto testIt = refIt + 1; testIt != pins.end(); ++testIt )
1078 {
1079 ERC_SCH_PIN_CONTEXT& testPin = *testIt;
1080
1081 // Multiple pins in the same symbol that share a type,
1082 // name and position are considered
1083 // "stacked" and shouldn't trigger ERC errors
1084 if( refPin.Pin()->IsStacked( testPin.Pin() ) && refPin.Sheet() == testPin.Sheet() )
1085 continue;
1086
1087 ELECTRICAL_PINTYPE testType = testPin.Pin()->GetType();
1088
1089 if( ispowerNet )
1090 hasDriver |= DrivingPowerPinTypes.contains( testType );
1091 else
1092 hasDriver |= DrivingPinTypes.contains( testType );
1093
1094 PIN_ERROR erc = m_settings.GetPinMapValue( refType, testType );
1095
1096 if( erc != PIN_ERROR::OK && m_settings.IsTestEnabled( ERCE_PIN_TO_PIN_WARNING ) )
1097 {
1098 pin_mismatches.emplace_back( std::tuple<iterator_t, iterator_t, PIN_ERROR>{ refIt, testIt, erc } );
1099
1100 if( m_settings.GetERCSortingMetric() == ERC_PIN_SORTING_METRIC::SM_HEURISTICS )
1101 {
1102 pin_mismatch_counts[refIt] = m_settings.GetPinTypeWeight( ( *refIt ).Pin()->GetType() );
1103 pin_mismatch_counts[testIt] = m_settings.GetPinTypeWeight( ( *testIt ).Pin()->GetType() );
1104 }
1105 else
1106 {
1107 if( !pin_mismatch_counts.contains( testIt ) )
1108 pin_mismatch_counts.emplace( testIt, 1 );
1109 else
1110 pin_mismatch_counts[testIt]++;
1111
1112 if( !pin_mismatch_counts.contains( refIt ) )
1113 pin_mismatch_counts.emplace( refIt, 1 );
1114 else
1115 pin_mismatch_counts[refIt]++;
1116 }
1117 }
1118 }
1119 }
1120
1121 std::multimap<size_t, iterator_t, std::greater<size_t>> pins_dsc;
1122
1123 std::transform( pin_mismatch_counts.begin(), pin_mismatch_counts.end(),
1124 std::inserter( pins_dsc, pins_dsc.begin() ),
1125 []( const auto& p )
1126 {
1127 return std::pair<size_t, iterator_t>( p.second, p.first );
1128 } );
1129
1130 for( const auto& [amount, pinItBind] : pins_dsc )
1131 {
1132 auto& pinIt = pinItBind;
1133
1134 if( pin_mismatches.empty() )
1135 break;
1136
1137 SCH_PIN* pin = ( *pinIt ).Pin();
1138 VECTOR2I position = pin->GetPosition();
1139
1140 iterator_t nearest_pin = pins.end();
1141 double smallest_distance = std::numeric_limits<double>::infinity();
1142 PIN_ERROR erc;
1143
1144 std::erase_if(
1145 pin_mismatches,
1146 [&]( const auto& tuple )
1147 {
1148 iterator_t other;
1149
1150 if( pinIt == std::get<0>( tuple ) )
1151 other = std::get<1>( tuple );
1152 else if( pinIt == std::get<1>( tuple ) )
1153 other = std::get<0>( tuple );
1154 else
1155 return false;
1156
1157 if( ( *pinIt ).Sheet().Cmp( ( *other ).Sheet() ) != 0 )
1158 {
1159 if( std::isinf( smallest_distance ) )
1160 {
1161 nearest_pin = other;
1162 erc = std::get<2>( tuple );
1163 }
1164 }
1165 else
1166 {
1167 double distance = position.Distance( ( *other ).Pin()->GetPosition() );
1168
1169 if( std::isinf( smallest_distance ) || distance < smallest_distance )
1170 {
1171 smallest_distance = distance;
1172 nearest_pin = other;
1173 erc = std::get<2>( tuple );
1174 }
1175 }
1176
1177 return true;
1178 } );
1179
1180 if( nearest_pin != pins.end() )
1181 {
1182 SCH_PIN* other_pin = ( *nearest_pin ).Pin();
1183
1186 ercItem->SetItems( pin, other_pin );
1187 ercItem->SetSheetSpecificPath( ( *pinIt ).Sheet() );
1188 ercItem->SetItemsSheetPaths( ( *pinIt ).Sheet(), ( *nearest_pin ).Sheet() );
1189
1190 ercItem->SetErrorMessage( wxString::Format( _( "Pins of type %s and %s are connected" ),
1191 ElectricalPinTypeGetText( pin->GetType() ),
1192 ElectricalPinTypeGetText( other_pin->GetType() ) ) );
1193
1194 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
1195 pinToScreenMap[pin]->Append( marker );
1196 errors++;
1197 }
1198 }
1199
1200 if( needsDriver.Pin() && !hasDriver && !has_noconnect )
1201 {
1202 int err_code = ispowerNet ? ERCE_POWERPIN_NOT_DRIVEN : ERCE_PIN_NOT_DRIVEN;
1203
1204 if( m_settings.IsTestEnabled( err_code ) )
1205 {
1206 std::vector<ERC_SCH_PIN_CONTEXT*> pinsToMark;
1207
1208 if( m_showAllErrors )
1209 {
1210 if( !nonPowerPinsNeedingDrivers.empty() )
1211 pinsToMark = nonPowerPinsNeedingDrivers;
1212 else
1213 pinsToMark = pinsNeedingDrivers;
1214 }
1215 else
1216 {
1217 if( !nonPowerPinsNeedingDrivers.empty() )
1218 pinsToMark.push_back( nonPowerPinsNeedingDrivers.front() );
1219 else
1220 pinsToMark.push_back( &needsDriver );
1221 }
1222
1223 for( ERC_SCH_PIN_CONTEXT* pinCtx : pinsToMark )
1224 {
1225 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( err_code );
1226
1227 ercItem->SetItems( pinCtx->Pin() );
1228 ercItem->SetSheetSpecificPath( pinCtx->Sheet() );
1229 ercItem->SetItemsSheetPaths( pinCtx->Sheet() );
1230
1231 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pinCtx->Pin()->GetPosition() );
1232 pinToScreenMap[pinCtx->Pin()]->Append( marker );
1233 errors++;
1234 }
1235 }
1236 }
1237 }
1238
1239 return errors;
1240}
1241
1242
1244{
1245 int errors = 0;
1246
1247 std::unordered_map<wxString, std::pair<wxString, SCH_PIN*>> pinToNetMap;
1248
1249 for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
1250 {
1251 const wxString& netName = net.first.Name;
1252
1253 for( CONNECTION_SUBGRAPH* subgraph : net.second )
1254 {
1255 for( SCH_ITEM* item : subgraph->GetItems() )
1256 {
1257 if( item->Type() == SCH_PIN_T )
1258 {
1259 SCH_PIN* pin = static_cast<SCH_PIN*>( item );
1260 const SCH_SHEET_PATH& sheet = subgraph->GetSheet();
1261
1262 if( !pin->GetParentSymbol()->IsMultiUnit() )
1263 continue;
1264
1265 wxString name = pin->GetParentSymbol()->GetRef( &sheet ) + ":" + pin->GetShownNumber();
1266
1267 if( !pinToNetMap.count( name ) )
1268 {
1269 pinToNetMap[name] = std::make_pair( netName, pin );
1270 }
1271 else if( pinToNetMap[name].first != netName )
1272 {
1273 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_NET );
1274
1275 ercItem->SetErrorMessage( wxString::Format( _( "Pin %s is connected to both %s and %s" ),
1276 pin->GetShownNumber(),
1277 netName,
1278 pinToNetMap[name].first ) );
1279
1280 ercItem->SetItems( pin, pinToNetMap[name].second );
1281 ercItem->SetSheetSpecificPath( sheet );
1282 ercItem->SetItemsSheetPaths( sheet, sheet );
1283
1284 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
1285 sheet.LastScreen()->Append( marker );
1286 errors += 1;
1287 }
1288 }
1289 }
1290 }
1291 }
1292
1293 return errors;
1294}
1295
1296
1298{
1299 int errors = 0;
1300
1301 for( const SCH_SHEET_PATH& sheet : m_sheetList )
1302 {
1303 SCH_SCREEN* screen = sheet.LastScreen();
1304
1305 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1306 {
1307 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1308 LIB_SYMBOL* libSymbol = symbol->GetLibSymbolRef().get();
1309
1310 if( !libSymbol )
1311 continue;
1312
1313 if( libSymbol->GetDuplicatePinNumbersAreJumpers() )
1314 continue;
1315
1316 std::vector<SCH_PIN*> pins = symbol->GetPins( &sheet );
1317
1318 std::map<wxString, std::vector<std::pair<SCH_PIN*, wxString>>> pinsByNumber;
1319
1320 for( SCH_PIN* pin : pins )
1321 {
1322 SCH_CONNECTION* conn = pin->Connection( &sheet );
1323 wxString netName = conn ? conn->GetNetName() : wxString();
1324
1325 pinsByNumber[pin->GetNumber()].emplace_back( pin, netName );
1326 }
1327
1328 for( const auto& [pinNumber, pinNetPairs] : pinsByNumber )
1329 {
1330 if( pinNetPairs.size() < 2 )
1331 continue;
1332
1333 wxString firstNet = pinNetPairs[0].second;
1334 bool hasDifferentNets = false;
1335 SCH_PIN* conflictPin = nullptr;
1336
1337 for( size_t i = 1; i < pinNetPairs.size(); i++ )
1338 {
1339 if( pinNetPairs[i].second != firstNet )
1340 {
1341 hasDifferentNets = true;
1342 conflictPin = pinNetPairs[i].first;
1343 break;
1344 }
1345 }
1346
1347 if( hasDifferentNets )
1348 {
1349 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DUPLICATE_PIN_ERROR );
1350 wxString msg;
1351
1352 msg.Printf( _( "Pin %s on symbol '%s' is connected to different nets: %s and %s" ),
1353 pinNumber,
1354 symbol->GetRef( &sheet ),
1355 firstNet.IsEmpty() ? _( "<no net>" ) : firstNet,
1356 pinNetPairs[1].second.IsEmpty() ? _( "<no net>" ) : pinNetPairs[1].second );
1357
1358 ercItem->SetErrorMessage( msg );
1359 ercItem->SetItems( pinNetPairs[0].first, conflictPin );
1360 ercItem->SetSheetSpecificPath( sheet );
1361 ercItem->SetItemsSheetPaths( sheet, sheet );
1362
1363 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ),
1364 pinNetPairs[0].first->GetPosition() );
1365 screen->Append( marker );
1366 errors++;
1367 }
1368 }
1369 }
1370 }
1371
1372 return errors;
1373}
1374
1375
1377{
1378 int errors = 0;
1379
1380 auto isGround =
1381 []( const wxString& txt )
1382 {
1383 wxString upper = txt.Upper();
1384 return upper.Contains( wxT( "GND" ) );
1385 };
1386
1387 for( const SCH_SHEET_PATH& sheet : m_sheetList )
1388 {
1389 SCH_SCREEN* screen = sheet.LastScreen();
1390
1391 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1392 {
1393 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1394 bool hasGroundNet = false;
1395 std::vector<SCH_PIN*> mismatched;
1396
1397 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
1398 {
1399 SCH_CONNECTION* conn = pin->Connection( &sheet );
1400 wxString net = conn ? conn->GetNetName() : wxString();
1401 bool netIsGround = isGround( net );
1402
1403 // We are only interested in power pins
1404 if( pin->GetType() != ELECTRICAL_PINTYPE::PT_POWER_OUT
1405 && pin->GetType() != ELECTRICAL_PINTYPE::PT_POWER_IN )
1406 {
1407 continue;
1408 }
1409
1410 if( netIsGround )
1411 hasGroundNet = true;
1412
1413 if( isGround( pin->GetShownName() ) && !netIsGround )
1414 mismatched.push_back( pin );
1415 }
1416
1417 if( hasGroundNet )
1418 {
1419 for( SCH_PIN* pin : mismatched )
1420 {
1421 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_GROUND_PIN_NOT_GROUND );
1422
1423 ercItem->SetErrorMessage( wxString::Format( _( "Pin %s not connected to ground net" ),
1424 pin->GetShownName() ) );
1425 ercItem->SetItems( pin );
1426 ercItem->SetSheetSpecificPath( sheet );
1427 ercItem->SetItemsSheetPaths( sheet );
1428
1429 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
1430 screen->Append( marker );
1431 errors++;
1432 }
1433 }
1434 }
1435 }
1436
1437 return errors;
1438}
1439
1440
1442{
1443 int warnings = 0;
1444
1445 for( const SCH_SHEET_PATH& sheet : m_sheetList )
1446 {
1447 SCH_SCREEN* screen = sheet.LastScreen();
1448
1449 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1450 {
1451 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1452
1453 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
1454 {
1455 bool valid;
1456 pin->GetStackedPinNumbers( &valid );
1457
1458 if( !valid )
1459 {
1460 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_STACKED_PIN_SYNTAX );
1461 ercItem->SetItems( pin );
1462 ercItem->SetSheetSpecificPath( sheet );
1463 ercItem->SetItemsSheetPaths( sheet );
1464
1465 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
1466 screen->Append( marker );
1467 warnings++;
1468 }
1469 }
1470 }
1471 }
1472
1473 return warnings;
1474}
1475
1476
1478{
1479 int errCount = 0;
1480
1481 std::unordered_map<wxString, std::pair<SCH_ITEM*, SCH_SHEET_PATH>> globalLabels;
1482 std::unordered_map<wxString, std::pair<SCH_ITEM*, SCH_SHEET_PATH>> localLabels;
1483
1484 for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
1485 {
1486 for( CONNECTION_SUBGRAPH* subgraph : net.second )
1487 {
1488 const SCH_SHEET_PATH& sheet = subgraph->GetSheet();
1489
1490 for( SCH_ITEM* item : subgraph->GetItems() )
1491 {
1492 if( item->Type() == SCH_LABEL_T || item->Type() == SCH_GLOBAL_LABEL_T )
1493 {
1494 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( item );
1495 wxString text = label->GetShownText( &sheet, false );
1496
1497 auto& map = item->Type() == SCH_LABEL_T ? localLabels : globalLabels;
1498
1499 if( !map.count( text ) )
1500 {
1501 map[text] = std::make_pair( label, sheet );
1502 }
1503 }
1504 }
1505 }
1506 }
1507
1508 for( auto& [globalText, globalItem] : globalLabels )
1509 {
1510 for( auto& [localText, localItem] : localLabels )
1511 {
1512 if( globalText == localText )
1513 {
1514 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_SAME_LOCAL_GLOBAL_LABEL );
1515 ercItem->SetItems( globalItem.first, localItem.first );
1516 ercItem->SetSheetSpecificPath( globalItem.second );
1517 ercItem->SetItemsSheetPaths( globalItem.second, localItem.second );
1518
1519 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), globalItem.first->GetPosition() );
1520 globalItem.second.LastScreen()->Append( marker );
1521
1522 errCount++;
1523 }
1524 }
1525 }
1526
1527 return errCount;
1528}
1529
1530
1532{
1533 int errors = 0;
1534 std::unordered_map<wxString, std::vector<std::tuple<wxString, SCH_ITEM*, SCH_SHEET_PATH>>> generalMap;
1535
1536 auto logError =
1537 [&]( const wxString& normalized, SCH_ITEM* item, const SCH_SHEET_PATH& sheet,
1538 const std::tuple<wxString, SCH_ITEM*, SCH_SHEET_PATH>& other )
1539 {
1540 auto& [otherText, otherItem, otherSheet] = other;
1541 ERCE_T typeOfWarning = ERCE_SIMILAR_LABELS;
1542
1543 if( item->Type() == SCH_PIN_T && otherItem->Type() == SCH_PIN_T )
1544 {
1545 //Two Pins
1546 typeOfWarning = ERCE_SIMILAR_POWER;
1547 }
1548 else if( item->Type() == SCH_PIN_T || otherItem->Type() == SCH_PIN_T )
1549 {
1550 //Pin and Label
1551 typeOfWarning = ERCE_SIMILAR_LABEL_AND_POWER;
1552 }
1553 else
1554 {
1555 //Two Labels
1556 typeOfWarning = ERCE_SIMILAR_LABELS;
1557 }
1558
1559 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( typeOfWarning );
1560 ercItem->SetItems( item, otherItem );
1561 ercItem->SetSheetSpecificPath( sheet );
1562 ercItem->SetItemsSheetPaths( sheet, otherSheet );
1563
1564 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), item->GetPosition() );
1565 sheet.LastScreen()->Append( marker );
1566 };
1567
1568 for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
1569 {
1570 for( CONNECTION_SUBGRAPH* subgraph : net.second )
1571 {
1572 const SCH_SHEET_PATH& sheet = subgraph->GetSheet();
1573
1574 for( SCH_ITEM* item : subgraph->GetItems() )
1575 {
1576 switch( item->Type() )
1577 {
1578 case SCH_LABEL_T:
1579 case SCH_HIER_LABEL_T:
1580 case SCH_GLOBAL_LABEL_T:
1581 {
1582 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( item );
1583 wxString unnormalized = label->GetShownText( &sheet, false );
1584 wxString normalized = unnormalized.Lower();
1585
1586 generalMap[normalized].emplace_back( std::make_tuple( unnormalized, label, sheet ) );
1587
1588 for( const auto& otherTuple : generalMap.at( normalized ) )
1589 {
1590 const auto& [otherText, otherItem, otherSheet] = otherTuple;
1591
1592 if( unnormalized != otherText )
1593 {
1594 // Similar local labels on different sheets are fine
1595 if( item->Type() == SCH_LABEL_T && otherItem->Type() == SCH_LABEL_T
1596 && sheet != otherSheet )
1597 {
1598 continue;
1599 }
1600
1601 logError( normalized, label, sheet, otherTuple );
1602 errors += 1;
1603 }
1604 }
1605
1606 break;
1607 }
1608 case SCH_PIN_T:
1609 {
1610 SCH_PIN* pin = static_cast<SCH_PIN*>( item );
1611
1612 if( !pin->IsPower() )
1613 continue;
1614
1615 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( pin->GetParentSymbol() );
1616 wxString unnormalized = symbol->GetValue( true, &sheet, false );
1617 wxString normalized = unnormalized.Lower();
1618
1619 generalMap[normalized].emplace_back( std::make_tuple( unnormalized, pin, sheet ) );
1620
1621 for( const auto& otherTuple : generalMap.at( normalized ) )
1622 {
1623 const auto& [otherText, otherItem, otherSheet] = otherTuple;
1624
1625 if( unnormalized != otherText )
1626 {
1627 logError( normalized, pin, sheet, otherTuple );
1628 errors += 1;
1629 }
1630 }
1631
1632 break;
1633 }
1634
1635 default:
1636 break;
1637 }
1638 }
1639 }
1640 }
1641
1642 return errors;
1643}
1644
1645
1647{
1648 wxCHECK( m_schematic, 0 );
1649
1650 LIBRARY_MANAGER& manager = Pgm().GetLibraryManager();
1652 wxString msg;
1653 int err_count = 0;
1654
1655 for( SCH_SCREEN* screen = m_screens.GetFirst(); screen; screen = m_screens.GetNext() )
1656 {
1657 std::vector<SCH_MARKER*> markers;
1658
1659 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1660 {
1661 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1662 LIB_SYMBOL* libSymbolInSchematic = symbol->GetLibSymbolRef().get();
1663
1664 if( !libSymbolInSchematic )
1665 continue;
1666
1667 wxString libName = symbol->GetLibId().GetLibNickname();
1668
1669 std::optional<const LIBRARY_TABLE_ROW*> optRow =
1670 manager.GetRow( LIBRARY_TABLE_TYPE::SYMBOL, libName );
1671
1672 if( !optRow || ( *optRow )->Disabled() )
1673 {
1674 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES ) )
1675 {
1676 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
1677 ercItem->SetItems( symbol );
1678 msg.Printf( _( "The current configuration does not include the symbol library '%s'" ),
1679 UnescapeString( libName ) );
1680 ercItem->SetErrorMessage( msg );
1681
1682 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1683 }
1684
1685 continue;
1686 }
1687 else if( !adapter->IsLibraryLoaded( libName ) )
1688 {
1689 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES ) )
1690 {
1691 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
1692 std::optional<wxString> uri =
1693 manager.GetFullURI( LIBRARY_TABLE_TYPE::SYMBOL, libName, true );
1694 wxCHECK2( uri.has_value(), uri = wxEmptyString );
1695 ercItem->SetItems( symbol );
1696 msg.Printf( _( "The symbol library '%s' was not found at '%s'" ),
1697 UnescapeString( libName ), *uri );
1698 ercItem->SetErrorMessage( msg );
1699
1700 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1701 }
1702
1703 continue;
1704 }
1705
1706 wxString symbolName = symbol->GetLibId().GetLibItemName();
1707 LIB_SYMBOL* libSymbol = adapter->LoadSymbol( symbol->GetLibId() );
1708
1709 if( libSymbol == nullptr )
1710 {
1711 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES ) )
1712 {
1713 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
1714 ercItem->SetItems( symbol );
1715 msg.Printf( _( "Symbol '%s' not found in symbol library '%s'" ),
1716 UnescapeString( symbolName ),
1717 UnescapeString( libName ) );
1718 ercItem->SetErrorMessage( msg );
1719
1720 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1721 }
1722
1723 continue;
1724 }
1725
1726 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
1728
1729 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_MISMATCH ) )
1730 {
1731 // We have to check for duplicate pins first as they will cause Compare() to fail.
1732 // Symbols with duplicate pins are valid if those pins share the same net, so we
1733 // only skip the comparison here. The actual error checking for duplicate pins on
1734 // different nets is done in TestDuplicatePinNets().
1735 std::vector<wxString> messages;
1736
1737 if( !libSymbolInSchematic->GetDuplicatePinNumbersAreJumpers() )
1738 {
1739 UNITS_PROVIDER unitsProvider( schIUScale, EDA_UNITS::MILS );
1740 CheckDuplicatePins( libSymbolInSchematic, messages, &unitsProvider );
1741 }
1742
1743 if( messages.empty() && flattenedSymbol->Compare( *libSymbolInSchematic, flags ) != 0 )
1744 {
1745 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_MISMATCH );
1746 ercItem->SetItems( symbol );
1747 msg.Printf( _( "Symbol '%s' doesn't match copy in library '%s'" ),
1748 UnescapeString( symbolName ),
1749 UnescapeString( libName ) );
1750 ercItem->SetErrorMessage( msg );
1751
1752 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1753 }
1754 }
1755 }
1756
1757 for( SCH_MARKER* marker : markers )
1758 {
1759 screen->Append( marker );
1760 err_count += 1;
1761 }
1762 }
1763
1764 return err_count;
1765}
1766
1767
1769{
1770 wxCHECK( m_schematic, 0 );
1771
1772 wxString msg;
1773 int err_count = 0;
1774
1775 typedef int (*TESTER_FN_PTR)( const wxString&, PROJECT* );
1776
1777 TESTER_FN_PTR linkTester = (TESTER_FN_PTR) aCvPcb->IfaceOrAddress( KIFACE_TEST_FOOTPRINT_LINK );
1778
1779 for( SCH_SHEET_PATH& sheet : m_sheetList )
1780 {
1781 std::vector<SCH_MARKER*> markers;
1782
1783 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
1784 {
1785 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1786 wxString footprint = symbol->GetFootprintFieldText( true, &sheet, false );
1787
1788 if( footprint.IsEmpty() )
1789 continue;
1790
1791 LIB_ID fpID;
1792
1793 if( fpID.Parse( footprint, true ) >= 0 )
1794 {
1795 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
1796 msg.Printf( _( "'%s' is not a valid footprint identifier" ), footprint );
1797 ercItem->SetErrorMessage( msg );
1798 ercItem->SetItems( symbol );
1799 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1800 continue;
1801 }
1802
1803 wxString libName = fpID.GetLibNickname();
1804 wxString fpName = fpID.GetLibItemName();
1805 int ret = (linkTester)( footprint, aProject );
1806
1808 {
1809 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
1810 msg.Printf( _( "The current configuration does not include the footprint library '%s'" ),
1811 libName );
1812 ercItem->SetErrorMessage( msg );
1813 ercItem->SetItems( symbol );
1814 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1815 }
1817 {
1818 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
1819 msg.Printf( _( "The footprint library '%s' is not enabled in the current configuration" ),
1820 libName );
1821 ercItem->SetErrorMessage( msg );
1822 ercItem->SetItems( symbol );
1823 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1824 }
1826 {
1827 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
1828 msg.Printf( _( "Footprint '%s' not found in library '%s'" ),
1829 fpName,
1830 libName );
1831 ercItem->SetErrorMessage( msg );
1832 ercItem->SetItems( symbol );
1833 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1834 }
1835 }
1836
1837 for( SCH_MARKER* marker : markers )
1838 {
1839 sheet.LastScreen()->Append( marker );
1840 err_count += 1;
1841 }
1842 }
1843
1844 return err_count;
1845}
1846
1847
1849{
1850 wxCHECK( m_schematic, 0 );
1851
1852 wxString msg;
1853 int err_count = 0;
1854
1855 for( SCH_SHEET_PATH& sheet : m_sheetList )
1856 {
1857 std::vector<SCH_MARKER*> markers;
1858
1859 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
1860 {
1861 SCH_SYMBOL* sch_symbol = static_cast<SCH_SYMBOL*>( item );
1862 std::unique_ptr<LIB_SYMBOL>& lib_symbol = sch_symbol->GetLibSymbolRef();
1863
1864 if( !lib_symbol )
1865 continue;
1866
1867 wxArrayString filters = lib_symbol->GetFPFilters();
1868
1869 if( filters.empty() )
1870 continue;
1871
1872 wxString lowerId = sch_symbol->GetFootprintFieldText( true, &sheet, false ).Lower();
1873 LIB_ID footprint;
1874
1875 if( footprint.Parse( lowerId ) > 0 )
1876 continue;
1877
1878 wxString lowerItemName = footprint.GetUniStringLibItemName().Lower();
1879 bool found = false;
1880
1881 for( wxString filter : filters )
1882 {
1883 filter.LowerCase();
1884
1885 // If the filter contains a ':' character, include the library name in the pattern
1886 if( filter.Contains( wxS( ":" ) ) )
1887 found |= lowerId.Matches( filter );
1888 else
1889 found |= lowerItemName.Matches( filter );
1890
1891 if( found )
1892 break;
1893 }
1894
1895 if( !found )
1896 {
1897 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
1898 msg.Printf( _( "Assigned footprint (%s) doesn't match footprint filters (%s)" ),
1899 footprint.GetUniStringLibItemName(),
1900 wxJoin( filters, ' ' ) );
1901 ercItem->SetErrorMessage( msg );
1902 ercItem->SetItems( sch_symbol );
1903 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), sch_symbol->GetPosition() ) );
1904 }
1905 }
1906
1907 for( SCH_MARKER* marker : markers )
1908 {
1909 sheet.LastScreen()->Append( marker );
1910 err_count += 1;
1911 }
1912 }
1913
1914 return err_count;
1915}
1916
1917
1919{
1920 const int gridSize = m_schematic->Settings().m_ConnectionGridSize;
1921 int err_count = 0;
1922
1923 for( SCH_SCREEN* screen = m_screens.GetFirst(); screen; screen = m_screens.GetNext() )
1924 {
1925 std::vector<SCH_MARKER*> markers;
1926
1927 for( SCH_ITEM* item : screen->Items() )
1928 {
1929 if( item->Type() == SCH_LINE_T && item->IsConnectable() )
1930 {
1931 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1932
1933 if( ( line->GetStartPoint().x % gridSize ) != 0
1934 || ( line->GetStartPoint().y % gridSize ) != 0 )
1935 {
1936 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
1937 ercItem->SetItems( line );
1938
1939 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), line->GetStartPoint() ) );
1940 }
1941 else if( ( line->GetEndPoint().x % gridSize ) != 0
1942 || ( line->GetEndPoint().y % gridSize ) != 0 )
1943 {
1944 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
1945 ercItem->SetItems( line );
1946
1947 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), line->GetEndPoint() ) );
1948 }
1949 }
1950 if( item->Type() == SCH_BUS_WIRE_ENTRY_T )
1951 {
1952 SCH_BUS_WIRE_ENTRY* entry = static_cast<SCH_BUS_WIRE_ENTRY*>( item );
1953
1954 for( const VECTOR2I& point : entry->GetConnectionPoints() )
1955 {
1956 if( ( point.x % gridSize ) != 0
1957 || ( point.y % gridSize ) != 0 )
1958 {
1959 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
1960 ercItem->SetItems( entry );
1961
1962 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), point ) );
1963 }
1964 }
1965 }
1966 else if( item->Type() == SCH_SYMBOL_T )
1967 {
1968 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1969
1970 for( SCH_PIN* pin : symbol->GetPins( nullptr ) )
1971 {
1972 if( pin->GetType() == ELECTRICAL_PINTYPE::PT_NC )
1973 continue;
1974
1975 VECTOR2I pinPos = pin->GetPosition();
1976
1977 if( ( pinPos.x % gridSize ) != 0 || ( pinPos.y % gridSize ) != 0 )
1978 {
1979 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
1980 ercItem->SetItems( pin );
1981
1982 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), pinPos ) );
1983 break;
1984 }
1985 }
1986 }
1987 }
1988
1989 for( SCH_MARKER* marker : markers )
1990 {
1991 screen->Append( marker );
1992 err_count += 1;
1993 }
1994 }
1995
1996 return err_count;
1997}
1998
1999
2001{
2002 WX_STRING_REPORTER reporter;
2003 int err_count = 0;
2004 SIM_LIB_MGR libMgr( &m_schematic->Project() );
2005 wxString variant = m_schematic->GetCurrentVariant();
2006
2007 for( SCH_SHEET_PATH& sheet : m_sheetList )
2008 {
2009 if( sheet.GetExcludedFromSim( variant ) )
2010 continue;
2011
2012 std::vector<SCH_MARKER*> markers;
2013
2014 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
2015 {
2016 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
2017
2018 // Power symbols and other symbols which have the reference starting with "#" are
2019 // not included in simulation
2020 if( symbol->GetRef( &sheet ).StartsWith( '#' ) || symbol->ResolveExcludedFromSim() )
2021 continue;
2022
2023 // Reset for each symbol
2024 reporter.Clear();
2025
2026 SIM_LIBRARY::MODEL model = libMgr.CreateModel( &sheet, *symbol, true, 0, variant, reporter );
2027
2028 if( reporter.HasMessage() )
2029 {
2030 wxString msg = reporter.GetMessages();
2031 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_SIMULATION_MODEL );
2032
2033 //Remove \n and \r at e.o.l if any:
2034 msg.Trim();
2035
2036 ercItem->SetErrorMessage( msg );
2037 ercItem->SetItems( symbol );
2038
2039 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
2040 }
2041 }
2042
2043 for( SCH_MARKER* marker : markers )
2044 {
2045 sheet.LastScreen()->Append( marker );
2046 err_count += 1;
2047 }
2048 }
2049
2050 return err_count;
2051}
2052
2053
2055 KIFACE* aCvPcb, PROJECT* aProject, PROGRESS_REPORTER* aProgressReporter )
2056{
2057 m_sheetList.AnnotatePowerSymbols();
2058
2059 // Test duplicate sheet names inside a given sheet. While one can have multiple references
2060 // to the same file, each must have a unique name.
2061 if( m_settings.IsTestEnabled( ERCE_DUPLICATE_SHEET_NAME ) )
2062 {
2063 if( aProgressReporter )
2064 aProgressReporter->AdvancePhase( _( "Checking sheet names..." ) );
2065
2067 }
2068
2069 // The connection graph has a whole set of ERC checks it can run
2070 if( aProgressReporter )
2071 aProgressReporter->AdvancePhase( _( "Checking conflicts..." ) );
2072
2073 // If we are using the new connectivity, make sure that we do a full-rebuild
2074 if( aEditFrame )
2075 {
2076 if( ADVANCED_CFG::GetCfg().m_IncrementalConnectivity )
2077 aEditFrame->RecalculateConnections( nullptr, GLOBAL_CLEANUP );
2078 else
2079 aEditFrame->RecalculateConnections( nullptr, NO_CLEANUP );
2080 }
2081
2082 m_schematic->ConnectionGraph()->RunERC();
2083
2084 if( aProgressReporter )
2085 aProgressReporter->AdvancePhase( _( "Checking units..." ) );
2086
2087 // Test is all units of each multiunit symbol have the same footprint assigned.
2088 if( m_settings.IsTestEnabled( ERCE_DIFFERENT_UNIT_FP ) )
2089 {
2090 if( aProgressReporter )
2091 aProgressReporter->AdvancePhase( _( "Checking footprints..." ) );
2092
2094 }
2095
2096 if( m_settings.IsTestEnabled( ERCE_MISSING_UNIT )
2097 || m_settings.IsTestEnabled( ERCE_MISSING_INPUT_PIN )
2098 || m_settings.IsTestEnabled( ERCE_MISSING_POWER_INPUT_PIN )
2099 || m_settings.IsTestEnabled( ERCE_MISSING_BIDI_PIN ) )
2100 {
2102 }
2103
2104 if( aProgressReporter )
2105 aProgressReporter->AdvancePhase( _( "Checking pins..." ) );
2106
2107 if( m_settings.IsTestEnabled( ERCE_DIFFERENT_UNIT_NET ) )
2109
2110 if( m_settings.IsTestEnabled( ERCE_DUPLICATE_PIN_ERROR ) )
2112
2113 // Test pins on each net against the pin connection table
2114 if( m_settings.IsTestEnabled( ERCE_PIN_TO_PIN_ERROR )
2115 || m_settings.IsTestEnabled( ERCE_POWERPIN_NOT_DRIVEN )
2116 || m_settings.IsTestEnabled( ERCE_PIN_NOT_DRIVEN ) )
2117 {
2118 TestPinToPin();
2119 }
2120
2121 if( m_settings.IsTestEnabled( ERCE_GROUND_PIN_NOT_GROUND ) )
2123
2124 if( m_settings.IsTestEnabled( ERCE_STACKED_PIN_SYNTAX ) )
2126
2127 // Test similar labels (i;e. labels which are identical when
2128 // using case insensitive comparisons)
2129 if( m_settings.IsTestEnabled( ERCE_SIMILAR_LABELS )
2130 || m_settings.IsTestEnabled( ERCE_SIMILAR_POWER )
2131 || m_settings.IsTestEnabled( ERCE_SIMILAR_LABEL_AND_POWER ) )
2132 {
2133 if( aProgressReporter )
2134 aProgressReporter->AdvancePhase( _( "Checking similar labels..." ) );
2135
2137 }
2138
2139 if( m_settings.IsTestEnabled( ERCE_SAME_LOCAL_GLOBAL_LABEL ) )
2140 {
2141 if( aProgressReporter )
2142 aProgressReporter->AdvancePhase( _( "Checking local and global labels..." ) );
2143
2145 }
2146
2147 if( m_settings.IsTestEnabled( ERCE_UNRESOLVED_VARIABLE ) )
2148 {
2149 if( aProgressReporter )
2150 aProgressReporter->AdvancePhase( _( "Checking for unresolved variables..." ) );
2151
2152 TestTextVars( aDrawingSheet );
2153 }
2154
2155 if( m_settings.IsTestEnabled( ERCE_FIELD_NAME_WHITESPACE ) )
2156 {
2157 if( aProgressReporter )
2158 aProgressReporter->AdvancePhase( _( "Checking field names..." ) );
2159
2161 }
2162
2163 if( m_settings.IsTestEnabled( ERCE_SIMULATION_MODEL ) )
2164 {
2165 if( aProgressReporter )
2166 aProgressReporter->AdvancePhase( _( "Checking SPICE models..." ) );
2167
2169 }
2170
2171 if( m_settings.IsTestEnabled( ERCE_NOCONNECT_CONNECTED ) )
2172 {
2173 if( aProgressReporter )
2174 aProgressReporter->AdvancePhase( _( "Checking no connect pins for connections..." ) );
2175
2177 }
2178
2179 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES )
2180 || m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_MISMATCH ) )
2181 {
2182 if( aProgressReporter )
2183 aProgressReporter->AdvancePhase( _( "Checking for library symbol issues..." ) );
2184
2186 }
2187
2188 if( m_settings.IsTestEnabled( ERCE_FOOTPRINT_LINK_ISSUES ) && aCvPcb )
2189 {
2190 if( aProgressReporter )
2191 aProgressReporter->AdvancePhase( _( "Checking for footprint link issues..." ) );
2192
2193 TestFootprintLinkIssues( aCvPcb, aProject );
2194 }
2195
2196 if( m_settings.IsTestEnabled( ERCE_FOOTPRINT_FILTERS ) )
2197 {
2198 if( aProgressReporter )
2199 aProgressReporter->AdvancePhase( _( "Checking footprint assignments against footprint filters..." ) );
2200
2202 }
2203
2204 if( m_settings.IsTestEnabled( ERCE_ENDPOINT_OFF_GRID ) )
2205 {
2206 if( aProgressReporter )
2207 aProgressReporter->AdvancePhase( _( "Checking for off grid pins and wires..." ) );
2208
2210 }
2211
2212 if( m_settings.IsTestEnabled( ERCE_FOUR_WAY_JUNCTION ) )
2213 {
2214 if( aProgressReporter )
2215 aProgressReporter->AdvancePhase( _( "Checking for four way junctions..." ) );
2216
2218 }
2219
2220 if( m_settings.IsTestEnabled( ERCE_LABEL_MULTIPLE_WIRES ) )
2221 {
2222 if( aProgressReporter )
2223 aProgressReporter->AdvancePhase( _( "Checking for labels on more than one wire..." ) );
2224
2226 }
2227
2228 if( m_settings.IsTestEnabled( ERCE_UNDEFINED_NETCLASS ) )
2229 {
2230 if( aProgressReporter )
2231 aProgressReporter->AdvancePhase( _( "Checking for undefined netclasses..." ) );
2232
2234 }
2235
2236 m_schematic->ResolveERCExclusionsPostUpdate();
2237}
const char * name
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:114
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
constexpr Vec Centre() const
Definition box2.h:97
A subgraph is a set of items that are electrically connected on a single sheet.
const std::set< SCH_ITEM * > & GetItems() const
Provide a read-only reference to the items in the subgraph.
const SCH_ITEM * GetNoConnect() const
const SCH_SHEET_PATH & GetSheet() const
Base class to handle basic graphic items.
Store the list of graphic items: rect, lines, polygons and texts to draw/plot the title block and fra...
DS_DRAW_ITEM_BASE * GetFirst()
void BuildDrawItemsList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Drawing or plot the drawing sheet.
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
void SetSheetLayer(const wxString &aSheetLayer)
Set the sheet layer to draw/plot.
void SetSheetCount(int aSheetCount)
Set the value of the count of sheets, for basic inscriptions.
void SetPageNumber(const wxString &aPageNumber)
Set the value of the sheet number.
DS_DRAW_ITEM_BASE * GetNext()
void SetProject(const PROJECT *aProject)
A graphic text.
const PAGE_INFO & GetPageInfo()
const TITLE_BLOCK & GetTitleBlock()
virtual VECTOR2I GetPosition() const
Definition eda_item.h:278
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:111
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:98
EE_TYPE OfType(KICAD_T aType) const
Definition sch_rtree.h:241
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
Definition erc_item.cpp:312
A class used to associate a SCH_PIN with its owning SCH_SHEET_PATH, in order to handle ERC checks acr...
const SCH_SHEET_PATH & Sheet() const
Get the SCH_SHEET_PATH context for the paired SCH_PIN.
SCH_PIN * Pin() const
Get the SCH_PIN for this context.
int TestLibSymbolIssues()
Test symbols for changed library symbols and broken symbol library links.
Definition erc.cpp:1646
const NET_MAP & m_nets
Definition erc.h:208
int TestStackedPinNotation()
Checks for pin numbers that resemble stacked pin notation but are invalid.
Definition erc.cpp:1441
void TestTextVars(DS_PROXY_VIEW_ITEM *aDrawingSheet)
Check for any unresolved text variable references.
Definition erc.cpp:186
int TestPinToPin()
Checks the full netlist against the pin-to-pin connectivity requirements.
Definition erc.cpp:983
int TestSimilarLabels()
Checks for labels that differ only in capitalization.
Definition erc.cpp:1531
SCH_MULTI_UNIT_REFERENCE_MAP m_refMap
Definition erc.h:207
SCH_SCREENS m_screens
Definition erc.h:206
int TestFootprintLinkIssues(KIFACE *aCvPcb, PROJECT *aProject)
Test footprint links against the current footprint libraries.
Definition erc.cpp:1768
int TestOffGridEndpoints()
Test pins and wire ends for being off grid.
Definition erc.cpp:1918
int TestDuplicateSheetNames(bool aCreateMarker)
Inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated).
Definition erc.cpp:143
int TestSameLocalGlobalLabel()
Checks for global and local labels with the same name.
Definition erc.cpp:1477
int TestMultUnitPinConflicts()
Checks if shared pins on multi-unit symbols have been connected to different nets.
Definition erc.cpp:1243
int TestNoConnectPins()
In KiCad 5 and earlier, you could connect stuff up to pins with NC electrical type.
Definition erc.cpp:892
int TestFootprintFilters()
Test symbols to ensure that assigned footprint passes any given footprint filters.
Definition erc.cpp:1848
int TestFieldNameWhitespace()
Check for field names with leading or trailing whitespace.
Definition erc.cpp:441
int TestDuplicatePinNets()
Checks if duplicate pin numbers within a symbol are connected to different nets.
Definition erc.cpp:1297
ERC_SETTINGS & m_settings
Definition erc.h:204
int TestFourWayJunction()
Test to see if there are potentially confusing 4-way junctions in the schematic.
Definition erc.cpp:813
int TestMissingNetclasses()
Tests for netclasses that are referenced but not defined.
Definition erc.cpp:705
int TestSimModelIssues()
Test SPICE models for various issues.
Definition erc.cpp:2000
SCH_SHEET_LIST m_sheetList
Definition erc.h:205
bool m_showAllErrors
Definition erc.h:209
int TestGroundPins()
Checks for ground-labeled pins not on a ground net while another pin is.
Definition erc.cpp:1376
SCHEMATIC * m_schematic
Definition erc.h:203
void RunTests(DS_PROXY_VIEW_ITEM *aDrawingSheet, SCH_EDIT_FRAME *aEditFrame, KIFACE *aCvPcb, PROJECT *aProject, PROGRESS_REPORTER *aProgressReporter)
Definition erc.cpp:2054
int TestMissingUnits()
Test for uninstantiated units of multi unit symbols.
Definition erc.cpp:571
int TestLabelMultipleWires()
Test to see if there are labels that are connected to more than one wire.
Definition erc.cpp:758
int TestMultiunitFootprints()
Test if all units of each multiunit symbol have the same footprint assigned.
Definition erc.cpp:510
bool IsLibraryLoaded(const wxString &aNickname)
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
std::optional< LIBRARY_TABLE_ROW * > GetRow(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:49
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition lib_id.cpp:52
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
Definition lib_id.h:112
const UTF8 & GetLibItemName() const
Definition lib_id.h:102
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition lib_id.h:87
Define a library symbol object.
Definition lib_symbol.h:83
std::vector< const SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
int GetUnitCount() const override
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
bool GetDuplicatePinNumbersAreJumpers() const
Definition lib_symbol.h:753
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the user-defined display name for aUnit for symbols with units.
virtual LIBRARY_MANAGER & GetLibraryManager() const
Definition pgm_base.h:133
A progress reporter interface for use in multi-threaded environments.
virtual void AdvancePhase()=0
Use the next available virtual zone of the dialog progress bar.
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
Container for project specific data.
Definition project.h:65
virtual bool HasMessage() const
Returns true if any messages were reported.
Definition reporter.h:134
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Class for a wire to bus entry.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString GetNetName() const
Schematic editor (Eeschema) main window.
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, PROGRESS_REPORTER *aProgressReporter=nullptr)
Generate the connection data for the entire schematic hierarchy.
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0, const wxString &aVariantName=wxEmptyString) const
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:168
int GetBodyStyle() const
Definition sch_item.h:248
bool ResolveExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:284
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const override
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:42
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Definition sch_line.cpp:717
VECTOR2I GetEndPoint() const
Definition sch_line.h:148
VECTOR2I GetStartPoint() const
Definition sch_line.h:139
bool IsEndPoint(const VECTOR2I &aPoint) const override
Test if aPt is an end point of this schematic object.
Definition sch_line.h:91
bool IsGraphicLine() const
Return if the line is a graphic (non electrical line)
Definition sch_line.cpp:986
bool IsVisible() const
Definition sch_pin.cpp:391
bool IsStacked(const SCH_PIN *aPin) const
Definition sch_pin.cpp:480
bool IsPower() const
Check if the pin is either a global or local power pin.
Definition sch_pin.cpp:385
ELECTRICAL_PINTYPE GetType() const
Definition sch_pin.cpp:315
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
SCH_REFERENCE & GetItem(size_t aIdx)
A helper to define a symbol's reference designator in a schematic.
const SCH_SHEET_PATH & GetSheetPath() const
const wxString GetFootprint() const
SCH_SYMBOL * GetSymbol() const
LIB_SYMBOL * GetLibPart() const
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:119
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
VECTOR2I GetPosition() const override
Definition sch_shape.h:85
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SCREEN * LastScreen()
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the sheet's fields.
Definition sch_sheet.h:88
VECTOR2I GetPosition() const override
Definition sch_sheet.h:496
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition sch_sheet.h:233
wxString GetShownName(bool aAllowExtraText) const
Definition sch_sheet.h:138
Schematic symbol object.
Definition sch_symbol.h:76
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, const wxString &aVariantName=wxEmptyString) const override
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
const wxString GetFootprintFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, const wxString &aVariantName=wxEmptyString) const
VECTOR2I GetPosition() const override
Definition sch_symbol.h:867
const LIB_ID & GetLibId() const override
Definition sch_symbol.h:165
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition sch_symbol.h:184
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
virtual wxString GetShownText(const RENDER_SETTINGS *aSettings, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
VECTOR2I GetPosition() const override
Definition sch_text.h:147
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition sch_text.cpp:297
virtual wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Definition sch_text.cpp:318
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< SCH_PIN * > &aPins, REPORTER &aReporter)
An interface to the global shared library manager that is schematic-specific and linked to one projec...
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
const TRANSFORM & GetTransform() const
Definition symbol.h:247
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition transform.cpp:44
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
Definition vector2d.h:561
A wrapper for reporting to a wxString object.
Definition reporter.h:191
void Clear() override
Definition reporter.cpp:84
const wxString & GetMessages() const
Definition reporter.cpp:78
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition common.cpp:558
The common library.
#define FOR_ERC_DRC
Expand '${var-name}' templates in text.
Definition common.h:96
#define _(s)
@ NO_RECURSE
Definition eda_item.h:53
void CheckDuplicatePins(LIB_SYMBOL *aSymbol, std::vector< wxString > &aMessages, UNITS_PROVIDER *aUnitsProvider)
const wxString CommentERC_V[]
Definition erc.cpp:96
const wxString CommentERC_H[]
Definition erc.cpp:79
const std::set< ELECTRICAL_PINTYPE > DrivenPinTypes
Definition erc.cpp:134
const std::set< ELECTRICAL_PINTYPE > DrivingPinTypes
Definition erc.cpp:116
const std::set< ELECTRICAL_PINTYPE > DrivingPowerPinTypes
Definition erc.cpp:128
ERCE_T
ERC error codes.
@ ERCE_POWERPIN_NOT_DRIVEN
Power input pin connected to some others pins but no power out pin to drive it.
@ ERCE_SIMILAR_POWER
2 power pins are equal for case insensitive comparisons.
@ ERCE_MISSING_POWER_INPUT_PIN
Symbol has power input pins that are not placed on the schematic.
@ ERCE_GROUND_PIN_NOT_GROUND
A ground-labeled pin is not on a ground net while another pin is.
@ ERCE_SIMILAR_LABELS
2 labels are equal for case insensitive comparisons.
@ ERCE_STACKED_PIN_SYNTAX
Pin name resembles stacked pin notation.
@ ERCE_ENDPOINT_OFF_GRID
Pin or wire-end off grid.
@ ERCE_SAME_LOCAL_GLOBAL_LABEL
2 labels are equal for case insensitive comparisons.
@ ERCE_SIMILAR_LABEL_AND_POWER
label and pin are equal for case insensitive comparisons.
@ ERCE_FOOTPRINT_LINK_ISSUES
The footprint link is invalid, or points to a missing (or inactive) footprint or library.
@ ERCE_DUPLICATE_PIN_ERROR
@ ERCE_DIFFERENT_UNIT_NET
Shared pin in a multi-unit symbol is connected to more than one net.
@ ERCE_FOUR_WAY_JUNCTION
A four-way junction was found.
@ ERCE_UNDEFINED_NETCLASS
A netclass was referenced but not defined.
@ ERCE_UNRESOLVED_VARIABLE
A text variable could not be resolved.
@ ERCE_SIMULATION_MODEL
An error was found in the simulation model.
@ ERCE_LIB_SYMBOL_MISMATCH
Symbol doesn't match copy in library.
@ ERCE_GENERIC_ERROR
@ ERCE_DIFFERENT_UNIT_FP
Different units of the same symbol have different footprints assigned.
@ ERCE_NOCONNECT_CONNECTED
A no connect symbol is connected to more than 1 pin.
@ ERCE_PIN_TO_PIN_WARNING
@ ERCE_PIN_NOT_DRIVEN
Pin connected to some others pins but no pin to drive it.
@ ERCE_MISSING_INPUT_PIN
Symbol has input pins that are not placed.
@ ERCE_MISSING_UNIT
Symbol has units that are not placed on the schematic.
@ ERCE_FIELD_NAME_WHITESPACE
Field name has leading or trailing whitespace.
@ ERCE_DUPLICATE_SHEET_NAME
Duplicate sheet names within a given sheet.
@ ERCE_MISSING_BIDI_PIN
Symbol has bi-directional pins that are not placed.
@ ERCE_LIB_SYMBOL_ISSUES
Symbol not found in active libraries.
@ ERCE_FOOTPRINT_FILTERS
The assigned footprint doesn't match the footprint filters.
@ ERCE_GENERIC_WARNING
@ ERCE_LABEL_MULTIPLE_WIRES
A label is connected to more than one wire.
@ ERCE_PIN_TO_PIN_ERROR
PIN_ERROR
The values a pin-to-pin entry in the pin matrix can take on.
@ KIFACE_TEST_FOOTPRINT_LINK_LIBRARY_NOT_ENABLED
Definition kiface_ids.h:48
@ KIFACE_TEST_FOOTPRINT_LINK
Definition kiface_ids.h:46
@ KIFACE_TEST_FOOTPRINT_LINK_NO_LIBRARY
Definition kiface_ids.h:47
@ KIFACE_TEST_FOOTPRINT_LINK_NO_FOOTPRINT
Definition kiface_ids.h:49
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
Definition pin_type.h:36
@ PT_INPUT
usual pin input: must be connected
Definition pin_type.h:37
@ PT_NC
not connected (must be left open)
Definition pin_type.h:50
@ PT_OUTPUT
usual output
Definition pin_type.h:38
@ PT_TRISTATE
tri state bus pin
Definition pin_type.h:40
@ PT_BIDI
input or output (like port for a microprocessor)
Definition pin_type.h:39
@ PT_POWER_OUT
output of a regulator: intended to be connected to power input pins
Definition pin_type.h:47
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
Definition pin_type.h:46
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
Definition pin_type.h:45
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
Definition pin_type.h:43
wxString ElectricalPinTypeGetText(ELECTRICAL_PINTYPE)
Definition pin_type.cpp:207
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
@ NO_CLEANUP
Definition schematic.h:75
@ GLOBAL_CLEANUP
Definition schematic.h:77
wxString UnescapeString(const wxString &aSource)
Implement a participant in the KIWAY alchemy.
Definition kiway.h:156
virtual void * IfaceOrAddress(int aDataId)=0
Return pointer to the requested object.
KIBIS_MODEL * model
KIBIS_PIN * pin
@ SCH_LINE_T
Definition typeinfo.h:167
@ SCH_NO_CONNECT_T
Definition typeinfo.h:164
@ SCH_SYMBOL_T
Definition typeinfo.h:176
@ SCH_FIELD_T
Definition typeinfo.h:154
@ SCH_LABEL_T
Definition typeinfo.h:171
@ SCH_LOCATE_ANY_T
Definition typeinfo.h:203
@ SCH_SHEET_T
Definition typeinfo.h:179
@ SCH_HIER_LABEL_T
Definition typeinfo.h:173
@ SCH_TEXT_T
Definition typeinfo.h:155
@ SCH_BUS_WIRE_ENTRY_T
Definition typeinfo.h:165
@ SCH_TEXTBOX_T
Definition typeinfo.h:156
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:172
@ SCH_PIN_T
Definition typeinfo.h:157
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695