2019-03-11 21:32:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2020-10-07 13:15:31 +00:00
|
|
|
* Copyright (C) 2018-2020 CERN
|
2021-01-24 22:25:32 +00:00
|
|
|
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-03-11 21:32:05 +00:00
|
|
|
* @author Jon Evans <jon@craftyjon.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ERC_SETTINGS_H
|
|
|
|
#define _ERC_SETTINGS_H
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
#include <erc_item.h>
|
2020-07-03 21:08:17 +00:00
|
|
|
#include <pin_type.h>
|
2020-06-08 02:19:46 +00:00
|
|
|
#include <settings/nested_settings.h>
|
2020-03-10 18:46:57 +00:00
|
|
|
#include <widgets/ui_common.h>
|
|
|
|
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
class SCH_MARKER;
|
2020-07-03 21:08:17 +00:00
|
|
|
class SCHEMATIC;
|
|
|
|
|
|
|
|
|
|
|
|
/// ERC error codes
|
|
|
|
enum ERCE_T
|
|
|
|
{
|
|
|
|
ERCE_UNSPECIFIED = 0,
|
|
|
|
ERCE_FIRST,
|
2020-10-07 13:15:31 +00:00
|
|
|
ERCE_DUPLICATE_SHEET_NAME = ERCE_FIRST, ///< Duplicate sheet names within a given sheet.
|
2022-03-17 20:23:14 +00:00
|
|
|
ERCE_ENDPOINT_OFF_GRID, ///< Pin or wire-end off grid.
|
2020-10-07 13:15:31 +00:00
|
|
|
ERCE_PIN_NOT_CONNECTED, ///< Pin not connected and not no connect symbol.
|
|
|
|
ERCE_PIN_NOT_DRIVEN, ///< Pin connected to some others pins but no pin to drive it.
|
2024-02-02 23:04:56 +00:00
|
|
|
///< pins to drive it can be output, passive, 3sttae, I/O
|
2020-11-02 11:41:58 +00:00
|
|
|
ERCE_POWERPIN_NOT_DRIVEN, ///< Power input pin connected to some others pins but no
|
2024-02-02 23:04:56 +00:00
|
|
|
///< power out pin to drive it.
|
2020-10-07 13:15:31 +00:00
|
|
|
ERCE_HIERACHICAL_LABEL, ///< Mismatch between hierarchical labels and pins sheets.
|
|
|
|
ERCE_NOCONNECT_CONNECTED, ///< A no connect symbol is connected to more than 1 pin.
|
|
|
|
ERCE_NOCONNECT_NOT_CONNECTED, ///< A no connect symbol is not connected to anything.
|
|
|
|
ERCE_LABEL_NOT_CONNECTED, ///< Label not connected to anything.
|
|
|
|
ERCE_SIMILAR_LABELS, ///< 2 labels are equal for case insensitive comparisons.
|
2021-06-14 18:00:08 +00:00
|
|
|
ERCE_DIFFERENT_UNIT_FP, ///< Different units of the same symbol have different
|
2024-02-02 23:04:56 +00:00
|
|
|
///< footprints assigned.
|
|
|
|
ERCE_MISSING_POWER_INPUT_PIN, ///< Symbol has power input pins that are not placed on the
|
|
|
|
///< schematic
|
2022-11-26 04:40:01 +00:00
|
|
|
ERCE_MISSING_INPUT_PIN, ///< Symbol has input pins that are not placed
|
|
|
|
ERCE_MISSING_BIDI_PIN, ///< Symbol has bi-directional pins that are not placed
|
|
|
|
ERCE_MISSING_UNIT, ///< Symbol has units that are not placed on the schematic
|
2021-06-14 18:00:08 +00:00
|
|
|
ERCE_DIFFERENT_UNIT_NET, ///< Shared pin in a multi-unit symbol is connected to
|
2024-02-02 23:04:56 +00:00
|
|
|
///< more than one net.
|
2020-10-07 13:15:31 +00:00
|
|
|
ERCE_BUS_ALIAS_CONFLICT, ///< Conflicting bus alias definitions across sheets.
|
|
|
|
ERCE_DRIVER_CONFLICT, ///< Conflicting drivers (labels, etc) on a subgraph.
|
|
|
|
ERCE_BUS_ENTRY_CONFLICT, ///< A wire connected to a bus doesn't match the bus.
|
|
|
|
ERCE_BUS_TO_BUS_CONFLICT, ///< A connection between bus objects doesn't share at least
|
2024-02-02 23:04:56 +00:00
|
|
|
///< one net.
|
2020-10-07 13:15:31 +00:00
|
|
|
ERCE_BUS_TO_NET_CONFLICT, ///< A bus wire is graphically connected to a net port/pin
|
2024-02-02 23:04:56 +00:00
|
|
|
///< (or vice versa).
|
2022-08-14 11:03:18 +00:00
|
|
|
ERCE_NETCLASS_CONFLICT, ///< Multiple labels assign different netclasses to same net.
|
2020-10-07 13:15:31 +00:00
|
|
|
ERCE_GLOBLABEL, ///< A global label is unique.
|
|
|
|
ERCE_UNRESOLVED_VARIABLE, ///< A text variable could not be resolved.
|
2024-02-16 13:22:17 +00:00
|
|
|
ERCE_UNDEFINED_NETCLASS, ///< A netclass was referenced but not defined.
|
2022-11-07 12:27:58 +00:00
|
|
|
ERCE_SIMULATION_MODEL, ///< An error was found in the simulation model.
|
2020-10-07 13:15:31 +00:00
|
|
|
ERCE_WIRE_DANGLING, ///< Some wires are not connected to anything else.
|
2024-02-16 13:22:17 +00:00
|
|
|
ERCE_LIB_SYMBOL_ISSUES, ///< Symbol not found in active libraries.
|
|
|
|
ERCE_LIB_SYMBOL_MISMATCH, ///< Symbol doesn't match copy in library.
|
2024-02-01 17:29:16 +00:00
|
|
|
ERCE_FOOTPRINT_LINK_ISSUES, ///< The footprint link is invalid, or points to a missing
|
|
|
|
///< (or inactive) footprint or library.
|
2021-01-24 22:25:32 +00:00
|
|
|
ERCE_UNANNOTATED, ///< Symbol has not been annotated.
|
|
|
|
ERCE_EXTRA_UNITS, ///< Symbol has more units than are defined.
|
|
|
|
ERCE_DIFFERENT_UNIT_VALUE, ///< Units of same symbol have different values.
|
|
|
|
ERCE_DUPLICATE_REFERENCE, ///< More than one symbol with the same reference.
|
2021-06-16 20:02:39 +00:00
|
|
|
ERCE_BUS_ENTRY_NEEDED, ///< Importer failed to auto-place a bus entry.
|
2021-01-24 22:25:32 +00:00
|
|
|
|
2021-06-16 20:02:39 +00:00
|
|
|
ERCE_LAST = ERCE_BUS_ENTRY_NEEDED,
|
2020-07-03 21:08:17 +00:00
|
|
|
|
|
|
|
// Errors after this point will not automatically appear in the Severities Panel
|
|
|
|
|
|
|
|
ERCE_PIN_TO_PIN_WARNING, // pin connected to an other pin: warning level
|
|
|
|
ERCE_PIN_TO_PIN_ERROR, // pin connected to an other pin: error level
|
2021-01-24 22:25:32 +00:00
|
|
|
ERCE_ANNOTATION_ACTION // Not actually an error; just an action performed during
|
|
|
|
// annotation which is passed back through the error handler.
|
2020-07-03 21:08:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// The values a pin-to-pin entry in the pin matrix can take on
|
|
|
|
enum class PIN_ERROR
|
|
|
|
{
|
|
|
|
OK,
|
|
|
|
WARNING,
|
2020-07-04 15:51:00 +00:00
|
|
|
PP_ERROR,
|
2020-07-03 21:08:17 +00:00
|
|
|
UNCONNECTED
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Types of drive on a net (used for legacy ERC)
|
|
|
|
#define NPI 4 // Net with Pin isolated, this pin has type Not Connected and must be left N.C.
|
|
|
|
#define DRV 3 // Net driven by a signal (a pin output for instance)
|
|
|
|
#define NET_NC 2 // Net "connected" to a "NoConnect symbol"
|
|
|
|
#define NOD 1 // Net not driven ( Such as 2 or more connected inputs )
|
|
|
|
#define NOC 0 // initial state of a net: no connection
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
/**
|
|
|
|
* Container for ERC settings
|
|
|
|
*
|
|
|
|
* Currently only stores flags about checks to run, but could later be expanded
|
|
|
|
* to contain the matrix of electrical pin types.
|
|
|
|
*/
|
2020-06-08 02:19:46 +00:00
|
|
|
class ERC_SETTINGS : public NESTED_SETTINGS
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-06-08 02:19:46 +00:00
|
|
|
ERC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
|
2020-03-13 17:25:07 +00:00
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
virtual ~ERC_SETTINGS();
|
2020-03-13 17:25:07 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
bool operator==( const ERC_SETTINGS& other ) const
|
|
|
|
{
|
2022-09-06 20:26:36 +00:00
|
|
|
return ( other.m_ERCSeverities == m_ERCSeverities );
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=( const ERC_SETTINGS& other ) const
|
|
|
|
{
|
|
|
|
return !( other == *this );
|
|
|
|
}
|
|
|
|
|
2020-03-10 18:46:57 +00:00
|
|
|
bool IsTestEnabled( int aErrorCode ) const
|
|
|
|
{
|
2020-08-30 19:25:31 +00:00
|
|
|
return GetSeverity( aErrorCode ) != RPT_SEVERITY_IGNORE;
|
2020-03-10 18:46:57 +00:00
|
|
|
}
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2020-12-14 13:33:51 +00:00
|
|
|
SEVERITY GetSeverity( int aErrorCode ) const;
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2020-12-14 13:33:51 +00:00
|
|
|
void SetSeverity( int aErrorCode, SEVERITY aSeverity );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2020-07-03 21:08:17 +00:00
|
|
|
void ResetPinMap();
|
|
|
|
|
|
|
|
PIN_ERROR GetPinMapValue( int aFirstType, int aSecondType ) const
|
|
|
|
{
|
|
|
|
wxASSERT( aFirstType < ELECTRICAL_PINTYPES_TOTAL
|
|
|
|
&& aSecondType < ELECTRICAL_PINTYPES_TOTAL );
|
|
|
|
return m_PinMap[aFirstType][aSecondType];
|
|
|
|
}
|
|
|
|
|
|
|
|
PIN_ERROR GetPinMapValue( ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType ) const
|
|
|
|
{
|
|
|
|
return m_PinMap[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )];
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetPinMapValue( int aFirstType, int aSecondType, PIN_ERROR aValue )
|
|
|
|
{
|
|
|
|
wxASSERT( aFirstType < ELECTRICAL_PINTYPES_TOTAL
|
|
|
|
&& aSecondType < ELECTRICAL_PINTYPES_TOTAL );
|
|
|
|
m_PinMap[aFirstType][aSecondType] = aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetPinMapValue( ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType,
|
|
|
|
PIN_ERROR aValue )
|
|
|
|
{
|
|
|
|
m_PinMap[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )] = aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetPinMinDrive( ELECTRICAL_PINTYPE aFirstType, ELECTRICAL_PINTYPE aSecondType ) const
|
|
|
|
{
|
|
|
|
return m_PinMinDrive[static_cast<int>( aFirstType )][static_cast<int>( aSecondType )];
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2024-01-29 15:59:28 +00:00
|
|
|
std::map<int, SEVERITY> m_ERCSeverities;
|
|
|
|
std::set<wxString> m_ErcExclusions; // Serialized excluded ERC markers
|
|
|
|
std::map<wxString, wxString> m_ErcExclusionComments; // Map from serialization to comment
|
2020-07-03 21:08:17 +00:00
|
|
|
|
|
|
|
PIN_ERROR m_PinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL];
|
|
|
|
|
|
|
|
static int m_PinMinDrive[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL];
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
static PIN_ERROR m_defaultPinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL];
|
2019-03-11 21:32:05 +00:00
|
|
|
};
|
|
|
|
|
2021-01-24 22:25:32 +00:00
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
/**
|
2020-10-07 13:15:31 +00:00
|
|
|
* An implementation of the RC_ITEM_LIST interface which uses the global SHEETLIST
|
2020-06-08 02:19:46 +00:00
|
|
|
* to fulfill the contract.
|
|
|
|
*/
|
|
|
|
class SHEETLIST_ERC_ITEMS_PROVIDER : public RC_ITEMS_PROVIDER
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
SCHEMATIC* m_schematic;
|
|
|
|
int m_severities;
|
|
|
|
std::vector<SCH_MARKER*> m_filteredMarkers;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SHEETLIST_ERC_ITEMS_PROVIDER( SCHEMATIC* aSchematic ) :
|
|
|
|
m_schematic( aSchematic ),
|
|
|
|
m_severities( 0 )
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void SetSeverities( int aSeverities ) override;
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
int GetCount( int aSeverity = -1 ) const override;
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
std::shared_ptr<RC_ITEM> GetItem( int aIndex ) const override;
|
2020-08-11 13:33:16 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
std::shared_ptr<ERC_ITEM> GetERCItem( int aIndex ) const;
|
2020-06-08 02:19:46 +00:00
|
|
|
|
|
|
|
void DeleteItem( int aIndex, bool aDeep ) override;
|
2020-08-04 00:41:56 +00:00
|
|
|
|
2021-01-13 03:18:44 +00:00
|
|
|
private:
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
void visitMarkers( std::function<void( SCH_MARKER* )> aVisitor ) const;
|
2020-06-08 02:19:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
#endif // _ERC_SETTINGS_H
|