KiCad PCB EDA Suite
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 (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Jon Evans <jon@craftyjon.com>
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 #ifndef _ERC_SETTINGS_H
23 #define _ERC_SETTINGS_H
24 
25 #include <erc_item.h>
26 #include <pin_type.h>
28 #include <widgets/ui_common.h>
29 
30 
31 class SCH_MARKER;
32 class SCHEMATIC;
33 
34 
36 enum ERCE_T
37 {
73 
75 
76  // Errors after this point will not automatically appear in the Severities Panel
77 
78  ERCE_PIN_TO_PIN_WARNING, // pin connected to an other pin: warning level
79  ERCE_PIN_TO_PIN_ERROR, // pin connected to an other pin: error level
80  ERCE_ANNOTATION_ACTION // Not actually an error; just an action performed during
81  // annotation which is passed back through the error handler.
82 };
83 
85 enum class PIN_ERROR
86 {
87  OK,
88  WARNING,
89  PP_ERROR,
91 };
92 
94 #define NPI 4 // Net with Pin isolated, this pin has type Not Connected and must be left N.C.
95 #define DRV 3 // Net driven by a signal (a pin output for instance)
96 #define NET_NC 2 // Net "connected" to a "NoConnect symbol"
97 #define NOD 1 // Net not driven ( Such as 2 or more connected inputs )
98 #define NOC 0 // initial state of a net: no connection
99 
107 {
108 public:
109  ERC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
110 
111  virtual ~ERC_SETTINGS();
112 
113  bool operator==( const ERC_SETTINGS& other ) const
114  {
115  return ( other.m_Severities == m_Severities );
116  }
117 
118  bool operator!=( const ERC_SETTINGS& other ) const
119  {
120  return !( other == *this );
121  }
122 
123  bool IsTestEnabled( int aErrorCode ) const
124  {
125  return GetSeverity( aErrorCode ) != RPT_SEVERITY_IGNORE;
126  }
127 
128  SEVERITY GetSeverity( int aErrorCode ) const;
129 
130  void SetSeverity( int aErrorCode, SEVERITY aSeverity );
131 
132  void ResetPinMap();
133 
134  PIN_ERROR GetPinMapValue( int aFirstType, int aSecondType ) const
135  {
136  wxASSERT( aFirstType < ELECTRICAL_PINTYPES_TOTAL
137  && aSecondType < ELECTRICAL_PINTYPES_TOTAL );
138  return m_PinMap[aFirstType][aSecondType];
139  }
140 
142  {
143  return m_PinMap[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )];
144  }
145 
146  void SetPinMapValue( int aFirstType, int aSecondType, PIN_ERROR aValue )
147  {
148  wxASSERT( aFirstType < ELECTRICAL_PINTYPES_TOTAL
149  && aSecondType < ELECTRICAL_PINTYPES_TOTAL );
150  m_PinMap[aFirstType][aSecondType] = aValue;
151  }
152 
153  void SetPinMapValue( ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType,
154  PIN_ERROR aValue )
155  {
156  m_PinMap[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )] = aValue;
157  }
158 
159  int GetPinMinDrive( ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType ) const
160  {
161  return m_PinMinDrive[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )];
162  }
163 
164 public:
165 
166  std::map<int, SEVERITY> m_Severities;
167  std::set<wxString> m_ErcExclusions;
168 
170 
172 
173 private:
174 
176 };
177 
178 
184 {
185 private:
188  std::vector<SCH_MARKER*> m_filteredMarkers;
189 
190 public:
192  m_schematic( aSchematic ),
193  m_severities( 0 )
194  { }
195 
196  void SetSeverities( int aSeverities ) override;
197 
198  int GetCount( int aSeverity = -1 ) const override;
199 
200  std::shared_ptr<RC_ITEM> GetItem( int aIndex ) const override;
201 
202  std::shared_ptr<ERC_ITEM> GetERCItem( int aIndex ) const;
203 
204  void DeleteItem( int aIndex, bool aDeep ) override;
205 
206  void DeleteAllItems( bool aIncludeExclusions, bool aDeep ) override;
207 
208 private:
209 
210  void visitMarkers( std::function<void( SCH_MARKER* )> aVisitor ) const;
211 };
212 
213 
214 #endif // _ERC_SETTINGS_H
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:171
Pin not connected and not no connect symbol.
Definition: erc_settings.h:41
Units of same symbol have different values.
Definition: erc_settings.h:70
A connection between bus objects doesn't share at least one net.
Definition: erc_settings.h:59
int GetPinMinDrive(ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType) const
Definition: erc_settings.h:159
Different units of the same symbol have different footprints assigned.
Definition: erc_settings.h:51
Power input pin connected to some others pins but no power out pin to drive it.
Definition: erc_settings.h:44
Holds all the data relating to one schematic.
Definition: schematic.h:59
bool IsTestEnabled(int aErrorCode) const
Definition: erc_settings.h:123
A bus wire is graphically connected to a net port/pin (or vice versa).
Definition: erc_settings.h:61
void SetPinMapValue(ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType, PIN_ERROR aValue)
Definition: erc_settings.h:153
A label attached to a bus isn't in bus format.
Definition: erc_settings.h:58
Some wires are not connected to anything else.
Definition: erc_settings.h:65
PIN_ERROR
The values a pin-to-pin entry in the pin matrix can take on.
Definition: erc_settings.h:85
Label not connected to anything.
Definition: erc_settings.h:49
An implementation of the RC_ITEM_LIST interface which uses the global SHEETLIST to fulfill the contra...
Definition: erc_settings.h:183
void SetSeverity(int aErrorCode, SEVERITY aSeverity)
PIN_ERROR GetPinMapValue(ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType) const
Definition: erc_settings.h:141
Library symbol changed from current symbol in schematic or the library symbol link no longer valid.
Definition: erc_settings.h:66
bool operator==(const ERC_SETTINGS &other) const
Definition: erc_settings.h:113
std::set< wxString > m_ErcExclusions
Definition: erc_settings.h:167
Provide an abstract interface of a RC_ITEM* list manager.
Definition: rc_item.h:45
void ResetPinMap()
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:175
void visitMarkers(std::function< void(SCH_MARKER *)> aVisitor) const
void DeleteItem(int aIndex, bool aDeep) override
Remove (and optionally deletes) the indexed item from the list.
NESTED_SETTINGS is a JSON_SETTINGS that lives inside a JSON_SETTINGS.
std::vector< SCH_MARKER * > m_filteredMarkers
Definition: erc_settings.h:188
Pin connected to some others pins but no pin to drive it.
Definition: erc_settings.h:42
std::shared_ptr< ERC_ITEM > GetERCItem(int aIndex) const
Shared pin in a multi-unit symbol is connected to more than one net.
Definition: erc_settings.h:53
2 labels are equal for case insensitive comparisons.
Definition: erc_settings.h:50
Functions to provide common constants and other functions to assist in making a consistent UI.
PIN_ERROR m_PinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
Definition: erc_settings.h:169
Container for ERC settings.
Definition: erc_settings.h:106
Symbol has not been annotated.
Definition: erc_settings.h:68
int GetCount(int aSeverity=-1) const override
SEVERITY
Importer failed to auto-place a bus entry.
Definition: erc_settings.h:72
A wire connected to a bus doesn't match the bus.
Definition: erc_settings.h:57
ERCE_T
ERC error codes.
Definition: erc_settings.h:36
A no connect symbol is not connected to anything.
Definition: erc_settings.h:48
A global label is unique.
Definition: erc_settings.h:63
A text variable could not be resolved.
Definition: erc_settings.h:64
std::map< int, SEVERITY > m_Severities
Definition: erc_settings.h:166
A no connect symbol is connected to more than 1 pin.
Definition: erc_settings.h:47
ERC_SETTINGS(JSON_SETTINGS *aParent, const std::string &aPath)
More than one symbol with the same reference.
Definition: erc_settings.h:71
Mismatch between hierarchical labels and pins sheets.
Definition: erc_settings.h:46
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
Definition: pin_type.h:35
void SetPinMapValue(int aFirstType, int aSecondType, PIN_ERROR aValue)
Definition: erc_settings.h:146
Conflicting bus alias definitions across sheets.
Definition: erc_settings.h:55
PIN_ERROR GetPinMapValue(int aFirstType, int aSecondType) const
Definition: erc_settings.h:134
void DeleteAllItems(bool aIncludeExclusions, bool aDeep) override
virtual ~ERC_SETTINGS()
std::shared_ptr< RC_ITEM > GetItem(int aIndex) const override
Retrieve a RC_ITEM by index.
#define ELECTRICAL_PINTYPES_TOTAL
Definition: pin_type.h:53
Symbol has more units than are defined.
Definition: erc_settings.h:69
Duplicate sheet names within a given sheet.
Definition: erc_settings.h:40
Conflicting drivers (labels, etc) on a subgraph.
Definition: erc_settings.h:56
SHEETLIST_ERC_ITEMS_PROVIDER(SCHEMATIC *aSchematic)
Definition: erc_settings.h:191
bool operator!=(const ERC_SETTINGS &other) const
Definition: erc_settings.h:118
void SetSeverities(int aSeverities) override
SEVERITY GetSeverity(int aErrorCode) const