KiCad PCB EDA Suite
Loading...
Searching...
No Matches
erc_settings.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 (C) 2018-2020 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Jon Evans <[email protected]>
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 along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include <erc/erc_item.h>
25#include <pin_type.h>
27#include <widgets/ui_common.h>
28
29
30class SCH_MARKER;
31class SCHEMATIC;
32
33
36{
90
92
94 ERCE_PIN_TO_PIN_WARNING, // pin connected to an other pin: warning level
95 ERCE_PIN_TO_PIN_ERROR, // pin connected to an other pin: error level
96 ERCE_ANNOTATION_ACTION, // Not actually an error; just an action performed during
97 // annotation which is passed back through the error handler.
101
103enum class PIN_ERROR
104{
105 OK,
106 WARNING,
107 PP_ERROR,
109};
110
113{
116};
117
119#define NPI 4 // Net with Pin isolated, this pin has type Not Connected and must be left N.C.
120#define DRV 3 // Net driven by a signal (a pin output for instance)
121#define NET_NC 2 // Net "connected" to a "NoConnect symbol"
122#define NOD 1 // Net not driven ( Such as 2 or more connected inputs )
123#define NOC 0 // initial state of a net: no connection
124
132{
133public:
134 ERC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
135
136 virtual ~ERC_SETTINGS();
137
138 bool operator==( const ERC_SETTINGS& other ) const
139 {
140 return ( other.m_ERCSeverities == m_ERCSeverities );
141 }
142
143 bool operator!=( const ERC_SETTINGS& other ) const
144 {
145 return !( other == *this );
146 }
147
148 bool IsTestEnabled( int aErrorCode ) const
149 {
150 return GetSeverity( aErrorCode ) != RPT_SEVERITY_IGNORE;
151 }
152
153 SEVERITY GetSeverity( int aErrorCode ) const;
154
155 void SetSeverity( int aErrorCode, SEVERITY aSeverity );
156
157 void ResetPinMap();
158
166 {
167 wxASSERT( static_cast<int>( aPinType ) < ELECTRICAL_PINTYPES_TOTAL );
168 return m_PinTypeWeights.at( aPinType );
169 }
170
176
177 PIN_ERROR GetPinMapValue( int aFirstType, int aSecondType ) const
178 {
179 wxASSERT( aFirstType < ELECTRICAL_PINTYPES_TOTAL
180 && aSecondType < ELECTRICAL_PINTYPES_TOTAL );
181 return m_PinMap[aFirstType][aSecondType];
182 }
183
185 {
186 return m_PinMap[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )];
187 }
188
189 void SetPinMapValue( int aFirstType, int aSecondType, PIN_ERROR aValue )
190 {
191 wxASSERT( aFirstType < ELECTRICAL_PINTYPES_TOTAL
192 && aSecondType < ELECTRICAL_PINTYPES_TOTAL );
193 m_PinMap[aFirstType][aSecondType] = aValue;
194 }
195
197 PIN_ERROR aValue )
198 {
199 m_PinMap[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )] = aValue;
200 }
201
202 int GetPinMinDrive( ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType ) const
203 {
204 return m_PinMinDrive[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )];
205 }
206
207public:
208
209 std::map<int, SEVERITY> m_ERCSeverities;
210 std::set<wxString> m_ErcExclusions; // Serialized excluded ERC markers
211 std::map<wxString, wxString> m_ErcExclusionComments; // Map from serialization to comment
212
214
216
217private:
218
220
226 std::map<ELECTRICAL_PINTYPE, int> m_PinTypeWeights;
227
233};
234
235
241{
242private:
245 std::vector<SCH_MARKER*> m_filteredMarkers;
246
247public:
249 m_schematic( aSchematic ),
250 m_severities( 0 )
251 { }
252
253 // We own at least one list of raw pointers. Don't let the compiler fill in copy c'tors that
254 // will only land us in trouble.
257
258 void SetSeverities( int aSeverities ) override;
259
260 int GetCount( int aSeverity = -1 ) const override;
261
262 std::shared_ptr<RC_ITEM> GetItem( int aIndex ) const override;
263
264 std::shared_ptr<ERC_ITEM> GetERCItem( int aIndex ) const;
265
266 void DeleteItem( int aIndex, bool aDeep ) override;
267
268private:
269
270 void visitMarkers( std::function<void( SCH_MARKER* )> aVisitor ) const;
271};
272
Container for ERC settings.
Definition: erc_settings.h:132
bool IsTestEnabled(int aErrorCode) const
Definition: erc_settings.h:148
ERC_PIN_SORTING_METRIC m_ERCSortingMetric
The type of sorting used by the ERC checker to resolve multi-pin errors.
Definition: erc_settings.h:232
std::map< wxString, wxString > m_ErcExclusionComments
Definition: erc_settings.h:211
PIN_ERROR GetPinMapValue(ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType) const
Definition: erc_settings.h:184
std::map< ELECTRICAL_PINTYPE, int > m_PinTypeWeights
Weights for electrical pins used in ERC to decide which pin gets the marker in case of a multi-pin er...
Definition: erc_settings.h:226
static PIN_ERROR m_defaultPinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
Default Look up table which gives the ERC error level for a pair of connected pins.
Definition: erc_settings.h:219
ERC_PIN_SORTING_METRIC GetERCSortingMetric() const
Get the type of sorting metric the ERC checker should use to resolve multi-pin errors.
Definition: erc_settings.h:175
bool operator!=(const ERC_SETTINGS &other) const
Definition: erc_settings.h:143
SEVERITY GetSeverity(int aErrorCode) const
void SetPinMapValue(ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType, PIN_ERROR aValue)
Definition: erc_settings.h:196
void ResetPinMap()
void SetSeverity(int aErrorCode, SEVERITY aSeverity)
bool operator==(const ERC_SETTINGS &other) const
Definition: erc_settings.h:138
virtual ~ERC_SETTINGS()
PIN_ERROR GetPinMapValue(int aFirstType, int aSecondType) const
Definition: erc_settings.h:177
int GetPinTypeWeight(ELECTRICAL_PINTYPE aPinType) const
Get the weight for an electrical pin type.
Definition: erc_settings.h:165
std::map< int, SEVERITY > m_ERCSeverities
Definition: erc_settings.h:209
std::set< wxString > m_ErcExclusions
Definition: erc_settings.h:210
static int m_PinMinDrive[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
Look up table which gives the minimal drive for a pair of connected pins on a net.
Definition: erc_settings.h:215
void SetPinMapValue(int aFirstType, int aSecondType, PIN_ERROR aValue)
Definition: erc_settings.h:189
PIN_ERROR m_PinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
Definition: erc_settings.h:213
int GetPinMinDrive(ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType) const
Definition: erc_settings.h:202
NESTED_SETTINGS is a JSON_SETTINGS that lives inside a JSON_SETTINGS.
Provide an abstract interface of a RC_ITEM* list manager.
Definition: rc_item.h:52
Holds all the data relating to one schematic.
Definition: schematic.h:88
An implementation of the RC_ITEM_LIST interface which uses the global SHEETLIST to fulfill the contra...
Definition: erc_settings.h:241
int GetCount(int aSeverity=-1) const override
void SetSeverities(int aSeverities) override
void visitMarkers(std::function< void(SCH_MARKER *)> aVisitor) const
SHEETLIST_ERC_ITEMS_PROVIDER(const SHEETLIST_ERC_ITEMS_PROVIDER &)=delete
SHEETLIST_ERC_ITEMS_PROVIDER(SCHEMATIC *aSchematic)
Definition: erc_settings.h:248
void DeleteItem(int aIndex, bool aDeep) override
Remove (and optionally deletes) the indexed item from the list.
std::shared_ptr< ERC_ITEM > GetERCItem(int aIndex) const
std::vector< SCH_MARKER * > m_filteredMarkers
Definition: erc_settings.h:245
SHEETLIST_ERC_ITEMS_PROVIDER & operator=(const SHEETLIST_ERC_ITEMS_PROVIDER &)=delete
std::shared_ptr< RC_ITEM > GetItem(int aIndex) const override
Retrieve a RC_ITEM by index.
ERCE_T
ERC error codes.
Definition: erc_settings.h:36
@ ERCE_UNSPECIFIED
Definition: erc_settings.h:37
@ ERCE_UNANNOTATED
Symbol has not been annotated.
Definition: erc_settings.h:82
@ ERCE_POWERPIN_NOT_DRIVEN
Power input pin connected to some others pins but no power out pin to drive it.
Definition: erc_settings.h:44
@ ERCE_DRIVER_CONFLICT
Conflicting drivers (labels, etc) on a subgraph.
Definition: erc_settings.h:65
@ ERCE_SIMILAR_POWER
2 power pins are equal for case insensitive comparisons.
Definition: erc_settings.h:51
@ ERCE_MISSING_POWER_INPUT_PIN
Symbol has power input pins that are not placed on the schematic.
Definition: erc_settings.h:57
@ ERCE_UNCONNECTED_WIRE_ENDPOINT
A label is connected to more than one wire.
Definition: erc_settings.h:89
@ ERCE_GROUND_PIN_NOT_GROUND
A ground-labeled pin is not on a ground net while another pin is.
Definition: erc_settings.h:71
@ ERCE_SIMILAR_LABELS
2 labels are equal for case insensitive comparisons.
Definition: erc_settings.h:50
@ ERCE_ANNOTATION_ACTION
Definition: erc_settings.h:96
@ ERCE_FIRST
Definition: erc_settings.h:38
@ ERCE_LABEL_NOT_CONNECTED
Label not connected to any pins.
Definition: erc_settings.h:49
@ ERCE_ENDPOINT_OFF_GRID
Pin or wire-end off grid.
Definition: erc_settings.h:40
@ ERCE_DUPLICATE_REFERENCE
More than one symbol with the same reference.
Definition: erc_settings.h:85
@ ERCE_EXTRA_UNITS
Symbol has more units than are defined.
Definition: erc_settings.h:83
@ ERCE_SAME_LOCAL_GLOBAL_LABEL
2 labels are equal for case insensitive comparisons.
Definition: erc_settings.h:54
@ ERCE_BUS_TO_BUS_CONFLICT
A connection between bus objects doesn't share at least one net.
Definition: erc_settings.h:67
@ ERCE_LAST
Definition: erc_settings.h:91
@ ERCE_SIMILAR_LABEL_AND_POWER
label and pin are equal for case insensitive comparisons.
Definition: erc_settings.h:52
@ ERCE_LABEL_SINGLE_PIN
A label is connected only to a single pin.
Definition: erc_settings.h:72
@ ERCE_BUS_ENTRY_CONFLICT
A wire connected to a bus doesn't match the bus.
Definition: erc_settings.h:66
@ ERCE_FOOTPRINT_LINK_ISSUES
The footprint link is invalid, or points to a missing (or inactive) footprint or library.
Definition: erc_settings.h:79
@ ERCE_BUS_TO_NET_CONFLICT
A bus wire is graphically connected to a net port/pin (or vice versa).
Definition: erc_settings.h:69
@ ERCE_DUPLICATE_PIN_ERROR
Definition: erc_settings.h:93
@ ERCE_NOCONNECT_NOT_CONNECTED
A no connect symbol is not connected to anything.
Definition: erc_settings.h:48
@ ERCE_DIFFERENT_UNIT_NET
Shared pin in a multi-unit symbol is connected to more than one net.
Definition: erc_settings.h:62
@ ERCE_FOUR_WAY_JUNCTION
A four-way junction was found.
Definition: erc_settings.h:87
@ ERCE_PIN_NOT_CONNECTED
Pin not connected and not no connect symbol.
Definition: erc_settings.h:41
@ ERCE_UNDEFINED_NETCLASS
A netclass was referenced but not defined.
Definition: erc_settings.h:74
@ ERCE_BUS_ENTRY_NEEDED
Importer failed to auto-place a bus entry.
Definition: erc_settings.h:86
@ ERCE_UNRESOLVED_VARIABLE
A text variable could not be resolved.
Definition: erc_settings.h:73
@ ERCE_SIMULATION_MODEL
An error was found in the simulation model.
Definition: erc_settings.h:75
@ ERCE_LIB_SYMBOL_MISMATCH
Symbol doesn't match copy in library.
Definition: erc_settings.h:78
@ ERCE_GENERIC_ERROR
Definition: erc_settings.h:99
@ ERCE_DIFFERENT_UNIT_FP
Different units of the same symbol have different footprints assigned.
Definition: erc_settings.h:55
@ ERCE_NOCONNECT_CONNECTED
A no connect symbol is connected to more than 1 pin.
Definition: erc_settings.h:47
@ ERCE_PIN_TO_PIN_WARNING
Definition: erc_settings.h:94
@ ERCE_PIN_NOT_DRIVEN
Pin connected to some others pins but no pin to drive it.
Definition: erc_settings.h:42
@ ERCE_MISSING_INPUT_PIN
Symbol has input pins that are not placed.
Definition: erc_settings.h:59
@ ERCE_MISSING_UNIT
Symbol has units that are not placed on the schematic.
Definition: erc_settings.h:61
@ ERCE_DUPLICATE_SHEET_NAME
Duplicate sheet names within a given sheet.
Definition: erc_settings.h:39
@ ERCE_MISSING_BIDI_PIN
Symbol has bi-directional pins that are not placed.
Definition: erc_settings.h:60
@ ERCE_LIB_SYMBOL_ISSUES
Symbol not found in active libraries.
Definition: erc_settings.h:77
@ ERCE_FOOTPRINT_FILTERS
The assigned footprint doesn't match the footprint filters.
Definition: erc_settings.h:81
@ ERCE_HIERACHICAL_LABEL
Mismatch between hierarchical labels and pins sheets.
Definition: erc_settings.h:46
@ ERCE_WIRE_DANGLING
Some wires are not connected to anything else.
Definition: erc_settings.h:76
@ ERCE_BUS_ALIAS_CONFLICT
Conflicting bus alias definitions across sheets.
Definition: erc_settings.h:64
@ ERCE_GENERIC_WARNING
Definition: erc_settings.h:98
@ ERCE_SINGLE_GLOBAL_LABEL
A label only exists once in the schematic.
Definition: erc_settings.h:53
@ ERCE_LABEL_MULTIPLE_WIRES
A label is connected to more than one wire.
Definition: erc_settings.h:88
@ ERCE_DIFFERENT_UNIT_VALUE
Units of same symbol have different values.
Definition: erc_settings.h:84
@ ERCE_PIN_TO_PIN_ERROR
Definition: erc_settings.h:95
ERC_PIN_SORTING_METRIC
The sorting metric used for erc resolution of multi-pin errors.
Definition: erc_settings.h:113
PIN_ERROR
The values a pin-to-pin entry in the pin matrix can take on.
Definition: erc_settings.h:104
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
Definition: pin_type.h:36
#define ELECTRICAL_PINTYPES_TOTAL
Definition: pin_type.h:56
SEVERITY
@ RPT_SEVERITY_IGNORE
Functions to provide common constants and other functions to assist in making a consistent UI.