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>
|
2021-01-10 22:55:30 +00:00
|
|
|
* Copyright (C) 1992-2021 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
|
|
|
|
*/
|
|
|
|
|
2020-08-30 19:25:31 +00:00
|
|
|
#include "connection_graph.h"
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <common.h> // for ExpandEnvVarSubstitutions
|
2020-08-30 19:25:31 +00:00
|
|
|
#include <erc.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <lib_pin.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>
|
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>
|
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>
|
2015-07-29 12:18:53 +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
|
|
|
|
};
|
|
|
|
|
2020-07-03 21:08:17 +00:00
|
|
|
int ERC_TESTER::TestDuplicateSheetNames( bool aCreateMarker )
|
2009-07-09 17:02:15 +00:00
|
|
|
{
|
2011-10-07 14:41:30 +00:00
|
|
|
SCH_SCREEN* screen;
|
2010-10-26 20:25:48 +00:00
|
|
|
int err_count = 0;
|
2020-05-13 02:00:37 +00:00
|
|
|
|
2020-07-03 21:08:17 +00:00
|
|
|
SCH_SCREENS screenList( m_schematic->Root() );
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2020-07-03 21:08:17 +00:00
|
|
|
for( screen = screenList.GetFirst(); screen != nullptr; screen = screenList.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
|
2020-05-28 13:36:54 +00:00
|
|
|
if( sheet->GetName().CmpNoCase( test_item->GetName() ) == 0 )
|
2009-07-09 17:02:15 +00:00
|
|
|
{
|
2010-06-28 13:11:14 +00:00
|
|
|
if( aCreateMarker )
|
|
|
|
{
|
2020-08-11 13:33:16 +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
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DRAW_ITEM_LIST wsItems;
|
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() );
|
|
|
|
return str.Matches( wxT( "*${*}*" ) );
|
|
|
|
};
|
|
|
|
|
2021-02-22 16:37:43 +00:00
|
|
|
if( aDrawingSheet )
|
2020-05-28 13:36:54 +00:00
|
|
|
{
|
|
|
|
wsItems.SetMilsToIUfactor( IU_PER_MILS );
|
2020-10-18 20:30:37 +00:00
|
|
|
wsItems.SetPageNumber( "1" );
|
2020-09-04 20:37:23 +00:00
|
|
|
wsItems.SetSheetCount( 1 );
|
|
|
|
wsItems.SetFileName( "dummyFilename" );
|
|
|
|
wsItems.SetSheetName( "dummySheet" );
|
|
|
|
wsItems.SetSheetLayer( "dummyLayer" );
|
|
|
|
wsItems.SetProject( &m_schematic->Prj() );
|
2021-02-22 16:37:43 +00:00
|
|
|
wsItems.BuildDrawItemsList( aDrawingSheet->GetPageInfo(), aDrawingSheet->GetTitleBlock());
|
2020-05-28 13:36:54 +00:00
|
|
|
}
|
|
|
|
|
2020-08-23 21:41:52 +00:00
|
|
|
SCH_SHEET_PATH savedCurrentSheet = m_schematic->CurrentSheet();
|
|
|
|
SCH_SHEET_LIST sheets = m_schematic->GetSheets();
|
2020-03-29 01:12:29 +00:00
|
|
|
|
2020-08-23 21:41:52 +00:00
|
|
|
for( SCH_SHEET_PATH& sheet : sheets )
|
2020-03-29 01:12:29 +00:00
|
|
|
{
|
2020-08-23 21:41:52 +00:00
|
|
|
m_schematic->SetCurrentSheet( sheet );
|
|
|
|
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
|
|
|
{
|
2020-07-31 22:56:42 +00:00
|
|
|
if( unresolved( field.GetShownText() ) )
|
2020-03-29 01:12:29 +00:00
|
|
|
{
|
2021-03-19 20:27:30 +00:00
|
|
|
wxPoint pos = field.GetPosition() - symbol->GetPosition();
|
|
|
|
pos = symbol->GetTransform().TransformCoordinate( pos );
|
|
|
|
pos += symbol->GetPosition();
|
2020-04-24 13:36:10 +00:00
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
std::shared_ptr<ERC_ITEM> ercItem =
|
|
|
|
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
2020-04-24 13:36:10 +00:00
|
|
|
ercItem->SetItems( &field );
|
2020-03-29 01:12:29 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, pos );
|
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
|
|
|
{
|
2020-07-31 22:56:42 +00:00
|
|
|
if( unresolved( field.GetShownText() ) )
|
2020-03-29 01:12:29 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
std::shared_ptr<ERC_ITEM> ercItem =
|
|
|
|
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
2020-04-24 13:36:10 +00:00
|
|
|
ercItem->SetItems( &field );
|
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, field.GetPosition() );
|
2020-03-29 01:12:29 +00:00
|
|
|
screen->Append( marker );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
|
|
|
|
{
|
|
|
|
if( pin->GetShownText().Matches( wxT( "*${*}*" ) ) )
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
std::shared_ptr<ERC_ITEM> ercItem =
|
|
|
|
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
2020-04-24 13:36:10 +00:00
|
|
|
ercItem->SetItems( pin );
|
|
|
|
|
|
|
|
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 ) )
|
|
|
|
{
|
|
|
|
if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
std::shared_ptr<ERC_ITEM> ercItem =
|
|
|
|
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
2020-04-24 13:36:10 +00:00
|
|
|
ercItem->SetItems( text );
|
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() );
|
2020-03-29 01:12:29 +00:00
|
|
|
screen->Append( marker );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
{
|
|
|
|
if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
std::shared_ptr<ERC_ITEM> ercItem =
|
|
|
|
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
2021-02-22 16:37:43 +00:00
|
|
|
ercItem->SetErrorMessage( _( "Unresolved text variable in drawing sheet." ) );
|
2020-05-28 13:36:54 +00:00
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() );
|
|
|
|
screen->Append( marker );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-29 01:12:29 +00:00
|
|
|
}
|
2020-08-23 21:41:52 +00:00
|
|
|
|
|
|
|
m_schematic->SetCurrentSheet( savedCurrentSheet );
|
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
|
|
|
{
|
2019-08-07 18:23:59 +00:00
|
|
|
wxString msg;
|
|
|
|
int err_count = 0;
|
2020-05-13 02:00:37 +00:00
|
|
|
|
2020-07-03 21:08:17 +00:00
|
|
|
SCH_SCREENS screens( m_schematic->Root() );
|
2019-08-07 18:23:59 +00:00
|
|
|
std::vector< std::shared_ptr<BUS_ALIAS> > aliases;
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
2019-08-07 18:23:59 +00:00
|
|
|
std::unordered_set< std::shared_ptr<BUS_ALIAS> > 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
|
|
|
{
|
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
|
|
|
{
|
2019-08-07 18:23:59 +00:00
|
|
|
if( alias->GetName() == test->GetName() && alias->Members() != test->Members() )
|
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 );
|
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, wxPoint() );
|
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
|
|
|
{
|
2020-07-03 21:08:17 +00:00
|
|
|
SCH_SHEET_LIST sheets = m_schematic->GetSheets();
|
|
|
|
|
2018-01-19 15:12:36 +00:00
|
|
|
int errors = 0;
|
|
|
|
std::map<wxString, LIB_ID> footprints;
|
|
|
|
SCH_MULTI_UNIT_REFERENCE_MAP refMap;
|
2020-11-15 16:08:31 +00:00
|
|
|
sheets.GetMultiUnitSymbols( refMap, true );
|
2018-01-19 15:12:36 +00:00
|
|
|
|
2021-06-14 18:00:08 +00:00
|
|
|
for( std::pair<const wxString, SCH_REFERENCE_LIST>& symbol : 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-07 00:10:08 +00:00
|
|
|
int ERC_TESTER::TestNoConnectPins()
|
|
|
|
{
|
|
|
|
int err_count = 0;
|
|
|
|
|
|
|
|
for( const SCH_SHEET_PATH& sheet : m_schematic->GetSheets() )
|
|
|
|
{
|
|
|
|
std::map<wxPoint, std::vector<SCH_PIN*>> pinMap;
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
for( auto& pair : pinMap )
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
ercItem->SetErrorMessage( _( "Pins with \"no connection\" type are connected" ) );
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
ERC_SETTINGS& settings = m_schematic->ErcSettings();
|
|
|
|
const NET_MAP& nets = m_schematic->ConnectionGraph()->GetNetMap();
|
|
|
|
|
|
|
|
int errors = 0;
|
|
|
|
|
|
|
|
for( const std::pair<NET_NAME_CODE, std::vector<CONNECTION_SUBGRAPH*>> net : nets )
|
|
|
|
{
|
|
|
|
std::vector<SCH_PIN*> pins;
|
|
|
|
std::unordered_map<EDA_ITEM*, SCH_SCREEN*> pinToScreenMap;
|
|
|
|
|
|
|
|
for( CONNECTION_SUBGRAPH* subgraph: net.second )
|
|
|
|
{
|
|
|
|
for( EDA_ITEM* item : subgraph->m_items )
|
|
|
|
{
|
|
|
|
if( item->Type() == SCH_PIN_T )
|
|
|
|
{
|
|
|
|
pins.emplace_back( static_cast<SCH_PIN*>( item ) );
|
|
|
|
pinToScreenMap[item] = subgraph->m_sheet.LastScreen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Single-pin nets are handled elsewhere
|
|
|
|
if( pins.size() < 2 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
std::set<std::pair<SCH_PIN*, SCH_PIN*>> tested;
|
|
|
|
|
2020-10-22 01:35:09 +00:00
|
|
|
SCH_PIN* needsDriver = nullptr;
|
|
|
|
bool hasDriver = false;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
for( SCH_PIN* refPin : pins )
|
|
|
|
{
|
|
|
|
if( refPin->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN )
|
|
|
|
{
|
|
|
|
ispowerNet = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-30 19:25:31 +00:00
|
|
|
for( SCH_PIN* refPin : pins )
|
|
|
|
{
|
|
|
|
ELECTRICAL_PINTYPE refType = refPin->GetType();
|
|
|
|
|
2020-10-22 01:47:00 +00:00
|
|
|
if( DrivenPinTypes.count( refType ) )
|
|
|
|
{
|
|
|
|
// 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
|
2020-10-22 01:47:00 +00:00
|
|
|
if( !needsDriver ||
|
2021-01-25 03:17:56 +00:00
|
|
|
( !needsDriver->IsVisible() && refPin->IsVisible() ) ||
|
|
|
|
( ispowerNet != needsDriver->IsPowerConnection() &&
|
|
|
|
ispowerNet == refPin->IsPowerConnection() ) )
|
|
|
|
{
|
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
|
|
|
|
2020-08-30 19:25:31 +00:00
|
|
|
for( SCH_PIN* testPin : pins )
|
|
|
|
{
|
|
|
|
if( testPin == refPin )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
std::pair<SCH_PIN*, SCH_PIN*> pair1 = std::make_pair( refPin, testPin );
|
|
|
|
std::pair<SCH_PIN*, SCH_PIN*> pair2 = std::make_pair( testPin, refPin );
|
|
|
|
|
|
|
|
if( tested.count( pair1 ) || tested.count( pair2 ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
tested.insert( pair1 );
|
|
|
|
tested.insert( pair2 );
|
|
|
|
|
|
|
|
ELECTRICAL_PINTYPE testType = testPin->GetType();
|
|
|
|
|
2020-11-02 11:41:58 +00:00
|
|
|
if( ispowerNet )
|
|
|
|
hasDriver |= ( DrivingPowerPinTypes.count( testType ) != 0 );
|
|
|
|
else
|
|
|
|
hasDriver |= ( DrivingPinTypes.count( testType ) != 0 );
|
2020-10-22 01:35:09 +00:00
|
|
|
|
2020-08-30 19:25:31 +00:00
|
|
|
PIN_ERROR erc = settings.GetPinMapValue( refType, testType );
|
|
|
|
|
|
|
|
if( erc != PIN_ERROR::OK )
|
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem =
|
|
|
|
ERC_ITEM::Create( erc == PIN_ERROR::WARNING ? ERCE_PIN_TO_PIN_WARNING :
|
|
|
|
ERCE_PIN_TO_PIN_ERROR );
|
|
|
|
ercItem->SetItems( refPin, testPin );
|
2021-01-13 03:18:44 +00:00
|
|
|
ercItem->SetIsSheetSpecific();
|
2020-08-30 19:25:31 +00:00
|
|
|
|
|
|
|
ercItem->SetErrorMessage(
|
|
|
|
wxString::Format( _( "Pins of type %s and %s are connected" ),
|
|
|
|
ElectricalPinTypeGetText( refType ),
|
|
|
|
ElectricalPinTypeGetText( testType ) ) );
|
|
|
|
|
|
|
|
SCH_MARKER* marker =
|
|
|
|
new SCH_MARKER( ercItem, refPin->GetTransformedPosition() );
|
|
|
|
pinToScreenMap[refPin]->Append( marker );
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-22 01:35:09 +00:00
|
|
|
|
|
|
|
if( needsDriver && !hasDriver )
|
|
|
|
{
|
2020-11-02 11:41:58 +00:00
|
|
|
int err_code = ispowerNet ? ERCE_POWERPIN_NOT_DRIVEN : ERCE_PIN_NOT_DRIVEN;
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( err_code );
|
|
|
|
|
2020-10-22 01:35:09 +00:00
|
|
|
ercItem->SetItems( needsDriver );
|
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, needsDriver->GetTransformedPosition() );
|
|
|
|
pinToScreenMap[needsDriver]->Append( marker );
|
|
|
|
errors++;
|
|
|
|
}
|
2020-08-30 19:25:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return errors;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ERC_TESTER::TestMultUnitPinConflicts()
|
|
|
|
{
|
|
|
|
const NET_MAP& nets = m_schematic->ConnectionGraph()->GetNetMap();
|
|
|
|
|
|
|
|
int errors = 0;
|
|
|
|
|
|
|
|
std::unordered_map<wxString, std::pair<wxString, SCH_PIN*>> pinToNetMap;
|
|
|
|
|
|
|
|
for( const std::pair<NET_NAME_CODE, std::vector<CONNECTION_SUBGRAPH*>> net : nets )
|
|
|
|
{
|
|
|
|
const wxString& netName = net.first.first;
|
|
|
|
std::vector<SCH_PIN*> pins;
|
|
|
|
|
|
|
|
for( CONNECTION_SUBGRAPH* subgraph : net.second )
|
|
|
|
{
|
|
|
|
for( EDA_ITEM* item : subgraph->m_items )
|
|
|
|
{
|
|
|
|
if( item->Type() == SCH_PIN_T )
|
|
|
|
{
|
|
|
|
SCH_PIN* pin = static_cast<SCH_PIN*>( item );
|
|
|
|
|
|
|
|
if( !pin->GetLibPin()->GetParent()->IsMulti() )
|
|
|
|
continue;
|
|
|
|
|
2020-11-15 13:58:21 +00:00
|
|
|
wxString name = pin->GetParentSymbol()->GetRef( &subgraph->m_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 );
|
2021-01-13 03:18:44 +00:00
|
|
|
ercItem->SetIsSheetSpecific();
|
2020-08-30 19:25:31 +00:00
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem,
|
|
|
|
pin->GetTransformedPosition() );
|
|
|
|
subgraph->m_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
|
|
|
const NET_MAP& nets = m_schematic->ConnectionGraph()->GetNetMap();
|
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
|
|
|
|
2020-08-30 19:42:46 +00:00
|
|
|
std::unordered_map<wxString, SCH_TEXT*> labelMap;
|
2015-12-20 12:40:17 +00:00
|
|
|
|
2020-08-30 19:42:46 +00:00
|
|
|
for( const std::pair<NET_NAME_CODE, std::vector<CONNECTION_SUBGRAPH*>> net : nets )
|
2015-12-20 12:40:17 +00:00
|
|
|
{
|
2020-08-30 19:42:46 +00:00
|
|
|
std::vector<SCH_PIN*> pins;
|
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
|
|
|
{
|
2020-08-30 19:42:46 +00:00
|
|
|
for( EDA_ITEM* item : subgraph->m_items )
|
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:
|
|
|
|
{
|
|
|
|
SCH_TEXT* text = static_cast<SCH_TEXT*>( item );
|
2015-12-20 12:40:17 +00:00
|
|
|
|
2020-08-30 19:42:46 +00:00
|
|
|
wxString normalized = text->GetShownText().Lower();
|
2015-12-20 12:40:17 +00:00
|
|
|
|
2020-08-30 19:42:46 +00:00
|
|
|
if( !labelMap.count( normalized ) )
|
|
|
|
{
|
|
|
|
labelMap[normalized] = text;
|
|
|
|
}
|
|
|
|
else if( labelMap.at( normalized )->GetShownText() != text->GetShownText() )
|
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_SIMILAR_LABELS );
|
|
|
|
ercItem->SetItems( text, labelMap.at( normalized ) );
|
2015-12-20 12:40:17 +00:00
|
|
|
|
2020-08-30 19:42:46 +00:00
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() );
|
|
|
|
subgraph->m_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 );
|
|
|
|
|
2020-12-18 12:47:10 +00:00
|
|
|
SYMBOL_LIB_TABLE* libTable = m_schematic->Prj().SchSymbolLibTable();
|
|
|
|
wxString msg;
|
|
|
|
int err_count = 0;
|
2020-10-07 13:15:31 +00:00
|
|
|
|
|
|
|
SCH_SCREENS screens( m_schematic->Root() );
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = 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
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
|
2020-10-07 13:15:31 +00:00
|
|
|
|
|
|
|
wxCHECK2( symbol, continue );
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL* libSymbolInSchematic = symbol->GetLibSymbolRef().get();
|
2020-10-07 13:15:31 +00:00
|
|
|
|
|
|
|
wxCHECK2( libSymbolInSchematic, continue );
|
|
|
|
|
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
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
|
|
|
ercItem->SetItems( symbol );
|
2020-12-18 12:47:10 +00:00
|
|
|
msg.Printf( _( "The current configuration does not include the library '%s'." ),
|
|
|
|
libName );
|
2020-10-07 13:15:31 +00:00
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
|
2020-10-19 14:32:30 +00:00
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
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
|
|
|
{
|
2020-12-18 12:47:10 +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." ),
|
|
|
|
libName );
|
|
|
|
ercItem->SetErrorMessage( msg );
|
2020-10-07 13:15:31 +00:00
|
|
|
|
2020-12-18 12:47:10 +00:00
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
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 )
|
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
|
|
|
ercItem->SetItems( symbol );
|
2020-12-21 14:52:36 +00:00
|
|
|
msg.Printf( "Symbol '%s' not found in symbol library '%s'.",
|
2020-12-18 12:47:10 +00:00
|
|
|
symbolName,
|
|
|
|
libName );
|
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
|
|
|
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
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();
|
2020-12-18 12:47:10 +00:00
|
|
|
|
|
|
|
if( *flattenedSymbol != *libSymbolInSchematic )
|
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
|
|
|
ercItem->SetItems( symbol );
|
|
|
|
msg.Printf( "Symbol '%s' has been modified in library '%s'.",
|
|
|
|
symbolName,
|
|
|
|
libName );
|
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|