Update compatibility mode and save flags in ngspice.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16955
This commit is contained in:
Jeff Young 2024-02-13 14:38:02 +00:00
parent 0cf433b28e
commit 12c8f5b14d
5 changed files with 29 additions and 3 deletions

View File

@ -511,6 +511,7 @@ void DIALOG_SIM_COMMAND::ApplySettings( SIM_TAB* aTab )
options &= ~NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_DISSIPATIONS;
aTab->SetSimOptions( options );
m_simulatorFrame->ReloadSimulator( m_simCommand, options );
#define TO_INT( ctrl ) (int) EDA_UNIT_UTILS::UI::ValueFromString( unityScale, EDA_UNITS::UNSCALED, \
ctrl->GetValue() )

View File

@ -74,10 +74,8 @@ NGSPICE::NGSPICE() :
NGSPICE::~NGSPICE() = default;
void NGSPICE::Init( const SPICE_SETTINGS* aSettings )
void NGSPICE::updateNgspiceSettings()
{
Command( "reset" );
for( const std::string& command : GetSettingCommands() )
{
wxLogTrace( traceNgspice, "Sending Ngspice configuration command '%s'.", command );
@ -86,6 +84,13 @@ void NGSPICE::Init( const SPICE_SETTINGS* aSettings )
}
void NGSPICE::Init( const SPICE_SETTINGS* aSettings )
{
Command( "reset" );
updateNgspiceSettings();
}
wxString NGSPICE::CurrentPlotName() const
{
return wxString( m_ngSpice_CurPlot() );
@ -277,6 +282,7 @@ bool NGSPICE::Attach( const std::shared_ptr<SIMULATION_MODEL>& aModel, const wxS
if( model && model->GetNetlist( aSimCommand, aSimOptions, &formatter, aReporter ) )
{
SIMULATOR::Attach( aModel, aSimCommand, aSimOptions, aReporter );
updateNgspiceSettings();
LoadNetlist( formatter.GetString() );
return true;
}

View File

@ -163,6 +163,8 @@ private:
///< Execute commands from a file
bool loadSpinit( const std::string& aFileName );
void updateNgspiceSettings();
///< Check a few different locations for codemodel files and returns one if it exists.
std::string findCmPath() const;

View File

@ -358,6 +358,18 @@ bool SIMULATOR_FRAME::LoadSimulator( const wxString& aSimCommand, unsigned aSimO
}
void SIMULATOR_FRAME::ReloadSimulator( const wxString& aSimCommand, unsigned aSimOptions )
{
wxString errors;
WX_STRING_REPORTER reporter( &errors );
if( !m_simulator->Attach( m_circuitModel, aSimCommand, aSimOptions, reporter ) )
{
DisplayErrorMessage( this, _( "Errors during netlist generation.\n\n" ) + errors );
}
}
void SIMULATOR_FRAME::StartSimulation()
{
SIM_TAB* simTab = m_ui->GetCurrentSimTab();

View File

@ -80,6 +80,11 @@ public:
*/
bool LoadSimulator( const wxString& aSimCommand, unsigned aSimOptions );
/**
* Re-send the current command and settings to the simulator. Use the existing netlist.
*/
void ReloadSimulator( const wxString& aSimCommand, unsigned aSimOptions );
void StartSimulation();
/**