KiCad PCB EDA Suite
erc_item.cpp
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) 2020 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU 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, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 
25 #include "wx/html/m_templ.h"
26 #include "wx/html/styleparams.h"
27 #include <erc.h>
28 #include <erc_item.h>
29 #include <i18n_utility.h>
30 
31 
32 // These, being statically-defined, require specialized I18N handling. We continue to
33 // use the _() macro so that string harvesting by the I18N framework doesn't have to be
34 // specialized, but we don't translate on initialization and instead do it in the getters.
35 
36 #undef _
37 #define _(s) s
38 
39 // NOTE: Avoid changing the settings key for an ERC item after it has been created
40 
41 ERC_ITEM ERC_ITEM::heading_connections( 0, _( "Connections" ), "" );
42 ERC_ITEM ERC_ITEM::heading_conflicts( 0, _( "Conflicts" ), "" );
43 ERC_ITEM ERC_ITEM::heading_misc( 0, _( "Miscellaneous" ), "" );
44 
46  _( "Duplicate sheet names within a given sheet" ),
47  wxT( "duplicate_sheet_names" ) );
48 
50  _( "Pin not connected" ),
51  wxT( "pin_not_connected" ) );
52 
54  _( "Input pin not driven by any Output pins" ),
55  wxT( "pin_not_driven" ) );
56 
58  _( "Input Power pin not driven by any Output Power pins" ),
59  wxT( "power_pin_not_driven" ) );
60 
62  _( "Conflict problem between pins" ),
63  wxT( "pin_to_pin" ) );
64 
66  _( "Conflict problem between pins" ),
67  wxT( "pin_to_pin" ) );
68 
70  _( "Mismatch between hierarchical labels and sheet pins" ),
71  wxT( "hier_label_mismatch" ) );
72 
74  _( "A pin with a \"no connection\" flag is connected" ),
75  wxT( "no_connect_connected" ) );
76 
78  _( "Unconnected \"no connection\" flag" ),
79  wxT( "no_connect_dangling" ) );
80 
82  _( "Label not connected to anything" ),
83  wxT( "label_dangling" ) );
84 
86  _( "Global label not connected anywhere else in the schematic" ),
87  wxT( "global_label_dangling" ) );
88 
90  _( "Labels are similar (lower/upper case difference only)"),
91  wxT( "similar_labels" ) );
92 
94  _( "Different footprint assigned in another unit of the symbol" ),
95  wxT( "different_unit_footprint" ) );
96 
98  _( "Different net assigned to a shared pin in another unit of the symbol" ),
99  wxT( "different_unit_net" ) );
100 
102  _( "Conflict between bus alias definitions across schematic sheets" ),
103  wxT( "bus_definition_conflict" ) );
104 
106  _( "More than one name given to this bus or net" ),
107  wxT( "multiple_net_names" ) );
108 
110  _( "Net is graphically connected to a bus but not a bus member" ),
111  wxT( "net_not_bus_member" ) );
112 
114  _( "Label attached to bus item does not describe a bus" ),
115  wxT( "bus_label_syntax" ) );
116 
118  _( "Buses are graphically connected but share no bus members" ),
119  wxT( "bus_to_bus_conflict" ) );
120 
122  _( "Invalid connection between bus and net items" ),
123  wxT( "bus_to_net_conflict" ) );
124 
126  _( "Unresolved text variable" ),
127  wxT( "unresolved_variable" ) );
128 
130  _( "Wires not connected to anything" ),
131  wxT( "wire_dangling" ) );
132 
134  _( "Library symbol issue" ),
135  wxT( "lib_symbol_issues" ) );
136 
138  _( "Symbol is not annotated" ),
139  wxT( "unannotated" ) );
140 
142  _( "Symbol has more units than are defined" ),
143  wxT( "extra_units" ) );
144 
146  _( "Units of same symbol have different values" ),
147  wxT( "unit_value_mismatch" ) );
148 
150  _( "Duplicate reference designators" ),
151  wxT( "duplicate_reference" ) );
152 
154  _( "Bus Entry needed" ),
155  wxT( "bus_entry_needed" ) );
156 
157 std::vector<std::reference_wrapper<RC_ITEM>> ERC_ITEM::allItemTypes( {
168 
182 
190  } );
191 
192 
193 
194 std::shared_ptr<ERC_ITEM> ERC_ITEM::Create( int aErrorCode )
195 {
196  switch( aErrorCode )
197  {
198  case ERCE_DUPLICATE_SHEET_NAME: return std::make_shared<ERC_ITEM>( duplicateSheetName );
199  case ERCE_PIN_NOT_CONNECTED: return std::make_shared<ERC_ITEM>( pinNotConnected );
200  case ERCE_PIN_NOT_DRIVEN: return std::make_shared<ERC_ITEM>( pinNotDriven );
201  case ERCE_POWERPIN_NOT_DRIVEN: return std::make_shared<ERC_ITEM>( powerpinNotDriven );
202  case ERCE_PIN_TO_PIN_WARNING: return std::make_shared<ERC_ITEM>( pinTableWarning );
203  case ERCE_PIN_TO_PIN_ERROR: return std::make_shared<ERC_ITEM>( pinTableError );
204  case ERCE_HIERACHICAL_LABEL: return std::make_shared<ERC_ITEM>( hierLabelMismatch );
205  case ERCE_NOCONNECT_CONNECTED: return std::make_shared<ERC_ITEM>( noConnectConnected );
206  case ERCE_NOCONNECT_NOT_CONNECTED: return std::make_shared<ERC_ITEM>( noConnectDangling );
207  case ERCE_LABEL_NOT_CONNECTED: return std::make_shared<ERC_ITEM>( labelDangling );
208  case ERCE_SIMILAR_LABELS: return std::make_shared<ERC_ITEM>( similarLabels );
209  case ERCE_DIFFERENT_UNIT_FP: return std::make_shared<ERC_ITEM>( differentUnitFootprint );
210  case ERCE_DIFFERENT_UNIT_NET: return std::make_shared<ERC_ITEM>( differentUnitNet );
211  case ERCE_BUS_ALIAS_CONFLICT: return std::make_shared<ERC_ITEM>( busDefinitionConflict );
212  case ERCE_DRIVER_CONFLICT: return std::make_shared<ERC_ITEM>( multipleNetNames );
213  case ERCE_BUS_ENTRY_CONFLICT: return std::make_shared<ERC_ITEM>( netNotBusMember );
214  case ERCE_BUS_LABEL_ERROR: return std::make_shared<ERC_ITEM>( busLabelSyntax );
215  case ERCE_BUS_TO_BUS_CONFLICT: return std::make_shared<ERC_ITEM>( busToBusConflict );
216  case ERCE_BUS_TO_NET_CONFLICT: return std::make_shared<ERC_ITEM>( busToNetConflict );
217  case ERCE_GLOBLABEL: return std::make_shared<ERC_ITEM>( globalLabelDangling );
218  case ERCE_UNRESOLVED_VARIABLE: return std::make_shared<ERC_ITEM>( unresolvedVariable );
219  case ERCE_WIRE_DANGLING: return std::make_shared<ERC_ITEM>( wireDangling );
220  case ERCE_LIB_SYMBOL_ISSUES: return std::make_shared<ERC_ITEM>( libSymbolIssues );
221  case ERCE_UNANNOTATED: return std::make_shared<ERC_ITEM>( unannotated );
222  case ERCE_EXTRA_UNITS: return std::make_shared<ERC_ITEM>( extraUnits );
223  case ERCE_DIFFERENT_UNIT_VALUE: return std::make_shared<ERC_ITEM>( differentUnitValue );
224  case ERCE_DUPLICATE_REFERENCE: return std::make_shared<ERC_ITEM>( duplicateReference );
225  case ERCE_BUS_ENTRY_NEEDED: return std::make_shared<ERC_ITEM>( busEntryNeeded );
226  case ERCE_UNSPECIFIED:
227  default:
228  wxFAIL_MSG( "Unknown ERC error code" );
229  return nullptr;
230  }
231 
232  return nullptr;
233 }
static ERC_ITEM unannotated
Definition: erc_item.h:97
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
static ERC_ITEM busToNetConflict
Definition: erc_item.h:93
static ERC_ITEM pinTableError
Definition: erc_item.h:79
Different units of the same symbol have different footprints assigned.
Definition: erc_settings.h:51
static ERC_ITEM noConnectConnected
Definition: erc_item.h:81
Power input pin connected to some others pins but no power out pin to drive it.
Definition: erc_settings.h:44
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
Definition: erc_item.cpp:194
static ERC_ITEM differentUnitNet
Definition: erc_item.h:87
A bus wire is graphically connected to a net port/pin (or vice versa).
Definition: erc_settings.h:61
static ERC_ITEM busLabelSyntax
Definition: erc_item.h:91
A label attached to a bus isn't in bus format.
Definition: erc_settings.h:58
static ERC_ITEM heading_conflicts
Definition: erc_item.h:71
#define _(s)
Definition: erc_item.cpp:37
Some wires are not connected to anything else.
Definition: erc_settings.h:65
Label not connected to anything.
Definition: erc_settings.h:49
Library symbol changed from current symbol in schematic or the library symbol link no longer valid.
Definition: erc_settings.h:66
static ERC_ITEM similarLabels
Definition: erc_item.h:85
static ERC_ITEM busEntryNeeded
Definition: erc_item.h:101
static ERC_ITEM duplicateReference
Definition: erc_item.h:100
static ERC_ITEM heading_connections
Definition: erc_item.h:70
static ERC_ITEM heading_misc
Definition: erc_item.h:72
Pin connected to some others pins but no pin to drive it.
Definition: erc_settings.h:42
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
static ERC_ITEM multipleNetNames
Definition: erc_item.h:89
static ERC_ITEM labelDangling
Definition: erc_item.h:83
static ERC_ITEM noConnectDangling
Definition: erc_item.h:82
static ERC_ITEM pinTableWarning
Definition: erc_item.h:78
static ERC_ITEM unresolvedVariable
Definition: erc_item.h:94
Symbol has not been annotated.
Definition: erc_settings.h:68
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
static ERC_ITEM extraUnits
Definition: erc_item.h:98
A no connect symbol is not connected to anything.
Definition: erc_settings.h:48
static ERC_ITEM pinNotDriven
Definition: erc_item.h:76
Some functions to handle hotkeys in KiCad.
static ERC_ITEM duplicateSheetName
Definition: erc_item.h:74
A global label is unique.
Definition: erc_settings.h:63
A text variable could not be resolved.
Definition: erc_settings.h:64
A no connect symbol is connected to more than 1 pin.
Definition: erc_settings.h:47
static ERC_ITEM busDefinitionConflict
Definition: erc_item.h:88
static ERC_ITEM netNotBusMember
Definition: erc_item.h:90
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
static ERC_ITEM libSymbolIssues
Definition: erc_item.h:96
Conflicting bus alias definitions across sheets.
Definition: erc_settings.h:55
static ERC_ITEM powerpinNotDriven
Definition: erc_item.h:77
static std::vector< std::reference_wrapper< RC_ITEM > > allItemTypes
A list of all ERC_ITEM types which are valid error codes.
Definition: erc_item.h:68
static ERC_ITEM pinNotConnected
Definition: erc_item.h:75
static ERC_ITEM differentUnitFootprint
Definition: erc_item.h:86
Symbol has more units than are defined.
Definition: erc_settings.h:69
Duplicate sheet names within a given sheet.
Definition: erc_settings.h:40
static ERC_ITEM busToBusConflict
Definition: erc_item.h:92
static ERC_ITEM hierLabelMismatch
Definition: erc_item.h:80
Conflicting drivers (labels, etc) on a subgraph.
Definition: erc_settings.h:56
static ERC_ITEM globalLabelDangling
Definition: erc_item.h:84
static ERC_ITEM wireDangling
Definition: erc_item.h:95
static ERC_ITEM differentUnitValue
Definition: erc_item.h:99