Revert "Do not use double component primitives in Spice netlist exporter"

This commit creates more issues than resolves. It could happen that
there are components with different reference types (e.g. U1 and IC1)
that would be later converted to X1, causing a conflict.
This commit is contained in:
Maciej Suminski 2016-08-31 11:51:17 +02:00
parent 9287b42648
commit fcedef836a
6 changed files with 11 additions and 30 deletions

View File

@ -118,7 +118,7 @@ bool DIALOG_SIM_SETTINGS::TransferDataFromWindow()
try
{
simCmd += wxString::Format( "%s %s %s %s",
simCmd += wxString::Format( "v%s %s %s %s",
m_dcSource1->GetValue(),
SPICE_VALUE( m_dcStart1->GetValue() ).ToSpiceString(),
SPICE_VALUE( m_dcStop1->GetValue() ).ToSpiceString(),
@ -146,7 +146,7 @@ bool DIALOG_SIM_SETTINGS::TransferDataFromWindow()
try
{
simCmd += wxString::Format( "%s %s %s %s",
simCmd += wxString::Format( "v%s %s %s %s",
m_dcSource2->GetValue(),
SPICE_VALUE( m_dcStart2->GetValue() ).ToSpiceString(),
SPICE_VALUE( m_dcStop2->GetValue() ).ToSpiceString(),
@ -278,7 +278,7 @@ int DIALOG_SIM_SETTINGS::ShowModal()
for( auto item : m_exporter->GetSpiceItems() )
{
if( item.m_primitive == SP_VSOURCE )
if( item.m_primitive == 'V' )
{
for( auto c : cmbSrc )
c.first->Append( item.m_refName );

View File

@ -81,7 +81,7 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* aFormatter, unsigned aCtl
for( const auto& item : m_spiceItems )
{
aFormatter->Print( 0, "%s ", (const char*) GetSpiceComponentName( item.m_parent, aCtl ).c_str() );
aFormatter->Print( 0, "%c%s ", item.m_primitive, (const char*) item.m_refName.c_str() );
// Pins to node mapping
int activePinIndex = 0;
@ -151,23 +151,6 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* aFormatter, unsigned aCtl
}
wxString NETLIST_EXPORTER_PSPICE::GetSpiceComponentName( SCH_COMPONENT* aComponent, unsigned aCtl )
{
const wxString compName = aComponent->GetField( REFERENCE )->GetText();
// Get the component number
const char* number = compName.c_str();
while( isalpha( *number ) )
++number;
if( number == nullptr )
number = compName.c_str();
return GetSpiceField( SF_PRIMITIVE, aComponent, aCtl ) + wxString( number );
}
wxString NETLIST_EXPORTER_PSPICE::GetSpiceField( SPICE_FIELD aField,
SCH_COMPONENT* aComponent, unsigned aCtl )
{
@ -303,7 +286,7 @@ bool NETLIST_EXPORTER_PSPICE::ProcessNetlist( unsigned aCtl )
spiceItem.m_primitive = GetSpiceField( SF_PRIMITIVE, comp, aCtl )[0];
spiceItem.m_model = GetSpiceField( SF_MODEL, comp, aCtl );
spiceItem.m_refName = GetSpiceComponentName( comp, aCtl );
spiceItem.m_refName = comp->GetRef( &sheetList[sheet_idx] );
// Duplicate references will result in simulation errors
if( refNames.count( spiceItem.m_refName ) )

View File

@ -165,11 +165,6 @@ public:
return m_spiceFields[(int) aField];
}
/**
* @brief Returns a component name in the Spice world.
*/
static wxString GetSpiceComponentName( SCH_COMPONENT* aComponent, unsigned aCtl );
/**
* @brief Retrieves either the requested field value or the default value.
*/

View File

@ -96,7 +96,7 @@ wxString NETLIST_EXPORTER_PSPICE_SIM::GetSpiceDevice( const wxString& aComponent
if( it == spiceItems.end() )
return wxEmptyString;
return wxString( it->m_refName );
return wxString( it->m_primitive + it->m_refName );
}

View File

@ -566,7 +566,7 @@ void SIM_PLOT_FRAME::applyTuners()
for( auto& tuner : m_tuners )
{
/// @todo no ngspice hardcoding
std::string command( "alter @" + tuner->GetSpiceName().Lower()
std::string command( "alter @" + tuner->GetSpiceName()
+ "=" + tuner->GetValue().ToSpiceString() );
m_simulator->Command( command );

View File

@ -37,7 +37,10 @@ TUNER_SLIDER::TUNER_SLIDER( SIM_PLOT_FRAME* aFrame, wxWindow* aParent, SCH_COMPO
m_name->SetLabel( compName );
m_value = SPICE_VALUE( aComponent->GetField( VALUE )->GetText() );
m_changed = false;
m_spiceName = NETLIST_EXPORTER_PSPICE::GetSpiceComponentName( aComponent, 0 );
// Generate Spice component name
char prim = NETLIST_EXPORTER_PSPICE::GetSpiceField( SF_PRIMITIVE, aComponent, 0 )[0];
m_spiceName = wxString( prim + compName ).Lower();
// Call Set*() methods to update fields and slider
m_max = SPICE_VALUE( 2.0 ) * m_value;