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, see <https://www.gnu.org/licenses/>.
20 */
21
22#include <algorithm>
23#include <numeric>
24#include <set>
25
26#include "connection_graph.h"
27#include "kiface_ids.h"
28#include <advanced_config.h>
29#include <common.h> // for ExpandEnvVarSubstitutions
30#include <erc/erc.h>
33#include <string_utils.h>
34#include <sch_pin.h>
35#include <project_sch.h>
38#include <sch_bus_entry.h>
39#include <sch_edit_frame.h>
40#include <sch_marker.h>
41#include <sch_reference_list.h>
42#include <sch_rule_area.h>
43#include <sch_sheet.h>
44#include <sch_sheet_pin.h>
45#include <sch_pin.h>
46#include <sch_textbox.h>
47#include <sch_line.h>
48#include <schematic.h>
49#include <lib_symbol.h>
50#include <sch_symbol.h>
51#include <pin_map.h>
54#include <vector>
55#include <wx/ffile.h>
56#include <sim/sim_lib_mgr.h>
57#include <progress_reporter.h>
58#include <kiway.h>
59#include <pgm_base.h>
61#include <trace_helpers.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
186int ERC_TESTER::TestPinMap( KIFACE* aCvPcb, PROJECT* aProject )
187{
188 int errors = 0;
189 const bool checkStale = m_settings.IsTestEnabled( ERCE_PIN_MAP_STALE_PIN );
190 const bool checkDuplicate = m_settings.IsTestEnabled( ERCE_PIN_MAP_DUPLICATE_PAD );
191 const bool checkBadPad = m_settings.IsTestEnabled( ERCE_PIN_MAP_BAD_PAD );
192
193 typedef void ( *PAD_NUMBERS_FN_PTR )( const wxString&, PROJECT*, std::set<wxString>& );
194
195 PAD_NUMBERS_FN_PTR padFetcher =
196 aCvPcb ? (PAD_NUMBERS_FN_PTR) aCvPcb->IfaceOrAddress( KIFACE_FOOTPRINT_PAD_NUMBERS ) : nullptr;
197
198 std::map<wxString, std::set<wxString>> padCache;
199
200 auto getPads = [&]( const wxString& aFootprintId ) -> const std::set<wxString>&
201 {
202 auto it = padCache.find( aFootprintId );
203
204 if( it != padCache.end() )
205 return it->second;
206
207 std::set<wxString>& pads = padCache[aFootprintId];
208
209 if( padFetcher && !aFootprintId.IsEmpty() )
210 padFetcher( aFootprintId, aProject, pads );
211
212 return pads;
213 };
214
215 // Pin maps and the symbol's pin numbers are library-symbol properties, so iterate unique
216 // screens (not sheet paths) to avoid double-reporting on reused hierarchical sheets.
217 for( SCH_SCREEN* screen = m_screens.GetFirst(); screen; screen = m_screens.GetNext() )
218 {
219 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
220 {
221 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
222 LIB_SYMBOL* lib = symbol->GetLibSymbolRef().get();
223
224 if( !lib )
225 continue;
226
227 const PIN_MAP_SET& maps = lib->GetEffectivePinMaps();
228
229 if( maps.IsEmpty() )
230 continue;
231
232 std::set<wxString> pinNumbers;
233
234 for( const SCH_PIN* pin : lib->GetPins() )
235 pinNumbers.insert( pin->GetNumber() );
236
237 const std::vector<std::set<wxString>>& jumperGroups = lib->JumperPinGroups();
238
239 auto sharesJumperGroup = [&]( const wxString& aPinA, const wxString& aPinB )
240 {
241 for( const std::set<wxString>& group : jumperGroups )
242 {
243 if( group.count( aPinA ) && group.count( aPinB ) )
244 return true;
245 }
246
247 return false;
248 };
249
250 for( const PIN_MAP& map : maps.GetAll() )
251 {
252 if( checkStale )
253 {
254 for( const PIN_MAP_ENTRY& entry : map.GetEntries() )
255 {
256 if( pinNumbers.count( entry.m_PinNumber ) )
257 continue;
258
259 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_PIN_MAP_STALE_PIN );
260 ercItem->SetItems( symbol );
261 ercItem->SetErrorMessage(
262 wxString::Format( _( "Pin map '%s' references unknown symbol pin '%s'" ), map.GetName(),
263 entry.m_PinNumber ) );
264 screen->Append( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
265 errors++;
266 }
267 }
268
269 // A single pin stacked across several pads is allowed. Two pins on one pad is not.
270 if( checkDuplicate )
271 {
272 std::map<wxString, wxString> padToPin;
273
274 for( const PIN_MAP_ENTRY& entry : map.GetEntries() )
275 {
276 for( const wxString& pad : ExpandStackedPinNotation( entry.m_PadNumber ) )
277 {
278 auto it = padToPin.find( pad );
279
280 if( it == padToPin.end() )
281 {
282 padToPin[pad] = entry.m_PinNumber;
283 }
284 else if( it->second != entry.m_PinNumber
285 && !sharesJumperGroup( it->second, entry.m_PinNumber ) )
286 {
287 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_PIN_MAP_DUPLICATE_PAD );
288 ercItem->SetItems( symbol );
289 ercItem->SetErrorMessage(
290 wxString::Format( _( "Symbol pins '%s' and '%s' both map to pad '%s'" ),
291 it->second, entry.m_PinNumber, pad ) );
292 screen->Append( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
293 errors++;
294 }
295 }
296 }
297 }
298 }
299
300 if( checkBadPad && padFetcher )
301 {
302 for( const ASSOCIATED_FOOTPRINT& assoc : lib->GetEffectiveAssociatedFootprints() )
303 {
304 const PIN_MAP* boundMap = maps.FindByName( assoc.m_MapName );
305
306 if( !boundMap )
307 continue;
308
309 const std::set<wxString>& pads = getPads( assoc.m_FootprintLibId.GetUniStringLibId() );
310
311 if( pads.empty() )
312 continue;
313
314 for( const PIN_MAP_ENTRY& entry : boundMap->GetEntries() )
315 {
316 for( const wxString& pad : ExpandStackedPinNotation( entry.m_PadNumber ) )
317 {
318 if( pads.count( pad ) )
319 continue;
320
321 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_PIN_MAP_BAD_PAD );
322 ercItem->SetItems( symbol );
323 ercItem->SetErrorMessage( wxString::Format(
324 _( "Pin map '%s' references pad '%s' not present on footprint '%s'" ),
325 boundMap->GetName(), pad, assoc.m_FootprintLibId.GetUniStringLibId() ) );
326 screen->Append( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
327 errors++;
328 }
329 }
330 }
331 }
332 }
333 }
334
335 if( m_settings.IsTestEnabled( ERCE_PIN_MAP_UNMAPPED_PIN ) && padFetcher )
336 {
337 const wxString variant = m_schematic ? m_schematic->GetCurrentVariant() : wxString();
338
339 for( SCH_SHEET_PATH& sheet : m_sheetList )
340 {
341 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
342 {
343 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
344 LIB_SYMBOL* lib = symbol->GetLibSymbolRef().get();
345
346 if( !lib || lib->GetEffectiveAssociatedFootprints().empty() )
347 continue;
348
349 wxString fpText = symbol->GetFootprintFieldText( true, &sheet, false );
350 LIB_ID fpId;
351
352 if( fpText.IsEmpty() || fpId.Parse( fpText, true ) >= 0 )
353 continue;
354
355 const std::set<wxString>& pads = getPads( fpId.GetUniStringLibId() );
356
357 if( pads.empty() )
358 continue;
359
360 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
361 {
362 if( pin->IsDangling() )
363 continue;
364
365 SCH_PIN::PAD_RESOLUTION state = SCH_PIN::PAD_RESOLUTION::MAPPED;
366 pin->GetEffectivePadNumber( sheet, variant, fpId, &pads, &state );
367
368 if( state != SCH_PIN::PAD_RESOLUTION::UNMAPPED )
369 continue;
370
371 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_PIN_MAP_UNMAPPED_PIN );
372 ercItem->SetItems( pin );
373 ercItem->SetErrorMessage(
374 wxString::Format( _( "Pin '%s' is connected but maps to no pad on footprint '%s'" ),
375 pin->GetNumber(), fpText ) );
376 sheet.LastScreen()->Append( new SCH_MARKER( std::move( ercItem ), pin->GetPosition() ) );
377 errors++;
378 }
379 }
380 }
381 }
382
383 return errors;
384}
385
386
388{
390
391 auto unresolved =
392 [this]( wxString str )
393 {
394 str = ExpandEnvVarSubstitutions( str, &m_schematic->Project() );
395 return str.Matches( wxS( "*${*}*" ) );
396 };
397
398 auto testAssertion =
399 []( const SCH_ITEM* item, const SCH_SHEET_PATH& sheet, SCH_SCREEN* screen,
400 const wxString& text, const VECTOR2I& pos )
401 {
402 static wxRegEx warningExpr( wxS( "^\\$\\{ERC_WARNING\\s*([^}]*)\\}(.*)$" ) );
403 static wxRegEx errorExpr( wxS( "^\\$\\{ERC_ERROR\\s*([^}]*)\\}(.*)$" ) );
404
405 if( warningExpr.Matches( text ) )
406 {
407 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_GENERIC_WARNING );
408 wxString ercText = warningExpr.GetMatch( text, 1 );
409
410 if( item )
411 ercItem->SetItems( item );
412 else
413 ercText += _( " (in drawing sheet)" );
414
415 ercItem->SetSheetSpecificPath( sheet );
416 ercItem->SetErrorMessage( ercText );
417
418 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pos );
419 screen->Append( marker );
420
421 return true;
422 }
423
424 if( errorExpr.Matches( text ) )
425 {
426 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_GENERIC_ERROR );
427 wxString ercText = errorExpr.GetMatch( text, 1 );
428
429 if( item )
430 ercItem->SetItems( item );
431 else
432 ercText += _( " (in drawing sheet)" );
433
434 ercItem->SetSheetSpecificPath( sheet );
435 ercItem->SetErrorMessage( ercText );
436
437 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pos );
438 screen->Append( marker );
439
440 return true;
441 }
442
443 return false;
444 };
445
446 if( aDrawingSheet )
447 {
448 wsItems.SetPageNumber( wxS( "1" ) );
449 wsItems.SetSheetCount( 1 );
450 wsItems.SetFileName( wxS( "dummyFilename" ) );
451 wsItems.SetSheetName( wxS( "dummySheet" ) );
452 wsItems.SetSheetLayer( wxS( "dummyLayer" ) );
453 wsItems.SetProject( &m_schematic->Project() );
454 wsItems.BuildDrawItemsList( aDrawingSheet->GetPageInfo(), aDrawingSheet->GetTitleBlock() );
455 }
456
457 for( const SCH_SHEET_PATH& sheet : m_sheetList )
458 {
459 SCH_SCREEN* screen = sheet.LastScreen();
460
461 for( SCH_ITEM* item : screen->Items().OfType( SCH_LOCATE_ANY_T ) )
462 {
463 if( item->Type() == SCH_SYMBOL_T )
464 {
465 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
466
467 for( SCH_FIELD& field : symbol->GetFields() )
468 {
469 if( unresolved( field.GetShownText( &sheet, true ) ) )
470 {
472 ercItem->SetItems( symbol );
473 ercItem->SetSheetSpecificPath( sheet );
474
475 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), field.GetPosition() );
476 screen->Append( marker );
477 }
478
479 testAssertion( &field, sheet, screen, field.GetText(), field.GetPosition() );
480 }
481
482 if( symbol->GetLibSymbolRef() )
483 {
485 [&]( SCH_ITEM* child )
486 {
487 if( child->Type() == SCH_FIELD_T )
488 {
489 // test only SCH_SYMBOL fields, not LIB_SYMBOL fields
490 }
491 else if( child->Type() == SCH_TEXT_T )
492 {
493 SCH_TEXT* textItem = static_cast<SCH_TEXT*>( child );
494
495 if( unresolved( textItem->GetShownText( &sheet, true ) ) )
496 {
498 ercItem->SetItems( symbol );
499 ercItem->SetSheetSpecificPath( sheet );
500
501 BOX2I bbox = textItem->GetBoundingBox();
502 bbox = symbol->GetTransform().TransformCoordinate( bbox );
503 VECTOR2I pos = bbox.Centre() + symbol->GetPosition();
504
505 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pos );
506 screen->Append( marker );
507 }
508
509 testAssertion( symbol, sheet, screen, textItem->GetText(),
510 textItem->GetPosition() );
511 }
512 else if( child->Type() == SCH_TEXTBOX_T )
513 {
514 SCH_TEXTBOX* textboxItem = static_cast<SCH_TEXTBOX*>( child );
515
516 if( unresolved( textboxItem->GetShownText( nullptr, &sheet, true ) ) )
517 {
519 ercItem->SetItems( symbol );
520 ercItem->SetSheetSpecificPath( sheet );
521
522 BOX2I bbox = textboxItem->GetBoundingBox();
523 bbox = symbol->GetTransform().TransformCoordinate( bbox );
524 VECTOR2I pos = bbox.Centre() + symbol->GetPosition();
525
526 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pos );
527 screen->Append( marker );
528 }
529
530 testAssertion( symbol, sheet, screen, textboxItem->GetText(),
531 textboxItem->GetPosition() );
532 }
533 },
535 }
536 }
537 else if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item ) )
538 {
539 for( SCH_FIELD& field : label->GetFields() )
540 {
541 if( unresolved( field.GetShownText( &sheet, true ) ) )
542 {
544 ercItem->SetItems( label );
545 ercItem->SetSheetSpecificPath( sheet );
546
547 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), field.GetPosition() );
548 screen->Append( marker );
549 }
550
551 testAssertion( &field, sheet, screen, field.GetText(), field.GetPosition() );
552 }
553 }
554 else if( item->Type() == SCH_SHEET_T )
555 {
556 SCH_SHEET* subSheet = static_cast<SCH_SHEET*>( item );
557
558 for( SCH_FIELD& field : subSheet->GetFields() )
559 {
560 if( unresolved( field.GetShownText( &sheet, true ) ) )
561 {
563 ercItem->SetItems( subSheet );
564 ercItem->SetSheetSpecificPath( sheet );
565
566 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), field.GetPosition() );
567 screen->Append( marker );
568 }
569
570 testAssertion( &field, sheet, screen, field.GetText(), field.GetPosition() );
571 }
572
573 SCH_SHEET_PATH subSheetPath = sheet;
574 subSheetPath.push_back( subSheet );
575
576 for( SCH_SHEET_PIN* pin : subSheet->GetPins() )
577 {
578 if( pin->GetShownText( &subSheetPath, true ).Matches( wxS( "*${*}*" ) ) )
579 {
581 ercItem->SetItems( pin );
582 ercItem->SetSheetSpecificPath( sheet );
583
584 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
585 screen->Append( marker );
586 }
587 }
588 }
589 else if( SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( item ) )
590 {
591 if( text->GetShownText( &sheet, true ).Matches( wxS( "*${*}*" ) ) )
592 {
594 ercItem->SetItems( text );
595 ercItem->SetSheetSpecificPath( sheet );
596
597 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), text->GetPosition() );
598 screen->Append( marker );
599 }
600
601 testAssertion( text, sheet, screen, text->GetText(), text->GetPosition() );
602 }
603 else if( SCH_TEXTBOX* textBox = dynamic_cast<SCH_TEXTBOX*>( item ) )
604 {
605 if( textBox->GetShownText( nullptr, &sheet, true ).Matches( wxS( "*${*}*" ) ) )
606 {
608 ercItem->SetItems( textBox );
609 ercItem->SetSheetSpecificPath( sheet );
610
611 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), textBox->GetPosition() );
612 screen->Append( marker );
613 }
614
615 testAssertion( textBox, sheet, screen, textBox->GetText(), textBox->GetPosition() );
616 }
617 }
618
619 for( DS_DRAW_ITEM_BASE* item = wsItems.GetFirst(); item; item = wsItems.GetNext() )
620 {
621 if( DS_DRAW_ITEM_TEXT* text = dynamic_cast<DS_DRAW_ITEM_TEXT*>( item ) )
622 {
623 if( testAssertion( nullptr, sheet, screen, text->GetText(), text->GetPosition() ) )
624 {
625 // Don't run unresolved test
626 }
627 else if( text->GetShownText( true ).Matches( wxS( "*${*}*" ) ) )
628 {
629 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
630 ercItem->SetErrorMessage( _( "Unresolved text variable in drawing sheet" ) );
631 ercItem->SetSheetSpecificPath( sheet );
632
633 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), text->GetPosition() );
634 screen->Append( marker );
635 }
636 }
637 }
638 }
639}
640
641
643{
644 int warnings = 0;
645
646 for( const SCH_SHEET_PATH& sheet : m_sheetList )
647 {
648 SCH_SCREEN* screen = sheet.LastScreen();
649
650 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
651 {
652 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
653
654 for( SCH_FIELD& field : symbol->GetFields() )
655 {
656 wxString trimmedFieldName = field.GetName();
657 trimmedFieldName.Trim();
658 trimmedFieldName.Trim( false );
659
660 if( field.GetName() != trimmedFieldName )
661 {
663 ercItem->SetItems( symbol, &field );
664 ercItem->SetItemsSheetPaths( sheet, sheet );
665 ercItem->SetSheetSpecificPath( sheet );
666 ercItem->SetErrorMessage(
667 wxString::Format(
668 _( "Field name has leading or trailing whitespace: '%s'" ),
669 field.GetName() ) );
670
671 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), field.GetPosition() );
672 screen->Append( marker );
673 warnings++;
674 }
675 }
676 }
677
678 for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
679 {
680 SCH_SHEET* subSheet = static_cast<SCH_SHEET*>( item );
681
682 for( SCH_FIELD& field : subSheet->GetFields() )
683 {
684 wxString trimmedFieldName = field.GetName();
685 trimmedFieldName.Trim();
686 trimmedFieldName.Trim( false );
687
688 if( field.GetName() != trimmedFieldName )
689 {
691 ercItem->SetItems( subSheet, &field );
692 ercItem->SetItemsSheetPaths( sheet, sheet );
693 ercItem->SetSheetSpecificPath( sheet );
694 ercItem->SetErrorMessage(
695 wxString::Format(
696 _( "Field name has leading or trailing whitespace: '%s'" ),
697 field.GetName() ) );
698
699 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), field.GetPosition() );
700 screen->Append( marker );
701 warnings++;
702 }
703 }
704 }
705 }
706
707 return warnings;
708}
709
710
712{
713 int errors = 0;
714
715 for( std::pair<const wxString, SCH_REFERENCE_LIST>& symbol : m_refMap )
716 {
717 SCH_REFERENCE_LIST& refList = symbol.second;
718
719 if( refList.GetCount() == 0 )
720 {
721 wxFAIL; // it should not happen
722 continue;
723 }
724
725 // Reference footprint
726 SCH_SYMBOL* unit = nullptr;
727 wxString unitName;
728 wxString unitFP;
729
730 for( size_t ii = 0; ii < refList.GetCount(); ++ii )
731 {
732 SCH_SHEET_PATH sheetPath = refList.GetItem( ii ).GetSheetPath();
733 unitFP = refList.GetItem( ii ).GetFootprint();
734
735 if( !unitFP.IsEmpty() )
736 {
737 unit = refList.GetItem( ii ).GetSymbol();
738 unitName = unit->GetRef( &sheetPath, true );
739 break;
740 }
741 }
742
743 for( size_t ii = 0; ii < refList.GetCount(); ++ii )
744 {
745 SCH_REFERENCE& secondRef = refList.GetItem( ii );
746 SCH_SYMBOL* secondUnit = secondRef.GetSymbol();
747 wxString secondName = secondUnit->GetRef( &secondRef.GetSheetPath(), true );
748 const wxString secondFp = secondRef.GetFootprint();
749 wxString msg;
750
751 if( unit && !secondFp.IsEmpty() && unitFP != secondFp )
752 {
753 msg.Printf( _( "Different footprints assigned to %s and %s" ),
754 unitName, secondName );
755
756 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_FP );
757 ercItem->SetErrorMessage( msg );
758 ercItem->SetItems( unit, secondUnit );
759
760 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), secondUnit->GetPosition() );
761 secondRef.GetSheetPath().LastScreen()->Append( marker );
762
763 ++errors;
764 }
765 }
766 }
767
768 return errors;
769}
770
771
773{
774 int errors = 0;
775
776 for( std::pair<const wxString, SCH_REFERENCE_LIST>& symbol : m_refMap )
777 {
778 SCH_REFERENCE_LIST& refList = symbol.second;
779
780 wxCHECK2( refList.GetCount(), continue );
781
782 // Reference unit
783 SCH_REFERENCE& base_ref = refList.GetItem( 0 );
784 SCH_SYMBOL* unit = base_ref.GetSymbol();
785 LIB_SYMBOL* libSymbol = base_ref.GetLibPart();
786
787 if( static_cast<ssize_t>( refList.GetCount() ) == libSymbol->GetUnitCount() )
788 continue;
789
790 std::set<int> lib_units;
791 std::set<int> instance_units;
792 std::set<int> missing_units;
793
794 auto report =
795 [&]( std::set<int>& aMissingUnits, const wxString& aErrorMsg, int aErrorCode )
796 {
797 wxString msg;
798 wxString missing_pin_units = wxS( "[ " );
799 int ii = 0;
800
801 for( int missing_unit : aMissingUnits )
802 {
803 if( ii++ == 3 )
804 {
805 missing_pin_units += wxS( "..." );
806 break;
807 }
808
809 missing_pin_units += libSymbol->GetUnitDisplayName( missing_unit, false ) + ", " ;
810 }
811
812 missing_pin_units.Truncate( missing_pin_units.length() - 2 );
813 missing_pin_units += wxS( " ]" );
814
815 msg.Printf( aErrorMsg, symbol.first, missing_pin_units );
816
817 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( aErrorCode );
818 ercItem->SetErrorMessage( msg );
819 ercItem->SetItems( unit );
820 ercItem->SetSheetSpecificPath( base_ref.GetSheetPath() );
821 ercItem->SetItemsSheetPaths( base_ref.GetSheetPath() );
822
823 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), unit->GetPosition() );
824 base_ref.GetSheetPath().LastScreen()->Append( marker );
825
826 ++errors;
827 };
828
829 for( int ii = 1; ii <= libSymbol->GetUnitCount(); ++ii )
830 lib_units.insert( lib_units.end(), ii );
831
832 for( size_t ii = 0; ii < refList.GetCount(); ++ii )
833 instance_units.insert( instance_units.end(), refList.GetItem( ii ).GetUnit() );
834
835 std::set_difference( lib_units.begin(), lib_units.end(),
836 instance_units.begin(), instance_units.end(),
837 std::inserter( missing_units, missing_units.begin() ) );
838
839 if( !missing_units.empty() && m_settings.IsTestEnabled( ERCE_MISSING_UNIT ) )
840 {
841 report( missing_units, _( "Symbol %s has unplaced units %s" ), ERCE_MISSING_UNIT );
842 }
843
844 std::set<int> missing_power;
845 std::set<int> missing_input;
846 std::set<int> missing_bidi;
847
848 for( int missing_unit : missing_units )
849 {
850 int bodyStyle = 0;
851
852 for( size_t ii = 0; ii < refList.GetCount(); ++ii )
853 {
854 if( refList.GetItem( ii ).GetUnit() == missing_unit )
855 {
856 bodyStyle = refList.GetItem( ii ).GetSymbol()->GetBodyStyle();
857 break;
858 }
859 }
860
861 for( SCH_PIN* pin : libSymbol->GetGraphicalPins( missing_unit, bodyStyle ) )
862 {
863 switch( pin->GetType() )
864 {
866 missing_power.insert( missing_unit );
867 break;
868
870 missing_bidi.insert( missing_unit );
871 break;
872
874 missing_input.insert( missing_unit );
875 break;
876
877 default:
878 break;
879 }
880 }
881 }
882
883 if( !missing_power.empty() && m_settings.IsTestEnabled( ERCE_MISSING_POWER_INPUT_PIN ) )
884 {
885 report( missing_power, _( "Symbol %s has input power pins in units %s that are not placed" ),
887 }
888
889 if( !missing_input.empty() && m_settings.IsTestEnabled( ERCE_MISSING_INPUT_PIN ) )
890 {
891 report( missing_input, _( "Symbol %s has input pins in units %s that are not placed" ),
893 }
894
895 if( !missing_bidi.empty() && m_settings.IsTestEnabled( ERCE_MISSING_BIDI_PIN ) )
896 {
897 report( missing_bidi, _( "Symbol %s has bidirectional pins in units %s that are not placed" ),
899 }
900 }
901
902 return errors;
903}
904
905
907{
908 int err_count = 0;
909 std::shared_ptr<NET_SETTINGS>& settings = m_schematic->Project().GetProjectFile().NetSettings();
910 wxString defaultNetclass = settings->GetDefaultNetclass()->GetName();
911
912 auto logError =
913 [&]( const SCH_SHEET_PATH& sheet, SCH_ITEM* item, const wxString& netclass )
914 {
915 err_count++;
916
917 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNDEFINED_NETCLASS );
918
919 ercItem->SetItems( item );
920 ercItem->SetErrorMessage( wxString::Format( _( "Netclass %s is not defined" ), netclass ) );
921
922 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), item->GetPosition() );
923 sheet.LastScreen()->Append( marker );
924 };
925
926 for( const SCH_SHEET_PATH& sheet : m_sheetList )
927 {
928 for( SCH_ITEM* item : sheet.LastScreen()->Items() )
929 {
930 item->RunOnChildren(
931 [&]( SCH_ITEM* aChild )
932 {
933 if( aChild->Type() == SCH_FIELD_T )
934 {
935 SCH_FIELD* field = static_cast<SCH_FIELD*>( aChild );
936
937 if( field->GetCanonicalName() == wxT( "Netclass" ) )
938 {
939 wxString netclass = field->GetShownText( &sheet, false );
940
941 if( !netclass.empty() && !netclass.IsSameAs( defaultNetclass )
942 && !settings->HasNetclass( netclass ) )
943 {
944 logError( sheet, item, netclass );
945 }
946 }
947 }
948
949 return true;
950 },
952 }
953 }
954
955 return err_count;
956}
957
958
960{
961 int err_count = 0;
962
963 for( const SCH_SHEET_PATH& sheet : m_sheetList )
964 {
965 std::map<VECTOR2I, std::vector<SCH_ITEM*>> connMap;
966
967 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_LABEL_T ) )
968 {
969 SCH_LABEL* label = static_cast<SCH_LABEL*>( item );
970
971 for( const VECTOR2I& pt : label->GetConnectionPoints() )
972 connMap[pt].emplace_back( label );
973 }
974
975 for( const std::pair<const VECTOR2I, std::vector<SCH_ITEM*>>& pair : connMap )
976 {
977 std::vector<SCH_ITEM*> lines;
978
979 for( SCH_ITEM* item : sheet.LastScreen()->Items().Overlapping( SCH_LINE_T, pair.first ) )
980 {
981 SCH_LINE* line = static_cast<SCH_LINE*>( item );
982
983 if( line->IsGraphicLine() )
984 continue;
985
986 // If the line is connected at the endpoint, then there will be a junction
987 if( !line->IsEndPoint( pair.first ) )
988 lines.emplace_back( line );
989 }
990
991 if( lines.size() > 1 )
992 {
993 err_count++;
994 lines.resize( 3 ); // Only show the first 3 lines and if there are only two, adds a nullptr
995
996 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LABEL_MULTIPLE_WIRES );
997 wxString msg = wxString::Format( _( "Label connects more than one wire at %d, %d" ),
998 pair.first.x, pair.first.y );
999
1000 ercItem->SetItems( pair.second.front(), lines[0], lines[1], lines[2] );
1001 ercItem->SetErrorMessage( msg );
1002 ercItem->SetSheetSpecificPath( sheet );
1003
1004 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pair.first );
1005 sheet.LastScreen()->Append( marker );
1006 }
1007 }
1008 }
1009
1010 return err_count;
1011}
1012
1013
1015{
1016 int err_count = 0;
1017
1018 auto pinStackAlreadyRepresented =
1019 []( SCH_PIN* pin, std::vector<SCH_ITEM*>& collection ) -> bool
1020 {
1021 for( SCH_ITEM*& item : collection )
1022 {
1023 if( item->Type() == SCH_PIN_T && item->GetParentSymbol() == pin->GetParentSymbol() )
1024 {
1025 if( pin->IsVisible() && !static_cast<SCH_PIN*>( item )->IsVisible() )
1026 item = pin;
1027
1028 return true;
1029 }
1030 }
1031
1032 return false;
1033 };
1034
1035 for( const SCH_SHEET_PATH& sheet : m_sheetList )
1036 {
1037 std::map<VECTOR2I, std::vector<SCH_ITEM*>> connMap;
1038 SCH_SCREEN* screen = sheet.LastScreen();
1039
1040 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1041 {
1042 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1043
1044 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
1045 {
1046 std::vector<SCH_ITEM*>& entry = connMap[pin->GetPosition()];
1047
1048 // Only one pin per pin-stack.
1049 if( pinStackAlreadyRepresented( pin, entry ) )
1050 continue;
1051
1052 entry.emplace_back( pin );
1053 }
1054 }
1055
1056 for( SCH_ITEM* item : screen->Items().OfType( SCH_LINE_T ) )
1057 {
1058 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1059
1060 if( line->IsGraphicLine() )
1061 continue;
1062
1063 for( const VECTOR2I& pt : line->GetConnectionPoints() )
1064 connMap[pt].emplace_back( line );
1065 }
1066
1067 for( const std::pair<const VECTOR2I, std::vector<SCH_ITEM*>>& pair : connMap )
1068 {
1069 if( pair.second.size() >= 4 )
1070 {
1071 err_count++;
1072
1073 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOUR_WAY_JUNCTION );
1074
1075 ercItem->SetItems( pair.second[0], pair.second[1], pair.second[2], pair.second[3] );
1076
1077 wxString msg = wxString::Format( _( "Four items connected at %d, %d" ),
1078 pair.first.x, pair.first.y );
1079 ercItem->SetErrorMessage( msg );
1080
1081 ercItem->SetSheetSpecificPath( sheet );
1082
1083 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pair.first );
1084 sheet.LastScreen()->Append( marker );
1085 }
1086 }
1087 }
1088
1089 return err_count;
1090}
1091
1092
1094{
1095 int err_count = 0;
1096
1097 for( const SCH_SHEET_PATH& sheet : m_sheetList )
1098 {
1099 std::map<VECTOR2I, std::vector<SCH_ITEM*>> pinMap;
1100
1101 auto addOther =
1102 [&]( const VECTOR2I& pt, SCH_ITEM* aOther )
1103 {
1104 if( pinMap.count( pt ) )
1105 pinMap[pt].emplace_back( aOther );
1106 };
1107
1108 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
1109 {
1110 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1111
1112 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
1113 {
1114 if( pin->GetType() == ELECTRICAL_PINTYPE::PT_NC )
1115 pinMap[pin->GetPosition()].emplace_back( pin );
1116 }
1117 }
1118
1119 for( SCH_ITEM* item : sheet.LastScreen()->Items() )
1120 {
1121 if( item->Type() == SCH_SYMBOL_T )
1122 {
1123 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1124
1125 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
1126 {
1127 if( pin->GetType() != ELECTRICAL_PINTYPE::PT_NC )
1128 addOther( pin->GetPosition(), pin );
1129 }
1130 }
1131 else if( item->IsConnectable() && item->Type() != SCH_NO_CONNECT_T )
1132 {
1133 for( const VECTOR2I& pt : item->GetConnectionPoints() )
1134 addOther( pt, item );
1135 }
1136 }
1137
1138 for( const std::pair<const VECTOR2I, std::vector<SCH_ITEM*>>& pair : pinMap )
1139 {
1140 if( pair.second.size() > 1 )
1141 {
1142 bool all_nc = true;
1143
1144 for( SCH_ITEM* item : pair.second )
1145 {
1146 if( item->Type() != SCH_PIN_T )
1147 {
1148 all_nc = false;
1149 break;
1150 }
1151
1152 SCH_PIN* pin = static_cast<SCH_PIN*>( item );
1153
1154 if( pin->GetType() != ELECTRICAL_PINTYPE::PT_NC )
1155 {
1156 all_nc = false;
1157 break;
1158 }
1159 }
1160
1161 if( all_nc )
1162 continue;
1163
1164 err_count++;
1165
1166 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_CONNECTED );
1167
1168 ercItem->SetItems( pair.second[0], pair.second[1],
1169 pair.second.size() > 2 ? pair.second[2] : nullptr,
1170 pair.second.size() > 3 ? pair.second[3] : nullptr );
1171 ercItem->SetErrorMessage( _( "Pin with 'no connection' type is connected" ) );
1172 ercItem->SetSheetSpecificPath( sheet );
1173
1174 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pair.first );
1175 sheet.LastScreen()->Append( marker );
1176 }
1177 }
1178 }
1179
1180 return err_count;
1181}
1182
1183
1185{
1186 int errors = 0;
1187
1188 // Map each net name to the pins (with sheet context) found on that net so we can later
1189 // perform cross-net compatibility checks for grouped net chains.
1190 std::unordered_map<wxString, std::vector<ERC_SCH_PIN_CONTEXT>> netToPins;
1191
1192 for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
1193 {
1194 using iterator_t = std::vector<ERC_SCH_PIN_CONTEXT>::iterator;
1195 std::vector<ERC_SCH_PIN_CONTEXT> pins;
1196 std::unordered_map<EDA_ITEM*, SCH_SCREEN*> pinToScreenMap;
1197 bool has_noconnect = false;
1198
1199 for( CONNECTION_SUBGRAPH* subgraph: net.second )
1200 {
1201 if( subgraph->GetNoConnect() )
1202 has_noconnect = true;
1203
1204 for( SCH_ITEM* item : subgraph->GetItems() )
1205 {
1206 if( item->Type() == SCH_PIN_T )
1207 {
1208 pins.emplace_back( static_cast<SCH_PIN*>( item ), subgraph->GetSheet() );
1209 netToPins[ net.first.Name ].emplace_back( static_cast<SCH_PIN*>( item ), subgraph->GetSheet() );
1210 pinToScreenMap[item] = subgraph->GetSheet().LastScreen();
1211 }
1212 }
1213 }
1214
1215 std::sort( pins.begin(), pins.end(),
1216 []( const ERC_SCH_PIN_CONTEXT& lhs, const ERC_SCH_PIN_CONTEXT& rhs )
1217 {
1218 int ret = StrNumCmp( lhs.Pin()->GetParentSymbol()->GetRef( &lhs.Sheet() ),
1219 rhs.Pin()->GetParentSymbol()->GetRef( &rhs.Sheet() ) );
1220
1221 if( ret == 0 )
1222 ret = StrNumCmp( lhs.Pin()->GetNumber(), rhs.Pin()->GetNumber() );
1223
1224 if( ret == 0 )
1225 ret = lhs < rhs; // Fallback to hash to guarantee deterministic sort
1226
1227 return ret < 0;
1228 } );
1229
1230 ERC_SCH_PIN_CONTEXT needsDriver;
1232 bool hasDriver = false;
1233 std::vector<ERC_SCH_PIN_CONTEXT*> pinsNeedingDrivers;
1234 std::vector<ERC_SCH_PIN_CONTEXT*> nonPowerPinsNeedingDrivers;
1235 std::vector<ERC_SCH_PIN_CONTEXT*> powerInPinsNeedingDrivers;
1236
1237 // We need different drivers for power nets and normal nets.
1238 // A power net has at least one pin having the ELECTRICAL_PINTYPE::PT_POWER_IN
1239 // and power nets can be driven only by ELECTRICAL_PINTYPE::PT_POWER_OUT pins
1240 bool ispowerNet = false;
1241
1242 for( ERC_SCH_PIN_CONTEXT& refPin : pins )
1243 {
1244 if( refPin.Pin()->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN )
1245 {
1246 ispowerNet = true;
1247 break;
1248 }
1249 }
1250
1251 std::vector<std::tuple<iterator_t, iterator_t, PIN_ERROR>> pin_mismatches;
1252 std::map<iterator_t, int> pin_mismatch_counts;
1253
1254 for( auto refIt = pins.begin(); refIt != pins.end(); ++refIt )
1255 {
1256 ERC_SCH_PIN_CONTEXT& refPin = *refIt;
1257 ELECTRICAL_PINTYPE refType = refPin.Pin()->GetType();
1258
1259 if( DrivenPinTypes.contains( refType ) )
1260 {
1261 // needsDriver will be the pin shown in the error report eventually, so try to
1262 // upgrade to a "better" pin if possible: something visible and only a power symbol
1263 // if this net needs a power driver
1264 pinsNeedingDrivers.push_back( &refPin );
1265
1266 if( !refPin.Pin()->IsPower() )
1267 nonPowerPinsNeedingDrivers.push_back( &refPin );
1268
1269 if( refType == ELECTRICAL_PINTYPE::PT_POWER_IN )
1270 powerInPinsNeedingDrivers.push_back( &refPin );
1271
1272 if( !needsDriver.Pin()
1273 || ( !needsDriver.Pin()->IsVisible() && refPin.Pin()->IsVisible() )
1274 || ( ispowerNet != ( needsDriverType == ELECTRICAL_PINTYPE::PT_POWER_IN )
1275 && ispowerNet == ( refType == ELECTRICAL_PINTYPE::PT_POWER_IN ) ) )
1276 {
1277 needsDriver = refPin;
1278 needsDriverType = needsDriver.Pin()->GetType();
1279 }
1280 }
1281
1282 if( ispowerNet )
1283 hasDriver |= ( DrivingPowerPinTypes.count( refType ) != 0 );
1284 else
1285 hasDriver |= ( DrivingPinTypes.count( refType ) != 0 );
1286
1287 for( auto testIt = refIt + 1; testIt != pins.end(); ++testIt )
1288 {
1289 ERC_SCH_PIN_CONTEXT& testPin = *testIt;
1290
1291 // Multiple pins in the same symbol that share a type,
1292 // name and position are considered
1293 // "stacked" and shouldn't trigger ERC errors
1294 if( refPin.Pin()->IsStacked( testPin.Pin() ) && refPin.Sheet() == testPin.Sheet() )
1295 continue;
1296
1297 ELECTRICAL_PINTYPE testType = testPin.Pin()->GetType();
1298
1299 if( ispowerNet )
1300 hasDriver |= DrivingPowerPinTypes.contains( testType );
1301 else
1302 hasDriver |= DrivingPinTypes.contains( testType );
1303
1304 PIN_ERROR erc = m_settings.GetPinMapValue( refType, testType );
1305
1308
1309 if( erc != PIN_ERROR::OK && m_settings.IsTestEnabled( ercCode ) )
1310 {
1311 pin_mismatches.emplace_back( std::tuple<iterator_t, iterator_t, PIN_ERROR>{ refIt, testIt, erc } );
1312
1313 if( m_settings.GetERCSortingMetric() == ERC_PIN_SORTING_METRIC::SM_HEURISTICS )
1314 {
1315 pin_mismatch_counts[refIt] = m_settings.GetPinTypeWeight( ( *refIt ).Pin()->GetType() );
1316 pin_mismatch_counts[testIt] = m_settings.GetPinTypeWeight( ( *testIt ).Pin()->GetType() );
1317 }
1318 else
1319 {
1320 if( !pin_mismatch_counts.contains( testIt ) )
1321 pin_mismatch_counts.emplace( testIt, 1 );
1322 else
1323 pin_mismatch_counts[testIt]++;
1324
1325 if( !pin_mismatch_counts.contains( refIt ) )
1326 pin_mismatch_counts.emplace( refIt, 1 );
1327 else
1328 pin_mismatch_counts[refIt]++;
1329 }
1330 }
1331 }
1332 }
1333
1334 std::multimap<size_t, iterator_t, std::greater<size_t>> pins_dsc;
1335
1336 std::transform( pin_mismatch_counts.begin(), pin_mismatch_counts.end(),
1337 std::inserter( pins_dsc, pins_dsc.begin() ),
1338 []( const auto& p )
1339 {
1340 return std::pair<size_t, iterator_t>( p.second, p.first );
1341 } );
1342
1343 for( const auto& [amount, pinItBind] : pins_dsc )
1344 {
1345 auto& pinIt = pinItBind;
1346
1347 if( pin_mismatches.empty() )
1348 break;
1349
1350 SCH_PIN* pin = ( *pinIt ).Pin();
1351 VECTOR2I position = pin->GetPosition();
1352
1353 iterator_t nearest_pin = pins.end();
1354 double smallest_distance = std::numeric_limits<double>::infinity();
1355 PIN_ERROR erc;
1356
1357 std::erase_if(
1358 pin_mismatches,
1359 [&]( const auto& tuple )
1360 {
1361 iterator_t other;
1362
1363 if( pinIt == std::get<0>( tuple ) )
1364 other = std::get<1>( tuple );
1365 else if( pinIt == std::get<1>( tuple ) )
1366 other = std::get<0>( tuple );
1367 else
1368 return false;
1369
1370 if( ( *pinIt ).Sheet().Cmp( ( *other ).Sheet() ) != 0 )
1371 {
1372 if( std::isinf( smallest_distance ) )
1373 {
1374 nearest_pin = other;
1375 erc = std::get<2>( tuple );
1376 }
1377 }
1378 else
1379 {
1380 double distance = position.Distance( ( *other ).Pin()->GetPosition() );
1381
1382 if( std::isinf( smallest_distance ) || distance < smallest_distance )
1383 {
1384 smallest_distance = distance;
1385 nearest_pin = other;
1386 erc = std::get<2>( tuple );
1387 }
1388 }
1389
1390 return true;
1391 } );
1392
1393 if( nearest_pin != pins.end() )
1394 {
1395 SCH_PIN* other_pin = ( *nearest_pin ).Pin();
1396
1399 ercItem->SetItems( pin, other_pin );
1400 ercItem->SetSheetSpecificPath( ( *pinIt ).Sheet() );
1401 ercItem->SetItemsSheetPaths( ( *pinIt ).Sheet(), ( *nearest_pin ).Sheet() );
1402
1403 ercItem->SetErrorMessage( wxString::Format( _( "Pins of type %s and %s are connected" ),
1404 ElectricalPinTypeGetText( pin->GetType() ),
1405 ElectricalPinTypeGetText( other_pin->GetType() ) ) );
1406
1407 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
1408 pinToScreenMap[pin]->Append( marker );
1409 errors++;
1410 }
1411 }
1412
1413 if( needsDriver.Pin() && !hasDriver && !has_noconnect )
1414 {
1415 int err_code = ispowerNet ? ERCE_POWERPIN_NOT_DRIVEN : ERCE_PIN_NOT_DRIVEN;
1416
1417 // NEW: For power nets, before reporting a not-driven error, look across the
1418 // net chain (multi-net chain formed via passives) to see if there is a
1419 // power driver pin on any other net in the same chain. If so, suppress the
1420 // error because the net chain as a whole is driven.
1421 bool suppressForNetChainDriver = false;
1422
1423 if( ispowerNet && m_schematic && m_schematic->ConnectionGraph() )
1424 {
1425 const wxString& thisNetName = net.first.Name;
1426 const auto& netChains = m_schematic->ConnectionGraph()->GetCommittedNetChains();
1427
1428 auto netHasPowerDriver = [&]( const wxString& aNetName ) -> bool
1429 {
1430 // Scan m_nets for the named net and test its pins for a power driver type.
1431 for( const auto& n : m_nets )
1432 {
1433 if( n.first.Name != aNetName )
1434 continue;
1435
1436 for( CONNECTION_SUBGRAPH* sg : n.second )
1437 {
1438 for( SCH_ITEM* item : sg->GetItems() )
1439 {
1440 if( item->Type() == SCH_PIN_T )
1441 {
1442 SCH_PIN* p = static_cast<SCH_PIN*>( item );
1443 if( DrivingPowerPinTypes.contains( p->GetType() ) )
1444 return true;
1445 }
1446 }
1447 }
1448
1449 break; // found matching net (whether driver or not)
1450 }
1451
1452 return false;
1453 };
1454
1455 for( const auto& sig : netChains )
1456 {
1457 if( !sig )
1458 continue;
1459
1460 const auto& sigNets = sig->GetNets();
1461 bool containsThisNet = std::find( sigNets.begin(), sigNets.end(), thisNetName ) != sigNets.end();
1462
1463 if( !containsThisNet )
1464 continue;
1465
1466 // Look for a different net in this chain that has a power driver.
1467 for( const wxString& otherNet : sigNets )
1468 {
1469 if( otherNet == thisNetName )
1470 continue; // skip same net (we already know it lacks a driver)
1471
1472 if( netHasPowerDriver( otherNet ) )
1473 {
1474 suppressForNetChainDriver = true;
1475 break;
1476 }
1477 }
1478
1479 break; // examined the containing chain
1480 }
1481 }
1482
1483 if( !suppressForNetChainDriver && m_settings.IsTestEnabled( err_code ) )
1484 {
1485 std::vector<ERC_SCH_PIN_CONTEXT*> pinsToMark;
1486
1487 // The marker should land on a pin matching the error message: for an
1488 // ERCE_POWERPIN_NOT_DRIVEN error mark a PT_POWER_IN pin (which is what the
1489 // error refers to), for ERCE_PIN_NOT_DRIVEN prefer a pin that is not on a
1490 // power symbol so the marker is anchored to the consuming pin rather than
1491 // a power flag.
1492 if( m_showAllErrors )
1493 {
1494 if( ispowerNet && !powerInPinsNeedingDrivers.empty() )
1495 pinsToMark = powerInPinsNeedingDrivers;
1496 else if( !nonPowerPinsNeedingDrivers.empty() )
1497 pinsToMark = nonPowerPinsNeedingDrivers;
1498 else
1499 pinsToMark = pinsNeedingDrivers;
1500 }
1501 else
1502 {
1503 if( ispowerNet && !powerInPinsNeedingDrivers.empty() )
1504 pinsToMark.push_back( powerInPinsNeedingDrivers.front() );
1505 else
1506 pinsToMark.push_back( &needsDriver );
1507 }
1508
1509 for( ERC_SCH_PIN_CONTEXT* pinCtx : pinsToMark )
1510 {
1511 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( err_code );
1512
1513 ercItem->SetItems( pinCtx->Pin() );
1514 ercItem->SetSheetSpecificPath( pinCtx->Sheet() );
1515 ercItem->SetItemsSheetPaths( pinCtx->Sheet() );
1516
1517 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pinCtx->Pin()->GetPosition() );
1518 pinToScreenMap[pinCtx->Pin()]->Append( marker );
1519 errors++;
1520 }
1521 }
1522 }
1523 }
1524
1525 // --- Additional net-chain-level checking ---
1526 // If a pin participates in a grouped net chain (spanning multiple nets via passives), ensure
1527 // that all other pins reachable through that chain are electrically compatible even if
1528 // they reside on different nets.
1529 // We only consider pairs on DIFFERENT nets here to avoid duplicating existing net-level
1530 // mismatches already reported above.
1531 if( m_schematic && m_schematic->ConnectionGraph() )
1532 {
1533 auto& netChains = m_schematic->ConnectionGraph()->GetCommittedNetChains();
1534 wxLogTrace( traceSchNetChain, "ERC TestPinToPin: cross-chain phase start chains=%zu",
1535 netChains.size() );
1536
1537 for( const auto& sig : netChains )
1538 {
1539 if( !sig )
1540 continue;
1541
1542 const wxString chainName = sig->GetName();
1543 const auto& sigNets = sig->GetNets();
1544
1545 // Collect all pin contexts across the nets in this chain.
1546 std::vector<ERC_SCH_PIN_CONTEXT> netChainPins;
1547 netChainPins.reserve( sigNets.size() * 4 );
1548
1549 for( const wxString& n : sigNets )
1550 {
1551 auto it = netToPins.find( n );
1552 if( it != netToPins.end() )
1553 {
1554 const auto& vec = it->second;
1555 netChainPins.insert( netChainPins.end(), vec.begin(), vec.end() );
1556 }
1557 }
1558
1559 if( netChainPins.size() < 2 )
1560 continue; // nothing to compare
1561
1562 wxLogTrace( traceSchNetChain,
1563 "ERC TestPinToPin: chain '%s' nets=%zu collectedPins=%zu",
1564 TO_UTF8( chainName ), sigNets.size(), netChainPins.size() );
1565
1566 // For deterministic behavior, sort by reference/pin number similar to earlier pass.
1567 std::sort( netChainPins.begin(), netChainPins.end(),
1568 []( const ERC_SCH_PIN_CONTEXT& lhs, const ERC_SCH_PIN_CONTEXT& rhs )
1569 {
1570 int ret = StrNumCmp( lhs.Pin()->GetParentSymbol()->GetRef( &lhs.Sheet() ),
1571 rhs.Pin()->GetParentSymbol()->GetRef( &rhs.Sheet() ) );
1572 if( ret == 0 )
1573 ret = StrNumCmp( lhs.Pin()->GetNumber(), rhs.Pin()->GetNumber() );
1574 if( ret == 0 )
1575 ret = lhs < rhs;
1576 return ret < 0;
1577 } );
1578
1579 // Build a quick map from pin -> net name for skipping intra-net pairs.
1580 std::unordered_map<SCH_PIN*, wxString> pinNet;
1581 for( const auto& netEntry : netToPins )
1582 for( const auto& ctx : netEntry.second )
1583 pinNet[ ctx.Pin() ] = netEntry.first;
1584
1585 for( size_t i = 0; i < netChainPins.size(); ++i )
1586 {
1587 SCH_PIN* aPin = netChainPins[i].Pin();
1588 ELECTRICAL_PINTYPE aType = aPin->GetType();
1589 const wxString& aNet = pinNet[aPin];
1590
1591 for( size_t j = i + 1; j < netChainPins.size(); ++j )
1592 {
1593 SCH_PIN* bPin = netChainPins[j].Pin();
1594 const wxString& bNet = pinNet[bPin];
1595
1596 if( aNet == bNet )
1597 continue; // already handled at net-level
1598
1599 ELECTRICAL_PINTYPE bType = bPin->GetType();
1600 PIN_ERROR erc = m_settings.GetPinMapValue( aType, bType );
1601
1604
1605 if( erc != PIN_ERROR::OK && m_settings.IsTestEnabled( ercCode ) )
1606 {
1607 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ercCode );
1608
1609 ercItem->SetItems( aPin, bPin );
1610 ercItem->SetSheetSpecificPath( netChainPins[i].Sheet() );
1611 ercItem->SetItemsSheetPaths( netChainPins[i].Sheet(), netChainPins[j].Sheet() );
1612 ercItem->SetErrorMessage( wxString::Format(
1613 _( "Pins of type %s and %s are connected via net chain %s" ),
1614 ElectricalPinTypeGetText( aType ),
1615 ElectricalPinTypeGetText( bType ), chainName ) );
1616
1617 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), aPin->GetPosition() );
1618 netChainPins[i].Sheet().LastScreen()->Append( marker );
1619 errors++;
1620 }
1621 }
1622 }
1623 }
1624 }
1625
1626 return errors;
1627}
1628
1629
1631{
1632 int errors = 0;
1633
1634 std::unordered_map<wxString, std::pair<wxString, SCH_PIN*>> pinToNetMap;
1635
1636 for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
1637 {
1638 const wxString& netName = net.first.Name;
1639
1640 for( CONNECTION_SUBGRAPH* subgraph : net.second )
1641 {
1642 for( SCH_ITEM* item : subgraph->GetItems() )
1643 {
1644 if( item->Type() == SCH_PIN_T )
1645 {
1646 SCH_PIN* pin = static_cast<SCH_PIN*>( item );
1647 const SCH_SHEET_PATH& sheet = subgraph->GetSheet();
1648
1649 if( !pin->GetParentSymbol()->IsMultiUnit() )
1650 continue;
1651
1652 wxString name = pin->GetParentSymbol()->GetRef( &sheet ) + ":" + pin->GetShownNumber();
1653
1654 if( !pinToNetMap.count( name ) )
1655 {
1656 pinToNetMap[name] = std::make_pair( netName, pin );
1657 }
1658 else if( pinToNetMap[name].first != netName )
1659 {
1660 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_NET );
1661
1662 ercItem->SetErrorMessage( wxString::Format( _( "Pin %s is connected to both %s and %s" ),
1663 pin->GetShownNumber(),
1664 netName,
1665 pinToNetMap[name].first ) );
1666
1667 ercItem->SetItems( pin, pinToNetMap[name].second );
1668 ercItem->SetSheetSpecificPath( sheet );
1669 ercItem->SetItemsSheetPaths( sheet, sheet );
1670
1671 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
1672 sheet.LastScreen()->Append( marker );
1673 errors += 1;
1674 }
1675 }
1676 }
1677 }
1678 }
1679
1680 return errors;
1681}
1682
1683
1685{
1686 int errors = 0;
1687
1688 for( const SCH_SHEET_PATH& sheet : m_sheetList )
1689 {
1690 SCH_SCREEN* screen = sheet.LastScreen();
1691
1692 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1693 {
1694 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1695 LIB_SYMBOL* libSymbol = symbol->GetLibSymbolRef().get();
1696
1697 if( !libSymbol )
1698 continue;
1699
1700 if( libSymbol->GetDuplicatePinNumbersAreJumpers() )
1701 continue;
1702
1703 std::vector<SCH_PIN*> pins = symbol->GetPins( &sheet );
1704
1705 std::map<wxString, std::vector<std::pair<SCH_PIN*, wxString>>> pinsByNumber;
1706
1707 for( SCH_PIN* pin : pins )
1708 {
1709 SCH_CONNECTION* conn = pin->Connection( &sheet );
1710 wxString netName = conn ? conn->GetNetName() : wxString();
1711
1712 pinsByNumber[pin->GetNumber()].emplace_back( pin, netName );
1713 }
1714
1715 for( const auto& [pinNumber, pinNetPairs] : pinsByNumber )
1716 {
1717 if( pinNetPairs.size() < 2 )
1718 continue;
1719
1720 wxString firstNet = pinNetPairs[0].second;
1721 bool hasDifferentNets = false;
1722 SCH_PIN* conflictPin = nullptr;
1723
1724 for( size_t i = 1; i < pinNetPairs.size(); i++ )
1725 {
1726 if( pinNetPairs[i].second != firstNet )
1727 {
1728 hasDifferentNets = true;
1729 conflictPin = pinNetPairs[i].first;
1730 break;
1731 }
1732 }
1733
1734 if( hasDifferentNets )
1735 {
1736 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DUPLICATE_PIN_ERROR );
1737 wxString msg;
1738
1739 msg.Printf( _( "Pin %s on symbol '%s' is connected to different nets: %s and %s" ),
1740 pinNumber,
1741 symbol->GetRef( &sheet ),
1742 firstNet.IsEmpty() ? _( "<no net>" ) : firstNet,
1743 pinNetPairs[1].second.IsEmpty() ? _( "<no net>" ) : pinNetPairs[1].second );
1744
1745 ercItem->SetErrorMessage( msg );
1746 ercItem->SetItems( pinNetPairs[0].first, conflictPin );
1747 ercItem->SetSheetSpecificPath( sheet );
1748 ercItem->SetItemsSheetPaths( sheet, sheet );
1749
1750 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ),
1751 pinNetPairs[0].first->GetPosition() );
1752 screen->Append( marker );
1753 errors++;
1754 }
1755 }
1756 }
1757 }
1758
1759 return errors;
1760}
1761
1762
1764{
1765 int errors = 0;
1766
1767 auto isGround =
1768 []( const wxString& txt )
1769 {
1770 wxString upper = txt.Upper();
1771
1772 return upper.Contains( wxT( "GND" ) )
1773 || upper == wxT( "EARTH" ) || upper.StartsWith( wxT( "EARTH_" ) )
1774 || upper == wxT( "VSS" ) || upper == wxT( "VSSA" );
1775 };
1776
1777 for( const SCH_SHEET_PATH& sheet : m_sheetList )
1778 {
1779 SCH_SCREEN* screen = sheet.LastScreen();
1780
1781 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1782 {
1783 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1784 bool hasGroundNet = false;
1785 std::vector<SCH_PIN*> mismatched;
1786
1787 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
1788 {
1789 SCH_CONNECTION* conn = pin->Connection( &sheet );
1790 wxString net = conn ? conn->GetNetName() : wxString();
1791 bool netIsGround = isGround( net );
1792
1793 // We are only interested in power pins
1794 if( pin->GetType() != ELECTRICAL_PINTYPE::PT_POWER_OUT
1795 && pin->GetType() != ELECTRICAL_PINTYPE::PT_POWER_IN )
1796 {
1797 continue;
1798 }
1799
1800 if( netIsGround )
1801 hasGroundNet = true;
1802
1803 if( isGround( pin->GetShownName() ) && !netIsGround )
1804 mismatched.push_back( pin );
1805 }
1806
1807 if( hasGroundNet )
1808 {
1809 for( SCH_PIN* pin : mismatched )
1810 {
1811 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_GROUND_PIN_NOT_GROUND );
1812
1813 ercItem->SetErrorMessage( wxString::Format( _( "Pin %s not connected to ground net" ),
1814 pin->GetShownName() ) );
1815 ercItem->SetItems( pin );
1816 ercItem->SetSheetSpecificPath( sheet );
1817 ercItem->SetItemsSheetPaths( sheet );
1818
1819 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
1820 screen->Append( marker );
1821 errors++;
1822 }
1823 }
1824 }
1825 }
1826
1827 return errors;
1828}
1829
1830
1832{
1833 int warnings = 0;
1834
1835 for( const SCH_SHEET_PATH& sheet : m_sheetList )
1836 {
1837 SCH_SCREEN* screen = sheet.LastScreen();
1838
1839 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1840 {
1841 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1842
1843 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
1844 {
1845 bool valid;
1846 pin->GetStackedPinNumbers( &valid );
1847
1848 if( !valid )
1849 {
1850 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_STACKED_PIN_SYNTAX );
1851 ercItem->SetItems( pin );
1852 ercItem->SetSheetSpecificPath( sheet );
1853 ercItem->SetItemsSheetPaths( sheet );
1854
1855 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
1856 screen->Append( marker );
1857 warnings++;
1858 }
1859 }
1860 }
1861 }
1862
1863 return warnings;
1864}
1865
1866
1868{
1869 int errCount = 0;
1870
1871 std::unordered_map<wxString, std::pair<SCH_ITEM*, SCH_SHEET_PATH>> globalLabels;
1872 std::unordered_map<wxString, std::pair<SCH_ITEM*, SCH_SHEET_PATH>> localLabels;
1873
1874 for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
1875 {
1876 for( CONNECTION_SUBGRAPH* subgraph : net.second )
1877 {
1878 const SCH_SHEET_PATH& sheet = subgraph->GetSheet();
1879
1880 for( SCH_ITEM* item : subgraph->GetItems() )
1881 {
1882 if( item->Type() == SCH_LABEL_T || item->Type() == SCH_GLOBAL_LABEL_T )
1883 {
1884 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( item );
1885 wxString text = label->GetShownText( &sheet, false );
1886
1887 auto& map = item->Type() == SCH_LABEL_T ? localLabels : globalLabels;
1888
1889 if( !map.count( text ) )
1890 {
1891 map[text] = std::make_pair( label, sheet );
1892 }
1893 }
1894 else if( item->Type() == SCH_PIN_T )
1895 {
1896 SCH_PIN* pin = static_cast<SCH_PIN*>( item );
1897
1898 if( !pin->IsPower() )
1899 continue;
1900
1901 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( pin->GetParentSymbol() );
1902
1903 if( !symbol )
1904 continue;
1905
1906 wxString text = ( pin->IsGlobalPower() && !symbol->IsGlobalPower() )
1907 ? pin->GetShownName()
1908 : symbol->GetValue( true, &sheet, false );
1909
1910 auto& map = pin->IsGlobalPower() ? globalLabels : localLabels;
1911
1912 if( !map.count( text ) )
1913 {
1914 map[text] = std::make_pair( pin, sheet );
1915 }
1916 }
1917 }
1918 }
1919 }
1920
1921 for( auto& [globalText, globalItem] : globalLabels )
1922 {
1923 for( auto& [localText, localItem] : localLabels )
1924 {
1925 if( globalText == localText )
1926 {
1927 ERCE_T errorCode = ( globalItem.first->Type() == SCH_PIN_T && localItem.first->Type() == SCH_PIN_T )
1930
1931 if( !m_settings.IsTestEnabled( errorCode ) )
1932 continue;
1933
1934 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( errorCode );
1935 ercItem->SetItems( globalItem.first, localItem.first );
1936 ercItem->SetSheetSpecificPath( globalItem.second );
1937 ercItem->SetItemsSheetPaths( globalItem.second, localItem.second );
1938
1939 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), globalItem.first->GetPosition() );
1940 globalItem.second.LastScreen()->Append( marker );
1941
1942 errCount++;
1943 }
1944 }
1945 }
1946
1947 return errCount;
1948}
1949
1950
1952{
1953 int errors = 0;
1954 std::unordered_map<wxString, std::vector<std::tuple<wxString, SCH_ITEM*, SCH_SHEET_PATH>>> generalMap;
1955
1956 auto logError =
1957 [&]( const wxString& normalized, SCH_ITEM* item, const SCH_SHEET_PATH& sheet,
1958 const std::tuple<wxString, SCH_ITEM*, SCH_SHEET_PATH>& other )
1959 {
1960 auto& [otherText, otherItem, otherSheet] = other;
1961 ERCE_T typeOfWarning = ERCE_SIMILAR_LABELS;
1962
1963 if( item->Type() == SCH_PIN_T && otherItem->Type() == SCH_PIN_T )
1964 {
1965 //Two Pins
1966 typeOfWarning = ERCE_SIMILAR_POWER;
1967 }
1968 else if( item->Type() == SCH_PIN_T || otherItem->Type() == SCH_PIN_T )
1969 {
1970 //Pin and Label
1971 typeOfWarning = ERCE_SIMILAR_LABEL_AND_POWER;
1972 }
1973 else
1974 {
1975 //Two Labels
1976 typeOfWarning = ERCE_SIMILAR_LABELS;
1977 }
1978
1979 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( typeOfWarning );
1980 ercItem->SetItems( item, otherItem );
1981 ercItem->SetSheetSpecificPath( sheet );
1982 ercItem->SetItemsSheetPaths( sheet, otherSheet );
1983
1984 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), item->GetPosition() );
1985 sheet.LastScreen()->Append( marker );
1986 };
1987
1988 for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
1989 {
1990 for( CONNECTION_SUBGRAPH* subgraph : net.second )
1991 {
1992 const SCH_SHEET_PATH& sheet = subgraph->GetSheet();
1993
1994 for( SCH_ITEM* item : subgraph->GetItems() )
1995 {
1996 switch( item->Type() )
1997 {
1998 case SCH_LABEL_T:
1999 case SCH_HIER_LABEL_T:
2000 case SCH_GLOBAL_LABEL_T:
2001 {
2002 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( item );
2003 wxString unnormalized = label->GetShownText( &sheet, false );
2004 wxString normalized = unnormalized.Lower();
2005
2006 generalMap[normalized].emplace_back( std::make_tuple( unnormalized, label, sheet ) );
2007
2008 for( const auto& otherTuple : generalMap.at( normalized ) )
2009 {
2010 const auto& [otherText, otherItem, otherSheet] = otherTuple;
2011
2012 if( unnormalized != otherText )
2013 {
2014 // Similar local labels on different sheets are fine
2015 if( item->Type() == SCH_LABEL_T && otherItem->Type() == SCH_LABEL_T
2016 && sheet != otherSheet )
2017 {
2018 continue;
2019 }
2020
2021 logError( normalized, label, sheet, otherTuple );
2022 errors += 1;
2023 }
2024 }
2025
2026 break;
2027 }
2028 case SCH_PIN_T:
2029 {
2030 SCH_PIN* pin = static_cast<SCH_PIN*>( item );
2031
2032 if( !pin->IsPower() )
2033 continue;
2034
2035 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( pin->GetParentSymbol() );
2036 wxString unnormalized = symbol->GetValue( true, &sheet, false );
2037 wxString normalized = unnormalized.Lower();
2038
2039 generalMap[normalized].emplace_back( std::make_tuple( unnormalized, pin, sheet ) );
2040
2041 for( const auto& otherTuple : generalMap.at( normalized ) )
2042 {
2043 const auto& [otherText, otherItem, otherSheet] = otherTuple;
2044
2045 if( unnormalized != otherText )
2046 {
2047 logError( normalized, pin, sheet, otherTuple );
2048 errors += 1;
2049 }
2050 }
2051
2052 break;
2053 }
2054
2055 default:
2056 break;
2057 }
2058 }
2059 }
2060 }
2061
2062 return errors;
2063}
2064
2065
2067{
2068 wxCHECK( m_schematic, 0 );
2069
2070 LIBRARY_MANAGER& manager = Pgm().GetLibraryManager();
2072 wxString msg;
2073 int err_count = 0;
2074
2075 for( SCH_SCREEN* screen = m_screens.GetFirst(); screen; screen = m_screens.GetNext() )
2076 {
2077 std::vector<SCH_MARKER*> markers;
2078
2079 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
2080 {
2081 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
2082 LIB_SYMBOL* libSymbolInSchematic = symbol->GetLibSymbolRef().get();
2083
2084 if( !libSymbolInSchematic )
2085 continue;
2086
2087 wxString libName = symbol->GetLibId().GetLibNickname();
2088
2089 std::optional<const LIBRARY_TABLE_ROW*> optRow =
2090 manager.GetRow( LIBRARY_TABLE_TYPE::SYMBOL, libName );
2091
2092 if( !optRow || ( *optRow )->Disabled() )
2093 {
2094 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES ) )
2095 {
2096 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
2097 ercItem->SetItems( symbol );
2098 msg.Printf( _( "The current configuration does not include the symbol library '%s'" ),
2099 UnescapeString( libName ) );
2100 ercItem->SetErrorMessage( msg );
2101
2102 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
2103 }
2104
2105 continue;
2106 }
2107 else if( !adapter->IsLibraryLoaded( libName ) )
2108 {
2109 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES ) )
2110 {
2111 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
2112 std::optional<wxString> uri =
2113 manager.GetFullURI( LIBRARY_TABLE_TYPE::SYMBOL, libName, true );
2114 wxCHECK2( uri.has_value(), uri = wxEmptyString );
2115 ercItem->SetItems( symbol );
2116 msg.Printf( _( "The symbol library '%s' was not found at '%s'" ),
2117 UnescapeString( libName ), *uri );
2118 ercItem->SetErrorMessage( msg );
2119
2120 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
2121 }
2122
2123 continue;
2124 }
2125
2126 wxString symbolName = symbol->GetLibId().GetLibItemName();
2127 LIB_SYMBOL* libSymbol = adapter->LoadSymbol( symbol->GetLibId() );
2128
2129 if( libSymbol == nullptr )
2130 {
2131 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES ) )
2132 {
2133 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
2134 ercItem->SetItems( symbol );
2135 msg.Printf( _( "Symbol '%s' not found in symbol library '%s'" ),
2136 UnescapeString( symbolName ),
2137 UnescapeString( libName ) );
2138 ercItem->SetErrorMessage( msg );
2139
2140 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
2141 }
2142
2143 continue;
2144 }
2145
2146 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
2148
2149 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_MISMATCH ) )
2150 {
2151 // We have to check for duplicate pins first as they will cause Compare() to fail.
2152 // Symbols with duplicate pins are valid if those pins share the same net, so we
2153 // only skip the comparison here. The actual error checking for duplicate pins on
2154 // different nets is done in TestDuplicatePinNets().
2155 std::vector<wxString> messages;
2156
2157 if( !libSymbolInSchematic->GetDuplicatePinNumbersAreJumpers() )
2158 {
2159 UNITS_PROVIDER unitsProvider( schIUScale, EDA_UNITS::MILS );
2160 CheckDuplicatePins( libSymbolInSchematic, messages, &unitsProvider );
2161 }
2162
2163 if( messages.empty() && flattenedSymbol->Compare( *libSymbolInSchematic, flags ) != 0 )
2164 {
2165 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_MISMATCH );
2166 ercItem->SetItems( symbol );
2167 msg.Printf( _( "Symbol '%s' doesn't match copy in library '%s'" ),
2168 UnescapeString( symbolName ),
2169 UnescapeString( libName ) );
2170 ercItem->SetErrorMessage( msg );
2171
2172 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
2173 }
2174 }
2175 }
2176
2177 for( SCH_MARKER* marker : markers )
2178 {
2179 screen->Append( marker );
2180 err_count += 1;
2181 }
2182 }
2183
2184 return err_count;
2185}
2186
2187
2189{
2190 wxCHECK( m_schematic, 0 );
2191
2192 if( std::optional<LIBRARY_MANAGER_ADAPTER*> adapter =
2193 Pgm().GetLibraryManager().Adapter( LIBRARY_TABLE_TYPE::FOOTPRINT ) )
2194 {
2195 ( *adapter )->BlockUntilLoaded();
2196 }
2197
2198 wxString msg;
2199 int err_count = 0;
2200
2201 typedef int (*TESTER_FN_PTR)( const wxString&, PROJECT* );
2202
2203 TESTER_FN_PTR linkTester = (TESTER_FN_PTR) aCvPcb->IfaceOrAddress( KIFACE_TEST_FOOTPRINT_LINK );
2204
2205 for( SCH_SHEET_PATH& sheet : m_sheetList )
2206 {
2207 std::vector<SCH_MARKER*> markers;
2208
2209 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
2210 {
2211 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
2212 wxString footprint = symbol->GetFootprintFieldText( true, &sheet, false );
2213
2214 if( footprint.IsEmpty() )
2215 continue;
2216
2217 LIB_ID fpID;
2218
2219 if( fpID.Parse( footprint, true ) >= 0 )
2220 {
2221 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
2222 msg.Printf( _( "'%s' is not a valid footprint identifier" ), footprint );
2223 ercItem->SetErrorMessage( msg );
2224 ercItem->SetItems( symbol );
2225 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
2226 continue;
2227 }
2228
2229 wxString libName = fpID.GetLibNickname();
2230 wxString fpName = fpID.GetLibItemName();
2231 int ret = (linkTester)( footprint, aProject );
2232
2234 {
2235 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
2236 msg.Printf( _( "The current configuration does not include the footprint library '%s'" ),
2237 libName );
2238 ercItem->SetErrorMessage( msg );
2239 ercItem->SetItems( symbol );
2240 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
2241 }
2243 {
2244 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
2245 msg.Printf( _( "The footprint library '%s' is not enabled in the current configuration" ),
2246 libName );
2247 ercItem->SetErrorMessage( msg );
2248 ercItem->SetItems( symbol );
2249 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
2250 }
2252 {
2253 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
2254 msg.Printf( _( "Footprint '%s' not found in library '%s'" ),
2255 fpName,
2256 libName );
2257 ercItem->SetErrorMessage( msg );
2258 ercItem->SetItems( symbol );
2259 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
2260 }
2261 }
2262
2263 for( SCH_MARKER* marker : markers )
2264 {
2265 sheet.LastScreen()->Append( marker );
2266 err_count += 1;
2267 }
2268 }
2269
2270 return err_count;
2271}
2272
2273
2275{
2276 wxCHECK( m_schematic, 0 );
2277
2278 wxString msg;
2279 int err_count = 0;
2280
2281 for( SCH_SHEET_PATH& sheet : m_sheetList )
2282 {
2283 std::vector<SCH_MARKER*> markers;
2284
2285 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
2286 {
2287 SCH_SYMBOL* sch_symbol = static_cast<SCH_SYMBOL*>( item );
2288 std::unique_ptr<LIB_SYMBOL>& lib_symbol = sch_symbol->GetLibSymbolRef();
2289
2290 if( !lib_symbol )
2291 continue;
2292
2293 wxArrayString filters = lib_symbol->GetFPFilters();
2294
2295 if( filters.empty() )
2296 continue;
2297
2298 wxString lowerId = sch_symbol->GetFootprintFieldText( true, &sheet, false ).Lower();
2299 LIB_ID footprint;
2300
2301 if( footprint.Parse( lowerId ) > 0 )
2302 continue;
2303
2304 wxString lowerItemName = footprint.GetUniStringLibItemName().Lower();
2305 bool found = false;
2306
2307 for( wxString filter : filters )
2308 {
2309 filter.LowerCase();
2310
2311 // If the filter contains a ':' character, include the library name in the pattern
2312 if( filter.Contains( wxS( ":" ) ) )
2313 found |= lowerId.Matches( filter );
2314 else
2315 found |= lowerItemName.Matches( filter );
2316
2317 if( found )
2318 break;
2319 }
2320
2321 if( !found )
2322 {
2323 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_FILTERS );
2324 msg.Printf( _( "Assigned footprint (%s) doesn't match footprint filters (%s)" ),
2325 footprint.GetUniStringLibItemName(),
2326 wxJoin( filters, ' ' ) );
2327 ercItem->SetErrorMessage( msg );
2328 ercItem->SetItems( sch_symbol );
2329 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), sch_symbol->GetPosition() ) );
2330 }
2331 }
2332
2333 for( SCH_MARKER* marker : markers )
2334 {
2335 sheet.LastScreen()->Append( marker );
2336 err_count += 1;
2337 }
2338 }
2339
2340 return err_count;
2341}
2342
2343
2345{
2346 const int gridSize = m_schematic->Settings().m_ConnectionGridSize;
2347 int err_count = 0;
2348
2349 for( SCH_SCREEN* screen = m_screens.GetFirst(); screen; screen = m_screens.GetNext() )
2350 {
2351 std::vector<SCH_MARKER*> markers;
2352
2353 for( SCH_ITEM* item : screen->Items() )
2354 {
2355 if( item->Type() == SCH_LINE_T && item->IsConnectable() )
2356 {
2357 SCH_LINE* line = static_cast<SCH_LINE*>( item );
2358
2359 if( ( line->GetStartPoint().x % gridSize ) != 0
2360 || ( line->GetStartPoint().y % gridSize ) != 0 )
2361 {
2362 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
2363 ercItem->SetItems( line );
2364
2365 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), line->GetStartPoint() ) );
2366 }
2367 else if( ( line->GetEndPoint().x % gridSize ) != 0
2368 || ( line->GetEndPoint().y % gridSize ) != 0 )
2369 {
2370 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
2371 ercItem->SetItems( line );
2372
2373 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), line->GetEndPoint() ) );
2374 }
2375 }
2376 if( item->Type() == SCH_BUS_WIRE_ENTRY_T )
2377 {
2378 SCH_BUS_WIRE_ENTRY* entry = static_cast<SCH_BUS_WIRE_ENTRY*>( item );
2379
2380 for( const VECTOR2I& point : entry->GetConnectionPoints() )
2381 {
2382 if( ( point.x % gridSize ) != 0
2383 || ( point.y % gridSize ) != 0 )
2384 {
2385 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
2386 ercItem->SetItems( entry );
2387
2388 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), point ) );
2389 }
2390 }
2391 }
2392 else if( item->Type() == SCH_SYMBOL_T )
2393 {
2394 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
2395
2396 for( SCH_PIN* pin : symbol->GetPins( nullptr ) )
2397 {
2398 if( pin->GetType() == ELECTRICAL_PINTYPE::PT_NC )
2399 continue;
2400
2401 VECTOR2I pinPos = pin->GetPosition();
2402
2403 if( ( pinPos.x % gridSize ) != 0 || ( pinPos.y % gridSize ) != 0 )
2404 {
2405 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
2406 ercItem->SetItems( pin );
2407
2408 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), pinPos ) );
2409 break;
2410 }
2411 }
2412 }
2413 }
2414
2415 for( SCH_MARKER* marker : markers )
2416 {
2417 screen->Append( marker );
2418 err_count += 1;
2419 }
2420 }
2421
2422 return err_count;
2423}
2424
2425
2427{
2429 int err_count = 0;
2430 SIM_LIB_MGR libMgr( &m_schematic->Project() );
2431 wxString variant = m_schematic->GetCurrentVariant();
2432
2433 for( SCH_SHEET_PATH& sheet : m_sheetList )
2434 {
2435 if( sheet.GetExcludedFromSim( variant ) )
2436 continue;
2437
2438 std::vector<SCH_MARKER*> markers;
2439
2440 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
2441 {
2442 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
2443
2444 // Power symbols and other symbols which have the reference starting with "#" are
2445 // not included in simulation
2446 if( symbol->GetRef( &sheet ).StartsWith( '#' ) || symbol->ResolveExcludedFromSim() )
2447 continue;
2448
2449 // Reset for each symbol
2450 reporter.Clear();
2451
2452 SIM_LIBRARY::MODEL model = libMgr.CreateModel( &sheet, *symbol, true, 0, variant, reporter );
2453
2454 if( reporter.HasMessage() )
2455 {
2456 wxString msg = reporter.GetMessages();
2457 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_SIMULATION_MODEL );
2458
2459 //Remove \n and \r at e.o.l if any:
2460 msg.Trim();
2461
2462 ercItem->SetErrorMessage( msg );
2463 ercItem->SetItems( symbol );
2464
2465 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
2466 }
2467 }
2468
2469 for( SCH_MARKER* marker : markers )
2470 {
2471 sheet.LastScreen()->Append( marker );
2472 err_count += 1;
2473 }
2474 }
2475
2476 return err_count;
2477}
2478
2479
2481 KIFACE* aCvPcb, PROJECT* aProject, PROGRESS_REPORTER* aProgressReporter )
2482{
2483 m_sheetList.AnnotatePowerSymbols();
2484
2485 // Test duplicate sheet names inside a given sheet. While one can have multiple references
2486 // to the same file, each must have a unique name.
2487 if( m_settings.IsTestEnabled( ERCE_DUPLICATE_SHEET_NAME ) )
2488 {
2489 if( aProgressReporter )
2490 aProgressReporter->AdvancePhase( _( "Checking sheet names..." ) );
2491
2493 }
2494
2495 // Test pin-to-pad maps for stale pins, duplicate pad targets and bad pad references (issue #2282).
2496 if( m_settings.IsTestEnabled( ERCE_PIN_MAP_STALE_PIN ) || m_settings.IsTestEnabled( ERCE_PIN_MAP_DUPLICATE_PAD )
2497 || m_settings.IsTestEnabled( ERCE_PIN_MAP_BAD_PAD ) || m_settings.IsTestEnabled( ERCE_PIN_MAP_UNMAPPED_PIN ) )
2498 {
2499 if( aProgressReporter )
2500 aProgressReporter->AdvancePhase( _( "Checking pin maps..." ) );
2501
2502 TestPinMap( aCvPcb, aProject );
2503 }
2504
2505 // The connection graph has a whole set of ERC checks it can run
2506 if( aProgressReporter )
2507 aProgressReporter->AdvancePhase( _( "Checking conflicts..." ) );
2508
2509 // If we are using the new connectivity, make sure that we do a full-rebuild
2510 if( aEditFrame )
2511 {
2512 if( ADVANCED_CFG::GetCfg().m_IncrementalConnectivity )
2513 aEditFrame->RecalculateConnections( nullptr, GLOBAL_CLEANUP );
2514 else
2515 aEditFrame->RecalculateConnections( nullptr, NO_CLEANUP );
2516 }
2517
2518 m_schematic->ConnectionGraph()->RunERC();
2519
2520 if( aProgressReporter )
2521 aProgressReporter->AdvancePhase( _( "Checking units..." ) );
2522
2523 // Test is all units of each multiunit symbol have the same footprint assigned.
2524 if( m_settings.IsTestEnabled( ERCE_DIFFERENT_UNIT_FP ) )
2525 {
2526 if( aProgressReporter )
2527 aProgressReporter->AdvancePhase( _( "Checking footprints..." ) );
2528
2530 }
2531
2532 if( m_settings.IsTestEnabled( ERCE_MISSING_UNIT )
2533 || m_settings.IsTestEnabled( ERCE_MISSING_INPUT_PIN )
2534 || m_settings.IsTestEnabled( ERCE_MISSING_POWER_INPUT_PIN )
2535 || m_settings.IsTestEnabled( ERCE_MISSING_BIDI_PIN ) )
2536 {
2538 }
2539
2540 if( aProgressReporter )
2541 aProgressReporter->AdvancePhase( _( "Checking pins..." ) );
2542
2543 if( m_settings.IsTestEnabled( ERCE_DIFFERENT_UNIT_NET ) )
2545
2546 if( m_settings.IsTestEnabled( ERCE_DUPLICATE_PIN_ERROR ) )
2548
2549 // Test pins on each net against the pin connection table
2550 if( m_settings.IsTestEnabled( ERCE_PIN_TO_PIN_ERROR )
2551 || m_settings.IsTestEnabled( ERCE_PIN_TO_PIN_WARNING )
2552 || m_settings.IsTestEnabled( ERCE_POWERPIN_NOT_DRIVEN )
2553 || m_settings.IsTestEnabled( ERCE_PIN_NOT_DRIVEN ) )
2554 {
2555 TestPinToPin();
2556 }
2557
2558 if( m_settings.IsTestEnabled( ERCE_GROUND_PIN_NOT_GROUND ) )
2560
2561 if( m_settings.IsTestEnabled( ERCE_STACKED_PIN_SYNTAX ) )
2563
2564 // Test similar labels (i;e. labels which are identical when
2565 // using case insensitive comparisons)
2566 if( m_settings.IsTestEnabled( ERCE_SIMILAR_LABELS )
2567 || m_settings.IsTestEnabled( ERCE_SIMILAR_POWER )
2568 || m_settings.IsTestEnabled( ERCE_SIMILAR_LABEL_AND_POWER ) )
2569 {
2570 if( aProgressReporter )
2571 aProgressReporter->AdvancePhase( _( "Checking similar labels..." ) );
2572
2574 }
2575
2576 if( m_settings.IsTestEnabled( ERCE_SAME_LOCAL_GLOBAL_LABEL )
2577 || m_settings.IsTestEnabled( ERCE_SAME_LOCAL_GLOBAL_POWER ) )
2578 {
2579 if( aProgressReporter )
2580 aProgressReporter->AdvancePhase( _( "Checking local and global labels..." ) );
2581
2583 }
2584
2585 if( m_settings.IsTestEnabled( ERCE_UNRESOLVED_VARIABLE ) )
2586 {
2587 if( aProgressReporter )
2588 aProgressReporter->AdvancePhase( _( "Checking for unresolved variables..." ) );
2589
2590 TestTextVars( aDrawingSheet );
2591 }
2592
2593 if( m_settings.IsTestEnabled( ERCE_FIELD_NAME_WHITESPACE ) )
2594 {
2595 if( aProgressReporter )
2596 aProgressReporter->AdvancePhase( _( "Checking field names..." ) );
2597
2599 }
2600
2601 if( m_settings.IsTestEnabled( ERCE_SIMULATION_MODEL ) )
2602 {
2603 if( aProgressReporter )
2604 aProgressReporter->AdvancePhase( _( "Checking SPICE models..." ) );
2605
2607 }
2608
2609 if( m_settings.IsTestEnabled( ERCE_NOCONNECT_CONNECTED ) )
2610 {
2611 if( aProgressReporter )
2612 aProgressReporter->AdvancePhase( _( "Checking no connect pins for connections..." ) );
2613
2615 }
2616
2617 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES )
2618 || m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_MISMATCH ) )
2619 {
2620 if( aProgressReporter )
2621 aProgressReporter->AdvancePhase( _( "Checking for library symbol issues..." ) );
2622
2624 }
2625
2626 if( m_settings.IsTestEnabled( ERCE_FOOTPRINT_LINK_ISSUES ) && aCvPcb )
2627 {
2628 if( aProgressReporter )
2629 aProgressReporter->AdvancePhase( _( "Checking for footprint link issues..." ) );
2630
2631 TestFootprintLinkIssues( aCvPcb, aProject );
2632 }
2633
2634 if( m_settings.IsTestEnabled( ERCE_FOOTPRINT_FILTERS ) )
2635 {
2636 if( aProgressReporter )
2637 aProgressReporter->AdvancePhase( _( "Checking footprint assignments against footprint filters..." ) );
2638
2640 }
2641
2642 if( m_settings.IsTestEnabled( ERCE_ENDPOINT_OFF_GRID ) )
2643 {
2644 if( aProgressReporter )
2645 aProgressReporter->AdvancePhase( _( "Checking for off grid pins and wires..." ) );
2646
2648 }
2649
2650 if( m_settings.IsTestEnabled( ERCE_FOUR_WAY_JUNCTION ) )
2651 {
2652 if( aProgressReporter )
2653 aProgressReporter->AdvancePhase( _( "Checking for four way junctions..." ) );
2654
2656 }
2657
2658 if( m_settings.IsTestEnabled( ERCE_LABEL_MULTIPLE_WIRES ) )
2659 {
2660 if( aProgressReporter )
2661 aProgressReporter->AdvancePhase( _( "Checking for labels on more than one wire..." ) );
2662
2664 }
2665
2666 if( m_settings.IsTestEnabled( ERCE_UNDEFINED_NETCLASS ) )
2667 {
2668 if( aProgressReporter )
2669 aProgressReporter->AdvancePhase( _( "Checking for undefined netclasses..." ) );
2670
2672 }
2673
2674 m_schematic->ResolveERCExclusionsPostUpdate();
2675}
const char * name
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:123
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
constexpr Vec Centre() const
Definition box2.h:93
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:282
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:110
EE_TYPE OfType(KICAD_T aType) const
Definition sch_rtree.h:221
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
Definition erc_item.cpp:292
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:2066
const NET_MAP & m_nets
Definition erc.h:214
int TestStackedPinNotation()
Checks for pin numbers that resemble stacked pin notation but are invalid.
Definition erc.cpp:1831
void TestTextVars(DS_PROXY_VIEW_ITEM *aDrawingSheet)
Check for any unresolved text variable references.
Definition erc.cpp:387
int TestPinToPin()
Checks the full netlist against the pin-to-pin connectivity requirements.
Definition erc.cpp:1184
int TestSimilarLabels()
Checks for labels that differ only in capitalization.
Definition erc.cpp:1951
SCH_MULTI_UNIT_REFERENCE_MAP m_refMap
Definition erc.h:213
SCH_SCREENS m_screens
Definition erc.h:212
int TestFootprintLinkIssues(KIFACE *aCvPcb, PROJECT *aProject)
Test footprint links against the current footprint libraries.
Definition erc.cpp:2188
int TestOffGridEndpoints()
Test pins and wire ends for being off grid.
Definition erc.cpp:2344
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:1867
int TestMultUnitPinConflicts()
Checks if shared pins on multi-unit symbols have been connected to different nets.
Definition erc.cpp:1630
int TestNoConnectPins()
In KiCad 5 and earlier, you could connect stuff up to pins with NC electrical type.
Definition erc.cpp:1093
int TestFootprintFilters()
Test symbols to ensure that assigned footprint passes any given footprint filters.
Definition erc.cpp:2274
int TestPinMap(KIFACE *aCvPcb, PROJECT *aProject)
Check pin-to-pad maps (issue #2282): stale pin references, duplicate pad targets, bad pads and unmapp...
Definition erc.cpp:186
int TestFieldNameWhitespace()
Check for field names with leading or trailing whitespace.
Definition erc.cpp:642
int TestDuplicatePinNets()
Checks if duplicate pin numbers within a symbol are connected to different nets.
Definition erc.cpp:1684
ERC_SETTINGS & m_settings
Definition erc.h:210
int TestFourWayJunction()
Test to see if there are potentially confusing 4-way junctions in the schematic.
Definition erc.cpp:1014
int TestMissingNetclasses()
Tests for netclasses that are referenced but not defined.
Definition erc.cpp:906
int TestSimModelIssues()
Test SPICE models for various issues.
Definition erc.cpp:2426
SCH_SHEET_LIST m_sheetList
Definition erc.h:211
bool m_showAllErrors
Definition erc.h:215
int TestGroundPins()
Checks for ground-labeled pins not on a ground net while another pin is.
Definition erc.cpp:1763
SCHEMATIC * m_schematic
Definition erc.h:209
void RunTests(DS_PROXY_VIEW_ITEM *aDrawingSheet, SCH_EDIT_FRAME *aEditFrame, KIFACE *aCvPcb, PROJECT *aProject, PROGRESS_REPORTER *aProgressReporter)
Definition erc.cpp:2480
int TestMissingUnits()
Test for uninstantiated units of multi unit symbols.
Definition erc.cpp:772
int TestLabelMultipleWires()
Test to see if there are labels that are connected to more than one wire.
Definition erc.cpp:959
int TestMultiunitFootprints()
Test if all units of each multiunit symbol have the same footprint assigned.
Definition erc.cpp:711
bool IsLibraryLoaded(const wxString &aNickname)
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false)
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)
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition lib_id.cpp:65
wxString GetUniStringLibId() const
Definition lib_id.h:144
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
Definition lib_id.h:108
const UTF8 & GetLibItemName() const
Definition lib_id.h:98
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition lib_id.h:83
Define a library symbol object.
Definition lib_symbol.h:80
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.
const std::vector< ASSOCIATED_FOOTPRINT > & GetEffectiveAssociatedFootprints() const
Definition lib_symbol.h:256
std::vector< SCH_PIN * > GetPins() const override
const PIN_MAP_SET & GetEffectivePinMaps() const
Definition lib_symbol.h:241
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:800
std::vector< std::set< wxString > > & JumperPinGroups()
Each jumper pin group is a set of pin numbers that should be treated as internally connected.
Definition lib_symbol.h:807
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:126
A symbol-owned ordered set of named pin maps.
Definition pin_map.h:123
bool IsEmpty() const
Definition pin_map.h:139
const std::vector< PIN_MAP > & GetAll() const
Definition pin_map.h:138
const PIN_MAP * FindByName(const wxString &aName) const
Definition pin_map.cpp:133
A named pin map.
Definition pin_map.h:64
const std::vector< PIN_MAP_ENTRY > & GetEntries() const
Definition pin_map.h:91
const wxString & GetName() const
Definition pin_map.h:69
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:62
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:162
int GetBodyStyle() const
Definition sch_item.h:242
bool ResolveExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:298
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:38
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Definition sch_line.cpp:755
VECTOR2I GetEndPoint() const
Definition sch_line.h:144
VECTOR2I GetStartPoint() const
Definition sch_line.h:135
bool IsEndPoint(const VECTOR2I &aPoint) const override
Test if aPt is an end point of this schematic object.
Definition sch_line.h:87
bool IsGraphicLine() const
Return if the line is a graphic (non electrical line)
bool IsVisible() const
Definition sch_pin.cpp:485
PAD_RESOLUTION
Outcome of pin-to-pad resolution (issue #2282).
Definition sch_pin.h:161
VECTOR2I GetPosition() const override
Definition sch_pin.cpp:350
bool IsStacked(const SCH_PIN *aPin) const
Definition sch_pin.cpp:575
bool IsPower() const
Check if the pin is either a global or local power pin.
Definition sch_pin.cpp:479
ELECTRICAL_PINTYPE GetType() const
Definition sch_pin.cpp:407
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
int GetUnit() const
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:115
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
VECTOR2I GetPosition() const override
Definition sch_shape.h:84
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:44
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the sheet's fields.
Definition sch_sheet.h:87
VECTOR2I GetPosition() const override
Definition sch_sheet.h:490
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition sch_sheet.h:227
wxString GetShownName(bool aAllowExtraText) const
Definition sch_sheet.h:132
Schematic symbol object.
Definition sch_symbol.h:69
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
bool IsGlobalPower() const override
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:913
const LIB_ID & GetLibId() const override
Definition sch_symbol.h:158
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition sch_symbol.h:177
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:146
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition sch_text.cpp:341
virtual wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Definition sch_text.cpp:362
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:243
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition transform.cpp:40
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
Definition vector2d.h:549
A wrapper for reporting to a wxString object.
Definition reporter.h:189
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition common.cpp:721
The common library.
#define FOR_ERC_DRC
Expand '${var-name}' templates in text.
Definition common.h:95
#define _(s)
@ NO_RECURSE
Definition eda_item.h:50
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_SAME_LOCAL_GLOBAL_POWER
Local power port and global power port have the same name.
@ ERCE_PIN_MAP_BAD_PAD
Pin map references a pad absent from the footprint.
@ ERCE_FOOTPRINT_LINK_ISSUES
The footprint link is invalid, or points to a missing (or inactive) footprint or library.
@ ERCE_PIN_MAP_DUPLICATE_PAD
Two symbol pins map to one pad (not stacked/jumper).
@ 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_PIN_MAP_STALE_PIN
Pin map references a pin number not on the symbol.
@ 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_PIN_MAP_UNMAPPED_PIN
A connected pin resolves to no footprint pad.
@ 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.
const wxChar *const traceSchNetChain
Flag to enable tracing of schematic net chain rebuild and ERC cross-chain checks.
@ KIFACE_TEST_FOOTPRINT_LINK_LIBRARY_NOT_ENABLED
Definition kiface_ids.h:56
@ KIFACE_TEST_FOOTPRINT_LINK
Definition kiface_ids.h:54
@ KIFACE_TEST_FOOTPRINT_LINK_NO_LIBRARY
Definition kiface_ids.h:55
@ KIFACE_TEST_FOOTPRINT_LINK_NO_FOOTPRINT
Definition kiface_ids.h:57
@ KIFACE_FOOTPRINT_PAD_NUMBERS
Function pointer type: void (*)( const wxString& aFootprint, PROJECT* aProject, std::set<wxString>& a...
Definition kiface_ids.h:62
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:32
@ PT_INPUT
usual pin input: must be connected
Definition pin_type.h:33
@ PT_NC
not connected (must be left open)
Definition pin_type.h:46
@ PT_OUTPUT
usual output
Definition pin_type.h:34
@ PT_TRISTATE
tri state bus pin
Definition pin_type.h:36
@ PT_BIDI
input or output (like port for a microprocessor)
Definition pin_type.h:35
@ PT_POWER_OUT
output of a regulator: intended to be connected to power input pins
Definition pin_type.h:43
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
Definition pin_type.h:42
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
Definition pin_type.h:41
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
Definition pin_type.h:39
wxString ElectricalPinTypeGetText(ELECTRICAL_PINTYPE)
Definition pin_type.cpp:203
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
@ NO_CLEANUP
Definition schematic.h:77
@ GLOBAL_CLEANUP
Definition schematic.h:79
std::vector< wxString > ExpandStackedPinNotation(const wxString &aPinName, bool *aValid)
Expand stacked pin notation like [1,2,3], [1-4], [A1-A4], or [AA1-AA3,AB4,CD12-CD14] into individual ...
wxString UnescapeString(const wxString &aSource)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
A first-class footprint choice on a LIB_SYMBOL, tied to a named pin map.
Definition pin_map.h:158
Implement a participant in the KIWAY alchemy.
Definition kiway.h:152
virtual void * IfaceOrAddress(int aDataId)=0
Return pointer to the requested object.
One symbol-pin to footprint-pad mapping inside a PIN_MAP.
Definition pin_map.h:41
IbisParser parser & reporter
KIBIS_MODEL * model
KIBIS_PIN * pin
wxLogTrace helper definitions.
@ SCH_LINE_T
Definition typeinfo.h:160
@ SCH_NO_CONNECT_T
Definition typeinfo.h:157
@ SCH_SYMBOL_T
Definition typeinfo.h:169
@ SCH_FIELD_T
Definition typeinfo.h:147
@ SCH_LABEL_T
Definition typeinfo.h:164
@ SCH_LOCATE_ANY_T
Definition typeinfo.h:196
@ SCH_SHEET_T
Definition typeinfo.h:172
@ SCH_HIER_LABEL_T
Definition typeinfo.h:166
@ SCH_TEXT_T
Definition typeinfo.h:148
@ SCH_BUS_WIRE_ENTRY_T
Definition typeinfo.h:158
@ SCH_TEXTBOX_T
Definition typeinfo.h:149
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:165
@ SCH_PIN_T
Definition typeinfo.h:150
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683