diff --git a/eeschema/dialogs/dialog_sim_settings.cpp b/eeschema/dialogs/dialog_sim_settings.cpp index c02a934e1a..23a5901c6b 100644 --- a/eeschema/dialogs/dialog_sim_settings.cpp +++ b/eeschema/dialogs/dialog_sim_settings.cpp @@ -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 ); diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp index d29440c623..e962b542f3 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp @@ -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 ) ) diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.h b/eeschema/netlist_exporters/netlist_exporter_pspice.h index 9bced031be..26e93f5426 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.h +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.h @@ -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. */ diff --git a/eeschema/sim/netlist_exporter_pspice_sim.cpp b/eeschema/sim/netlist_exporter_pspice_sim.cpp index c35331d5f6..516618e8c7 100644 --- a/eeschema/sim/netlist_exporter_pspice_sim.cpp +++ b/eeschema/sim/netlist_exporter_pspice_sim.cpp @@ -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 ); } diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index f53add9e28..f2d1595fc6 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -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 ); diff --git a/eeschema/widgets/tuner_slider.cpp b/eeschema/widgets/tuner_slider.cpp index 5e77bb154c..9f863ba16d 100644 --- a/eeschema/widgets/tuner_slider.cpp +++ b/eeschema/widgets/tuner_slider.cpp @@ -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;