diff --git a/eeschema/netlist_exporters/netlist_exporter_spice.cpp b/eeschema/netlist_exporters/netlist_exporter_spice.cpp index e78d770661..68786f6c6b 100644 --- a/eeschema/netlist_exporters/netlist_exporter_spice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_spice.cpp @@ -480,7 +480,8 @@ void NETLIST_EXPORTER_SPICE::readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSym auto spiceGenerator = static_cast( kibisModel->SpiceGenerator() ); std::string modelData = spiceGenerator.IbisDevice( - aItem, m_schematic->Prj(), cacheFn.GetPath( wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR ) ); + aItem, m_schematic->Prj(), + cacheFn.GetPath( wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR ), aReporter ); cacheFile.Write( wxString( modelData ) ); m_rawIncludes.insert( cacheFn.GetFullPath() ); diff --git a/eeschema/sim/sim_model_kibis.cpp b/eeschema/sim/sim_model_kibis.cpp index 3d5c677b41..bc981ca55b 100644 --- a/eeschema/sim/sim_model_kibis.cpp +++ b/eeschema/sim/sim_model_kibis.cpp @@ -59,7 +59,8 @@ std::vector SPICE_GENERATOR_KIBIS::CurrentNames( const SPICE_ITEM& std::string SPICE_GENERATOR_KIBIS::IbisDevice( const SPICE_ITEM& aItem, const PROJECT& aProject, - const wxString& aCacheDir ) const + const wxString& aCacheDir, + REPORTER& aReporter ) const { std::string ibisLibFilename = SIM_MODEL::GetFieldValue( &aItem.fields, SIM_LIBRARY::LIBRARY_FIELD ); std::string ibisCompName = SIM_MODEL::GetFieldValue( &aItem.fields, SIM_LIBRARY::NAME_FIELD ); @@ -71,6 +72,7 @@ std::string SPICE_GENERATOR_KIBIS::IbisDevice( const SPICE_ITEM& aItem, const PR KIBIS kibis( std::string( path.c_str() ) ); kibis.m_cacheDir = std::string( aCacheDir.c_str() ); + kibis.m_reporter = &aReporter; if( !kibis.m_valid ) THROW_IO_ERROR( wxString::Format( _( "Invalid IBIS file '%s'" ), ibisLibFilename ) ); @@ -167,10 +169,10 @@ std::string SPICE_GENERATOR_KIBIS::IbisDevice( const SPICE_ITEM& aItem, const PR KIBIS_WAVEFORM_RECTANGULAR* waveform = new KIBIS_WAVEFORM_RECTANGULAR( &kibis ); if( const SIM_MODEL::PARAM* ton = m_model.FindParam( "ton" ) ) - waveform->m_ton = SIM_VALUE::ToDouble( ton->value, 1 ); + waveform->m_ton = SIM_VALUE::ToDouble( ton->value, 0 ); if( const SIM_MODEL::PARAM* toff = m_model.FindParam( "toff" ) ) - waveform->m_toff = SIM_VALUE::ToDouble( toff->value, 1 ); + waveform->m_toff = SIM_VALUE::ToDouble( toff->value, 0 ); if( const SIM_MODEL::PARAM* td = m_model.FindParam( "td" ) ) waveform->m_delay = SIM_VALUE::ToDouble( td->value, 0 ); diff --git a/eeschema/sim/sim_model_kibis.h b/eeschema/sim/sim_model_kibis.h index d121d96001..8a5b69b702 100644 --- a/eeschema/sim/sim_model_kibis.h +++ b/eeschema/sim/sim_model_kibis.h @@ -30,6 +30,7 @@ #include class SIM_LIBRARY_KIBIS; +class REPORTER; class SPICE_GENERATOR_KIBIS : public SPICE_GENERATOR @@ -42,7 +43,7 @@ public: std::vector CurrentNames( const SPICE_ITEM& aItem ) const override; std::string IbisDevice( const SPICE_ITEM& aItem, const PROJECT& aProject, - const wxString& aCacheDir ) const; + const wxString& aCacheDir, REPORTER& aReporter ) const; protected: std::vector> GetInstanceParams() const override; diff --git a/eeschema/sim/simulator_frame.cpp b/eeschema/sim/simulator_frame.cpp index ee0a9bcc43..e1c48f03de 100644 --- a/eeschema/sim/simulator_frame.cpp +++ b/eeschema/sim/simulator_frame.cpp @@ -61,6 +61,11 @@ #include +// Reporter is stored by pointer in KIBIS, so keep this here to avoid crashes +static wxString s_errors; +static WX_STRING_REPORTER s_reporter( &s_errors ); + + class SIM_THREAD_REPORTER : public SIMULATOR_REPORTER { public: @@ -348,8 +353,7 @@ void SIMULATOR_FRAME::UpdateTitle() bool SIMULATOR_FRAME::LoadSimulator( const wxString& aSimCommand, unsigned aSimOptions ) { - wxString errors; - WX_STRING_REPORTER reporter( &errors ); + s_errors.clear(); if( !m_schematicFrame->ReadyToNetlist( _( "Simulator requires a fully annotated schematic." ) ) ) return false; @@ -359,9 +363,9 @@ bool SIMULATOR_FRAME::LoadSimulator( const wxString& aSimCommand, unsigned aSimO m_schematicFrame->RecalculateConnections( nullptr, GLOBAL_CLEANUP ); if( !m_simulator->Attach( m_circuitModel, aSimCommand, aSimOptions, Prj().GetProjectPath(), - reporter ) ) + s_reporter ) ) { - DisplayErrorMessage( this, _( "Errors during netlist generation.\n\n" ) + errors ); + DisplayErrorMessage( this, _( "Errors during netlist generation.\n\n" ) + s_errors ); return false; } @@ -371,13 +375,10 @@ 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, Prj().GetProjectPath(), - reporter ) ) + s_reporter ) ) { - DisplayErrorMessage( this, _( "Errors during netlist generation.\n\n" ) + errors ); + DisplayErrorMessage( this, _( "Errors during netlist generation.\n\n" ) + s_errors ); } } @@ -560,17 +561,17 @@ bool SIMULATOR_FRAME::EditAnalysis() { SIM_TAB* simTab = m_ui->GetCurrentSimTab(); DIALOG_SIM_COMMAND dlg( this, m_circuitModel, m_simulator->Settings() ); - wxString errors; - WX_STRING_REPORTER reporter( &errors ); + + s_errors.clear(); if( !simTab ) return false; if( !m_circuitModel->ReadSchematicAndLibraries( NETLIST_EXPORTER_SPICE::OPTION_DEFAULT_FLAGS, - reporter ) ) + s_reporter ) ) { DisplayErrorMessage( this, _( "Errors during netlist generation.\n\n" ) - + errors ); + + s_errors ); } dlg.SetSimCommand( simTab->GetSimCommand() );