2011-10-07 14:41:30 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-07-29 12:18:53 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2020-10-07 13:15:31 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
2024-01-08 16:16:55 +00:00
|
|
|
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-07 14:41:30 +00:00
|
|
|
*
|
|
|
|
* 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, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2022-11-26 04:40:01 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <numeric>
|
|
|
|
|
2020-08-30 19:25:31 +00:00
|
|
|
#include "connection_graph.h"
|
2024-02-01 17:29:16 +00:00
|
|
|
#include "kiface_ids.h"
|
2023-08-13 23:44:10 +00:00
|
|
|
#include <advanced_config.h>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <common.h> // for ExpandEnvVarSubstitutions
|
2024-05-03 18:11:16 +00:00
|
|
|
#include <erc/erc.h>
|
|
|
|
#include <erc/erc_sch_pin_context.h>
|
2023-09-18 23:52:27 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2024-04-20 09:44:34 +00:00
|
|
|
#include <sch_pin.h>
|
2023-09-28 03:04:53 +00:00
|
|
|
#include <project_sch.h>
|
2023-11-04 13:58:24 +00:00
|
|
|
#include <project/project_file.h>
|
|
|
|
#include <project/net_settings.h>
|
2020-08-30 19:25:31 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_marker.h>
|
2018-01-19 15:12:36 +00:00
|
|
|
#include <sch_reference_list.h>
|
2024-04-25 14:24:46 +00:00
|
|
|
#include <sch_rule_area.h>
|
2020-08-30 19:25:31 +00:00
|
|
|
#include <sch_sheet.h>
|
2021-04-06 21:15:49 +00:00
|
|
|
#include <sch_sheet_pin.h>
|
2022-01-25 22:33:37 +00:00
|
|
|
#include <sch_textbox.h>
|
2022-03-17 20:23:14 +00:00
|
|
|
#include <sch_line.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
2021-02-22 23:47:17 +00:00
|
|
|
#include <drawing_sheet/ds_draw_item.h>
|
|
|
|
#include <drawing_sheet/ds_proxy_view_item.h>
|
2020-08-30 19:25:31 +00:00
|
|
|
#include <wx/ffile.h>
|
2023-01-02 22:47:46 +00:00
|
|
|
#include <sim/sim_lib_mgr.h>
|
2023-08-14 00:31:19 +00:00
|
|
|
#include <progress_reporter.h>
|
2024-02-02 23:04:56 +00:00
|
|
|
#include <kiway.h>
|
2022-11-12 19:45:56 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
/* ERC tests :
|
|
|
|
* 1 - conflicts between connected pins ( example: 2 connected outputs )
|
2009-11-03 13:26:31 +00:00
|
|
|
* 2 - minimal connections requirements ( 1 input *must* be connected to an
|
|
|
|
* output, or a passive pin )
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
/*
|
2020-01-18 20:51:28 +00:00
|
|
|
* Minimal ERC requirements:
|
|
|
|
* All pins *must* be connected (except ELECTRICAL_PINTYPE::PT_NC).
|
2009-11-03 13:26:31 +00:00
|
|
|
* When a pin is not connected in schematic, the user must place a "non
|
|
|
|
* connected" symbol to this pin.
|
2009-07-07 17:50:02 +00:00
|
|
|
* This ensures a forgotten connection will be detected.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Messages for matrix rows:
|
2014-01-18 09:07:05 +00:00
|
|
|
const wxString CommentERC_H[] =
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2018-04-06 13:46:16 +00:00
|
|
|
_( "Input Pin" ),
|
|
|
|
_( "Output Pin" ),
|
|
|
|
_( "Bidirectional Pin" ),
|
|
|
|
_( "Tri-State Pin" ),
|
|
|
|
_( "Passive Pin" ),
|
2021-01-24 22:25:32 +00:00
|
|
|
_( "Free Pin" ),
|
2018-04-06 13:46:16 +00:00
|
|
|
_( "Unspecified Pin" ),
|
|
|
|
_( "Power Input Pin" ),
|
|
|
|
_( "Power Output Pin" ),
|
|
|
|
_( "Open Collector" ),
|
|
|
|
_( "Open Emitter" ),
|
|
|
|
_( "No Connection" )
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
2009-07-07 17:50:02 +00:00
|
|
|
|
|
|
|
// Messages for matrix columns
|
2014-01-18 09:07:05 +00:00
|
|
|
const wxString CommentERC_V[] =
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-10-07 14:41:30 +00:00
|
|
|
_( "Input Pin" ),
|
|
|
|
_( "Output Pin" ),
|
|
|
|
_( "Bidirectional Pin" ),
|
|
|
|
_( "Tri-State Pin" ),
|
|
|
|
_( "Passive Pin" ),
|
2021-01-24 22:25:32 +00:00
|
|
|
_( "Free Pin" ),
|
2011-10-07 14:41:30 +00:00
|
|
|
_( "Unspecified Pin" ),
|
|
|
|
_( "Power Input Pin" ),
|
|
|
|
_( "Power Output Pin" ),
|
|
|
|
_( "Open Collector" ),
|
|
|
|
_( "Open Emitter" ),
|
2014-01-18 09:07:05 +00:00
|
|
|
_( "No Connection" )
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-11-02 11:41:58 +00:00
|
|
|
// List of pin types that are considered drivers for usual input pins
|
|
|
|
// i.e. pin type = ELECTRICAL_PINTYPE::PT_INPUT, but not PT_POWER_IN
|
|
|
|
// that need only a PT_POWER_OUT pin type to be driven
|
2020-10-22 01:35:09 +00:00
|
|
|
const std::set<ELECTRICAL_PINTYPE> DrivingPinTypes =
|
|
|
|
{
|
|
|
|
ELECTRICAL_PINTYPE::PT_OUTPUT,
|
2020-11-02 11:41:58 +00:00
|
|
|
ELECTRICAL_PINTYPE::PT_POWER_OUT,
|
|
|
|
ELECTRICAL_PINTYPE::PT_PASSIVE,
|
|
|
|
ELECTRICAL_PINTYPE::PT_TRISTATE,
|
|
|
|
ELECTRICAL_PINTYPE::PT_BIDI
|
|
|
|
};
|
|
|
|
|
|
|
|
// List of pin types that are considered drivers for power pins
|
|
|
|
// In fact only a ELECTRICAL_PINTYPE::PT_POWER_OUT pin type can drive
|
|
|
|
// power input pins
|
|
|
|
const std::set<ELECTRICAL_PINTYPE> DrivingPowerPinTypes =
|
|
|
|
{
|
2020-10-22 01:35:09 +00:00
|
|
|
ELECTRICAL_PINTYPE::PT_POWER_OUT
|
|
|
|
};
|
|
|
|
|
|
|
|
// List of pin types that require a driver elsewhere on the net
|
|
|
|
const std::set<ELECTRICAL_PINTYPE> DrivenPinTypes =
|
|
|
|
{
|
|
|
|
ELECTRICAL_PINTYPE::PT_INPUT,
|
|
|
|
ELECTRICAL_PINTYPE::PT_POWER_IN
|
|
|
|
};
|
|
|
|
|
2024-05-26 15:18:23 +00:00
|
|
|
extern void CheckDuplicatePins( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
|
|
|
|
UNITS_PROVIDER* aUnitsProvider );
|
|
|
|
|
2020-07-03 21:08:17 +00:00
|
|
|
int ERC_TESTER::TestDuplicateSheetNames( bool aCreateMarker )
|
2009-07-09 17:02:15 +00:00
|
|
|
{
|
2024-06-06 10:20:04 +00:00
|
|
|
int err_count = 0;
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( SCH_SCREEN* screen = m_screens.GetFirst(); screen; screen = m_screens.GetNext() )
|
2009-07-09 17:02:15 +00:00
|
|
|
{
|
2019-06-25 23:39:58 +00:00
|
|
|
std::vector<SCH_SHEET*> list;
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
|
2019-06-25 23:39:58 +00:00
|
|
|
list.push_back( static_cast<SCH_SHEET*>( item ) );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < list.size(); i++ )
|
2009-07-09 17:02:15 +00:00
|
|
|
{
|
2020-05-28 13:36:54 +00:00
|
|
|
SCH_SHEET* sheet = list[i];
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2019-06-25 23:39:58 +00:00
|
|
|
for( size_t j = i + 1; j < list.size(); j++ )
|
2009-07-09 17:02:15 +00:00
|
|
|
{
|
2020-03-16 11:05:01 +00:00
|
|
|
SCH_SHEET* test_item = list[j];
|
2009-07-09 17:02:15 +00:00
|
|
|
|
|
|
|
// We have found a second sheet: compare names
|
2015-12-20 12:40:17 +00:00
|
|
|
// we are using case insensitive comparison to avoid mistakes between
|
|
|
|
// similar names like Mysheet and mysheet
|
2023-05-05 13:21:56 +00:00
|
|
|
if( sheet->GetShownName( false ).CmpNoCase( test_item->GetShownName( false ) ) == 0 )
|
2009-07-09 17:02:15 +00:00
|
|
|
{
|
2010-06-28 13:11:14 +00:00
|
|
|
if( aCreateMarker )
|
|
|
|
{
|
2023-10-12 13:36:28 +00:00
|
|
|
std::shared_ptr<ERC_ITEM> ercItem =
|
|
|
|
ERC_ITEM::Create( ERCE_DUPLICATE_SHEET_NAME );
|
2020-05-28 13:36:54 +00:00
|
|
|
ercItem->SetItems( sheet, test_item );
|
2020-04-24 13:36:10 +00:00
|
|
|
|
2020-05-28 13:36:54 +00:00
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, sheet->GetPosition() );
|
2012-02-26 18:39:39 +00:00
|
|
|
screen->Append( marker );
|
2010-06-28 13:11:14 +00:00
|
|
|
}
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-07-09 17:02:15 +00:00
|
|
|
err_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err_count;
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
|
2020-03-29 01:12:29 +00:00
|
|
|
{
|
2023-06-12 21:33:55 +00:00
|
|
|
DS_DRAW_ITEM_LIST wsItems( schIUScale );
|
2020-05-28 13:36:54 +00:00
|
|
|
|
2020-07-31 22:56:42 +00:00
|
|
|
auto unresolved = [this]( wxString str )
|
|
|
|
{
|
|
|
|
str = ExpandEnvVarSubstitutions( str, &m_schematic->Prj() );
|
2023-10-12 13:36:28 +00:00
|
|
|
return str.Matches( wxS( "*${*}*" ) );
|
2020-07-31 22:56:42 +00:00
|
|
|
};
|
|
|
|
|
2021-02-22 16:37:43 +00:00
|
|
|
if( aDrawingSheet )
|
2020-05-28 13:36:54 +00:00
|
|
|
{
|
2023-01-17 04:14:38 +00:00
|
|
|
wsItems.SetPageNumber( wxS( "1" ) );
|
2020-09-04 20:37:23 +00:00
|
|
|
wsItems.SetSheetCount( 1 );
|
2023-01-17 04:14:38 +00:00
|
|
|
wsItems.SetFileName( wxS( "dummyFilename" ) );
|
|
|
|
wsItems.SetSheetName( wxS( "dummySheet" ) );
|
|
|
|
wsItems.SetSheetLayer( wxS( "dummyLayer" ) );
|
2020-09-04 20:37:23 +00:00
|
|
|
wsItems.SetProject( &m_schematic->Prj() );
|
2023-10-12 13:36:28 +00:00
|
|
|
wsItems.BuildDrawItemsList( aDrawingSheet->GetPageInfo(), aDrawingSheet->GetTitleBlock() );
|
2020-05-28 13:36:54 +00:00
|
|
|
}
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( const SCH_SHEET_PATH& sheet : m_sheetList )
|
2020-03-29 01:12:29 +00:00
|
|
|
{
|
2020-08-23 21:41:52 +00:00
|
|
|
SCH_SCREEN* screen = sheet.LastScreen();
|
|
|
|
|
2020-03-29 01:12:29 +00:00
|
|
|
for( SCH_ITEM* item : screen->Items().OfType( SCH_LOCATE_ANY_T ) )
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
if( item->Type() == SCH_SYMBOL_T )
|
2020-03-29 01:12:29 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
2020-03-29 01:12:29 +00:00
|
|
|
|
2021-03-19 20:27:30 +00:00
|
|
|
for( SCH_FIELD& field : symbol->GetFields() )
|
2020-03-29 01:12:29 +00:00
|
|
|
{
|
2023-11-12 14:14:41 +00:00
|
|
|
if( unresolved( field.GetShownText( &sheet, true ) ) )
|
2020-03-29 01:12:29 +00:00
|
|
|
{
|
2023-11-12 14:14:41 +00:00
|
|
|
auto ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
2020-04-24 13:36:10 +00:00
|
|
|
ercItem->SetItems( &field );
|
2024-01-08 16:16:55 +00:00
|
|
|
ercItem->SetSheetSpecificPath( sheet );
|
2020-03-29 01:12:29 +00:00
|
|
|
|
2023-03-07 00:37:33 +00:00
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, field.GetPosition() );
|
2020-03-29 01:12:29 +00:00
|
|
|
screen->Append( marker );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( item->Type() == SCH_SHEET_T )
|
|
|
|
{
|
2020-08-24 00:51:23 +00:00
|
|
|
SCH_SHEET* subSheet = static_cast<SCH_SHEET*>( item );
|
2020-03-29 01:12:29 +00:00
|
|
|
|
2020-08-24 00:51:23 +00:00
|
|
|
for( SCH_FIELD& field : subSheet->GetFields() )
|
2020-03-29 01:12:29 +00:00
|
|
|
{
|
2023-11-12 14:14:41 +00:00
|
|
|
if( unresolved( field.GetShownText( &sheet, true ) ) )
|
2020-03-29 01:12:29 +00:00
|
|
|
{
|
2023-11-12 14:14:41 +00:00
|
|
|
auto ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
2020-04-24 13:36:10 +00:00
|
|
|
ercItem->SetItems( &field );
|
2024-01-08 16:16:55 +00:00
|
|
|
ercItem->SetSheetSpecificPath( sheet );
|
2020-04-24 13:36:10 +00:00
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, field.GetPosition() );
|
2020-03-29 01:12:29 +00:00
|
|
|
screen->Append( marker );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-12 14:14:41 +00:00
|
|
|
SCH_SHEET_PATH subSheetPath = sheet;
|
|
|
|
subSheetPath.push_back( subSheet );
|
|
|
|
|
|
|
|
for( SCH_SHEET_PIN* pin : subSheet->GetPins() )
|
2020-03-29 01:12:29 +00:00
|
|
|
{
|
2023-11-12 14:14:41 +00:00
|
|
|
if( pin->GetShownText( &subSheetPath, true ).Matches( wxS( "*${*}*" ) ) )
|
2020-03-29 01:12:29 +00:00
|
|
|
{
|
2023-11-12 14:14:41 +00:00
|
|
|
auto ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
2020-04-24 13:36:10 +00:00
|
|
|
ercItem->SetItems( pin );
|
2024-01-08 16:16:55 +00:00
|
|
|
ercItem->SetSheetSpecificPath( sheet );
|
2020-04-24 13:36:10 +00:00
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetPosition() );
|
2020-03-29 01:12:29 +00:00
|
|
|
screen->Append( marker );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( item ) )
|
|
|
|
{
|
2023-11-12 14:14:41 +00:00
|
|
|
if( text->GetShownText( &sheet, true ).Matches( wxS( "*${*}*" ) ) )
|
2020-03-29 01:12:29 +00:00
|
|
|
{
|
2023-11-12 14:14:41 +00:00
|
|
|
auto ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
2020-04-24 13:36:10 +00:00
|
|
|
ercItem->SetItems( text );
|
2024-01-08 16:16:55 +00:00
|
|
|
ercItem->SetSheetSpecificPath( sheet );
|
2020-04-24 13:36:10 +00:00
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() );
|
2020-03-29 01:12:29 +00:00
|
|
|
screen->Append( marker );
|
|
|
|
}
|
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
else if( SCH_TEXTBOX* textBox = dynamic_cast<SCH_TEXTBOX*>( item ) )
|
|
|
|
{
|
2023-11-12 14:14:41 +00:00
|
|
|
if( textBox->GetShownText( &sheet, true ).Matches( wxS( "*${*}*" ) ) )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2023-11-12 14:14:41 +00:00
|
|
|
auto ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
2022-01-25 22:33:37 +00:00
|
|
|
ercItem->SetItems( textBox );
|
2024-01-08 16:16:55 +00:00
|
|
|
ercItem->SetSheetSpecificPath( sheet );
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, textBox->GetPosition() );
|
|
|
|
screen->Append( marker );
|
|
|
|
}
|
|
|
|
}
|
2020-03-29 01:12:29 +00:00
|
|
|
}
|
2020-05-28 13:36:54 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
for( DS_DRAW_ITEM_BASE* item = wsItems.GetFirst(); item; item = wsItems.GetNext() )
|
2020-05-28 13:36:54 +00:00
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
if( DS_DRAW_ITEM_TEXT* text = dynamic_cast<DS_DRAW_ITEM_TEXT*>( item ) )
|
2020-05-28 13:36:54 +00:00
|
|
|
{
|
2023-11-12 23:42:36 +00:00
|
|
|
if( text->GetShownText( true ).Matches( wxS( "*${*}*" ) ) )
|
2020-05-28 13:36:54 +00:00
|
|
|
{
|
2022-02-28 18:02:00 +00:00
|
|
|
std::shared_ptr<ERC_ITEM> erc = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
2022-09-15 22:43:00 +00:00
|
|
|
erc->SetErrorMessage( _( "Unresolved text variable in drawing sheet" ) );
|
2024-01-08 16:16:55 +00:00
|
|
|
erc->SetSheetSpecificPath( sheet );
|
2020-05-28 13:36:54 +00:00
|
|
|
|
2022-02-28 18:02:00 +00:00
|
|
|
SCH_MARKER* marker = new SCH_MARKER( erc, text->GetPosition() );
|
2020-05-28 13:36:54 +00:00
|
|
|
screen->Append( marker );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-29 01:12:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-03 21:08:17 +00:00
|
|
|
int ERC_TESTER::TestConflictingBusAliases()
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
2024-06-06 10:20:04 +00:00
|
|
|
wxString msg;
|
|
|
|
int err_count = 0;
|
|
|
|
std::vector<std::shared_ptr<BUS_ALIAS>> aliases;
|
2020-05-13 02:00:37 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( SCH_SCREEN* screen = m_screens.GetFirst(); screen; screen = m_screens.GetNext() )
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
2023-07-21 16:02:38 +00:00
|
|
|
const auto& screen_aliases = screen->GetBusAliases();
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-08-07 18:23:59 +00:00
|
|
|
for( const std::shared_ptr<BUS_ALIAS>& alias : screen_aliases )
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
2022-08-21 19:35:02 +00:00
|
|
|
std::vector<wxString> aliasMembers = alias->Members();
|
|
|
|
std::sort( aliasMembers.begin(), aliasMembers.end() );
|
|
|
|
|
2019-08-07 18:23:59 +00:00
|
|
|
for( const std::shared_ptr<BUS_ALIAS>& test : aliases )
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
2022-08-21 19:35:02 +00:00
|
|
|
std::vector<wxString> testMembers = test->Members();
|
|
|
|
std::sort( testMembers.begin(), testMembers.end() );
|
|
|
|
|
|
|
|
if( alias->GetName() == test->GetName() && aliasMembers != testMembers )
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
2020-03-16 11:05:01 +00:00
|
|
|
msg.Printf( _( "Bus alias %s has conflicting definitions on %s and %s" ),
|
|
|
|
alias->GetName(),
|
|
|
|
alias->GetParent()->GetFileName(),
|
|
|
|
test->GetParent()->GetFileName() );
|
|
|
|
|
2020-08-11 13:33:16 +00:00
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_BUS_ALIAS_CONFLICT );
|
2020-04-24 13:36:10 +00:00
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, VECTOR2I() );
|
2020-03-16 11:05:01 +00:00
|
|
|
test->GetParent()->Append( marker );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-08-07 18:23:59 +00:00
|
|
|
++err_count;
|
|
|
|
}
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-07 18:23:59 +00:00
|
|
|
|
|
|
|
aliases.insert( aliases.end(), screen_aliases.begin(), screen_aliases.end() );
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return err_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-03 21:08:17 +00:00
|
|
|
int ERC_TESTER::TestMultiunitFootprints()
|
2018-01-19 15:12:36 +00:00
|
|
|
{
|
|
|
|
int errors = 0;
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( std::pair<const wxString, SCH_REFERENCE_LIST>& symbol : m_refMap )
|
2018-01-19 15:12:36 +00:00
|
|
|
{
|
2021-06-14 18:00:08 +00:00
|
|
|
SCH_REFERENCE_LIST& refList = symbol.second;
|
2018-01-19 15:12:36 +00:00
|
|
|
|
|
|
|
if( refList.GetCount() == 0 )
|
|
|
|
{
|
|
|
|
wxFAIL; // it should not happen
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reference footprint
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* unit = nullptr;
|
|
|
|
wxString unitName;
|
|
|
|
wxString unitFP;
|
2018-01-19 15:12:36 +00:00
|
|
|
|
2020-08-29 13:41:47 +00:00
|
|
|
for( unsigned i = 0; i < refList.GetCount(); ++i )
|
2018-01-19 15:12:36 +00:00
|
|
|
{
|
|
|
|
SCH_SHEET_PATH sheetPath = refList.GetItem( i ).GetSheetPath();
|
2020-08-29 13:41:47 +00:00
|
|
|
unitFP = refList.GetItem( i ).GetFootprint();
|
2018-01-19 15:12:36 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
if( !unitFP.IsEmpty() )
|
2018-01-19 15:12:36 +00:00
|
|
|
{
|
2020-11-15 16:08:31 +00:00
|
|
|
unit = refList.GetItem( i ).GetSymbol();
|
2020-03-16 11:05:01 +00:00
|
|
|
unitName = unit->GetRef( &sheetPath, true );
|
2018-01-19 15:12:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-29 13:41:47 +00:00
|
|
|
for( unsigned i = 0; i < refList.GetCount(); ++i )
|
2018-01-19 15:12:36 +00:00
|
|
|
{
|
2020-03-16 11:05:01 +00:00
|
|
|
SCH_REFERENCE& secondRef = refList.GetItem( i );
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* secondUnit = secondRef.GetSymbol();
|
2020-04-24 13:36:10 +00:00
|
|
|
wxString secondName = secondUnit->GetRef( &secondRef.GetSheetPath(), true );
|
2020-08-29 13:41:47 +00:00
|
|
|
const wxString secondFp = secondRef.GetFootprint();
|
2020-04-24 13:36:10 +00:00
|
|
|
wxString msg;
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2020-09-20 01:20:41 +00:00
|
|
|
if( unit && !secondFp.IsEmpty() && unitFP != secondFp )
|
2018-01-19 15:12:36 +00:00
|
|
|
{
|
2020-04-24 13:36:10 +00:00
|
|
|
msg.Printf( _( "Different footprints assigned to %s and %s" ),
|
|
|
|
unitName, secondName );
|
|
|
|
|
2020-08-11 13:33:16 +00:00
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_FP );
|
2020-04-24 13:36:10 +00:00
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
ercItem->SetItems( unit, secondUnit );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, secondUnit->GetPosition() );
|
2020-03-16 11:05:01 +00:00
|
|
|
secondRef.GetSheetPath().LastScreen()->Append( marker );
|
2018-01-19 15:12:36 +00:00
|
|
|
|
|
|
|
++errors;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return errors;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-26 04:40:01 +00:00
|
|
|
int ERC_TESTER::TestMissingUnits()
|
|
|
|
{
|
|
|
|
int errors = 0;
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( std::pair<const wxString, SCH_REFERENCE_LIST>& symbol : m_refMap )
|
2022-11-26 04:40:01 +00:00
|
|
|
{
|
|
|
|
SCH_REFERENCE_LIST& refList = symbol.second;
|
|
|
|
|
|
|
|
wxCHECK2( refList.GetCount(), continue );
|
|
|
|
|
|
|
|
// Reference unit
|
|
|
|
SCH_REFERENCE& base_ref = refList.GetItem( 0 );
|
|
|
|
SCH_SYMBOL* unit = base_ref.GetSymbol();
|
2024-06-04 15:50:20 +00:00
|
|
|
LIB_SYMBOL& libSymbol = base_ref.GetSymbol()->GetLibSymbolRef();
|
2022-11-26 04:40:01 +00:00
|
|
|
|
2024-06-04 15:50:20 +00:00
|
|
|
if( static_cast<ssize_t>( refList.GetCount() ) == libSymbol.GetUnitCount() )
|
2022-11-26 04:40:01 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
std::set<int> lib_units;
|
|
|
|
std::set<int> instance_units;
|
|
|
|
std::set<int> missing_units;
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
auto report_missing =
|
|
|
|
[&]( std::set<int>& aMissingUnits, wxString aErrorMsg, int aErrorCode )
|
2022-11-26 04:40:01 +00:00
|
|
|
{
|
2024-06-06 10:20:04 +00:00
|
|
|
wxString msg;
|
|
|
|
wxString missing_pin_units = wxS( "[ " );
|
|
|
|
int ii = 0;
|
2022-11-26 04:40:01 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( int missing_unit : aMissingUnits )
|
|
|
|
{
|
|
|
|
if( ii++ == 3 )
|
|
|
|
{
|
|
|
|
missing_pin_units += wxS( "....." );
|
|
|
|
break;
|
|
|
|
}
|
2022-11-26 04:40:01 +00:00
|
|
|
|
2024-06-04 15:50:20 +00:00
|
|
|
missing_pin_units += libSymbol.GetUnitDisplayName( missing_unit ) + ", " ;
|
2024-06-06 10:20:04 +00:00
|
|
|
}
|
2022-11-26 04:40:01 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
missing_pin_units.Truncate( missing_pin_units.length() - 2 );
|
|
|
|
missing_pin_units += wxS( " ]" );
|
2022-11-26 04:40:01 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
msg.Printf( aErrorMsg, symbol.first, missing_pin_units );
|
2022-11-26 04:40:01 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( aErrorCode );
|
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
ercItem->SetItems( unit );
|
2022-11-26 04:40:01 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, unit->GetPosition() );
|
|
|
|
base_ref.GetSheetPath().LastScreen()->Append( marker );
|
|
|
|
|
|
|
|
++errors;
|
|
|
|
};
|
2022-11-26 04:40:01 +00:00
|
|
|
|
2024-06-04 15:50:20 +00:00
|
|
|
for( int ii = 1; ii <= libSymbol.GetUnitCount(); ++ii )
|
2022-11-26 04:40:01 +00:00
|
|
|
lib_units.insert( lib_units.end(), ii );
|
|
|
|
|
|
|
|
for( size_t ii = 0; ii < refList.GetCount(); ++ii )
|
|
|
|
instance_units.insert( instance_units.end(), refList.GetItem( ii ).GetUnit() );
|
|
|
|
|
|
|
|
std::set_difference( lib_units.begin(), lib_units.end(),
|
|
|
|
instance_units.begin(), instance_units.end(),
|
|
|
|
std::inserter( missing_units, missing_units.begin() ) );
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
if( !missing_units.empty() && m_settings.IsTestEnabled( ERCE_MISSING_UNIT ) )
|
2022-11-26 04:40:01 +00:00
|
|
|
{
|
|
|
|
report_missing( missing_units, _( "Symbol %s has unplaced units %s" ),
|
2023-10-12 13:36:28 +00:00
|
|
|
ERCE_MISSING_UNIT );
|
2022-11-26 04:40:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::set<int> missing_power;
|
|
|
|
std::set<int> missing_input;
|
|
|
|
std::set<int> missing_bidi;
|
|
|
|
|
|
|
|
for( int missing_unit : missing_units )
|
|
|
|
{
|
2024-04-20 09:44:34 +00:00
|
|
|
int bodyStyle = 0;
|
2022-11-26 04:40:01 +00:00
|
|
|
|
|
|
|
for( size_t ii = 0; ii < refList.GetCount(); ++ii )
|
|
|
|
{
|
|
|
|
if( refList.GetItem( ii ).GetUnit() == missing_unit )
|
|
|
|
{
|
2024-04-06 13:14:44 +00:00
|
|
|
bodyStyle = refList.GetItem( ii ).GetSymbol()->GetBodyStyle();
|
2022-11-26 04:40:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-04 15:50:20 +00:00
|
|
|
for( SCH_PIN* pin : libSymbol.GetPins( missing_unit, bodyStyle ) )
|
2022-11-26 04:40:01 +00:00
|
|
|
{
|
|
|
|
switch( pin->GetType() )
|
|
|
|
{
|
|
|
|
case ELECTRICAL_PINTYPE::PT_POWER_IN:
|
|
|
|
missing_power.insert( missing_unit );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELECTRICAL_PINTYPE::PT_BIDI:
|
|
|
|
missing_bidi.insert( missing_unit );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELECTRICAL_PINTYPE::PT_INPUT:
|
|
|
|
missing_input.insert( missing_unit );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
if( !missing_power.empty() && m_settings.IsTestEnabled( ERCE_MISSING_POWER_INPUT_PIN ) )
|
2022-11-26 04:40:01 +00:00
|
|
|
{
|
2023-10-12 13:36:28 +00:00
|
|
|
report_missing( missing_power,
|
|
|
|
_( "Symbol %s has input power pins in units %s that are not placed." ),
|
|
|
|
ERCE_MISSING_POWER_INPUT_PIN );
|
2022-11-26 04:40:01 +00:00
|
|
|
}
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
if( !missing_input.empty() && m_settings.IsTestEnabled( ERCE_MISSING_INPUT_PIN ) )
|
2022-11-26 04:40:01 +00:00
|
|
|
{
|
2023-10-12 13:36:28 +00:00
|
|
|
report_missing( missing_input,
|
|
|
|
_( "Symbol %s has input pins in units %s that are not placed." ),
|
|
|
|
ERCE_MISSING_INPUT_PIN );
|
2022-11-26 04:40:01 +00:00
|
|
|
}
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
if( !missing_bidi.empty() && m_settings.IsTestEnabled( ERCE_MISSING_BIDI_PIN ) )
|
2022-11-26 04:40:01 +00:00
|
|
|
{
|
2023-10-12 13:36:28 +00:00
|
|
|
report_missing( missing_bidi,
|
|
|
|
_( "Symbol %s has bidirectional pins in units %s that are not "
|
|
|
|
"placed." ),
|
|
|
|
ERCE_MISSING_BIDI_PIN );
|
2022-11-26 04:40:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return errors;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-11-04 13:58:24 +00:00
|
|
|
int ERC_TESTER::TestMissingNetclasses()
|
|
|
|
{
|
|
|
|
int err_count = 0;
|
|
|
|
std::shared_ptr<NET_SETTINGS>& settings = m_schematic->Prj().GetProjectFile().NetSettings();
|
2024-03-13 15:29:55 +00:00
|
|
|
wxString defaultNetclass = settings->m_DefaultNetClass->GetName();
|
2023-11-04 13:58:24 +00:00
|
|
|
|
|
|
|
auto logError =
|
|
|
|
[&]( const SCH_SHEET_PATH& sheet, SCH_ITEM* item, const wxString& netclass )
|
|
|
|
{
|
|
|
|
err_count++;
|
|
|
|
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNDEFINED_NETCLASS );
|
|
|
|
|
|
|
|
ercItem->SetItems( item );
|
|
|
|
ercItem->SetErrorMessage( wxString::Format( _( "Netclass %s is not defined" ),
|
|
|
|
netclass ) );
|
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, item->GetPosition() );
|
|
|
|
sheet.LastScreen()->Append( marker );
|
|
|
|
};
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( const SCH_SHEET_PATH& sheet : m_sheetList )
|
2023-11-04 13:58:24 +00:00
|
|
|
{
|
|
|
|
for( SCH_ITEM* item : sheet.LastScreen()->Items() )
|
|
|
|
{
|
|
|
|
item->RunOnChildren(
|
|
|
|
[&]( SCH_ITEM* aChild )
|
|
|
|
{
|
|
|
|
if( aChild->Type() == SCH_FIELD_T )
|
|
|
|
{
|
|
|
|
SCH_FIELD* field = static_cast<SCH_FIELD*>( aChild );
|
|
|
|
|
|
|
|
if( field->GetCanonicalName() == wxT( "Netclass" ) )
|
|
|
|
{
|
2024-06-04 11:46:34 +00:00
|
|
|
wxString netclass = field->GetShownText( &sheet, false );
|
2023-11-04 13:58:24 +00:00
|
|
|
|
2024-03-13 15:29:55 +00:00
|
|
|
if( !netclass.IsSameAs( defaultNetclass )
|
|
|
|
&& settings->m_NetClasses.count( netclass ) == 0 )
|
|
|
|
{
|
2023-11-04 13:58:24 +00:00
|
|
|
logError( sheet, item, netclass );
|
2024-03-13 15:29:55 +00:00
|
|
|
}
|
2023-11-04 13:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-05-03 19:04:41 +00:00
|
|
|
int ERC_TESTER::TestFourWayJunction()
|
|
|
|
{
|
|
|
|
int err_count = 0;
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( const SCH_SHEET_PATH& sheet : m_sheetList )
|
2024-05-03 19:04:41 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-07 00:10:08 +00:00
|
|
|
int ERC_TESTER::TestNoConnectPins()
|
|
|
|
{
|
|
|
|
int err_count = 0;
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( const SCH_SHEET_PATH& sheet : m_sheetList )
|
2020-07-07 00:10:08 +00:00
|
|
|
{
|
2023-09-04 16:27:12 +00:00
|
|
|
std::map<VECTOR2I, std::vector<SCH_ITEM*>> pinMap;
|
|
|
|
|
|
|
|
auto addOther =
|
|
|
|
[&]( const VECTOR2I& pt, SCH_ITEM* aOther )
|
|
|
|
{
|
|
|
|
if( pinMap.count( pt ) )
|
|
|
|
pinMap[pt].emplace_back( aOther );
|
|
|
|
};
|
2020-07-07 00:10:08 +00:00
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
|
2020-07-07 00:10:08 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
2020-07-07 00:10:08 +00:00
|
|
|
|
2021-01-19 23:50:18 +00:00
|
|
|
for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
|
2020-07-07 21:08:07 +00:00
|
|
|
{
|
|
|
|
if( pin->GetLibPin()->GetType() == ELECTRICAL_PINTYPE::PT_NC )
|
|
|
|
pinMap[pin->GetPosition()].emplace_back( pin );
|
|
|
|
}
|
2020-07-07 00:10:08 +00:00
|
|
|
}
|
|
|
|
|
2023-09-04 16:27:12 +00:00
|
|
|
for( SCH_ITEM* item : sheet.LastScreen()->Items() )
|
|
|
|
{
|
|
|
|
if( item->Type() == SCH_SYMBOL_T )
|
|
|
|
{
|
|
|
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
|
|
|
|
|
|
|
for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
|
|
|
|
{
|
|
|
|
if( pin->GetLibPin()->GetType() != ELECTRICAL_PINTYPE::PT_NC )
|
|
|
|
addOther( pin->GetPosition(), pin );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( item->IsConnectable() )
|
|
|
|
{
|
|
|
|
for( const VECTOR2I& pt : item->GetConnectionPoints() )
|
|
|
|
addOther( pt, item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( const std::pair<const VECTOR2I, std::vector<SCH_ITEM*>>& pair : pinMap )
|
2020-07-07 00:10:08 +00:00
|
|
|
{
|
|
|
|
if( pair.second.size() > 1 )
|
|
|
|
{
|
|
|
|
err_count++;
|
|
|
|
|
2020-08-11 13:33:16 +00:00
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_CONNECTED );
|
2020-07-07 00:10:08 +00:00
|
|
|
|
|
|
|
ercItem->SetItems( pair.second[0], pair.second[1],
|
|
|
|
pair.second.size() > 2 ? pair.second[2] : nullptr,
|
|
|
|
pair.second.size() > 3 ? pair.second[3] : nullptr );
|
2023-09-04 16:27:12 +00:00
|
|
|
ercItem->SetErrorMessage( _( "Pin with 'no connection' type is connected" ) );
|
2024-01-08 16:16:55 +00:00
|
|
|
ercItem->SetSheetSpecificPath( sheet );
|
2020-07-07 00:10:08 +00:00
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, pair.first );
|
|
|
|
sheet.LastScreen()->Append( marker );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-30 19:25:31 +00:00
|
|
|
int ERC_TESTER::TestPinToPin()
|
|
|
|
{
|
|
|
|
int errors = 0;
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
|
2020-08-30 19:25:31 +00:00
|
|
|
{
|
2023-01-21 23:25:40 +00:00
|
|
|
std::vector<ERC_SCH_PIN_CONTEXT> pins;
|
2020-08-30 19:25:31 +00:00
|
|
|
std::unordered_map<EDA_ITEM*, SCH_SCREEN*> pinToScreenMap;
|
2022-04-07 16:29:02 +00:00
|
|
|
bool has_noconnect = false;
|
2020-08-30 19:25:31 +00:00
|
|
|
|
|
|
|
for( CONNECTION_SUBGRAPH* subgraph: net.second )
|
|
|
|
{
|
2023-03-03 22:06:41 +00:00
|
|
|
if( subgraph->GetNoConnect() )
|
2022-04-07 16:29:02 +00:00
|
|
|
has_noconnect = true;
|
|
|
|
|
2023-03-03 22:06:41 +00:00
|
|
|
for( SCH_ITEM* item : subgraph->GetItems() )
|
2020-08-30 19:25:31 +00:00
|
|
|
{
|
|
|
|
if( item->Type() == SCH_PIN_T )
|
|
|
|
{
|
2023-03-03 22:06:41 +00:00
|
|
|
pins.emplace_back( static_cast<SCH_PIN*>( item ), subgraph->GetSheet() );
|
|
|
|
pinToScreenMap[item] = subgraph->GetSheet().LastScreen();
|
2020-08-30 19:25:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-01 10:37:01 +00:00
|
|
|
std::sort( pins.begin(), pins.end(),
|
|
|
|
[]( const ERC_SCH_PIN_CONTEXT& lhs, const ERC_SCH_PIN_CONTEXT& rhs )
|
|
|
|
{
|
|
|
|
int ret = StrNumCmp( lhs.Pin()->GetParentSymbol()->GetRef( &lhs.Sheet() ),
|
|
|
|
rhs.Pin()->GetParentSymbol()->GetRef( &rhs.Sheet() ) );
|
|
|
|
|
|
|
|
if( ret == 0 )
|
|
|
|
ret = StrNumCmp( lhs.Pin()->GetNumber(), rhs.Pin()->GetNumber() );
|
|
|
|
|
|
|
|
if( ret == 0 )
|
|
|
|
ret = lhs < rhs; // Fallback to hash to guarantee deterministic sort
|
|
|
|
|
|
|
|
return ret < 0;
|
|
|
|
} );
|
|
|
|
|
2023-01-21 23:25:40 +00:00
|
|
|
ERC_SCH_PIN_CONTEXT needsDriver;
|
|
|
|
bool hasDriver = false;
|
2020-10-22 01:35:09 +00:00
|
|
|
|
2020-11-02 11:41:58 +00:00
|
|
|
// We need different drivers for power nets and normal nets.
|
|
|
|
// A power net has at least one pin having the ELECTRICAL_PINTYPE::PT_POWER_IN
|
|
|
|
// and power nets can be driven only by ELECTRICAL_PINTYPE::PT_POWER_OUT pins
|
|
|
|
bool ispowerNet = false;
|
|
|
|
|
2023-01-21 23:25:40 +00:00
|
|
|
for( ERC_SCH_PIN_CONTEXT& refPin : pins )
|
2020-11-02 11:41:58 +00:00
|
|
|
{
|
2023-01-21 23:25:40 +00:00
|
|
|
if( refPin.Pin()->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN )
|
2020-11-02 11:41:58 +00:00
|
|
|
{
|
|
|
|
ispowerNet = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-06 16:05:39 +00:00
|
|
|
for( auto refIt = pins.begin(); refIt != pins.end(); ++refIt )
|
2020-08-30 19:25:31 +00:00
|
|
|
{
|
2023-10-06 16:05:39 +00:00
|
|
|
ERC_SCH_PIN_CONTEXT& refPin = *refIt;
|
2023-01-21 23:25:40 +00:00
|
|
|
ELECTRICAL_PINTYPE refType = refPin.Pin()->GetType();
|
2020-08-30 19:25:31 +00:00
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
if( DrivenPinTypes.contains( refType ) )
|
2020-10-22 01:47:00 +00:00
|
|
|
{
|
|
|
|
// needsDriver will be the pin shown in the error report eventually, so try to
|
2021-01-25 03:17:56 +00:00
|
|
|
// upgrade to a "better" pin if possible: something visible and only a power symbol
|
|
|
|
// if this net needs a power driver
|
2023-01-21 23:25:40 +00:00
|
|
|
if( !needsDriver.Pin()
|
|
|
|
|| ( !needsDriver.Pin()->IsVisible() && refPin.Pin()->IsVisible() )
|
|
|
|
|| ( ispowerNet
|
|
|
|
!= ( needsDriver.Pin()->GetType()
|
|
|
|
== ELECTRICAL_PINTYPE::PT_POWER_IN )
|
|
|
|
&& ispowerNet == ( refType == ELECTRICAL_PINTYPE::PT_POWER_IN ) ) )
|
2021-01-25 03:17:56 +00:00
|
|
|
{
|
2020-10-22 01:47:00 +00:00
|
|
|
needsDriver = refPin;
|
2021-01-25 03:17:56 +00:00
|
|
|
}
|
2020-10-22 01:47:00 +00:00
|
|
|
}
|
2020-10-22 01:35:09 +00:00
|
|
|
|
2020-11-02 11:41:58 +00:00
|
|
|
if( ispowerNet )
|
|
|
|
hasDriver |= ( DrivingPowerPinTypes.count( refType ) != 0 );
|
|
|
|
else
|
|
|
|
hasDriver |= ( DrivingPinTypes.count( refType ) != 0 );
|
2020-10-22 01:35:09 +00:00
|
|
|
|
2023-10-06 16:05:39 +00:00
|
|
|
for( auto testIt = refIt + 1; testIt != pins.end(); ++testIt )
|
2020-08-30 19:25:31 +00:00
|
|
|
{
|
2023-10-06 16:05:39 +00:00
|
|
|
ERC_SCH_PIN_CONTEXT& testPin = *testIt;
|
2020-08-30 19:25:31 +00:00
|
|
|
|
2022-07-30 20:10:14 +00:00
|
|
|
// Multiple pins in the same symbol that share a type,
|
|
|
|
// name and position are considered
|
|
|
|
// "stacked" and shouldn't trigger ERC errors
|
2023-03-07 00:37:33 +00:00
|
|
|
if( refPin.Pin()->IsStacked( testPin.Pin() ) && refPin.Sheet() == testPin.Sheet() )
|
2022-07-30 20:10:14 +00:00
|
|
|
continue;
|
2020-08-30 19:25:31 +00:00
|
|
|
|
2023-01-21 23:25:40 +00:00
|
|
|
ELECTRICAL_PINTYPE testType = testPin.Pin()->GetType();
|
2020-08-30 19:25:31 +00:00
|
|
|
|
2020-11-02 11:41:58 +00:00
|
|
|
if( ispowerNet )
|
2024-04-20 09:44:34 +00:00
|
|
|
hasDriver |= DrivingPowerPinTypes.contains( testType );
|
2020-11-02 11:41:58 +00:00
|
|
|
else
|
2024-04-20 09:44:34 +00:00
|
|
|
hasDriver |= DrivingPinTypes.contains( testType );
|
2020-10-22 01:35:09 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
PIN_ERROR erc = m_settings.GetPinMapValue( refType, testType );
|
2020-08-30 19:25:31 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
if( erc != PIN_ERROR::OK && m_settings.IsTestEnabled( ERCE_PIN_TO_PIN_WARNING ) )
|
2020-08-30 19:25:31 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem =
|
|
|
|
ERC_ITEM::Create( erc == PIN_ERROR::WARNING ? ERCE_PIN_TO_PIN_WARNING :
|
|
|
|
ERCE_PIN_TO_PIN_ERROR );
|
2023-01-21 23:25:40 +00:00
|
|
|
ercItem->SetItems( refPin.Pin(), testPin.Pin() );
|
|
|
|
ercItem->SetSheetSpecificPath( refPin.Sheet() );
|
|
|
|
ercItem->SetItemsSheetPaths( refPin.Sheet(), testPin.Sheet() );
|
2020-08-30 19:25:31 +00:00
|
|
|
|
|
|
|
ercItem->SetErrorMessage(
|
|
|
|
wxString::Format( _( "Pins of type %s and %s are connected" ),
|
2021-11-04 16:23:25 +00:00
|
|
|
ElectricalPinTypeGetText( refType ),
|
|
|
|
ElectricalPinTypeGetText( testType ) ) );
|
2020-08-30 19:25:31 +00:00
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, refPin.Pin()->GetPosition() );
|
2023-01-21 23:25:40 +00:00
|
|
|
pinToScreenMap[refPin.Pin()]->Append( marker );
|
2020-08-30 19:25:31 +00:00
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-22 01:35:09 +00:00
|
|
|
|
2023-01-21 23:25:40 +00:00
|
|
|
if( needsDriver.Pin() && !hasDriver && !has_noconnect )
|
2020-10-22 01:35:09 +00:00
|
|
|
{
|
2020-11-02 11:41:58 +00:00
|
|
|
int err_code = ispowerNet ? ERCE_POWERPIN_NOT_DRIVEN : ERCE_PIN_NOT_DRIVEN;
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
if( m_settings.IsTestEnabled( err_code ) )
|
2021-11-04 16:23:25 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( err_code );
|
|
|
|
|
2023-01-21 23:25:40 +00:00
|
|
|
ercItem->SetItems( needsDriver.Pin() );
|
2023-03-07 00:37:33 +00:00
|
|
|
ercItem->SetSheetSpecificPath( needsDriver.Sheet() );
|
|
|
|
ercItem->SetItemsSheetPaths( needsDriver.Sheet() );
|
2020-10-22 01:35:09 +00:00
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, needsDriver.Pin()->GetPosition() );
|
2023-01-21 23:25:40 +00:00
|
|
|
pinToScreenMap[needsDriver.Pin()]->Append( marker );
|
2021-11-04 16:23:25 +00:00
|
|
|
errors++;
|
|
|
|
}
|
2020-10-22 01:35:09 +00:00
|
|
|
}
|
2020-08-30 19:25:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return errors;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ERC_TESTER::TestMultUnitPinConflicts()
|
|
|
|
{
|
|
|
|
int errors = 0;
|
|
|
|
|
|
|
|
std::unordered_map<wxString, std::pair<wxString, SCH_PIN*>> pinToNetMap;
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
|
2020-08-30 19:25:31 +00:00
|
|
|
{
|
2022-08-03 09:10:23 +00:00
|
|
|
const wxString& netName = net.first.Name;
|
2020-08-30 19:25:31 +00:00
|
|
|
|
|
|
|
for( CONNECTION_SUBGRAPH* subgraph : net.second )
|
|
|
|
{
|
2023-03-03 22:06:41 +00:00
|
|
|
for( SCH_ITEM* item : subgraph->GetItems() )
|
2020-08-30 19:25:31 +00:00
|
|
|
{
|
|
|
|
if( item->Type() == SCH_PIN_T )
|
|
|
|
{
|
|
|
|
SCH_PIN* pin = static_cast<SCH_PIN*>( item );
|
2023-03-03 22:06:41 +00:00
|
|
|
const SCH_SHEET_PATH& sheet = subgraph->GetSheet();
|
2020-08-30 19:25:31 +00:00
|
|
|
|
2024-04-02 17:28:17 +00:00
|
|
|
if( !pin->GetLibPin()->GetParentSymbol()->IsMulti() )
|
2020-08-30 19:25:31 +00:00
|
|
|
continue;
|
|
|
|
|
2023-03-03 22:06:41 +00:00
|
|
|
wxString name = pin->GetParentSymbol()->GetRef( &sheet ) +
|
2021-06-17 09:37:13 +00:00
|
|
|
+ ":" + pin->GetShownNumber();
|
2020-08-30 19:25:31 +00:00
|
|
|
|
|
|
|
if( !pinToNetMap.count( name ) )
|
|
|
|
{
|
|
|
|
pinToNetMap[name] = std::make_pair( netName, pin );
|
|
|
|
}
|
|
|
|
else if( pinToNetMap[name].first != netName )
|
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem =
|
|
|
|
ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_NET );
|
|
|
|
|
|
|
|
ercItem->SetErrorMessage( wxString::Format(
|
|
|
|
_( "Pin %s is connected to both %s and %s" ),
|
2021-06-17 09:37:13 +00:00
|
|
|
pin->GetShownNumber(),
|
|
|
|
netName,
|
|
|
|
pinToNetMap[name].first ) );
|
2020-08-30 19:25:31 +00:00
|
|
|
|
|
|
|
ercItem->SetItems( pin, pinToNetMap[name].second );
|
2023-03-03 22:06:41 +00:00
|
|
|
ercItem->SetSheetSpecificPath( sheet );
|
|
|
|
ercItem->SetItemsSheetPaths( sheet, sheet );
|
2020-08-30 19:25:31 +00:00
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetPosition() );
|
2023-03-03 22:06:41 +00:00
|
|
|
sheet.LastScreen()->Append( marker );
|
2020-10-07 13:15:31 +00:00
|
|
|
errors += 1;
|
2020-08-30 19:25:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return errors;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-30 19:42:46 +00:00
|
|
|
int ERC_TESTER::TestSimilarLabels()
|
2015-12-20 12:40:17 +00:00
|
|
|
{
|
2020-08-30 19:42:46 +00:00
|
|
|
int errors = 0;
|
2015-12-20 12:40:17 +00:00
|
|
|
|
2023-03-07 00:37:33 +00:00
|
|
|
std::unordered_map<wxString, std::pair<SCH_LABEL_BASE*, SCH_SHEET_PATH>> labelMap;
|
2015-12-20 12:40:17 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
|
2015-12-20 12:40:17 +00:00
|
|
|
{
|
2020-08-30 19:42:46 +00:00
|
|
|
for( CONNECTION_SUBGRAPH* subgraph : net.second )
|
2015-12-20 12:40:17 +00:00
|
|
|
{
|
2023-11-12 14:14:41 +00:00
|
|
|
const SCH_SHEET_PATH& sheet = subgraph->GetSheet();
|
|
|
|
|
2023-03-03 22:06:41 +00:00
|
|
|
for( SCH_ITEM* item : subgraph->GetItems() )
|
2015-12-20 12:40:17 +00:00
|
|
|
{
|
2020-08-30 19:42:46 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
{
|
2022-01-25 22:33:37 +00:00
|
|
|
SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( item );
|
2015-12-20 12:40:17 +00:00
|
|
|
|
2023-11-12 14:14:41 +00:00
|
|
|
wxString normalized = label->GetShownText( &sheet, false ).Lower();
|
2015-12-20 12:40:17 +00:00
|
|
|
|
2020-08-30 19:42:46 +00:00
|
|
|
if( !labelMap.count( normalized ) )
|
|
|
|
{
|
2023-11-12 14:14:41 +00:00
|
|
|
labelMap[normalized] = std::make_pair( label, sheet );
|
|
|
|
break;
|
2020-08-30 19:42:46 +00:00
|
|
|
}
|
2023-11-12 14:14:41 +00:00
|
|
|
|
|
|
|
auto& [ otherLabel, otherSheet ] = labelMap.at( normalized );
|
|
|
|
|
|
|
|
if( otherLabel->GetShownText( &otherSheet, false )
|
|
|
|
!= label->GetShownText( &sheet, false ) )
|
2020-08-30 19:42:46 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_SIMILAR_LABELS );
|
2023-03-07 00:37:33 +00:00
|
|
|
ercItem->SetItems( label, labelMap.at( normalized ).first );
|
2023-11-12 14:14:41 +00:00
|
|
|
ercItem->SetSheetSpecificPath( sheet );
|
|
|
|
ercItem->SetItemsSheetPaths( sheet, labelMap.at( normalized ).second );
|
2015-12-20 12:40:17 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, label->GetPosition() );
|
2023-11-12 14:14:41 +00:00
|
|
|
sheet.LastScreen()->Append( marker );
|
2020-10-07 13:15:31 +00:00
|
|
|
errors += 1;
|
2020-08-30 19:42:46 +00:00
|
|
|
}
|
2015-12-20 12:40:17 +00:00
|
|
|
|
2020-08-30 19:42:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-12-20 12:40:17 +00:00
|
|
|
|
2020-08-30 19:42:46 +00:00
|
|
|
default:
|
|
|
|
break;
|
2015-12-20 12:40:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-30 19:42:46 +00:00
|
|
|
return errors;
|
2015-12-20 12:40:17 +00:00
|
|
|
}
|
2020-10-07 13:15:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
int ERC_TESTER::TestLibSymbolIssues()
|
|
|
|
{
|
|
|
|
wxCHECK( m_schematic, 0 );
|
|
|
|
|
2023-09-28 03:04:53 +00:00
|
|
|
SYMBOL_LIB_TABLE* libTable = PROJECT_SCH::SchSymbolLibTable( &m_schematic->Prj() );
|
2020-12-18 12:47:10 +00:00
|
|
|
wxString msg;
|
|
|
|
int err_count = 0;
|
2020-10-07 13:15:31 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( SCH_SCREEN* screen = m_screens.GetFirst(); screen; screen = m_screens.GetNext() )
|
2020-10-07 13:15:31 +00:00
|
|
|
{
|
2020-10-19 14:32:30 +00:00
|
|
|
std::vector<SCH_MARKER*> markers;
|
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
|
2020-10-07 13:15:31 +00:00
|
|
|
{
|
2022-03-17 20:23:14 +00:00
|
|
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
2024-06-04 15:50:20 +00:00
|
|
|
LIB_SYMBOL& libSymbolInSchematic = symbol->GetLibSymbolRef();
|
2020-10-07 13:15:31 +00:00
|
|
|
|
2020-12-18 12:47:10 +00:00
|
|
|
wxString libName = symbol->GetLibId().GetLibNickname();
|
2021-01-10 22:55:30 +00:00
|
|
|
LIB_TABLE_ROW* libTableRow = libTable->FindRow( libName, true );
|
2020-10-07 13:15:31 +00:00
|
|
|
|
2020-12-18 12:47:10 +00:00
|
|
|
if( !libTableRow )
|
2020-10-07 13:15:31 +00:00
|
|
|
{
|
2024-06-06 10:20:04 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES ) )
|
2024-02-16 13:22:17 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
|
|
|
ercItem->SetItems( symbol );
|
|
|
|
msg.Printf( _( "The current configuration does not include the symbol library '%s'" ),
|
|
|
|
UnescapeString( libName ) );
|
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
|
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
|
|
|
}
|
2020-10-07 13:15:31 +00:00
|
|
|
|
2021-06-17 21:15:02 +00:00
|
|
|
continue;
|
2020-10-07 13:15:31 +00:00
|
|
|
}
|
2020-12-18 12:47:10 +00:00
|
|
|
else if( !libTable->HasLibrary( libName, true ) )
|
2020-10-07 13:15:31 +00:00
|
|
|
{
|
2024-06-06 10:20:04 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES ) )
|
2024-02-16 13:22:17 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
|
|
|
ercItem->SetItems( symbol );
|
|
|
|
msg.Printf( _( "The library '%s' is not enabled in the current configuration" ),
|
|
|
|
UnescapeString( libName ) );
|
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
|
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
|
|
|
}
|
2020-10-07 13:15:31 +00:00
|
|
|
|
2021-06-17 21:15:02 +00:00
|
|
|
continue;
|
2020-12-18 12:47:10 +00:00
|
|
|
}
|
2020-10-19 14:34:59 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
wxString symbolName = symbol->GetLibId().GetLibItemName();
|
2021-06-17 21:22:10 +00:00
|
|
|
LIB_SYMBOL* libSymbol = SchGetLibSymbol( symbol->GetLibId(), libTable );
|
2020-12-18 12:47:10 +00:00
|
|
|
|
|
|
|
if( libSymbol == nullptr )
|
|
|
|
{
|
2024-06-06 10:20:04 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES ) )
|
2024-02-16 13:22:17 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
|
|
|
ercItem->SetItems( symbol );
|
|
|
|
msg.Printf( _( "Symbol '%s' not found in symbol library '%s'" ),
|
|
|
|
UnescapeString( symbolName ),
|
|
|
|
UnescapeString( libName ) );
|
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
|
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
|
|
|
}
|
2020-12-18 12:47:10 +00:00
|
|
|
|
2021-06-17 21:15:02 +00:00
|
|
|
continue;
|
2020-12-18 12:47:10 +00:00
|
|
|
}
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
|
2024-04-06 13:14:44 +00:00
|
|
|
constexpr int flags = SCH_ITEM::COMPARE_FLAGS::EQUALITY | SCH_ITEM::COMPARE_FLAGS::ERC;
|
2020-12-18 12:47:10 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_MISMATCH ) )
|
2020-12-18 12:47:10 +00:00
|
|
|
{
|
2024-05-26 15:18:23 +00:00
|
|
|
// We have to check for duplicate pins first as they will cause Compare() to fail.
|
|
|
|
std::vector<wxString> messages;
|
|
|
|
UNITS_PROVIDER unitsProvider( schIUScale, EDA_UNITS::MILS );
|
2024-06-04 15:50:20 +00:00
|
|
|
CheckDuplicatePins( &libSymbolInSchematic, messages, &unitsProvider );
|
2024-05-26 15:18:23 +00:00
|
|
|
|
|
|
|
if( !messages.empty() )
|
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DUPLICATE_PIN_ERROR );
|
|
|
|
ercItem->SetItems( symbol );
|
|
|
|
msg.Printf( _( "Symbol '%s' has multiple pins with the same pin number" ),
|
|
|
|
UnescapeString( symbolName ) );
|
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
|
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
|
|
|
}
|
2024-06-04 15:50:20 +00:00
|
|
|
else if( flattenedSymbol->Compare( libSymbolInSchematic, flags ) != 0 )
|
2024-05-26 15:18:23 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_MISMATCH );
|
|
|
|
ercItem->SetItems( symbol );
|
|
|
|
msg.Printf( _( "Symbol '%s' doesn't match copy in library '%s'" ),
|
|
|
|
UnescapeString( symbolName ),
|
|
|
|
UnescapeString( libName ) );
|
|
|
|
ercItem->SetErrorMessage( msg );
|
2020-12-18 12:47:10 +00:00
|
|
|
|
2024-05-26 15:18:23 +00:00
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
|
|
|
}
|
2020-10-07 13:15:31 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-19 14:32:30 +00:00
|
|
|
|
|
|
|
for( SCH_MARKER* marker : markers )
|
|
|
|
{
|
|
|
|
screen->Append( marker );
|
|
|
|
err_count += 1;
|
|
|
|
}
|
2020-10-07 13:15:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return err_count;
|
|
|
|
}
|
2022-03-17 20:23:14 +00:00
|
|
|
|
|
|
|
|
2024-02-01 17:29:16 +00:00
|
|
|
int ERC_TESTER::TestFootprintLinkIssues( KIFACE* aCvPcb, PROJECT* aProject )
|
|
|
|
{
|
|
|
|
wxCHECK( m_schematic, 0 );
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
int err_count = 0;
|
|
|
|
|
|
|
|
typedef int (*TESTER_FN_PTR)( const wxString&, PROJECT* );
|
|
|
|
|
|
|
|
TESTER_FN_PTR linkTester = (TESTER_FN_PTR) aCvPcb->IfaceOrAddress( KIFACE_TEST_FOOTPRINT_LINK );
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( SCH_SHEET_PATH& sheet : m_sheetList )
|
2024-02-01 17:29:16 +00:00
|
|
|
{
|
|
|
|
std::vector<SCH_MARKER*> markers;
|
|
|
|
|
|
|
|
for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
|
|
|
|
{
|
|
|
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
|
|
|
wxString footprint = symbol->GetFootprintFieldText( true, &sheet, false );
|
|
|
|
|
|
|
|
if( footprint.IsEmpty() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
LIB_ID fpID;
|
|
|
|
|
|
|
|
if( fpID.Parse( footprint, true ) >= 0 )
|
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
|
|
|
|
msg.Printf( _( "'%s' is not a valid footprint identifier." ), footprint );
|
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
ercItem->SetItems( symbol );
|
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString libName = fpID.GetLibNickname();
|
|
|
|
wxString fpName = fpID.GetLibItemName();
|
|
|
|
int ret = (linkTester)( footprint, aProject );
|
|
|
|
|
|
|
|
if( ret == KIFACE_TEST_FOOTPRINT_LINK_NO_LIBRARY )
|
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
|
|
|
|
msg.Printf( _( "The current configuration does not include the footprint library '%s'." ),
|
|
|
|
libName );
|
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
ercItem->SetItems( symbol );
|
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
|
|
|
}
|
|
|
|
else if( ret == KIFACE_TEST_FOOTPRINT_LINK_LIBRARY_NOT_ENABLED )
|
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
|
|
|
|
msg.Printf( _( "The footprint library '%s' is not enabled in the current configuration." ),
|
|
|
|
libName );
|
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
ercItem->SetItems( symbol );
|
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
|
|
|
}
|
|
|
|
else if( ret == KIFACE_TEST_FOOTPRINT_LINK_NO_FOOTPRINT )
|
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
|
|
|
|
msg.Printf( _( "Footprint '%s' not found in library '%s'." ),
|
|
|
|
fpName,
|
|
|
|
libName );
|
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
ercItem->SetItems( symbol );
|
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SCH_MARKER* marker : markers )
|
|
|
|
{
|
|
|
|
sheet.LastScreen()->Append( marker );
|
|
|
|
err_count += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-14 19:46:39 +00:00
|
|
|
int ERC_TESTER::TestOffGridEndpoints()
|
2022-03-17 20:23:14 +00:00
|
|
|
{
|
2023-10-14 19:46:39 +00:00
|
|
|
const int gridSize = m_schematic->Settings().m_ConnectionGridSize;
|
2024-06-06 10:20:04 +00:00
|
|
|
int err_count = 0;
|
2022-03-17 20:23:14 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( SCH_SCREEN* screen = m_screens.GetFirst(); screen; screen = m_screens.GetNext() )
|
2022-03-17 20:23:14 +00:00
|
|
|
{
|
|
|
|
std::vector<SCH_MARKER*> markers;
|
|
|
|
|
2022-03-20 22:16:20 +00:00
|
|
|
for( SCH_ITEM* item : screen->Items() )
|
2022-03-17 20:23:14 +00:00
|
|
|
{
|
|
|
|
if( item->Type() == SCH_LINE_T && item->IsConnectable() )
|
|
|
|
{
|
|
|
|
SCH_LINE* line = static_cast<SCH_LINE*>( item );
|
|
|
|
|
2023-10-14 19:46:39 +00:00
|
|
|
if( ( line->GetStartPoint().x % gridSize ) != 0
|
|
|
|
|| ( line->GetStartPoint().y % gridSize ) != 0 )
|
2022-03-17 20:23:14 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
|
|
|
|
ercItem->SetItems( line );
|
|
|
|
|
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, line->GetStartPoint() ) );
|
|
|
|
}
|
2023-10-14 19:46:39 +00:00
|
|
|
else if( ( line->GetEndPoint().x % gridSize ) != 0
|
|
|
|
|| ( line->GetEndPoint().y % gridSize ) != 0 )
|
2022-03-17 20:23:14 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
|
|
|
|
ercItem->SetItems( line );
|
|
|
|
|
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, line->GetEndPoint() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( item->Type() == SCH_SYMBOL_T )
|
|
|
|
{
|
|
|
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
|
|
|
|
|
|
|
for( SCH_PIN* pin : symbol->GetPins( nullptr ) )
|
|
|
|
{
|
2024-04-20 09:44:34 +00:00
|
|
|
VECTOR2I pinPos = pin->GetPosition();
|
2022-03-17 20:23:14 +00:00
|
|
|
|
2023-10-14 19:46:39 +00:00
|
|
|
if( ( pinPos.x % gridSize ) != 0 || ( pinPos.y % gridSize ) != 0 )
|
2022-03-17 20:23:14 +00:00
|
|
|
{
|
2023-10-14 19:46:39 +00:00
|
|
|
auto ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
|
2022-03-17 20:23:14 +00:00
|
|
|
ercItem->SetItems( pin );
|
|
|
|
|
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, pinPos ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SCH_MARKER* marker : markers )
|
|
|
|
{
|
|
|
|
screen->Append( marker );
|
|
|
|
err_count += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err_count;
|
2022-08-26 02:51:11 +00:00
|
|
|
}
|
2022-11-07 12:27:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
int ERC_TESTER::TestSimModelIssues()
|
|
|
|
{
|
2023-01-02 22:47:46 +00:00
|
|
|
wxString msg;
|
|
|
|
WX_STRING_REPORTER reporter( &msg );
|
|
|
|
int err_count = 0;
|
2023-09-06 10:37:50 +00:00
|
|
|
SIM_LIB_MGR libMgr( &m_schematic->Prj() );
|
2022-11-07 12:27:58 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( SCH_SHEET_PATH& sheet : m_sheetList )
|
2022-11-07 12:27:58 +00:00
|
|
|
{
|
2024-06-02 21:26:49 +00:00
|
|
|
if( sheet.GetExcludedFromSim() )
|
|
|
|
continue;
|
|
|
|
|
2022-11-07 12:27:58 +00:00
|
|
|
std::vector<SCH_MARKER*> markers;
|
|
|
|
|
|
|
|
for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
|
|
|
|
{
|
2023-04-01 08:16:44 +00:00
|
|
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
|
|
|
|
2023-04-14 18:40:41 +00:00
|
|
|
// Power symbols and other symbols which have the reference starting with "#" are
|
|
|
|
// not included in simulation
|
2023-08-08 16:32:08 +00:00
|
|
|
if( symbol->GetRef( &sheet ).StartsWith( '#' ) || symbol->GetExcludedFromSim() )
|
2023-04-01 08:16:44 +00:00
|
|
|
continue;
|
|
|
|
|
2023-01-02 22:47:46 +00:00
|
|
|
// Reset for each symbol
|
|
|
|
msg.Clear();
|
2022-11-07 12:27:58 +00:00
|
|
|
|
2023-09-06 10:37:50 +00:00
|
|
|
SIM_LIBRARY::MODEL model = libMgr.CreateModel( &sheet, *symbol, reporter );
|
2023-01-02 22:47:46 +00:00
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
2022-11-07 12:27:58 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_SIMULATION_MODEL );
|
2023-04-01 08:16:44 +00:00
|
|
|
|
|
|
|
//Remove \n and \r at e.o.l if any:
|
|
|
|
msg.Trim();
|
|
|
|
|
2023-01-02 22:47:46 +00:00
|
|
|
ercItem->SetErrorMessage( msg );
|
2022-11-07 12:27:58 +00:00
|
|
|
ercItem->SetItems( symbol );
|
|
|
|
|
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SCH_MARKER* marker : markers )
|
|
|
|
{
|
|
|
|
sheet.LastScreen()->Append( marker );
|
|
|
|
err_count += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err_count;
|
|
|
|
}
|
2023-08-13 23:44:10 +00:00
|
|
|
|
|
|
|
|
2024-04-25 14:24:46 +00:00
|
|
|
int ERC_TESTER::RunRuleAreaERC()
|
|
|
|
{
|
2024-06-06 10:20:04 +00:00
|
|
|
int numErrors = 0;
|
2024-04-25 14:24:46 +00:00
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
if( !m_settings.IsTestEnabled( ERCE_OVERLAPPING_RULE_AREAS ) )
|
2024-04-25 14:24:46 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
std::map<SCH_SCREEN*, std::vector<SCH_RULE_AREA*>> allScreenRuleAreas;
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
for( SCH_SCREEN* screen = m_screens.GetFirst(); screen; screen = m_screens.GetNext() )
|
2024-04-25 14:24:46 +00:00
|
|
|
{
|
|
|
|
for( SCH_ITEM* item : screen->Items().OfType( SCH_RULE_AREA_T ) )
|
|
|
|
{
|
|
|
|
allScreenRuleAreas[screen].push_back( static_cast<SCH_RULE_AREA*>( item ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-06 10:20:04 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_OVERLAPPING_RULE_AREAS ) )
|
2024-04-25 14:24:46 +00:00
|
|
|
numErrors += TestRuleAreaOverlappingRuleAreasERC( allScreenRuleAreas );
|
|
|
|
|
|
|
|
return numErrors;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ERC_TESTER::TestRuleAreaOverlappingRuleAreasERC(
|
|
|
|
std::map<SCH_SCREEN*, std::vector<SCH_RULE_AREA*>>& allScreenRuleAreas )
|
|
|
|
{
|
|
|
|
int numErrors = 0;
|
|
|
|
|
|
|
|
for( auto screenRuleAreas : allScreenRuleAreas )
|
|
|
|
{
|
|
|
|
std::vector<SCH_RULE_AREA*>& ruleAreas = screenRuleAreas.second;
|
|
|
|
|
|
|
|
for( std::size_t i = 0; i < ruleAreas.size(); ++i )
|
|
|
|
{
|
|
|
|
SHAPE_POLY_SET& polyFirst = ruleAreas[i]->GetPolyShape();
|
|
|
|
|
|
|
|
for( std::size_t j = i + 1; j < ruleAreas.size(); ++j )
|
|
|
|
{
|
|
|
|
SHAPE_POLY_SET polySecond = ruleAreas[j]->GetPolyShape();
|
2024-06-06 10:20:04 +00:00
|
|
|
|
2024-04-25 14:24:46 +00:00
|
|
|
if( polyFirst.Collide( &polySecond ) )
|
|
|
|
{
|
|
|
|
numErrors++;
|
|
|
|
|
|
|
|
SCH_SCREEN* screen = screenRuleAreas.first;
|
|
|
|
SCH_SHEET_PATH firstSheet = screen->GetClientSheetPaths()[0];
|
|
|
|
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem =
|
|
|
|
ERC_ITEM::Create( ERCE_OVERLAPPING_RULE_AREAS );
|
|
|
|
ercItem->SetItems( ruleAreas[i], ruleAreas[j] );
|
|
|
|
ercItem->SetSheetSpecificPath( firstSheet );
|
|
|
|
ercItem->SetItemsSheetPaths( firstSheet, firstSheet );
|
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, ruleAreas[i]->GetPosition() );
|
|
|
|
screen->Append( marker );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return numErrors;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-14 00:31:19 +00:00
|
|
|
void ERC_TESTER::RunTests( DS_PROXY_VIEW_ITEM* aDrawingSheet, SCH_EDIT_FRAME* aEditFrame,
|
2024-02-02 23:04:56 +00:00
|
|
|
KIFACE* aCvPcb, PROJECT* aProject, PROGRESS_REPORTER* aProgressReporter )
|
2023-08-13 23:44:10 +00:00
|
|
|
{
|
2024-06-06 16:58:48 +00:00
|
|
|
m_sheetList.AnnotatePowerSymbols();
|
2023-08-13 23:44:10 +00:00
|
|
|
|
|
|
|
// Test duplicate sheet names inside a given sheet. While one can have multiple references
|
|
|
|
// to the same file, each must have a unique name.
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_DUPLICATE_SHEET_NAME ) )
|
2023-08-13 23:44:10 +00:00
|
|
|
{
|
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking sheet names..." ) );
|
2023-10-12 13:36:28 +00:00
|
|
|
|
2023-08-13 23:44:10 +00:00
|
|
|
TestDuplicateSheetNames( true );
|
|
|
|
}
|
|
|
|
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_BUS_ALIAS_CONFLICT ) )
|
2023-08-13 23:44:10 +00:00
|
|
|
{
|
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking bus conflicts..." ) );
|
2023-10-12 13:36:28 +00:00
|
|
|
|
2023-08-13 23:44:10 +00:00
|
|
|
TestConflictingBusAliases();
|
|
|
|
}
|
|
|
|
|
|
|
|
// The connection graph has a whole set of ERC checks it can run
|
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking conflicts..." ) );
|
|
|
|
|
|
|
|
// If we are using the new connectivity, make sure that we do a full-rebuild
|
|
|
|
if( aEditFrame )
|
|
|
|
{
|
|
|
|
if( ADVANCED_CFG::GetCfg().m_IncrementalConnectivity )
|
|
|
|
aEditFrame->RecalculateConnections( nullptr, GLOBAL_CLEANUP );
|
|
|
|
else
|
|
|
|
aEditFrame->RecalculateConnections( nullptr, NO_CLEANUP );
|
|
|
|
}
|
|
|
|
|
2023-08-14 00:31:19 +00:00
|
|
|
m_schematic->ConnectionGraph()->RunERC();
|
2023-08-13 23:44:10 +00:00
|
|
|
|
2024-04-25 14:24:46 +00:00
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking rule areas..." ) );
|
|
|
|
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_OVERLAPPING_RULE_AREAS ) )
|
2024-04-25 14:24:46 +00:00
|
|
|
{
|
|
|
|
RunRuleAreaERC();
|
|
|
|
}
|
|
|
|
|
2023-08-13 23:44:10 +00:00
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking units..." ) );
|
|
|
|
|
|
|
|
// Test is all units of each multiunit symbol have the same footprint assigned.
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_DIFFERENT_UNIT_FP ) )
|
2023-08-13 23:44:10 +00:00
|
|
|
{
|
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking footprints..." ) );
|
2023-10-12 13:36:28 +00:00
|
|
|
|
2023-08-13 23:44:10 +00:00
|
|
|
TestMultiunitFootprints();
|
|
|
|
}
|
|
|
|
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_MISSING_UNIT )
|
|
|
|
|| m_settings.IsTestEnabled( ERCE_MISSING_INPUT_PIN )
|
|
|
|
|| m_settings.IsTestEnabled( ERCE_MISSING_POWER_INPUT_PIN )
|
|
|
|
|| m_settings.IsTestEnabled( ERCE_MISSING_BIDI_PIN ) )
|
2023-08-13 23:44:10 +00:00
|
|
|
{
|
|
|
|
TestMissingUnits();
|
|
|
|
}
|
|
|
|
|
2023-08-14 00:31:19 +00:00
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking pins..." ) );
|
2023-08-13 23:44:10 +00:00
|
|
|
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_DIFFERENT_UNIT_NET ) )
|
2023-08-13 23:44:10 +00:00
|
|
|
TestMultUnitPinConflicts();
|
|
|
|
|
|
|
|
// Test pins on each net against the pin connection table
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_PIN_TO_PIN_ERROR )
|
|
|
|
|| m_settings.IsTestEnabled( ERCE_POWERPIN_NOT_DRIVEN )
|
|
|
|
|| m_settings.IsTestEnabled( ERCE_PIN_NOT_DRIVEN ) )
|
2023-08-13 23:44:10 +00:00
|
|
|
{
|
|
|
|
TestPinToPin();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test similar labels (i;e. labels which are identical when
|
|
|
|
// using case insensitive comparisons)
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_SIMILAR_LABELS ) )
|
2023-08-13 23:44:10 +00:00
|
|
|
{
|
2023-08-14 00:31:19 +00:00
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking labels..." ) );
|
2023-10-12 13:36:28 +00:00
|
|
|
|
2023-08-13 23:44:10 +00:00
|
|
|
TestSimilarLabels();
|
|
|
|
}
|
|
|
|
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_UNRESOLVED_VARIABLE ) )
|
2023-08-13 23:44:10 +00:00
|
|
|
{
|
2023-08-14 00:31:19 +00:00
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking for unresolved variables..." ) );
|
2023-10-12 13:36:28 +00:00
|
|
|
|
2023-08-13 23:44:10 +00:00
|
|
|
TestTextVars( aDrawingSheet );
|
|
|
|
}
|
|
|
|
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_SIMULATION_MODEL ) )
|
2023-08-13 23:44:10 +00:00
|
|
|
{
|
2023-08-14 00:31:19 +00:00
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking SPICE models..." ) );
|
2023-10-12 13:36:28 +00:00
|
|
|
|
2023-08-13 23:44:10 +00:00
|
|
|
TestSimModelIssues();
|
|
|
|
}
|
|
|
|
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_NOCONNECT_CONNECTED ) )
|
2023-08-13 23:44:10 +00:00
|
|
|
{
|
2023-08-14 00:31:19 +00:00
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking no connect pins for connections..." ) );
|
2023-10-12 13:36:28 +00:00
|
|
|
|
2023-08-13 23:44:10 +00:00
|
|
|
TestNoConnectPins();
|
|
|
|
}
|
|
|
|
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES )
|
|
|
|
|| m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_MISMATCH ) )
|
2023-08-13 23:44:10 +00:00
|
|
|
{
|
2023-08-14 00:31:19 +00:00
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking for library symbol issues..." ) );
|
2023-10-12 13:36:28 +00:00
|
|
|
|
2023-08-13 23:44:10 +00:00
|
|
|
TestLibSymbolIssues();
|
|
|
|
}
|
|
|
|
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_FOOTPRINT_LINK_ISSUES ) && aCvPcb )
|
2024-02-01 17:29:16 +00:00
|
|
|
{
|
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking for footprint link issues..." ) );
|
|
|
|
|
|
|
|
TestFootprintLinkIssues( aCvPcb, aProject );
|
|
|
|
}
|
|
|
|
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_ENDPOINT_OFF_GRID ) )
|
2023-08-13 23:44:10 +00:00
|
|
|
{
|
2023-08-14 00:31:19 +00:00
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking for off grid pins and wires..." ) );
|
2023-10-12 13:36:28 +00:00
|
|
|
|
2023-10-14 19:46:39 +00:00
|
|
|
TestOffGridEndpoints();
|
2023-08-13 23:44:10 +00:00
|
|
|
}
|
|
|
|
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_FOUR_WAY_JUNCTION ) )
|
2024-05-03 19:04:41 +00:00
|
|
|
{
|
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking for four way junctions..." ) );
|
|
|
|
|
|
|
|
TestFourWayJunction();
|
|
|
|
}
|
|
|
|
|
2024-06-06 16:58:48 +00:00
|
|
|
if( m_settings.IsTestEnabled( ERCE_UNDEFINED_NETCLASS ) )
|
2023-11-04 13:58:24 +00:00
|
|
|
{
|
|
|
|
if( aProgressReporter )
|
|
|
|
aProgressReporter->AdvancePhase( _( "Checking for undefined netclasses..." ) );
|
|
|
|
|
|
|
|
TestMissingNetclasses();
|
|
|
|
}
|
|
|
|
|
2023-08-14 00:31:19 +00:00
|
|
|
m_schematic->ResolveERCExclusionsPostUpdate();
|
2023-10-12 13:36:28 +00:00
|
|
|
}
|