KiCad PCB EDA Suite
Loading...
Searching...
No Matches
conn_engine.h
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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include "conn_publish.h"
23
24namespace SCH_CONNECTIVITY
25{
39
53
64
76
89
103
109{
111 std::vector<KIID> pins;
112 std::vector<KIID> others;
114};
115
128
138
141
142// Orders sheet-local positions by instance path, then by x and y.
144{
145 bool operator()( const std::pair<KIID_PATH, VECTOR2I>& a, const std::pair<KIID_PATH, VECTOR2I>& b ) const
146 {
147 // Tuple comparison would bypass KIID_PATH's length-first ordering
148 if( a.first != b.first )
149 return a.first < b.first;
150
151 // VECTOR2I orders by length, which merges distinct positions at the same radius
152 return std::tie( a.second.x, a.second.y ) < std::tie( b.second.x, b.second.y );
153 }
154};
155
167
180
185{
186 wxString reference;
187 std::vector<MULTI_UNIT_INSTANCE> instances;
188 std::vector<UNIT_FACT> units;
189};
190
202
212
218{
222
224 std::vector<std::pair<KIID, VECTOR2I>> equivalentPins;
225};
226
240
251
257{
258 wxString name;
259 std::vector<ERC_PIN> pins;
260 bool noConnect = false;
261 bool powerDriven = false;
262};
263
276
288
299
311
317{
320 std::vector<KIID> items;
321
323 std::vector<KIID> equivalentItems;
324};
325
342
348{
350 std::vector<KIID> items;
352};
353
360{
361public:
362 ENGINE();
363 ENGINE( const ENGINE& ) = delete;
364 ENGINE& operator=( const ENGINE& ) = delete;
365
371 void Update( const SCH_SHEET_LIST& aPaths, uint64_t aTextEpoch, const BUS_ALIASES& aAliases,
372 bool aRebuild = false );
373
374 // Compare retained external text sources before the next Update, in its fresh text frame.
375 bool ExternalSourcesChanged( const SCH_SHEET_LIST& aPaths, bool aContextUnchanged = false ) const
376 {
377 return m_inputs.ExternalSourcesChanged( aPaths, aContextUnchanged );
378 }
379
380 // Discard evaluations while preserving session identities and version monotonicity.
381 void Clear();
382
383 const SESSION_KEYS& Keys() const { return m_keys; }
385 const PUBLICATION& Published() const { return m_published; }
386
391 std::vector<CLAIM> DriverCandidates( NODE_ID aComponent ) const;
392
402
404 std::vector<DRIVER_CONFLICT> DriverConflicts() const;
405
407 std::vector<WIRE_ENDPOINT> DanglingWireEndpoints() const;
408
410 std::vector<FLOATING_WIRE> FloatingWires() const;
411
413 std::vector<BUS_NET_CONFLICT> BusNetConflicts() const;
414
416 std::vector<BUS_BUS_CONFLICT> BusBusConflicts() const;
417
419 std::vector<BUS_ENTRY_CONFLICT> BusEntryConflicts() const;
420
422 std::vector<NO_CONNECT_PIN_CONFLICT> NoConnectPinConflicts() const;
423
425 std::vector<NO_CONNECT_FLAG_ERROR> NoConnectFlagErrors() const;
426
428 std::vector<UNCONNECTED_PIN> UnconnectedPins() const;
429
431 std::vector<LABEL_LOCATION> DanglingDirectives() const;
432
434 std::vector<LABEL_LOCATION> SingleGlobalLabels() const;
435
437 std::vector<NAMED_ITEM> NamedItems() const;
438
440 std::vector<MULTI_UNIT_CONFLICT> MultiUnitPinConflicts() const;
441
443 std::vector<ERC_PIN_NET> PinNets() const;
444
446 std::vector<LABEL_CONNECTION_ERROR> LabelConnectionErrors() const;
447
449 std::vector<LABEL_WIRE_CONFLICT> LabelWireConflicts() const;
450
452 std::vector<FOUR_WAY_JUNCTION> FourWayJunctions() const;
453
455 std::vector<SOURCE_LOCATION> EmptyLabels() const;
456
458 std::vector<FIELD_NAME_ERROR> InvalidFieldNames() const;
459
461 std::vector<DUPLICATE_SHEET_ERROR> DuplicateSheetNames() const;
462
464 std::vector<LIBRARY_SYMBOL_FACT> LibrarySymbols( const KIID_PATH& aPath ) const;
465
467 std::vector<VARIANT_SYMBOL_FACT> VariantSymbols( const KIID_PATH& aPath ) const;
468
470 std::vector<FOOTPRINT_SOURCE> FootprintSources() const;
471
473 std::vector<MULTI_UNIT_GROUP> MultiUnitSymbols() const;
474
476 std::vector<PIN_MAP_FACT> PinMapSymbols( SCREEN_ID aScreen ) const;
477
479 std::vector<UNMAPPED_PIN_CANDIDATE> UnmappedPinCandidates() const;
480
482 std::vector<SOURCE_LOCATION> InvalidPinNotation() const;
483
485 std::vector<SOURCE_LOCATION> WiredImplicitPowerPins() const;
486
488 std::vector<OFF_GRID_ENDPOINT> OffGridEndpoints( int aGrid ) const;
489
491 std::vector<GROUND_PIN_ERROR> GroundPinErrors() const;
492
494 std::vector<NETCLASS_REFERENCE> NetclassReferences() const;
495
497 std::vector<HIERARCHY_ERROR> HierarchyErrors() const;
498
500
501 // Current parser presentation, independent of electrical schema reuse.
502 std::shared_ptr<const BUS_SCHEMA::NODE> FindBusTree( const wxString& aText ) const
503 {
504 return m_records.FindTree( aText );
505 }
506
507private:
508 void clearStages( bool aRetainSourceValues = false );
509
511 std::vector<INST_ID> instancesInPageOrder() const;
512
518 std::set<RECORD_KEY, KEY_LESS> ercIslands() const;
519
529};
530} // namespace SCH_CONNECTIVITY
Definition kiid.h:46
One sequence for all cache tables for the lifetime of an engine session.
Definition conn_cache.h:37
Cache current component evaluations by exact node/version identity, within one stratum and key sessio...
std::vector< NO_CONNECT_PIN_CONFLICT > NoConnectPinConflicts() const
No-connect pins that touch other items, grouped by instance and position.
ENGINE(const ENGINE &)=delete
std::vector< MULTI_UNIT_GROUP > MultiUnitSymbols() const
Annotated multi-unit symbols grouped by reference, with instances in page order.
std::vector< ERC_PIN_NET > PinNets() const
Active pins for each named net, in net name order.
std::vector< NO_CONNECT_FLAG_ERROR > NoConnectFlagErrors() const
No-connect flags on reported islands that connect to many pins or to nothing.
bool ExternalSourcesChanged(const SCH_SHEET_LIST &aPaths, bool aContextUnchanged=false) const
std::vector< OFF_GRID_ENDPOINT > OffGridEndpoints(int aGrid) const
Off-grid endpoints on the first instance of each screen; one pin for each symbol.
std::vector< LABEL_LOCATION > SingleGlobalLabels() const
Global labels whose name occurs only once in the hierarchy.
std::vector< DUPLICATE_SHEET_ERROR > DuplicateSheetNames() const
Child sheet pairs whose names differ only in case, sorted by instance and pair.
const PUBLICATION & Published() const
std::shared_ptr< const BUS_SCHEMA::NODE > FindBusTree(const wxString &aText) const
std::vector< GROUND_PIN_ERROR > GroundPinErrors() const
Ground-named power pins off a ground net, sorted by instance and pin.
std::vector< PIN_MAP_FACT > PinMapSymbols(SCREEN_ID aScreen) const
Captured pin maps of one screen; empty for an unknown screen.
std::vector< BUS_BUS_CONFLICT > BusBusConflicts() const
Reported bus islands with mixed bus shapes, or with two claims that share no member.
std::vector< BUS_ENTRY_CONFLICT > BusEntryConflicts() const
Bus wire entries on reported islands whose net is not a member of the touched bus.
std::vector< UNCONNECTED_PIN > UnconnectedPins() const
Unconnected symbol pins on reported islands; each power symbol pin reports on its own.
COMPONENT_CACHE< SIGNAL_RESULT > m_signals
const COMPONENT_CACHE< SIGNAL_RESULT > & Signals() const
std::vector< DRIVER_CONFLICT > DriverConflicts() const
Islands with two different strong names; one result for each reported island.
std::vector< WIRE_ENDPOINT > DanglingWireEndpoints() const
Dangling ends of wires and bus wire entries on reported islands.
void clearStages(bool aRetainSourceValues=false)
std::vector< MULTI_UNIT_CONFLICT > MultiUnitPinConflicts() const
One conflict for each multi-unit reference and pin number with more than one net.
std::vector< VARIANT_SYMBOL_FACT > VariantSymbols(const KIID_PATH &aPath) const
Captured variant symbol overrides of one instance; empty for an unknown path.
const SESSION_KEYS & Keys() const
std::vector< NAMED_ITEM > NamedItems() const
Every label and power pin with its resolved name, on every instance.
std::set< RECORD_KEY, KEY_LESS > ercIslands() const
Islands that ERC reports.
std::vector< FOUR_WAY_JUNCTION > FourWayJunctions() const
Positions with four or more contacts, sorted by instance and position.
std::vector< BUS_NET_CONFLICT > BusNetConflicts() const
Reported islands whose ERC_ATOMS::kindConflict is set and that hold both a net and a bus item.
std::vector< FOOTPRINT_SOURCE > FootprintSources() const
Resolved footprint and filters of every symbol on every instance.
std::vector< LIBRARY_SYMBOL_FACT > LibrarySymbols(const KIID_PATH &aPath) const
Captured library links of the symbols on the screen of one instance; empty for an unknown path.
void Update(const SCH_SHEET_LIST &aPaths, uint64_t aTextEpoch, const BUS_ALIASES &aAliases, bool aRebuild=false)
Refresh inputs, bundle slots and signal summaries with the source text epoch and effective aliases.
std::vector< INST_ID > instancesInPageOrder() const
All captured instances, sorted by page order and then by instance path.
std::vector< NETCLASS_REFERENCE > NetclassReferences() const
Netclass field references of every instance, sorted by instance, item and name.
std::vector< LABEL_LOCATION > DanglingDirectives() const
Dangling directive labels on every instance.
std::vector< FLOATING_WIRE > FloatingWires() const
Wires and bus entries of each island whose net has no driver, on every instance.
std::vector< HIERARCHY_ERROR > HierarchyErrors() const
Hierarchical label and sheet pin mismatches, sorted by instance, item and kind.
std::vector< SOURCE_LOCATION > InvalidPinNotation() const
Pins whose shown number looks like stacked pin notation but does not parse.
std::vector< FIELD_NAME_ERROR > InvalidFieldNames() const
Field names with leading or trailing white space, sorted by instance, owner and field.
std::vector< SOURCE_LOCATION > WiredImplicitPowerPins() const
Hidden global power input pins that a wire also joins; one pin for each symbol.
std::vector< SOURCE_LOCATION > EmptyLabels() const
Labels whose raw text is empty or only white space, on every instance.
ENGINE & operator=(const ENGINE &)=delete
COMPONENT_CACHE< BUNDLE_BINDING > m_bundles
std::vector< LABEL_CONNECTION_ERROR > LabelConnectionErrors() const
Unconnected and single-pin labels on reported islands.
std::vector< UNMAPPED_PIN_CANDIDATE > UnmappedPinCandidates() const
Pins that need a pad check.
std::vector< LABEL_WIRE_CONFLICT > LabelWireConflicts() const
Labels that touch the interior of two or more wires; one result for each position.
std::vector< CLAIM > DriverCandidates(NODE_ID aComponent) const
Owned eligible claims of one published component, strongest first.
CACHE_VERSIONS m_versions
Main-thread extraction cache.
Definition conn_inputs.h:41
Fresh connectivity for one stratum.
Main-thread publication.
Main-thread island record preparation and cache writes.
Session IDs are dense handles, never a canonical ordering.
Definition conn_keys.h:146
Reconciles current bundles with persistent, exact-value slot versions.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
KIID niluuid(0)
Value keys and the key session of the schematic connectivity engine.
SOURCE_LOCATION UNCONNECTED_PIN
std::map< wxString, std::vector< wxString > > BUS_ALIASES
Bus alias table, from alias name to member texts.
Definition conn_bus.h:40
uint64_t SCREEN_ID
Process-local SCH_SCREEN::ConnectivityId(), never a file UUID.
Definition conn_keys.h:44
SOURCE_LOCATION LABEL_LOCATION
uint32_t NODE_ID
Session handle of a NODE_KEY graph node.
Definition conn_keys.h:43
Two bus claims on one island that share no member, or a bus vector joined to a bus group.
Definition conn_engine.h:82
A bus wire entry whose net is not a member of the bus it touches.
Definition conn_engine.h:95
KIID_PATH sheet
Definition conn_engine.h:96
KIID entry
Definition conn_engine.h:97
wxString busName
wxString netName
Definition conn_engine.h:99
VECTOR2I position
KIID bus
Definition conn_engine.h:98
An island that mixes net and bus items.
Definition conn_engine.h:70
Two different strong names on one island.
Definition conn_engine.h:45
Two child sheets of one sheet instance whose names differ only in case.
All active pins that the publication places on one named net.
std::vector< ERC_PIN > pins
One active symbol pin on one sheet instance, with the reference of its symbol.
A symbol or sheet field name with leading or trailing white space.
Up to four wires and bus entries of one island that has no driver.
The resolved footprint and the library footprint filters of one symbol on one sheet instance.
Four or more contacts at one position.
std::vector< KIID > equivalentItems
Every pin and line at the position, sorted.
std::vector< KIID > items
One pin for each symbol, then the lines; ERC reports four.
A power pin with a ground name that is not on a ground net, on a symbol with another pin on a ground ...
A hierarchical label or sheet pin with no partner, or a dangling sheet pin.
std::vector< KIID > equivalentItems
For a missing partner, all same-named labels or sheet pins.
A label that connects to nothing, or to only one pin.
A label that sits on the interior of two or more wires.
A pin number of one multi-unit symbol that different units connect to different nets.
All placed units that share one reference, with the unit table of the library symbol.
std::vector< UNIT_FACT > units
std::vector< MULTI_UNIT_INSTANCE > instances
One placed unit of an annotated multi-unit symbol.
A label or a power pin with its resolved net name.
A no-connect flag on a net with more than one pin, or on a net with no pin and no label.
KIID pin
If connected, the smallest pin that is not a power flag. Else niluuid.
bool connected
True for more than one pin, false for an unused flag.
VECTOR2I position
The pin position if connected and a pin exists, else the flag.
Pins of type no-connect that touch other items at one position.
std::vector< KIID > pins
No-connect pins at the position, sorted.
std::vector< KIID > others
Items that touch those pins, sorted.
A wire end, a bus entry end or a symbol pin that is not on the connection grid.
std::vector< std::pair< KIID, VECTOR2I > > equivalentPins
All off-grid pins of the symbol.
bool operator()(const std::pair< KIID_PATH, VECTOR2I > &a, const std::pair< KIID_PATH, VECTOR2I > &b) const
One item on one sheet instance, for a diagnostic that needs only a location.
A pin with a footprint that is not dangling, or that ignores dangling state.
Definition conn_engine.h:32
One dangling end of a wire or a bus wire entry.
Definition conn_engine.h:58
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ TYPE_NOT_INIT
Definition typeinfo.h:73
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683