ADDED: Optional check for four way junctions
Defaults to off because this is likely contentious Fixes https://gitlab.com/kicad/code/kicad/-/issues/17870
This commit is contained in:
parent
2139789c4c
commit
8463bd59b7
|
@ -607,6 +607,60 @@ int ERC_TESTER::TestMissingNetclasses()
|
|||
}
|
||||
|
||||
|
||||
int ERC_TESTER::TestFourWayJunction()
|
||||
{
|
||||
int err_count = 0;
|
||||
|
||||
for( const SCH_SHEET_PATH& sheet : m_schematic->GetSheets() )
|
||||
{
|
||||
std::map<VECTOR2I, std::vector<SCH_ITEM*>> connMap;
|
||||
SCH_SCREEN* screen = sheet.LastScreen();
|
||||
|
||||
for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
|
||||
{
|
||||
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
||||
|
||||
for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
|
||||
connMap[pin->GetPosition()].emplace_back( pin );
|
||||
}
|
||||
|
||||
for( SCH_ITEM* item : screen->Items().OfType( SCH_LINE_T ) )
|
||||
{
|
||||
SCH_LINE* line = static_cast<SCH_LINE*>( item );
|
||||
|
||||
if( line->IsGraphicLine() )
|
||||
continue;
|
||||
|
||||
for( const VECTOR2I& pt : line->GetConnectionPoints() )
|
||||
connMap[pt].emplace_back( line );
|
||||
}
|
||||
|
||||
for( const std::pair<const VECTOR2I, std::vector<SCH_ITEM*>>& pair : connMap )
|
||||
{
|
||||
if( pair.second.size() >= 4 )
|
||||
{
|
||||
err_count++;
|
||||
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOUR_WAY_JUNCTION );
|
||||
|
||||
ercItem->SetItems( pair.second[0], pair.second[1], pair.second[2], pair.second[3] );
|
||||
|
||||
wxString msg = wxString::Format( _( "Four items connected at %d, %d" ),
|
||||
pair.first.x, pair.first.y );
|
||||
ercItem->SetErrorMessage( msg );
|
||||
|
||||
ercItem->SetSheetSpecificPath( sheet );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, pair.first );
|
||||
sheet.LastScreen()->Append( marker );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return err_count;
|
||||
}
|
||||
|
||||
|
||||
int ERC_TESTER::TestNoConnectPins()
|
||||
{
|
||||
int err_count = 0;
|
||||
|
@ -1436,6 +1490,14 @@ void ERC_TESTER::RunTests( DS_PROXY_VIEW_ITEM* aDrawingSheet, SCH_EDIT_FRAME* aE
|
|||
TestOffGridEndpoints();
|
||||
}
|
||||
|
||||
if( settings.IsTestEnabled( ERCE_FOUR_WAY_JUNCTION ) )
|
||||
{
|
||||
if( aProgressReporter )
|
||||
aProgressReporter->AdvancePhase( _( "Checking for four way junctions..." ) );
|
||||
|
||||
TestFourWayJunction();
|
||||
}
|
||||
|
||||
if( settings.IsTestEnabled( ERCE_UNDEFINED_NETCLASS ) )
|
||||
{
|
||||
if( aProgressReporter )
|
||||
|
|
|
@ -111,6 +111,11 @@ public:
|
|||
*/
|
||||
int TestSimilarLabels();
|
||||
|
||||
/**
|
||||
* Test to see if there are potentially confusing 4-way junctions in the schematic.
|
||||
*/
|
||||
int TestFourWayJunction();
|
||||
|
||||
/**
|
||||
* Test symbols for changed library symbols and broken symbol library links.
|
||||
* @return the number of issues found
|
||||
|
|
|
@ -75,6 +75,10 @@ ERC_ITEM ERC_ITEM::hierLabelMismatch( ERCE_HIERACHICAL_LABEL,
|
|||
_( "Mismatch between hierarchical labels and sheet pins" ),
|
||||
wxT( "hier_label_mismatch" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::fourWayJunction( ERCE_FOUR_WAY_JUNCTION,
|
||||
_( "Four connection points are joined together" ),
|
||||
wxT( "four_way_junction" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::noConnectConnected( ERCE_NOCONNECT_CONNECTED,
|
||||
_( "A pin with a \"no connection\" flag is connected" ),
|
||||
wxT( "no_connect_connected" ) );
|
||||
|
@ -212,6 +216,7 @@ std::vector<std::reference_wrapper<RC_ITEM>> ERC_ITEM::allItemTypes( {
|
|||
ERC_ITEM::wireDangling,
|
||||
ERC_ITEM::busEntryNeeded,
|
||||
ERC_ITEM::endpointOffGrid,
|
||||
ERC_ITEM::fourWayJunction,
|
||||
|
||||
ERC_ITEM::heading_conflicts,
|
||||
ERC_ITEM::duplicateReference,
|
||||
|
@ -263,6 +268,7 @@ std::shared_ptr<ERC_ITEM> ERC_ITEM::Create( int aErrorCode )
|
|||
case ERCE_HIERACHICAL_LABEL: return std::make_shared<ERC_ITEM>( hierLabelMismatch );
|
||||
case ERCE_NOCONNECT_CONNECTED: return std::make_shared<ERC_ITEM>( noConnectConnected );
|
||||
case ERCE_NOCONNECT_NOT_CONNECTED: return std::make_shared<ERC_ITEM>( noConnectDangling );
|
||||
case ERCE_FOUR_WAY_JUNCTION: return std::make_shared<ERC_ITEM>( fourWayJunction );
|
||||
case ERCE_LABEL_NOT_CONNECTED: return std::make_shared<ERC_ITEM>( labelDangling );
|
||||
case ERCE_SIMILAR_LABELS: return std::make_shared<ERC_ITEM>( similarLabels );
|
||||
case ERCE_SINGLE_GLOBAL_LABEL: return std::make_shared<ERC_ITEM>( singleGlobalLabel );
|
||||
|
|
|
@ -192,6 +192,7 @@ private:
|
|||
static ERC_ITEM pinTableError;
|
||||
static ERC_ITEM hierLabelMismatch;
|
||||
static ERC_ITEM noConnectConnected;
|
||||
static ERC_ITEM fourWayJunction;
|
||||
static ERC_ITEM noConnectDangling;
|
||||
static ERC_ITEM labelDangling;
|
||||
static ERC_ITEM globalLabelDangling;
|
||||
|
|
|
@ -110,6 +110,7 @@ ERC_SETTINGS::ERC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
|
|||
m_ERCSeverities[ERCE_MISSING_INPUT_PIN] = RPT_SEVERITY_WARNING;
|
||||
m_ERCSeverities[ERCE_MISSING_BIDI_PIN] = RPT_SEVERITY_WARNING;
|
||||
m_ERCSeverities[ERCE_SIMULATION_MODEL] = RPT_SEVERITY_IGNORE;
|
||||
m_ERCSeverities[ERCE_FOUR_WAY_JUNCTION] = RPT_SEVERITY_IGNORE;
|
||||
|
||||
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "rule_severities",
|
||||
[&]() -> nlohmann::json
|
||||
|
|
|
@ -82,9 +82,10 @@ enum ERCE_T
|
|||
ERCE_DIFFERENT_UNIT_VALUE, ///< Units of same symbol have different values.
|
||||
ERCE_DUPLICATE_REFERENCE, ///< More than one symbol with the same reference.
|
||||
ERCE_BUS_ENTRY_NEEDED, ///< Importer failed to auto-place a bus entry.
|
||||
ERCE_FOUR_WAY_JUNCTION, ///< A four-way junction was found.
|
||||
|
||||
|
||||
ERCE_LAST = ERCE_BUS_ENTRY_NEEDED,
|
||||
ERCE_LAST = ERCE_FOUR_WAY_JUNCTION,
|
||||
|
||||
// Errors after this point will not automatically appear in the Severities Panel
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -51,6 +51,7 @@ set( QA_EESCHEMA_SRCS
|
|||
|
||||
sch_io/altium/test_altium_parser_sch.cpp
|
||||
|
||||
erc/test_erc_four_way.cpp
|
||||
erc/test_erc_label_not_connected.cpp
|
||||
erc/test_erc_stacking_pins.cpp
|
||||
erc/test_erc_global_labels.cpp
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2022 KiCad Developers, see AUTHORS.TXT for contributors.
|
||||
*
|
||||
* 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 3
|
||||
* 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, you may find one at
|
||||
* http://www.gnu.org/licenses/
|
||||
*/
|
||||
|
||||
#include <qa_utils/wx_utils/unit_test_utils.h>
|
||||
#include <schematic_utils/schematic_file_util.h>
|
||||
|
||||
#include <connection_graph.h>
|
||||
#include <schematic.h>
|
||||
#include <erc/erc_settings.h>
|
||||
#include <erc/erc.h>
|
||||
#include <erc/erc_report.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <locale_io.h>
|
||||
|
||||
struct ERC_REGRESSION_TEST_FIXTURE
|
||||
{
|
||||
ERC_REGRESSION_TEST_FIXTURE() :
|
||||
m_settingsManager( true /* headless */ )
|
||||
{ }
|
||||
|
||||
SETTINGS_MANAGER m_settingsManager;
|
||||
std::unique_ptr<SCHEMATIC> m_schematic;
|
||||
};
|
||||
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE( ERCFourWayJunctions, ERC_REGRESSION_TEST_FIXTURE )
|
||||
{
|
||||
LOCALE_IO dummy;
|
||||
|
||||
// Check for Errors when using global labels
|
||||
std::vector<std::pair<wxString, int>> tests =
|
||||
{
|
||||
{ "issue17870", 6 }
|
||||
};
|
||||
|
||||
for( const std::pair<wxString, int>& test : tests )
|
||||
{
|
||||
KI_TEST::LoadSchematic( m_settingsManager, test.first, m_schematic );
|
||||
|
||||
ERC_SETTINGS& settings = m_schematic->ErcSettings();
|
||||
SHEETLIST_ERC_ITEMS_PROVIDER errors( m_schematic.get() );
|
||||
|
||||
settings.m_ERCSeverities[ERCE_FOUR_WAY_JUNCTION] = RPT_SEVERITY_ERROR;
|
||||
|
||||
ERC_TESTER tester( m_schematic.get() );
|
||||
tester.TestFourWayJunction();
|
||||
|
||||
errors.SetSeverities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING );
|
||||
|
||||
ERC_REPORT reportWriter( m_schematic.get(), EDA_UNITS::MILLIMETRES );
|
||||
|
||||
BOOST_CHECK_MESSAGE( errors.GetCount() == test.second,
|
||||
"Expected " << test.second << " errors in " << test.first.ToStdString()
|
||||
<< " but got " << errors.GetCount() << "\n"
|
||||
<< reportWriter.GetTextReport() );
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue