Make IBIS errors visible / more obvious.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/18041
(cherry picked from commit 6dfd417767
)
This commit is contained in:
parent
90ee5e097a
commit
6dd5c7d733
|
@ -480,7 +480,8 @@ void NETLIST_EXPORTER_SPICE::readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSym
|
|||
|
||||
auto spiceGenerator = static_cast<const SPICE_GENERATOR_KIBIS&>( 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() );
|
||||
|
|
|
@ -59,7 +59,8 @@ std::vector<std::string> 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 );
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <project.h>
|
||||
|
||||
class SIM_LIBRARY_KIBIS;
|
||||
class REPORTER;
|
||||
|
||||
|
||||
class SPICE_GENERATOR_KIBIS : public SPICE_GENERATOR
|
||||
|
@ -42,7 +43,7 @@ public:
|
|||
std::vector<std::string> 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<std::reference_wrapper<const SIM_MODEL::PARAM>> GetInstanceParams() const override;
|
||||
|
|
|
@ -61,6 +61,11 @@
|
|||
#include <memory>
|
||||
|
||||
|
||||
// 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() );
|
||||
|
|
Loading…
Reference in New Issue