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 CERN
5  * @author Jon Evans <jon@craftyjon.com>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef _ERC_SETTINGS_H
22 #define _ERC_SETTINGS_H
23 
24 #include <erc_item.h>
25 #include <pin_type.h>
27 #include <widgets/ui_common.h>
28 
29 
30 class SCH_MARKER;
31 class SCHEMATIC;
32 
33 
35 enum ERCE_T
36 {
39  ERCE_DUPLICATE_SHEET_NAME = ERCE_FIRST, // duplicate sheet names within a given sheet
40  ERCE_PIN_NOT_CONNECTED, // pin not connected and not no connect symbol
41  ERCE_PIN_NOT_DRIVEN, // pin connected to some others pins but no pin to drive it
42  ERCE_HIERACHICAL_LABEL, // mismatch between hierarchical labels and pins sheets
43  ERCE_NOCONNECT_CONNECTED, // a no connect symbol is connected to more than 1 pin
44  ERCE_NOCONNECT_NOT_CONNECTED, // a no connect symbol is not connected to anything
45  ERCE_LABEL_NOT_CONNECTED, // label not connected to anything
46  ERCE_SIMILAR_LABELS, // 2 labels are equal fir case insensitive comparisons
47  ERCE_DIFFERENT_UNIT_FP, // different units of the same component have different footprints assigned
48  ERCE_DIFFERENT_UNIT_NET, // a shared pin in a multi-unit component is connected to more than one net
49  ERCE_BUS_ALIAS_CONFLICT, // conflicting bus alias definitions across sheets
50  ERCE_DRIVER_CONFLICT, // conflicting drivers (labels, etc) on a subgraph
51  ERCE_BUS_ENTRY_CONFLICT, // a wire connected to a bus doesn't match the bus
52  ERCE_BUS_LABEL_ERROR, // a label attached to a bus isn't in bus format
53  ERCE_BUS_TO_BUS_CONFLICT, // a connection between bus objects doesn't share at least one net
54  ERCE_BUS_TO_NET_CONFLICT, // a bus wire is graphically connected to a net port/pin (or vice versa)
55  ERCE_GLOBLABEL, // a global label is unique
56  ERCE_UNRESOLVED_VARIABLE, // a text variable could not be resolved
57  ERCE_WIRE_DANGLING, // some wires are not connected to anything else
59 
60  // Errors after this point will not automatically appear in the Severities Panel
61 
62  ERCE_PIN_TO_PIN_WARNING, // pin connected to an other pin: warning level
63  ERCE_PIN_TO_PIN_ERROR, // pin connected to an other pin: error level
64 };
65 
67 enum class PIN_ERROR
68 {
69  OK,
70  WARNING,
71  PP_ERROR,
73 };
74 
76 #define NPI 4 // Net with Pin isolated, this pin has type Not Connected and must be left N.C.
77 #define DRV 3 // Net driven by a signal (a pin output for instance)
78 #define NET_NC 2 // Net "connected" to a "NoConnect symbol"
79 #define NOD 1 // Net not driven ( Such as 2 or more connected inputs )
80 #define NOC 0 // initial state of a net: no connection
81 
89 {
90 public:
91  ERC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
92 
93  virtual ~ERC_SETTINGS();
94 
95  void LoadDefaults()
96  {
103  }
104 
105  bool operator==( const ERC_SETTINGS& other ) const
106  {
107  return ( other.m_Severities == m_Severities );
108  }
109 
110  bool operator!=( const ERC_SETTINGS& other ) const
111  {
112  return !( other == *this );
113  }
114 
115  bool IsTestEnabled( int aErrorCode ) const
116  {
117  return GetSeverity( aErrorCode ) != RPT_SEVERITY_IGNORE;
118  }
119 
120  int GetSeverity( int aErrorCode ) const;
121 
122  void SetSeverity( int aErrorCode, int aSeverity );
123 
124  void ResetPinMap();
125 
126  PIN_ERROR GetPinMapValue( int aFirstType, int aSecondType ) const
127  {
128  wxASSERT( aFirstType < ELECTRICAL_PINTYPES_TOTAL
129  && aSecondType < ELECTRICAL_PINTYPES_TOTAL );
130  return m_PinMap[aFirstType][aSecondType];
131  }
132 
134  {
135  return m_PinMap[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )];
136  }
137 
138  void SetPinMapValue( int aFirstType, int aSecondType, PIN_ERROR aValue )
139  {
140  wxASSERT( aFirstType < ELECTRICAL_PINTYPES_TOTAL
141  && aSecondType < ELECTRICAL_PINTYPES_TOTAL );
142  m_PinMap[aFirstType][aSecondType] = aValue;
143  }
144 
145  void SetPinMapValue( ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType,
146  PIN_ERROR aValue )
147  {
148  m_PinMap[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )] = aValue;
149  }
150 
151  int GetPinMinDrive( ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType ) const
152  {
153  return m_PinMinDrive[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )];
154  }
155 
156 public:
157 
158  std::map<int, int> m_Severities;
159 
161 
163 
164 private:
165 
167 };
168 
175 {
176 private:
179  std::vector<SCH_MARKER*> m_filteredMarkers;
180 
181 public:
183  m_schematic( aSchematic ),
184  m_severities( 0 )
185  { }
186 
187  void SetSeverities( int aSeverities ) override;
188 
189  int GetCount( int aSeverity = -1 ) override;
190 
191  std::shared_ptr<RC_ITEM> GetItem( int aIndex ) override;
192 
193  std::shared_ptr<ERC_ITEM> GetERCItem( int aIndex );
194 
195  void DeleteItem( int aIndex, bool aDeep ) override;
196 
197  void DeleteAllItems( bool aIncludeExclusions, bool aDeep ) override;
198 };
199 
200 
201 #endif
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:162
int GetPinMinDrive(ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType) const
Definition: erc_settings.h:151
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:42
bool IsTestEnabled(int aErrorCode) const
Definition: erc_settings.h:115
void SetPinMapValue(ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType, PIN_ERROR aValue)
Definition: erc_settings.h:145
PIN_ERROR
The values a pin-to-pin entry in the pin matrix can take on.
Definition: erc_settings.h:67
SHEETLIST_ERC_ITEMS_PROVIDER is an implementation of the RC_ITEM_LISTinterface which uses the global ...
Definition: erc_settings.h:174
PIN_ERROR GetPinMapValue(ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType) const
Definition: erc_settings.h:133
bool operator==(const ERC_SETTINGS &other) const
Definition: erc_settings.h:105
Provide an abstract interface of a RC_ITEM* list manager.
Definition: rc_item.h:43
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:166
std::shared_ptr< RC_ITEM > GetItem(int aIndex) override
Function GetItem retrieves a RC_ITEM by index.
void DeleteItem(int aIndex, bool aDeep) override
Function DeleteItem removes (and optionally deletes) the indexed item from the list.
NESTED_SETTINGS is a JSON_SETTINGS that lives inside a JSON_SETTINGS.
void SetSeverity(int aErrorCode, int aSeverity)
std::vector< SCH_MARKER * > m_filteredMarkers
Definition: erc_settings.h:179
int GetSeverity(int aErrorCode) const
Functions to provide common constants and other functions to assist in making a consistent UI.
int GetCount(int aSeverity=-1) override
PIN_ERROR m_PinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
Definition: erc_settings.h:160
std::map< int, int > m_Severities
Definition: erc_settings.h:158
Container for ERC settings.
Definition: erc_settings.h:88
ERCE_T
ERC error codes.
Definition: erc_settings.h:35
void LoadDefaults()
Definition: erc_settings.h:95
ERC_SETTINGS(JSON_SETTINGS *aParent, const std::string &aPath)
ELECTRICAL_PINTYPE
The component library pin object electrical types used in ERC tests.
Definition: pin_type.h:34
void SetPinMapValue(int aFirstType, int aSecondType, PIN_ERROR aValue)
Definition: erc_settings.h:138
PIN_ERROR GetPinMapValue(int aFirstType, int aSecondType) const
Definition: erc_settings.h:126
void DeleteAllItems(bool aIncludeExclusions, bool aDeep) override
virtual ~ERC_SETTINGS()
#define ELECTRICAL_PINTYPES_TOTAL
Definition: pin_type.h:51
std::shared_ptr< ERC_ITEM > GetERCItem(int aIndex)
SHEETLIST_ERC_ITEMS_PROVIDER(SCHEMATIC *aSchematic)
Definition: erc_settings.h:182
bool operator!=(const ERC_SETTINGS &other) const
Definition: erc_settings.h:110
void SetSeverities(int aSeverities) override