Remove error-prone SetReporter() API.
This commit is contained in:
parent
e09a15ae4c
commit
7a2a2e2df0
|
@ -203,11 +203,10 @@ bool DIALOG_SIM_MODEL<T_symbol, T_field>::TransferDataToWindow()
|
|||
if( !loadLibrary( libraryFilename ) )
|
||||
{
|
||||
m_libraryPathText->ChangeValue( libraryFilename );
|
||||
m_curModelType = SIM_MODEL::ReadTypeFromFields( m_fields, &reporter );
|
||||
m_curModelType = SIM_MODEL::ReadTypeFromFields( m_fields, reporter );
|
||||
|
||||
// load library will mangle the set reporter
|
||||
m_libraryModelsMgr.SetReporter( &reporter );
|
||||
m_libraryModelsMgr.CreateModel( nullptr, m_sortedPartPins, m_fields );
|
||||
m_libraryModelsMgr.CreateModel( nullptr, m_sortedPartPins, m_fields, reporter );
|
||||
|
||||
m_modelNameChoice->Append( _( "<unknown>" ) );
|
||||
m_modelNameChoice->SetSelection( 0 );
|
||||
|
@ -285,20 +284,18 @@ bool DIALOG_SIM_MODEL<T_symbol, T_field>::TransferDataToWindow()
|
|||
m_rbBuiltinModel->SetValue( true );
|
||||
|
||||
msg.clear();
|
||||
m_curModelType = SIM_MODEL::ReadTypeFromFields( m_fields, &reporter );
|
||||
m_curModelType = SIM_MODEL::ReadTypeFromFields( m_fields, reporter );
|
||||
|
||||
if( reporter.HasMessage() )
|
||||
DisplayErrorMessage( this, msg );
|
||||
}
|
||||
|
||||
m_builtinModelsMgr.SetReporter( &reporter );
|
||||
|
||||
for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() )
|
||||
{
|
||||
if( m_rbBuiltinModel->GetValue() && type == m_curModelType )
|
||||
{
|
||||
msg.clear();
|
||||
m_builtinModelsMgr.CreateModel( m_fields, m_sortedPartPins, false );
|
||||
m_builtinModelsMgr.CreateModel( m_fields, m_sortedPartPins, false, reporter );
|
||||
|
||||
if( reporter.HasMessage() )
|
||||
{
|
||||
|
@ -308,7 +305,7 @@ bool DIALOG_SIM_MODEL<T_symbol, T_field>::TransferDataToWindow()
|
|||
}
|
||||
else
|
||||
{
|
||||
m_builtinModelsMgr.CreateModel( type, m_sortedPartPins );
|
||||
m_builtinModelsMgr.CreateModel( type, m_sortedPartPins, reporter );
|
||||
}
|
||||
|
||||
SIM_MODEL::DEVICE_T deviceTypeT = SIM_MODEL::TypeInfo( type ).deviceType;
|
||||
|
@ -723,9 +720,8 @@ bool DIALOG_SIM_MODEL<T_symbol, T_field>::loadLibrary( const wxString& aLibraryP
|
|||
wxString msg;
|
||||
WX_STRING_REPORTER reporter( &msg );
|
||||
|
||||
m_libraryModelsMgr.SetReporter( &reporter );
|
||||
m_libraryModelsMgr.SetForceFullParse();
|
||||
m_libraryModelsMgr.SetLibrary( aLibraryPath );
|
||||
m_libraryModelsMgr.SetLibrary( aLibraryPath, reporter );
|
||||
|
||||
if( reporter.HasMessage() )
|
||||
{
|
||||
|
@ -738,9 +734,9 @@ bool DIALOG_SIM_MODEL<T_symbol, T_field>::loadLibrary( const wxString& aLibraryP
|
|||
for( const auto& [baseModelName, baseModel] : library()->GetModels() )
|
||||
{
|
||||
if( baseModelName == modelName )
|
||||
m_libraryModelsMgr.CreateModel( &baseModel, m_sortedPartPins, m_fields );
|
||||
m_libraryModelsMgr.CreateModel( &baseModel, m_sortedPartPins, m_fields, reporter );
|
||||
else
|
||||
m_libraryModelsMgr.CreateModel( &baseModel, m_sortedPartPins );
|
||||
m_libraryModelsMgr.CreateModel( &baseModel, m_sortedPartPins, reporter );
|
||||
}
|
||||
|
||||
if( reporter.HasMessage() )
|
||||
|
|
|
@ -1048,7 +1048,7 @@ int ERC_TESTER::TestSimModelIssues()
|
|||
WX_STRING_REPORTER reporter( &msg );
|
||||
SCH_SHEET_LIST sheets = m_schematic->GetSheets();
|
||||
int err_count = 0;
|
||||
SIM_LIB_MGR libMgr( &m_schematic->Prj(), &reporter );
|
||||
SIM_LIB_MGR libMgr( &m_schematic->Prj() );
|
||||
|
||||
for( SCH_SHEET_PATH& sheet : sheets )
|
||||
{
|
||||
|
@ -1066,7 +1066,7 @@ int ERC_TESTER::TestSimModelIssues()
|
|||
// Reset for each symbol
|
||||
msg.Clear();
|
||||
|
||||
SIM_LIBRARY::MODEL model = libMgr.CreateModel( &sheet, *symbol );
|
||||
SIM_LIBRARY::MODEL model = libMgr.CreateModel( &sheet, *symbol, reporter );
|
||||
|
||||
if( !msg.IsEmpty() )
|
||||
{
|
||||
|
|
|
@ -104,7 +104,6 @@ NETLIST_EXPORTER_SPICE::NETLIST_EXPORTER_SPICE( SCHEMATIC_IFACE* aSchematic,
|
|||
bool NETLIST_EXPORTER_SPICE::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
m_libMgr.SetReporter( &aReporter );
|
||||
FILE_OUTPUTFORMATTER formatter( aOutFileName, wxT( "wt" ), '\'' );
|
||||
return DoWriteNetlist( wxEmptyString, aNetlistOptions, formatter, aReporter );
|
||||
}
|
||||
|
@ -156,8 +155,6 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions
|
|||
std::set<std::string> refNames; // Set of reference names to check for duplication.
|
||||
int ncCounter = 1;
|
||||
|
||||
m_libMgr.SetReporter( &aReporter );
|
||||
|
||||
ReadDirectives( aNetlistOptions );
|
||||
|
||||
m_nets.clear();
|
||||
|
@ -227,7 +224,7 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions
|
|||
}
|
||||
|
||||
readRefName( sheet, *symbol, spiceItem, refNames );
|
||||
readModel( sheet, *symbol, spiceItem );
|
||||
readModel( sheet, *symbol, spiceItem, aReporter );
|
||||
readPinNumbers( *symbol, spiceItem, pins );
|
||||
readPinNetNames( *symbol, spiceItem, pins, ncCounter );
|
||||
|
||||
|
@ -237,8 +234,6 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions
|
|||
}
|
||||
}
|
||||
|
||||
m_libMgr.SetReporter( nullptr );
|
||||
|
||||
return !aReporter.HasMessage();
|
||||
}
|
||||
|
||||
|
@ -446,9 +441,9 @@ void NETLIST_EXPORTER_SPICE::readRefName( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aS
|
|||
|
||||
|
||||
void NETLIST_EXPORTER_SPICE::readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol,
|
||||
SPICE_ITEM& aItem )
|
||||
SPICE_ITEM& aItem, REPORTER& aReporter )
|
||||
{
|
||||
SIM_LIBRARY::MODEL libModel = m_libMgr.CreateModel( &aSheet, aSymbol );
|
||||
SIM_LIBRARY::MODEL libModel = m_libMgr.CreateModel( &aSheet, aSymbol, aReporter );
|
||||
|
||||
aItem.baseModelName = libModel.name;
|
||||
aItem.model = &libModel.model;
|
||||
|
|
|
@ -146,7 +146,8 @@ protected:
|
|||
private:
|
||||
void readRefName( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem,
|
||||
std::set<std::string>& aRefNames );
|
||||
void readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem );
|
||||
void readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem,
|
||||
REPORTER& aReporter );
|
||||
void readPinNumbers( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem,
|
||||
const std::vector<PIN_INFO>& aPins );
|
||||
void readPinNetNames( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem,
|
||||
|
|
|
@ -1406,8 +1406,6 @@ void SCH_EDIT_FRAME::RefreshOperatingPointDisplay()
|
|||
SIM_LIB_MGR simLibMgr( &Prj() );
|
||||
NULL_REPORTER devnull;
|
||||
|
||||
simLibMgr.SetReporter( &devnull );
|
||||
|
||||
// Patch for bug early in V7.99 dev
|
||||
if( settings.m_OPO_VRange.EndsWith( 'A' ) )
|
||||
settings.m_OPO_VRange[ settings.m_OPO_VRange.Length() - 1 ] = 'V';
|
||||
|
@ -1493,7 +1491,7 @@ void SCH_EDIT_FRAME::RefreshOperatingPointDisplay()
|
|||
}
|
||||
else
|
||||
{
|
||||
SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol ).model;
|
||||
SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol, devnull ).model;
|
||||
|
||||
SPICE_ITEM spiceItem;
|
||||
spiceItem.refName = ref;
|
||||
|
|
|
@ -715,9 +715,10 @@ void SCH_FIELD::OnScintillaCharAdded( SCINTILLA_TRICKS* aScintillaTricks,
|
|||
// SPICE operating points use ':' syntax for ports
|
||||
if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( parent ) )
|
||||
{
|
||||
NULL_REPORTER devnull;
|
||||
SCH_SHEET_PATH& sheet = schematic->CurrentSheet();
|
||||
SIM_LIB_MGR mgr( &schematic->Prj() );
|
||||
SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol ).model;
|
||||
SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol, devnull ).model;
|
||||
|
||||
for( wxString pin : model.GetPinNames() )
|
||||
{
|
||||
|
|
|
@ -49,13 +49,11 @@
|
|||
#include <cstring>
|
||||
|
||||
|
||||
#define IBIS_REPORTER REPORTER
|
||||
|
||||
class IBIS_ANY
|
||||
{
|
||||
public:
|
||||
IBIS_ANY( IBIS_REPORTER* aReporter ) { m_reporter = aReporter; };
|
||||
IBIS_REPORTER* m_reporter;
|
||||
IBIS_ANY( REPORTER* aReporter ) { m_reporter = aReporter; };
|
||||
REPORTER* m_reporter;
|
||||
|
||||
/** @brief Print a message
|
||||
*
|
||||
|
@ -69,6 +67,7 @@ public:
|
|||
if( m_reporter )
|
||||
m_reporter->Report( aMsg, aSeverity );
|
||||
};
|
||||
|
||||
protected:
|
||||
/** @brief Convert a double to string using scientific notation
|
||||
*
|
||||
|
@ -82,7 +81,7 @@ protected:
|
|||
class IBIS_INPUT : public IBIS_ANY
|
||||
{
|
||||
public:
|
||||
IBIS_INPUT( IBIS_REPORTER* aReporter ) : IBIS_ANY( aReporter ){};
|
||||
IBIS_INPUT( REPORTER* aReporter ) : IBIS_ANY( aReporter ){};
|
||||
/** @brief Check if the data held by the object is valid.
|
||||
*
|
||||
* @return true in case of success
|
||||
|
@ -111,7 +110,7 @@ enum class IBIS_MATRIX_TYPE
|
|||
class IBIS_MATRIX : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IBIS_MATRIX( IBIS_REPORTER* aReporter ) : IBIS_INPUT( aReporter ){};
|
||||
IBIS_MATRIX( REPORTER* aReporter ) : IBIS_INPUT( aReporter ){};
|
||||
virtual ~IBIS_MATRIX(){};
|
||||
|
||||
IBIS_MATRIX_TYPE m_type = IBIS_MATRIX_TYPE::UNDEFINED;
|
||||
|
@ -122,7 +121,7 @@ public:
|
|||
class IBIS_MATRIX_BANDED : public IBIS_MATRIX
|
||||
{
|
||||
public:
|
||||
IBIS_MATRIX_BANDED( IBIS_REPORTER* aReporter ) : IBIS_MATRIX( aReporter ){};
|
||||
IBIS_MATRIX_BANDED( REPORTER* aReporter ) : IBIS_MATRIX( aReporter ){};
|
||||
IBIS_MATRIX_TYPE m_type = IBIS_MATRIX_TYPE::BANDED;
|
||||
int m_dim = -2;
|
||||
int m_bandwidth = 0;
|
||||
|
@ -134,7 +133,7 @@ public:
|
|||
class IBIS_MATRIX_SPARSE : public IBIS_MATRIX
|
||||
{
|
||||
public:
|
||||
IBIS_MATRIX_SPARSE( IBIS_REPORTER* aReporter ) : IBIS_MATRIX( aReporter ){};
|
||||
IBIS_MATRIX_SPARSE( REPORTER* aReporter ) : IBIS_MATRIX( aReporter ){};
|
||||
IBIS_MATRIX_TYPE m_type = IBIS_MATRIX_TYPE::BANDED;
|
||||
int m_dim = -3;
|
||||
std::vector<double> m_data;
|
||||
|
@ -146,7 +145,7 @@ public:
|
|||
class IBIS_MATRIX_FULL : public IBIS_MATRIX
|
||||
{
|
||||
public:
|
||||
IBIS_MATRIX_FULL( IBIS_REPORTER* aReporter ) : IBIS_MATRIX( aReporter ){};
|
||||
IBIS_MATRIX_FULL( REPORTER* aReporter ) : IBIS_MATRIX( aReporter ){};
|
||||
IBIS_MATRIX_TYPE m_type = IBIS_MATRIX_TYPE::FULL;
|
||||
int m_dim = -4;
|
||||
std::vector<double> m_data;
|
||||
|
@ -158,14 +157,14 @@ public:
|
|||
class IBIS_SECTION : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IBIS_SECTION( IBIS_REPORTER* aReporter ) : IBIS_INPUT( aReporter ){};
|
||||
IBIS_SECTION( REPORTER* aReporter ) : IBIS_INPUT( aReporter ){};
|
||||
};
|
||||
|
||||
|
||||
class IbisHeader : IBIS_SECTION
|
||||
{
|
||||
public:
|
||||
IbisHeader( IBIS_REPORTER* aReporter ) : IBIS_SECTION( aReporter ){};
|
||||
IbisHeader( REPORTER* aReporter ) : IBIS_SECTION( aReporter ){};
|
||||
double m_ibisVersion = -1;
|
||||
double m_fileRevision = -1;
|
||||
std::string m_fileName;
|
||||
|
@ -182,7 +181,7 @@ public:
|
|||
class TypMinMaxValue : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
TypMinMaxValue( IBIS_REPORTER* aReporter ) : IBIS_INPUT( aReporter ){};
|
||||
TypMinMaxValue( REPORTER* aReporter ) : IBIS_INPUT( aReporter ){};
|
||||
double value[3] = { -1, -1, -1 };
|
||||
|
||||
bool Check() override;
|
||||
|
@ -192,7 +191,7 @@ public:
|
|||
class IbisComponentPackage : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IbisComponentPackage( IBIS_REPORTER* aReporter ) :
|
||||
IbisComponentPackage( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter ),
|
||||
m_Rpkg( aReporter ),
|
||||
m_Lpkg( aReporter ),
|
||||
|
@ -210,7 +209,7 @@ public:
|
|||
class IbisComponentPin : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IbisComponentPin( IBIS_REPORTER* aReporter ) :
|
||||
IbisComponentPin( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter )
|
||||
{};
|
||||
|
||||
|
@ -237,7 +236,7 @@ public:
|
|||
class IbisComponentPinMapping : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IbisComponentPinMapping( IBIS_REPORTER* aReporter ) :
|
||||
IbisComponentPinMapping( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter )
|
||||
{};
|
||||
|
||||
|
@ -258,7 +257,7 @@ public:
|
|||
class IbisDiffPinEntry : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IbisDiffPinEntry( IBIS_REPORTER* aReporter ) :
|
||||
IbisDiffPinEntry( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter ),
|
||||
tdelay( aReporter )
|
||||
{};
|
||||
|
@ -276,7 +275,7 @@ public:
|
|||
class IbisDiffPin : IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IbisDiffPin( IBIS_REPORTER* aReporter ) :
|
||||
IbisDiffPin( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter )
|
||||
{};
|
||||
|
||||
|
@ -286,7 +285,7 @@ public:
|
|||
class IbisComponent : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IbisComponent( IBIS_REPORTER* aReporter ) :
|
||||
IbisComponent( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter ),
|
||||
m_package( aReporter ),
|
||||
m_diffPin( aReporter )
|
||||
|
@ -320,7 +319,7 @@ public:
|
|||
class IbisModelSelector : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IbisModelSelector( IBIS_REPORTER* aReporter ) :
|
||||
IbisModelSelector( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter )
|
||||
{};
|
||||
|
||||
|
@ -337,7 +336,7 @@ public:
|
|||
class IVtableEntry : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IVtableEntry( IBIS_REPORTER* aReporter ) :
|
||||
IVtableEntry( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter ),
|
||||
I( aReporter )
|
||||
{};
|
||||
|
@ -353,7 +352,7 @@ public:
|
|||
class IVtable : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IVtable( IBIS_REPORTER* aReporter ) :
|
||||
IVtable( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter )
|
||||
{};
|
||||
|
||||
|
@ -392,7 +391,7 @@ private:
|
|||
class VTtableEntry : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
VTtableEntry( IBIS_REPORTER* aReporter ) :
|
||||
VTtableEntry( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter ),
|
||||
V( aReporter )
|
||||
{};
|
||||
|
@ -407,7 +406,7 @@ public:
|
|||
class VTtable : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
VTtable( IBIS_REPORTER* aReporter ) :
|
||||
VTtable( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter )
|
||||
{};
|
||||
|
||||
|
@ -460,7 +459,7 @@ public:
|
|||
class dvdtTypMinMax : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
dvdtTypMinMax( IBIS_REPORTER* aReporter ) : IBIS_INPUT( aReporter ){};
|
||||
dvdtTypMinMax( REPORTER* aReporter ) : IBIS_INPUT( aReporter ){};
|
||||
dvdt value[3];
|
||||
|
||||
bool Check() override;
|
||||
|
@ -470,7 +469,7 @@ public:
|
|||
class IbisRamp : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IbisRamp( IBIS_REPORTER* aReporter ) :
|
||||
IbisRamp( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter ),
|
||||
m_falling( aReporter ),
|
||||
m_rising( aReporter )
|
||||
|
@ -492,7 +491,7 @@ enum class IBIS_WAVEFORM_TYPE
|
|||
class IbisWaveform : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IbisWaveform( IBIS_REPORTER* aReporter ) : IBIS_INPUT( aReporter ), m_table( aReporter ){};
|
||||
IbisWaveform( REPORTER* aReporter ) : IBIS_INPUT( aReporter ), m_table( aReporter ){};
|
||||
|
||||
VTtable m_table;
|
||||
IBIS_WAVEFORM_TYPE m_type = IBIS_WAVEFORM_TYPE::RISING;
|
||||
|
@ -517,7 +516,7 @@ enum class IBIS_MODEL_POLARITY
|
|||
class IbisModel : IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IbisModel( IBIS_REPORTER* aReporter ) :
|
||||
IbisModel( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter ),
|
||||
m_C_comp( aReporter ),
|
||||
m_voltageRange( aReporter ),
|
||||
|
@ -580,7 +579,7 @@ public:
|
|||
class IbisPackageModel : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IbisPackageModel( IBIS_REPORTER* aReporter ) :
|
||||
IbisPackageModel( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter )
|
||||
{};
|
||||
|
||||
|
@ -604,7 +603,7 @@ public:
|
|||
class IbisFile : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IbisFile( IBIS_REPORTER* aReporter ) :
|
||||
IbisFile( REPORTER* aReporter ) :
|
||||
IBIS_INPUT( aReporter ),
|
||||
m_header( aReporter )
|
||||
{};
|
||||
|
@ -653,7 +652,7 @@ enum class IBIS_PARSER_CONTEXT
|
|||
class IbisParser : public IBIS_INPUT
|
||||
{
|
||||
public:
|
||||
IbisParser( IBIS_REPORTER* aReporter ) : IBIS_INPUT( aReporter ), m_ibisFile( aReporter ){};
|
||||
IbisParser( REPORTER* aReporter ) : IBIS_INPUT( aReporter ), m_ibisFile( aReporter ){};
|
||||
|
||||
bool m_parrot = true; // Write back all lines.
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2022 Fabien Corona f.corona<at>laposte.net
|
||||
* Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -85,7 +86,7 @@ IBIS_CORNER ReverseLogic( IBIS_CORNER aIn )
|
|||
return out;
|
||||
}
|
||||
|
||||
KIBIS::KIBIS( std::string aFileName, IBIS_REPORTER* aReporter ) :
|
||||
KIBIS::KIBIS( std::string aFileName, REPORTER* aReporter ) :
|
||||
KIBIS_ANY( this ),
|
||||
m_reporter( aReporter ),
|
||||
m_file( this )
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2022 Fabien Corona f.corona<at>laposte.net
|
||||
* Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -218,9 +219,10 @@ public:
|
|||
{
|
||||
m_valid = false;
|
||||
}; // Constructor for unitialized KIBIS members
|
||||
KIBIS( std::string aFileName, IBIS_REPORTER* aReporter = nullptr );
|
||||
|
||||
IBIS_REPORTER* m_reporter;
|
||||
KIBIS( std::string aFileName, REPORTER* aReporter = nullptr );
|
||||
|
||||
REPORTER* m_reporter;
|
||||
std::vector<KIBIS_COMPONENT> m_components;
|
||||
std::vector<KIBIS_MODEL> m_models;
|
||||
KIBIS_FILE m_file;
|
||||
|
|
|
@ -39,9 +39,8 @@
|
|||
using namespace std::placeholders;
|
||||
|
||||
|
||||
SIM_LIB_MGR::SIM_LIB_MGR( const PROJECT* aPrj, REPORTER* aReporter ) :
|
||||
SIM_LIB_MGR::SIM_LIB_MGR( const PROJECT* aPrj ) :
|
||||
m_project( aPrj ),
|
||||
m_reporter( aReporter ),
|
||||
m_forceFullParse( false )
|
||||
{
|
||||
}
|
||||
|
@ -128,7 +127,7 @@ wxString SIM_LIB_MGR::ResolveEmbeddedLibraryPath( const wxString& aLibPath,
|
|||
}
|
||||
|
||||
|
||||
void SIM_LIB_MGR::SetLibrary( const wxString& aLibraryPath )
|
||||
void SIM_LIB_MGR::SetLibrary( const wxString& aLibraryPath, REPORTER& aReporter )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -138,29 +137,30 @@ void SIM_LIB_MGR::SetLibrary( const wxString& aLibraryPath )
|
|||
std::bind( &SIM_LIB_MGR::ResolveEmbeddedLibraryPath, this, _1, _2 );
|
||||
|
||||
std::unique_ptr<SIM_LIBRARY> library = SIM_LIBRARY::Create( path, m_forceFullParse,
|
||||
m_reporter, &f2 );
|
||||
aReporter, &f2 );
|
||||
|
||||
Clear();
|
||||
m_libraries[path] = std::move( library );
|
||||
}
|
||||
catch( const IO_ERROR& e )
|
||||
{
|
||||
m_reporter->Report( e.What() );
|
||||
aReporter.Report( e.What() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SIM_MODEL& SIM_LIB_MGR::CreateModel( SIM_MODEL::TYPE aType, const std::vector<LIB_PIN*>& aPins )
|
||||
SIM_MODEL& SIM_LIB_MGR::CreateModel( SIM_MODEL::TYPE aType, const std::vector<LIB_PIN*>& aPins,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
m_models.push_back( SIM_MODEL::Create( aType, aPins, m_reporter ) );
|
||||
m_models.push_back( SIM_MODEL::Create( aType, aPins, aReporter ) );
|
||||
return *m_models.back();
|
||||
}
|
||||
|
||||
|
||||
SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel,
|
||||
const std::vector<LIB_PIN*>& aPins )
|
||||
const std::vector<LIB_PIN*>& aPins, REPORTER& aReporter )
|
||||
{
|
||||
m_models.push_back( SIM_MODEL::Create( aBaseModel, aPins, m_reporter ) );
|
||||
m_models.push_back( SIM_MODEL::Create( aBaseModel, aPins, aReporter ) );
|
||||
return *m_models.back();
|
||||
}
|
||||
|
||||
|
@ -168,21 +168,24 @@ SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel,
|
|||
template <typename T>
|
||||
SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
const std::vector<T>& aFields )
|
||||
const std::vector<T>& aFields, REPORTER& aReporter )
|
||||
{
|
||||
m_models.push_back( SIM_MODEL::Create( aBaseModel, aPins, aFields, m_reporter ) );
|
||||
m_models.push_back( SIM_MODEL::Create( aBaseModel, aPins, aFields, aReporter ) );
|
||||
return *m_models.back();
|
||||
}
|
||||
|
||||
template SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
const std::vector<SCH_FIELD>& aFields );
|
||||
const std::vector<SCH_FIELD>& aFields,
|
||||
REPORTER& aReporter );
|
||||
template SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
const std::vector<LIB_FIELD>& aFields );
|
||||
const std::vector<LIB_FIELD>& aFields,
|
||||
REPORTER& aReporter );
|
||||
|
||||
|
||||
SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, SCH_SYMBOL& aSymbol )
|
||||
SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, SCH_SYMBOL& aSymbol,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
// Note: currently this creates a resolved model (all Kicad variables references are resolved
|
||||
// before building the model).
|
||||
|
@ -239,7 +242,7 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S
|
|||
return StrNumCmp( lhs->GetNumber(), rhs->GetNumber(), true ) < 0;
|
||||
} );
|
||||
|
||||
SIM_LIBRARY::MODEL model = CreateModel( fields, sourcePins, true );
|
||||
SIM_LIBRARY::MODEL model = CreateModel( fields, sourcePins, true, aReporter );
|
||||
|
||||
model.model.SetIsStoredInValue( storeInValue );
|
||||
|
||||
|
@ -249,35 +252,37 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S
|
|||
|
||||
template <typename T>
|
||||
SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector<T>& aFields,
|
||||
const std::vector<LIB_PIN*>& aPins, bool aResolved )
|
||||
const std::vector<LIB_PIN*>& aPins, bool aResolved,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
std::string libraryPath = SIM_MODEL::GetFieldValue( &aFields, SIM_LIBRARY::LIBRARY_FIELD );
|
||||
std::string baseModelName = SIM_MODEL::GetFieldValue( &aFields, SIM_LIBRARY::NAME_FIELD );
|
||||
|
||||
if( libraryPath != "" )
|
||||
{
|
||||
return CreateModel( libraryPath, baseModelName, aFields, aPins );
|
||||
return CreateModel( libraryPath, baseModelName, aFields, aPins, aReporter );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_models.push_back( SIM_MODEL::Create( aFields, aPins, aResolved, m_reporter ) );
|
||||
m_models.push_back( SIM_MODEL::Create( aFields, aPins, aResolved, aReporter ) );
|
||||
return { baseModelName, *m_models.back() };
|
||||
}
|
||||
}
|
||||
|
||||
template SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector<SCH_FIELD>& aFields,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
bool aResolved );
|
||||
bool aResolved, REPORTER& aReporter );
|
||||
template SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector<LIB_FIELD>& aFields,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
bool aResolved );
|
||||
bool aResolved, REPORTER& aReporter );
|
||||
|
||||
|
||||
template <typename T>
|
||||
SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const wxString& aLibraryPath,
|
||||
const std::string& aBaseModelName,
|
||||
const std::vector<T>& aFields,
|
||||
const std::vector<LIB_PIN*>& aPins )
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
wxString path;
|
||||
wxString msg;
|
||||
|
@ -297,32 +302,26 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const wxString& aLibraryPath,
|
|||
std::bind( &SIM_LIB_MGR::ResolveEmbeddedLibraryPath, this, _1, _2 );
|
||||
|
||||
it = m_libraries.emplace( path, SIM_LIBRARY::Create( path, m_forceFullParse,
|
||||
m_reporter, &f2 ) ).first;
|
||||
aReporter, &f2 ) ).first;
|
||||
}
|
||||
|
||||
library = &*it->second;
|
||||
}
|
||||
catch( const IO_ERROR& e )
|
||||
{
|
||||
if( m_reporter )
|
||||
{
|
||||
msg.Printf( _( "Error loading simulation model library '%s': %s" ),
|
||||
path,
|
||||
e.What() );
|
||||
|
||||
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
|
||||
}
|
||||
aReporter.Report( msg, RPT_SEVERITY_ERROR );
|
||||
}
|
||||
|
||||
if( aBaseModelName == "" )
|
||||
{
|
||||
if( m_reporter )
|
||||
{
|
||||
msg.Printf( _( "Error loading simulation model: no '%s' field" ),
|
||||
SIM_LIBRARY::NAME_FIELD );
|
||||
|
||||
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
|
||||
}
|
||||
aReporter.Report( msg, RPT_SEVERITY_ERROR );
|
||||
|
||||
modelName = _( "unknown" ).ToStdString();
|
||||
}
|
||||
|
@ -332,20 +331,17 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const wxString& aLibraryPath,
|
|||
modelName = aBaseModelName;
|
||||
|
||||
if( !baseModel )
|
||||
{
|
||||
if( m_reporter )
|
||||
{
|
||||
msg.Printf( _( "Error loading simulation model: could not find base model '%s' "
|
||||
"in library '%s'" ),
|
||||
aBaseModelName,
|
||||
path );
|
||||
|
||||
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
|
||||
}
|
||||
aReporter.Report( msg, RPT_SEVERITY_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
m_models.push_back( SIM_MODEL::Create( baseModel, aPins, aFields, m_reporter ) );
|
||||
m_models.push_back( SIM_MODEL::Create( baseModel, aPins, aFields, aReporter ) );
|
||||
|
||||
return { modelName, *m_models.back() };
|
||||
}
|
||||
|
|
|
@ -40,36 +40,39 @@ class SCH_SYMBOL;
|
|||
class SIM_LIB_MGR
|
||||
{
|
||||
public:
|
||||
SIM_LIB_MGR( const PROJECT* aPrj, REPORTER* aReporter = nullptr );
|
||||
SIM_LIB_MGR( const PROJECT* aPrj );
|
||||
virtual ~SIM_LIB_MGR() = default;
|
||||
|
||||
void SetReporter( REPORTER* aReporter ) { m_reporter = aReporter; }
|
||||
void SetForceFullParse() { m_forceFullParse = true; }
|
||||
|
||||
void Clear();
|
||||
|
||||
void SetLibrary( const wxString& aLibraryPath );
|
||||
void SetLibrary( const wxString& aLibraryPath, REPORTER& aReporter );
|
||||
|
||||
SIM_MODEL& CreateModel( SIM_MODEL::TYPE aType, const std::vector<LIB_PIN*>& aPins );
|
||||
SIM_MODEL& CreateModel( SIM_MODEL::TYPE aType, const std::vector<LIB_PIN*>& aPins,
|
||||
REPORTER& aReporter );
|
||||
|
||||
SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector<LIB_PIN*>& aPins );
|
||||
SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector<LIB_PIN*>& aPins,
|
||||
REPORTER& aReporter );
|
||||
|
||||
template <typename T>
|
||||
SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector<LIB_PIN*>& aPins,
|
||||
const std::vector<T>& aFields );
|
||||
const std::vector<T>& aFields, REPORTER& aReporter );
|
||||
|
||||
// TODO: The argument can be made const.
|
||||
SIM_LIBRARY::MODEL CreateModel( const SCH_SHEET_PATH* aSheetPath, SCH_SYMBOL& aSymbol );
|
||||
SIM_LIBRARY::MODEL CreateModel( const SCH_SHEET_PATH* aSheetPath, SCH_SYMBOL& aSymbol,
|
||||
REPORTER& aReporter );
|
||||
|
||||
template <typename T>
|
||||
SIM_LIBRARY::MODEL CreateModel( const std::vector<T>& aFields,
|
||||
const std::vector<LIB_PIN*>& aPins, bool aResolved );
|
||||
const std::vector<LIB_PIN*>& aPins, bool aResolved,
|
||||
REPORTER& aReporter );
|
||||
|
||||
template <typename T>
|
||||
SIM_LIBRARY::MODEL CreateModel( const wxString& aLibraryPath,
|
||||
const std::string& aBaseModelName,
|
||||
const std::vector<T>& aFields,
|
||||
const std::vector<LIB_PIN*>& aPins );
|
||||
const std::vector<LIB_PIN*>& aPins, REPORTER& aReporter );
|
||||
|
||||
void SetModel( int aIndex, std::unique_ptr<SIM_MODEL> aModel );
|
||||
|
||||
|
@ -81,7 +84,6 @@ public:
|
|||
|
||||
private:
|
||||
const PROJECT* m_project;
|
||||
REPORTER* m_reporter;
|
||||
bool m_forceFullParse;
|
||||
std::map<wxString, std::unique_ptr<SIM_LIBRARY>> m_libraries;
|
||||
std::vector<std::unique_ptr<SIM_MODEL>> m_models;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
|
||||
std::unique_ptr<SIM_LIBRARY>
|
||||
SIM_LIBRARY::Create( const wxString& aFilePath, bool aForceFullParse, REPORTER* aReporter,
|
||||
SIM_LIBRARY::Create( const wxString& aFilePath, bool aForceFullParse, REPORTER& aReporter,
|
||||
std::function<wxString( const wxString&, const wxString& )>* aResolver )
|
||||
{
|
||||
std::unique_ptr<SIM_LIBRARY> library;
|
||||
|
@ -40,7 +40,6 @@ SIM_LIBRARY::Create( const wxString& aFilePath, bool aForceFullParse, REPORTER*
|
|||
else
|
||||
library = std::make_unique<SIM_LIBRARY_SPICE>( aForceFullParse );
|
||||
|
||||
library->m_reporter = aReporter;
|
||||
library->m_pathResolver = aResolver;
|
||||
library->ReadFile( aFilePath, aReporter );
|
||||
|
||||
|
@ -48,7 +47,7 @@ SIM_LIBRARY::Create( const wxString& aFilePath, bool aForceFullParse, REPORTER*
|
|||
}
|
||||
|
||||
|
||||
void SIM_LIBRARY::ReadFile( const wxString& aFilePath, REPORTER* aReporter )
|
||||
void SIM_LIBRARY::ReadFile( const wxString& aFilePath, REPORTER& aReporter )
|
||||
{
|
||||
m_filePath = aFilePath;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
* @return The library loaded in a newly constructed object.
|
||||
*/
|
||||
static std::unique_ptr<SIM_LIBRARY>
|
||||
Create( const wxString& aFilePath, bool aForceFullParse, REPORTER* aReporter,
|
||||
Create( const wxString& aFilePath, bool aForceFullParse, REPORTER& aReporter,
|
||||
std::function<wxString( const wxString&, const wxString& )>* aResolver );
|
||||
|
||||
/**
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
* @param aFilePath Path to the file.
|
||||
* @throw IO_ERROR on read or parsing error.
|
||||
*/
|
||||
virtual void ReadFile( const wxString& aFilePath, REPORTER* aReporter ) = 0;
|
||||
virtual void ReadFile( const wxString& aFilePath, REPORTER& aReporter ) = 0;
|
||||
|
||||
SIM_MODEL* FindModel( const std::string& aModelName ) const;
|
||||
|
||||
|
@ -80,8 +80,6 @@ protected:
|
|||
std::function<wxString( const wxString&, const wxString& )>* m_pathResolver;
|
||||
|
||||
std::string m_filePath;
|
||||
|
||||
REPORTER* m_reporter = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -29,14 +29,14 @@
|
|||
#include <lib_pin.h>
|
||||
|
||||
|
||||
void SIM_LIBRARY_KIBIS::ReadFile( const wxString& aFilePath, REPORTER* aReporter )
|
||||
void SIM_LIBRARY_KIBIS::ReadFile( const wxString& aFilePath, REPORTER& aReporter )
|
||||
{
|
||||
SIM_LIBRARY::ReadFile( aFilePath, aReporter );
|
||||
m_kibis = KIBIS( aFilePath.ToStdString(), m_reporter );
|
||||
m_kibis = KIBIS( aFilePath.ToStdString(), &aReporter );
|
||||
|
||||
if( !m_kibis.m_valid )
|
||||
{
|
||||
aReporter->Report( wxString::Format( _( "Invalid IBIS file '%s'" ), aFilePath ),
|
||||
aReporter.Report( wxString::Format( _( "Invalid IBIS file '%s'" ), aFilePath ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
static constexpr auto DIFF_FIELD = "Sim.Ibis.Diff";
|
||||
|
||||
// @copydoc SIM_LIBRARY::ReadFile()
|
||||
void ReadFile( const wxString& aFilePath, REPORTER* aReporter ) override;
|
||||
void ReadFile( const wxString& aFilePath, REPORTER& aReporter ) override;
|
||||
|
||||
bool InitModel( SIM_MODEL_KIBIS& aModel, wxString aCompName );
|
||||
bool isPinDiff( const std::string& aComp, const std::string& aPinNumber ) const;
|
||||
|
|
|
@ -33,7 +33,7 @@ SIM_LIBRARY_SPICE::SIM_LIBRARY_SPICE( bool aForceFullParse ) :
|
|||
}
|
||||
|
||||
|
||||
void SIM_LIBRARY_SPICE::ReadFile( const wxString& aFilePath, REPORTER* aReporter )
|
||||
void SIM_LIBRARY_SPICE::ReadFile( const wxString& aFilePath, REPORTER& aReporter )
|
||||
{
|
||||
SIM_LIBRARY::ReadFile( aFilePath, aReporter );
|
||||
m_spiceLibraryParser->ReadFile( aFilePath, aReporter );
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
SIM_LIBRARY_SPICE( bool aForceFullParse );
|
||||
|
||||
// @copydoc SIM_LIBRARY::ReadFile()
|
||||
void ReadFile( const wxString& aFilePath, REPORTER* aReporter ) override;
|
||||
void ReadFile( const wxString& aFilePath, REPORTER& aReporter ) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<SPICE_LIBRARY_PARSER> m_spiceLibraryParser;
|
||||
|
|
|
@ -373,12 +373,12 @@ SIM_MODEL::SPICE_INFO SIM_MODEL::SpiceInfo( TYPE aType )
|
|||
|
||||
|
||||
template TYPE SIM_MODEL::ReadTypeFromFields( const std::vector<SCH_FIELD>& aFields,
|
||||
REPORTER* aReporter );
|
||||
REPORTER& aReporter );
|
||||
template TYPE SIM_MODEL::ReadTypeFromFields( const std::vector<LIB_FIELD>& aFields,
|
||||
REPORTER* aReporter );
|
||||
REPORTER& aReporter );
|
||||
|
||||
template <typename T>
|
||||
TYPE SIM_MODEL::ReadTypeFromFields( const std::vector<T>& aFields, REPORTER* aReporter )
|
||||
TYPE SIM_MODEL::ReadTypeFromFields( const std::vector<T>& aFields, REPORTER& aReporter )
|
||||
{
|
||||
std::string deviceTypeFieldValue = GetFieldValue( &aFields, SIM_DEVICE_TYPE_FIELD );
|
||||
std::string typeFieldValue = GetFieldValue( &aFields, SIM_TYPE_FIELD );
|
||||
|
@ -398,21 +398,18 @@ TYPE SIM_MODEL::ReadTypeFromFields( const std::vector<T>& aFields, REPORTER* aRe
|
|||
if( typeFieldValue != "" )
|
||||
return TYPE::NONE;
|
||||
|
||||
if( aReporter )
|
||||
{
|
||||
if( aFields.size() > REFERENCE_FIELD )
|
||||
{
|
||||
aReporter->Report( wxString::Format( _( "No simulation model definition found for "
|
||||
aReporter.Report( wxString::Format( _( "No simulation model definition found for "
|
||||
"symbol '%s'." ),
|
||||
aFields[REFERENCE_FIELD].GetText() ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
}
|
||||
else
|
||||
{
|
||||
aReporter->Report( _( "No simulation model definition found." ),
|
||||
aReporter.Report( _( "No simulation model definition found." ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
return TYPE::NONE;
|
||||
}
|
||||
|
@ -449,7 +446,7 @@ void SIM_MODEL::WriteFields( std::vector<LIB_FIELD>& aFields ) const
|
|||
|
||||
|
||||
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( TYPE aType, const std::vector<LIB_PIN*>& aPins,
|
||||
REPORTER* aReporter )
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
std::unique_ptr<SIM_MODEL> model = Create( aType );
|
||||
|
||||
|
@ -469,7 +466,7 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( TYPE aType, const std::vector<LIB_
|
|||
|
||||
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
REPORTER* aReporter )
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
std::unique_ptr<SIM_MODEL> model;
|
||||
|
||||
|
@ -508,17 +505,18 @@ template <typename T>
|
|||
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
const std::vector<T>& aFields,
|
||||
REPORTER* aReporter )
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
std::unique_ptr<SIM_MODEL> model;
|
||||
|
||||
if( aBaseModel )
|
||||
{
|
||||
NULL_REPORTER devnull;
|
||||
TYPE type = aBaseModel->GetType();
|
||||
|
||||
// No REPORTER here; we're just checking to see if we have an override
|
||||
if( ReadTypeFromFields( aFields, nullptr ) != TYPE::NONE )
|
||||
type = ReadTypeFromFields( aFields, nullptr );
|
||||
if( ReadTypeFromFields( aFields, devnull ) != TYPE::NONE )
|
||||
type = ReadTypeFromFields( aFields, devnull );
|
||||
|
||||
if( dynamic_cast<const SIM_MODEL_SPICE_FALLBACK*>( aBaseModel ) )
|
||||
model = std::make_unique<SIM_MODEL_SPICE_FALLBACK>( type );
|
||||
|
@ -541,15 +539,12 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel,
|
|||
}
|
||||
catch( IO_ERROR& err )
|
||||
{
|
||||
if( aReporter )
|
||||
{
|
||||
aReporter->Report( wxString::Format( _( "Error reading simulation model from "
|
||||
aReporter.Report( wxString::Format( _( "Error reading simulation model from "
|
||||
"symbol '%s':\n%s" ),
|
||||
aFields[REFERENCE_FIELD].GetText(),
|
||||
err.Problem() ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
@ -557,18 +552,18 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel,
|
|||
template std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
const std::vector<SCH_FIELD>& aFields,
|
||||
REPORTER* aReporter );
|
||||
REPORTER& aReporter );
|
||||
|
||||
template std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
const std::vector<LIB_FIELD>& aFields,
|
||||
REPORTER* aReporter );
|
||||
REPORTER& aReporter );
|
||||
|
||||
|
||||
template <typename T>
|
||||
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const std::vector<T>& aFields,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
bool aResolved, REPORTER* aReporter )
|
||||
bool aResolved, REPORTER& aReporter )
|
||||
{
|
||||
TYPE type = ReadTypeFromFields( aFields, aReporter );
|
||||
std::unique_ptr<SIM_MODEL> model = SIM_MODEL::Create( type );
|
||||
|
@ -581,7 +576,7 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const std::vector<T>& aFields,
|
|||
{
|
||||
if( !aResolved )
|
||||
{
|
||||
aReporter->Report( parse_err.What(), RPT_SEVERITY_ERROR );
|
||||
aReporter.Report( parse_err.What(), RPT_SEVERITY_ERROR );
|
||||
return model;
|
||||
}
|
||||
|
||||
|
@ -603,26 +598,23 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const std::vector<T>& aFields,
|
|||
catch( const IO_ERROR& err )
|
||||
{
|
||||
// We own the pin syntax, so if we can't parse it then there's an error.
|
||||
if( aReporter )
|
||||
{
|
||||
aReporter->Report( wxString::Format( _( "Error reading simulation model from "
|
||||
aReporter.Report( wxString::Format( _( "Error reading simulation model from "
|
||||
"symbol '%s':\n%s" ),
|
||||
aFields[REFERENCE_FIELD].GetText(),
|
||||
err.Problem() ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
template std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const std::vector<SCH_FIELD>& aFields,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
bool aResolved, REPORTER* aReporter );
|
||||
bool aResolved, REPORTER& aReporter );
|
||||
template std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const std::vector<LIB_FIELD>& aFields,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
bool aResolved, REPORTER* aReporter );
|
||||
bool aResolved, REPORTER& aReporter );
|
||||
|
||||
|
||||
template <typename T>
|
||||
|
@ -1729,7 +1721,7 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject )
|
|||
{
|
||||
wxString msg;
|
||||
WX_STRING_REPORTER reporter( &msg );
|
||||
SIM_LIB_MGR libMgr( aProject, &reporter );
|
||||
SIM_LIB_MGR libMgr( aProject );
|
||||
std::vector<T_field> emptyFields;
|
||||
|
||||
// Pull out any following parameters from model name
|
||||
|
@ -1737,7 +1729,7 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject )
|
|||
spiceModelInfo.m_Text = spiceModel;
|
||||
|
||||
SIM_LIBRARY::MODEL model = libMgr.CreateModel( spiceLib, spiceModel.ToStdString(),
|
||||
emptyFields, sourcePins );
|
||||
emptyFields, sourcePins, reporter );
|
||||
|
||||
if( reporter.HasMessage() )
|
||||
libraryModel = false; // Fall back to raw spice model
|
||||
|
|
|
@ -408,25 +408,25 @@ public:
|
|||
|
||||
|
||||
template <typename T>
|
||||
static TYPE ReadTypeFromFields( const std::vector<T>& aFields, REPORTER* aReporter );
|
||||
static TYPE ReadTypeFromFields( const std::vector<T>& aFields, REPORTER& aReporter );
|
||||
|
||||
static std::unique_ptr<SIM_MODEL> Create( TYPE aType, const std::vector<LIB_PIN*>& aPins,
|
||||
REPORTER* aReporter );
|
||||
REPORTER& aReporter );
|
||||
|
||||
static std::unique_ptr<SIM_MODEL> Create( const SIM_MODEL* aBaseModel,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
REPORTER* aReporter );
|
||||
REPORTER& aReporter );
|
||||
|
||||
template <typename T>
|
||||
static std::unique_ptr<SIM_MODEL> Create( const SIM_MODEL* aBaseModel,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
const std::vector<T>& aFields,
|
||||
REPORTER* aReporter );
|
||||
REPORTER& aReporter );
|
||||
|
||||
template <typename T>
|
||||
static std::unique_ptr<SIM_MODEL> Create( const std::vector<T>& aFields,
|
||||
const std::vector<LIB_PIN*>& aPins,
|
||||
bool aResolved, REPORTER* aReporter );
|
||||
bool aResolved, REPORTER& aReporter );
|
||||
|
||||
template <typename T>
|
||||
static std::string GetFieldValue( const std::vector<T>* aFields, const wxString& aFieldName,
|
||||
|
|
|
@ -1395,8 +1395,9 @@ void SIMULATOR_FRAME_UI::UpdateTunerValue( const SCH_SHEET_PATH& aSheetPath, con
|
|||
return;
|
||||
}
|
||||
|
||||
NULL_REPORTER devnull;
|
||||
SIM_LIB_MGR mgr( &m_schematicFrame->Prj() );
|
||||
SIM_MODEL& model = mgr.CreateModel( &aSheetPath, *symbol ).model;
|
||||
SIM_MODEL& model = mgr.CreateModel( &aSheetPath, *symbol, devnull ).model;
|
||||
|
||||
const SIM_MODEL::PARAM* tunerParam = model.GetTunerParam();
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ void SPICE_LIBRARY_PARSER::parseFile( const wxString &aFilePath, REPORTER& aRepo
|
|||
}
|
||||
|
||||
|
||||
void SPICE_LIBRARY_PARSER::ReadFile( const wxString& aFilePath, REPORTER* aReporter )
|
||||
void SPICE_LIBRARY_PARSER::ReadFile( const wxString& aFilePath, REPORTER& aReporter )
|
||||
{
|
||||
m_library.m_models.clear();
|
||||
m_library.m_modelNames.clear();
|
||||
|
@ -215,7 +215,7 @@ void SPICE_LIBRARY_PARSER::ReadFile( const wxString& aFilePath, REPORTER* aRepor
|
|||
// (cmp/standard.bjt, cmp/standard.mos, etc.) have copious error which trip up our parser,
|
||||
// and our parser is *really* slow on such large files (nearly 5 seconds on my dev machine).
|
||||
if( !m_forceFullParse && aFilePath.Contains( wxS( "/LTspiceXVII/lib/cmp/standard" ) ) )
|
||||
readFallbacks( aFilePath, *aReporter );
|
||||
readFallbacks( aFilePath, aReporter );
|
||||
else
|
||||
parseFile( aFilePath, *aReporter );
|
||||
parseFile( aFilePath, aReporter );
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
virtual ~SPICE_LIBRARY_PARSER()
|
||||
{};
|
||||
|
||||
virtual void ReadFile( const wxString& aFilePath, REPORTER* aReporter );
|
||||
virtual void ReadFile( const wxString& aFilePath, REPORTER& aReporter );
|
||||
|
||||
protected:
|
||||
void readFallbacks( const wxString& aFilePath, REPORTER& aReporter );
|
||||
|
|
|
@ -545,9 +545,9 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
|
|||
|
||||
wxString msg;
|
||||
WX_STRING_REPORTER reporter( &msg );
|
||||
SIM_LIB_MGR mgr( &m_frame->Prj(), &reporter );
|
||||
SIM_LIB_MGR mgr( &m_frame->Prj() );
|
||||
|
||||
SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol ).model;
|
||||
SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol, reporter ).model;
|
||||
|
||||
if( reporter.HasMessage() )
|
||||
THROW_IO_ERROR( msg );
|
||||
|
|
|
@ -46,9 +46,11 @@ public:
|
|||
|
||||
void LoadLibrary( const std::string& aBaseName )
|
||||
{
|
||||
NULL_REPORTER devnull;
|
||||
std::string path = GetLibraryPath( aBaseName );
|
||||
|
||||
m_library = std::make_unique<SIM_LIBRARY_SPICE>( true );
|
||||
m_library->ReadFile( path, nullptr );
|
||||
m_library->ReadFile( path, devnull );
|
||||
}
|
||||
|
||||
void CompareToUsualDiodeModel( const SIM_MODEL& aModel, const std::string& aModelName, int aModelIndex )
|
||||
|
|
Loading…
Reference in New Issue