One (correct) error message is sufficient.
Fixes https://gitlab.com/kicad/code/kicad/issues/8225
This commit is contained in:
parent
e92dc96767
commit
87ca59f52e
|
@ -42,18 +42,20 @@
|
||||||
|
|
||||||
wxString NETLIST_EXPORTER_PSPICE::GetSpiceDevice( const wxString& aComponent ) const
|
wxString NETLIST_EXPORTER_PSPICE::GetSpiceDevice( const wxString& aComponent ) const
|
||||||
{
|
{
|
||||||
const auto& spiceItems = GetSpiceItems();
|
const std::list<SPICE_ITEM>& spiceItems = GetSpiceItems();
|
||||||
|
|
||||||
auto it = std::find_if( spiceItems.begin(), spiceItems.end(), [&]( const SPICE_ITEM& item ) {
|
auto it = std::find_if( spiceItems.begin(), spiceItems.end(),
|
||||||
return item.m_refName == aComponent;
|
[&]( const SPICE_ITEM& item )
|
||||||
} );
|
{
|
||||||
|
return item.m_refName == aComponent;
|
||||||
|
} );
|
||||||
|
|
||||||
if( it == spiceItems.end() )
|
if( it == spiceItems.end() )
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
|
|
||||||
// Prefix the device type if plain reference would result in a different device type
|
// Prefix the device type if plain reference would result in a different device type
|
||||||
return it->m_primitive != it->m_refName[0] ?
|
return it->m_primitive != it->m_refName[0] ? wxString( it->m_primitive + it->m_refName )
|
||||||
wxString( it->m_primitive + it->m_refName ) : it->m_refName;
|
: it->m_refName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,7 +92,7 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* aFormatter, unsigned aCtl
|
||||||
aFormatter->Print( 0, ".title %s\n", TO_UTF8( m_title ) );
|
aFormatter->Print( 0, ".title %s\n", TO_UTF8( m_title ) );
|
||||||
|
|
||||||
// Write .include directives
|
// Write .include directives
|
||||||
for( const auto& lib : m_libraries )
|
for( const wxString& lib : m_libraries )
|
||||||
{
|
{
|
||||||
wxString full_path;
|
wxString full_path;
|
||||||
|
|
||||||
|
@ -101,19 +103,21 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* aFormatter, unsigned aCtl
|
||||||
|
|
||||||
if( full_path.IsEmpty() )
|
if( full_path.IsEmpty() )
|
||||||
{
|
{
|
||||||
DisplayError( NULL, wxString::Format( _( "Could not find library file %s" ), lib ) );
|
DisplayError( NULL, wxString::Format( _( "Could not find library file %s." ), lib ) );
|
||||||
full_path = lib;
|
full_path = lib;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
full_path = lib; // just use the unaltered path
|
full_path = lib; // just use the unaltered path
|
||||||
|
}
|
||||||
|
|
||||||
aFormatter->Print( 0, ".include \"%s\"\n", TO_UTF8( full_path ) );
|
aFormatter->Print( 0, ".include \"%s\"\n", TO_UTF8( full_path ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int NC_counter = 1;
|
unsigned int NC_counter = 1;
|
||||||
|
|
||||||
for( const auto& item : m_spiceItems )
|
for( const SPICE_ITEM& item : m_spiceItems )
|
||||||
{
|
{
|
||||||
if( !item.m_enabled )
|
if( !item.m_enabled )
|
||||||
continue;
|
continue;
|
||||||
|
@ -171,30 +175,29 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* aFormatter, unsigned aCtl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString NETLIST_EXPORTER_PSPICE::GetSpiceField( SPICE_FIELD aField,
|
wxString NETLIST_EXPORTER_PSPICE::GetSpiceField( SPICE_FIELD aField, SCH_COMPONENT* aSymbol,
|
||||||
SCH_COMPONENT* aComponent, unsigned aCtl )
|
unsigned aCtl )
|
||||||
{
|
{
|
||||||
SCH_FIELD* field = aComponent->FindField( GetSpiceFieldName( aField ) );
|
SCH_FIELD* field = aSymbol->FindField( GetSpiceFieldName( aField ) );
|
||||||
return field ? field->GetShownText() : GetSpiceFieldDefVal( aField, aComponent, aCtl );
|
return field ? field->GetShownText() : GetSpiceFieldDefVal( aField, aSymbol, aCtl );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal( SPICE_FIELD aField,
|
wxString NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal( SPICE_FIELD aField, SCH_COMPONENT* aSymbol,
|
||||||
SCH_COMPONENT* aComponent, unsigned aCtl )
|
unsigned aCtl )
|
||||||
{
|
{
|
||||||
switch( aField )
|
switch( aField )
|
||||||
{
|
{
|
||||||
case SF_PRIMITIVE:
|
case SF_PRIMITIVE:
|
||||||
{
|
{
|
||||||
const wxString refName = aComponent->GetField( REFERENCE_FIELD )->GetShownText();
|
const wxString refName = aSymbol->GetField( REFERENCE_FIELD )->GetShownText();
|
||||||
return refName.GetChar( 0 );
|
return refName.GetChar( 0 );
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case SF_MODEL:
|
case SF_MODEL:
|
||||||
{
|
{
|
||||||
wxChar prim = aComponent->GetField( REFERENCE_FIELD )->GetShownText().GetChar( 0 );
|
wxChar prim = aSymbol->GetField( REFERENCE_FIELD )->GetShownText().GetChar( 0 );
|
||||||
wxString value = aComponent->GetField( VALUE_FIELD )->GetShownText();
|
wxString value = aSymbol->GetField( VALUE_FIELD )->GetShownText();
|
||||||
|
|
||||||
// Is it a passive component?
|
// Is it a passive component?
|
||||||
if( aCtl & NET_ADJUST_PASSIVE_VALS && ( prim == 'C' || prim == 'L' || prim == 'R' ) )
|
if( aCtl & NET_ADJUST_PASSIVE_VALS && ( prim == 'C' || prim == 'L' || prim == 'R' ) )
|
||||||
|
@ -222,42 +225,35 @@ wxString NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal( SPICE_FIELD aField,
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case SF_ENABLED:
|
case SF_ENABLED:
|
||||||
return wxString( "Y" );
|
return wxString( "Y" );
|
||||||
break;
|
|
||||||
|
|
||||||
case SF_NODE_SEQUENCE:
|
case SF_NODE_SEQUENCE:
|
||||||
{
|
{
|
||||||
wxString nodeSeq;
|
wxString nodeSeq;
|
||||||
std::vector<LIB_PIN*> pins;
|
std::vector<LIB_PIN*> pins;
|
||||||
|
|
||||||
wxCHECK( aComponent->GetPartRef(), wxString() );
|
wxCHECK( aSymbol->GetPartRef(), wxString() );
|
||||||
aComponent->GetPartRef()->GetPins( pins );
|
aSymbol->GetPartRef()->GetPins( pins );
|
||||||
|
|
||||||
for( auto pin : pins )
|
for( LIB_PIN* pin : pins )
|
||||||
nodeSeq += pin->GetNumber() + " ";
|
nodeSeq += pin->GetNumber() + " ";
|
||||||
|
|
||||||
nodeSeq.Trim();
|
nodeSeq.Trim();
|
||||||
|
|
||||||
return nodeSeq;
|
return nodeSeq;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case SF_LIB_FILE:
|
case SF_LIB_FILE:
|
||||||
// There is no default Spice library
|
// There is no default Spice library
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxASSERT_MSG( false, "Missing default value definition for a Spice field" );
|
wxASSERT_MSG( false, "Missing default value definition for a Spice field." );
|
||||||
break;
|
return wxString( "<unknown>" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return wxString( "<unknown>" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,7 +280,7 @@ bool NETLIST_EXPORTER_PSPICE::ProcessNetlist( unsigned aCtl )
|
||||||
SCH_SHEET_PATH sheet = sheetList[sheet_idx];
|
SCH_SHEET_PATH sheet = sheetList[sheet_idx];
|
||||||
|
|
||||||
// Process component attributes to find Spice directives
|
// Process component attributes to find Spice directives
|
||||||
for( auto item : sheet.LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
|
for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
|
||||||
{
|
{
|
||||||
SCH_COMPONENT* symbol = findNextSymbol( item, &sheet );
|
SCH_COMPONENT* symbol = findNextSymbol( item, &sheet );
|
||||||
|
|
||||||
|
@ -306,8 +302,8 @@ bool NETLIST_EXPORTER_PSPICE::ProcessNetlist( unsigned aCtl )
|
||||||
// Duplicate references will result in simulation errors
|
// Duplicate references will result in simulation errors
|
||||||
if( refNames.count( spiceItem.m_refName ) )
|
if( refNames.count( spiceItem.m_refName ) )
|
||||||
{
|
{
|
||||||
DisplayError( NULL, wxT( "There are duplicate components. "
|
DisplayError( NULL, wxT( "Multiple symbols have the same reference designator.\n"
|
||||||
"You need to annotate schematics first." ) );
|
"Annotation must be corrected before simulating." ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,7 +366,7 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl )
|
||||||
{
|
{
|
||||||
const SCH_SHEET_LIST& sheetList = m_schematic->GetSheets();
|
const SCH_SHEET_LIST& sheetList = m_schematic->GetSheets();
|
||||||
wxRegEx couplingK( "^[kK][[:digit:]]*[[:space:]]+[[:alnum:]]+[[:space:]]+[[:alnum:]]+",
|
wxRegEx couplingK( "^[kK][[:digit:]]*[[:space:]]+[[:alnum:]]+[[:space:]]+[[:alnum:]]+",
|
||||||
wxRE_ADVANCED );
|
wxRE_ADVANCED );
|
||||||
|
|
||||||
m_directives.clear();
|
m_directives.clear();
|
||||||
bool controlBlock = false;
|
bool controlBlock = false;
|
||||||
|
@ -378,7 +374,7 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl )
|
||||||
|
|
||||||
for( unsigned i = 0; i < sheetList.size(); i++ )
|
for( unsigned i = 0; i < sheetList.size(); i++ )
|
||||||
{
|
{
|
||||||
for( auto item : sheetList[i].LastScreen()->Items().OfType( SCH_TEXT_T ) )
|
for( SCH_ITEM* item : sheetList[i].LastScreen()->Items().OfType( SCH_TEXT_T ) )
|
||||||
{
|
{
|
||||||
wxString text = static_cast<SCH_TEXT*>( item )->GetShownText();
|
wxString text = static_cast<SCH_TEXT*>( item )->GetShownText();
|
||||||
|
|
||||||
|
@ -462,7 +458,7 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl )
|
||||||
|
|
||||||
void NETLIST_EXPORTER_PSPICE::writeDirectives( OUTPUTFORMATTER* aFormatter, unsigned aCtl ) const
|
void NETLIST_EXPORTER_PSPICE::writeDirectives( OUTPUTFORMATTER* aFormatter, unsigned aCtl ) const
|
||||||
{
|
{
|
||||||
for( auto& dir : m_directives )
|
for( const wxString& dir : m_directives )
|
||||||
{
|
{
|
||||||
aFormatter->Print( 0, "%s\n", TO_UTF8( dir ) );
|
aFormatter->Print( 0, "%s\n", TO_UTF8( dir ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,12 +185,12 @@ public:
|
||||||
/**
|
/**
|
||||||
* Retrieve either the requested field value or the default value.
|
* Retrieve either the requested field value or the default value.
|
||||||
*/
|
*/
|
||||||
static wxString GetSpiceField( SPICE_FIELD aField, SCH_COMPONENT* aComponent, unsigned aCtl );
|
static wxString GetSpiceField( SPICE_FIELD aField, SCH_COMPONENT* aSymbol, unsigned aCtl );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the default value for a given field.
|
* Retrieve the default value for a given field.
|
||||||
*/
|
*/
|
||||||
static wxString GetSpiceFieldDefVal( SPICE_FIELD aField, SCH_COMPONENT* aComponent,
|
static wxString GetSpiceFieldDefVal( SPICE_FIELD aField, SCH_COMPONENT* aSymbol,
|
||||||
unsigned aCtl );
|
unsigned aCtl );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1296,10 +1296,7 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
|
||||||
updateNetlistExporter();
|
updateNetlistExporter();
|
||||||
|
|
||||||
if( !m_exporter->ProcessNetlist( NET_ALL_FLAGS ) )
|
if( !m_exporter->ProcessNetlist( NET_ALL_FLAGS ) )
|
||||||
{
|
|
||||||
DisplayError( this, _( "There were errors during netlist export, aborted." ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if( plotPanelWindow != m_welcomePanel )
|
if( plotPanelWindow != m_welcomePanel )
|
||||||
m_settingsDlg->SetSimCommand( m_plots[plotPanelWindow].m_simCommand );
|
m_settingsDlg->SetSimCommand( m_plots[plotPanelWindow].m_simCommand );
|
||||||
|
|
Loading…
Reference in New Issue