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
58 
59  // Errors after this point will not automatically appear in the Severities Panel
60 
61  ERCE_PIN_TO_PIN_WARNING, // pin connected to an other pin: warning level
62  ERCE_PIN_TO_PIN_ERROR, // pin connected to an other pin: error level
63 };
64 
66 enum class PIN_ERROR
67 {
68  OK,
69  WARNING,
70  PP_ERROR,
72 };
73 
75 #define NPI 4 // Net with Pin isolated, this pin has type Not Connected and must be left N.C.
76 #define DRV 3 // Net driven by a signal (a pin output for instance)
77 #define NET_NC 2 // Net "connected" to a "NoConnect symbol"
78 #define NOD 1 // Net not driven ( Such as 2 or more connected inputs )
79 #define NOC 0 // initial state of a net: no connection
80 
88 {
89 public:
90  ERC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
91 
92  virtual ~ERC_SETTINGS();
93 
94  void LoadDefaults()
95  {
102  }
103 
104  bool operator==( const ERC_SETTINGS& other ) const
105  {
106  return ( other.m_Severities == m_Severities );
107  }
108 
109  bool operator!=( const ERC_SETTINGS& other ) const
110  {
111  return !( other == *this );
112  }
113 
114  bool IsTestEnabled( int aErrorCode ) const
115  {
116  return m_Severities.at( aErrorCode ) != RPT_SEVERITY_IGNORE;
117  }
118 
119  int GetSeverity( int aErrorCode ) const;
120 
121  void SetSeverity( int aErrorCode, int aSeverity );
122 
123  void ResetPinMap();
124 
125  PIN_ERROR GetPinMapValue( int aFirstType, int aSecondType ) const
126  {
127  wxASSERT( aFirstType < ELECTRICAL_PINTYPES_TOTAL
128  && aSecondType < ELECTRICAL_PINTYPES_TOTAL );
129  return m_PinMap[aFirstType][aSecondType];
130  }
131 
133  {
134  return m_PinMap[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )];
135  }
136 
137  void SetPinMapValue( int aFirstType, int aSecondType, PIN_ERROR aValue )
138  {
139  wxASSERT( aFirstType < ELECTRICAL_PINTYPES_TOTAL
140  && aSecondType < ELECTRICAL_PINTYPES_TOTAL );
141  m_PinMap[aFirstType][aSecondType] = aValue;
142  }
143 
144  void SetPinMapValue( ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType,
145  PIN_ERROR aValue )
146  {
147  m_PinMap[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )] = aValue;
148  }
149 
150  int GetPinMinDrive( ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType ) const
151  {
152  return m_PinMinDrive[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )];
153  }
154 
155 public:
156 
157  std::map<int, int> m_Severities;
158 
160 
162 
163 private:
164 
166 };
167 
174 {
175 private:
178  std::vector<SCH_MARKER*> m_filteredMarkers;
179 
180 public:
182  m_schematic( aSchematic ),
183  m_severities( 0 )
184  { }
185 
186  void SetSeverities( int aSeverities ) override;
187 
188  int GetCount( int aSeverity = -1 ) override;
189 
190  ERC_ITEM* GetItem( int aIndex ) override;
191 
192  void DeleteItem( int aIndex, bool aDeep ) override;
193 
194  void DeleteAllItems() override;
195 };
196 
197 
198 #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:161
int GetPinMinDrive(ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType) const
Definition: erc_settings.h:150
Electrical pin type handling.
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:114
void SetPinMapValue(ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType, PIN_ERROR aValue)
Definition: erc_settings.h:144
PIN_ERROR
The values a pin-to-pin entry in the pin matrix can take on.
Definition: erc_settings.h:66
SHEETLIST_ERC_ITEMS_PROVIDER is an implementation of the RC_ITEM_LISTinterface which uses the global ...
Definition: erc_settings.h:173
PIN_ERROR GetPinMapValue(ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType) const
Definition: erc_settings.h:132
bool operator==(const ERC_SETTINGS &other) const
Definition: erc_settings.h:104
Provide an abstract interface of a RC_ITEM* list manager.
Definition: rc_item.h:42
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:165
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:178
int GetSeverity(int aErrorCode) const
ERC_ITEM * GetItem(int aIndex) override
Function GetItem retrieves a RC_ITEM by index.
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:159
std::map< int, int > m_Severities
Definition: erc_settings.h:157
Container for ERC settings.
Definition: erc_settings.h:87
ERCE_T
ERC error codes.
Definition: erc_settings.h:35
void LoadDefaults()
Definition: erc_settings.h:94
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:37
void DeleteAllItems() override
Function DeleteAllItems removes and deletes all the items in the list.
void SetPinMapValue(int aFirstType, int aSecondType, PIN_ERROR aValue)
Definition: erc_settings.h:137
PIN_ERROR GetPinMapValue(int aFirstType, int aSecondType) const
Definition: erc_settings.h:125
virtual ~ERC_SETTINGS()
#define ELECTRICAL_PINTYPES_TOTAL
Definition: pin_type.h:54
SHEETLIST_ERC_ITEMS_PROVIDER(SCHEMATIC *aSchematic)
Definition: erc_settings.h:181
bool operator!=(const ERC_SETTINGS &other) const
Definition: erc_settings.h:109
void SetSeverities(int aSeverities) override