Sim Model Editor: Use SIM_LIB_MGR class to manage library models

This commit is contained in:
Mikolaj Wielgus 2022-11-19 01:45:28 +01:00
parent 21ae2dd1c0
commit 9b6f7d5db7
9 changed files with 158 additions and 129 deletions

View File

@ -46,10 +46,10 @@ DIALOG_SIM_MODEL<T>::DIALOG_SIM_MODEL( wxWindow* aParent, SCH_SYMBOL& aSymbol,
: DIALOG_SIM_MODEL_BASE( aParent ), : DIALOG_SIM_MODEL_BASE( aParent ),
m_symbol( aSymbol ), m_symbol( aSymbol ),
m_fields( aFields ), m_fields( aFields ),
m_builtinModelMgr( Prj() ), m_libraryModelsMgr( Prj() ),
m_curModelType( SIM_MODEL::TYPE::NONE ), m_builtinModelsMgr( Prj() ),
m_library( std::make_shared<SIM_LIBRARY_SPICE>() ),
m_prevModel( nullptr ), m_prevModel( nullptr ),
m_curModelType( SIM_MODEL::TYPE::NONE ),
m_scintillaTricks( nullptr ), m_scintillaTricks( nullptr ),
m_wasCodePreviewUpdated( true ), m_wasCodePreviewUpdated( true ),
m_firstCategory( nullptr ), m_firstCategory( nullptr ),
@ -143,7 +143,6 @@ bool DIALOG_SIM_MODEL<T>::TransferDataToWindow()
wxCommandEvent dummyEvent; wxCommandEvent dummyEvent;
int pinCount = m_sortedSymbolPins.size(); int pinCount = m_sortedSymbolPins.size();
std::string ref = SIM_MODEL::GetFieldValue( &m_fields, SIM_MODEL::REFERENCE_FIELD );
std::string libraryFilename = SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY::LIBRARY_FIELD ); std::string libraryFilename = SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY::LIBRARY_FIELD );
if( libraryFilename != "" ) if( libraryFilename != "" )
@ -159,7 +158,7 @@ bool DIALOG_SIM_MODEL<T>::TransferDataToWindow()
if( isIbisLoaded() && ( m_modelNameCombobox->GetSelection() >= 0 ) ) if( isIbisLoaded() && ( m_modelNameCombobox->GetSelection() >= 0 ) )
{ {
SIM_MODEL_KIBIS* kibismodel = dynamic_cast<SIM_MODEL_KIBIS*>( SIM_MODEL_KIBIS* kibismodel = dynamic_cast<SIM_MODEL_KIBIS*>(
m_libraryModels.at( m_modelNameCombobox->GetSelection() ).get() ); &m_libraryModelsMgr.GetModels().at( m_modelNameCombobox->GetSelection() ).get() );
if( kibismodel ) if( kibismodel )
{ {
@ -172,9 +171,9 @@ bool DIALOG_SIM_MODEL<T>::TransferDataToWindow()
if( strs.first if( strs.first
== SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY_KIBIS::PIN_FIELD ) ) == SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY_KIBIS::PIN_FIELD ) )
{ {
kibismodel->ChangePin( auto kibisLibrary = static_cast<const SIM_LIBRARY_KIBIS*>( library() );
*( std::dynamic_pointer_cast<SIM_LIBRARY_KIBIS>( m_library ) ),
strs.first ); kibismodel->ChangePin( *kibisLibrary, strs.first );
m_ibisPinCombobox->SetSelection( static_cast<int>( i ) ); m_ibisPinCombobox->SetSelection( static_cast<int>( i ) );
break; break;
} }
@ -214,9 +213,9 @@ bool DIALOG_SIM_MODEL<T>::TransferDataToWindow()
try try
{ {
if( m_useInstanceModelRadioButton->GetValue() && type == m_curModelType ) if( m_useInstanceModelRadioButton->GetValue() && type == m_curModelType )
m_builtinModelMgr.CreateModel( m_fields, m_sortedSymbolPins.size() ); m_builtinModelsMgr.CreateModel( m_fields, pinCount );
else else
m_builtinModelMgr.CreateModel( type, m_sortedSymbolPins.size() ); m_builtinModelsMgr.CreateModel( type, pinCount );
} }
catch( const IO_ERROR& e ) catch( const IO_ERROR& e )
{ {
@ -256,9 +255,9 @@ bool DIALOG_SIM_MODEL<T>::TransferDataFromWindow()
std::string path; std::string path;
if( m_useLibraryModelRadioButton->GetValue() || isIbisLoaded() ) if( ( library() && m_useLibraryModelRadioButton->GetValue() ) || isIbisLoaded() )
{ {
path = m_library->GetFilePath(); path = library()->GetFilePath();
wxFileName fn( path ); wxFileName fn( path );
if( fn.MakeRelativeTo( Prj().GetProjectPath() ) && !fn.GetFullPath().StartsWith( ".." ) ) if( fn.MakeRelativeTo( Prj().GetProjectPath() ) && !fn.GetFullPath().StartsWith( ".." ) )
@ -270,7 +269,7 @@ bool DIALOG_SIM_MODEL<T>::TransferDataFromWindow()
if( isIbisLoaded() ) if( isIbisLoaded() )
{ {
SIM_MODEL_KIBIS* kibismodel = dynamic_cast<SIM_MODEL_KIBIS*>( SIM_MODEL_KIBIS* kibismodel = dynamic_cast<SIM_MODEL_KIBIS*>(
m_libraryModels.at( m_modelNameCombobox->GetSelection() ).get() ); &m_libraryModelsMgr.GetModels().at( m_modelNameCombobox->GetSelection() ).get() );
if( kibismodel ) if( kibismodel )
{ {
@ -584,51 +583,21 @@ void DIALOG_SIM_MODEL<T>::removeOrphanedPinAssignments()
template <typename T> template <typename T>
void DIALOG_SIM_MODEL<T>::loadLibrary( const wxString& aFilePath ) void DIALOG_SIM_MODEL<T>::loadLibrary( const wxString& aLibraryPath )
{ {
const wxString absolutePath = Prj().AbsolutePath( aFilePath ); m_libraryModelsMgr.Clear();
m_libraryModelsMgr.CreateLibrary( std::string( aLibraryPath.ToUTF8() ) );
if( absolutePath.EndsWith( ".ibs" ) )
m_library = std::make_shared<SIM_LIBRARY_KIBIS>();
else
m_library = std::make_shared<SIM_LIBRARY_SPICE>();
try try
{ {
m_library->ReadFile( std::string( absolutePath.ToUTF8() ) ); std::string modelName = SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY::NAME_FIELD );
}
catch( const IO_ERROR& e )
{
DisplayErrorMessage( this, wxString::Format( _( "Failed reading model library '%s'." ),
absolutePath ),
e.What() );
return;
}
m_tclibraryPathName->ChangeValue( aFilePath ); for( auto& [baseModelName, baseModel] : library()->GetModels() )
m_libraryModels.clear();
try
{
for( auto& [baseModelName, baseModel] : m_library->GetModels() )
{ {
wxString expectedModelName = if( baseModelName == modelName )
SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY::NAME_FIELD ); m_libraryModelsMgr.CreateModel( baseModel, m_sortedSymbolPins.size(), m_fields );
// Only the current model is initialized from fields. Others have default
// initialization.
if( baseModelName == expectedModelName )
{
//TODO: it's not cur model.
m_libraryModels.push_back(
SIM_MODEL::Create( baseModel, m_sortedSymbolPins.size(), m_fields ) );
}
else else
{ m_libraryModelsMgr.CreateModel( baseModel, m_sortedSymbolPins.size() );
m_libraryModels.push_back( SIM_MODEL::Create( baseModel, m_sortedSymbolPins.size() ) );
}
} }
} }
catch( const IO_ERROR& e ) catch( const IO_ERROR& e )
@ -638,7 +607,7 @@ void DIALOG_SIM_MODEL<T>::loadLibrary( const wxString& aFilePath )
wxArrayString modelNames; wxArrayString modelNames;
for( auto& [modelName, model] : m_library->GetModels() ) for( auto& [modelName, model] : library()->GetModels() )
modelNames.Add( modelName ); modelNames.Add( modelName );
auto validator = dynamic_cast<MODEL_NAME_VALIDATOR*>( m_modelNameCombobox->GetValidator() ); auto validator = dynamic_cast<MODEL_NAME_VALIDATOR*>( m_modelNameCombobox->GetValidator() );
@ -646,6 +615,7 @@ void DIALOG_SIM_MODEL<T>::loadLibrary( const wxString& aFilePath )
if( validator ) if( validator )
validator->SetIncludes( modelNames ); validator->SetIncludes( modelNames );
m_tclibraryPathName->ChangeValue( aLibraryPath );
m_modelNameCombobox->Set( modelNames ); m_modelNameCombobox->Set( modelNames );
m_useLibraryModelRadioButton->SetValue( true ); m_useLibraryModelRadioButton->SetValue( true );
@ -843,10 +813,20 @@ SIM_MODEL& DIALOG_SIM_MODEL<T>::curModel() const
if( m_useLibraryModelRadioButton->GetValue() if( m_useLibraryModelRadioButton->GetValue()
&& m_modelNameCombobox->GetSelection() != wxNOT_FOUND ) && m_modelNameCombobox->GetSelection() != wxNOT_FOUND )
{ {
return *m_libraryModels.at( m_modelNameCombobox->GetSelection() ); return m_libraryModelsMgr.GetModels().at( m_modelNameCombobox->GetSelection() ).get();
} }
else else
return m_builtinModelMgr.GetModels().at( static_cast<int>( m_curModelType ) ); return m_builtinModelsMgr.GetModels().at( static_cast<int>( m_curModelType ) );
}
template <typename T>
const SIM_LIBRARY* DIALOG_SIM_MODEL<T>::library() const
{
if( m_libraryModelsMgr.GetLibraries().size() == 1 )
return &m_libraryModelsMgr.GetLibraries().begin()->second.get();
return nullptr;
} }
@ -1000,24 +980,19 @@ void DIALOG_SIM_MODEL<T>::onIbisPinCombobox( wxCommandEvent& aEvent )
{ {
wxArrayString modelLabels; wxArrayString modelLabels;
SIM_MODEL_KIBIS* modelkibis = dynamic_cast<SIM_MODEL_KIBIS*>( &curModel() ); SIM_MODEL_KIBIS& kibisModel = static_cast<SIM_MODEL_KIBIS&>( curModel() );
if( !modelkibis ) std::vector<std::pair<std::string, std::string>> strs = kibisModel.GetIbisPins();
{
wxFAIL;
return;
}
std::vector<std::pair<std::string, std::string>> strs = modelkibis->GetIbisPins();
std::string pinNumber = strs.at( m_ibisPinCombobox->GetSelection() ).first; std::string pinNumber = strs.at( m_ibisPinCombobox->GetSelection() ).first;
modelkibis->ChangePin( *std::dynamic_pointer_cast<SIM_LIBRARY_KIBIS>( m_library ), const SIM_LIBRARY_KIBIS* kibisLibrary = dynamic_cast<const SIM_LIBRARY_KIBIS*>( library() );
pinNumber );
modelkibis->m_enableDiff = dynamic_cast<SIM_LIBRARY_KIBIS*>( m_library.get() ) kibisModel.ChangePin( *kibisLibrary, pinNumber );
->isPinDiff( modelkibis->GetComponentName(), pinNumber );
for( wxString modelName : modelkibis->GetIbisModels() ) kibisModel.m_enableDiff = static_cast<const SIM_LIBRARY_KIBIS*>( library() )
->isPinDiff( kibisModel.GetComponentName(), pinNumber );
for( wxString modelName : kibisModel.GetIbisModels() )
modelLabels.Add( modelName ); modelLabels.Add( modelName );
m_ibisModelCombobox->Set( modelLabels ); m_ibisModelCombobox->Set( modelLabels );
@ -1096,11 +1071,13 @@ void DIALOG_SIM_MODEL<T>::onTypeChoice( wxCommandEvent& aEvent )
|| type == SIM_MODEL::TYPE::KIBIS_DRIVER_RECT || type == SIM_MODEL::TYPE::KIBIS_DRIVER_RECT
|| type == SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS ) ) || type == SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS ) )
{ {
SIM_MODEL_KIBIS* kibismodel = dynamic_cast<SIM_MODEL_KIBIS*>( SIM_MODEL_KIBIS& kibisModel = static_cast<SIM_MODEL_KIBIS&>(
m_libraryModels.at( m_modelNameCombobox->GetSelection() ).get() ); m_libraryModelsMgr.GetModels().at( m_modelNameCombobox->GetSelection() ).get() );
m_libraryModels.at( m_modelNameCombobox->GetSelection() ) = m_libraryModelsMgr.SetModel( m_modelNameCombobox->GetSelection(),
std::make_unique<SIM_MODEL_KIBIS>( type, *kibismodel, m_fields ); std::make_unique<SIM_MODEL_KIBIS>( type,
kibisModel,
m_fields ) );
} }
m_curModelType = type; m_curModelType = type;

View File

@ -99,7 +99,7 @@ private:
void removeOrphanedPinAssignments(); void removeOrphanedPinAssignments();
void loadLibrary( const wxString& aFilePath ); void loadLibrary( const wxString& aLibraryPath );
void addParamPropertyIfRelevant( int aParamIndex ); void addParamPropertyIfRelevant( int aParamIndex );
wxPGProperty* newParamProperty( int aParamIndex ) const; wxPGProperty* newParamProperty( int aParamIndex ) const;
@ -107,6 +107,7 @@ private:
int findSymbolPinRow( const wxString& aSymbolPinNumber ) const; int findSymbolPinRow( const wxString& aSymbolPinNumber ) const;
SIM_MODEL& curModel() const; SIM_MODEL& curModel() const;
const SIM_LIBRARY* library() const;
wxString getSymbolPinString( int aSymbolPinNumber ) const; wxString getSymbolPinString( int aSymbolPinNumber ) const;
wxString getModelPinString( int aModelPinIndex ) const; wxString getModelPinString( int aModelPinIndex ) const;
@ -133,21 +134,20 @@ private:
void onParamGridSetFocus( wxFocusEvent& aEvent ); void onParamGridSetFocus( wxFocusEvent& aEvent );
void onParamGridSelectionChange( wxPropertyGridEvent& aEvent ); void onParamGridSelectionChange( wxPropertyGridEvent& aEvent );
bool isIbisLoaded() { return dynamic_cast<SIM_LIBRARY_KIBIS*>( m_library.get() ); } bool isIbisLoaded() { return dynamic_cast<const SIM_LIBRARY_KIBIS*>( library() ); }
private: private:
SCH_SYMBOL& m_symbol; SCH_SYMBOL& m_symbol;
std::vector<T>& m_fields; std::vector<T>& m_fields;
SIM_LIB_MGR m_builtinModelMgr; SIM_LIB_MGR m_libraryModelsMgr;
SIM_LIB_MGR m_builtinModelsMgr;
const SIM_MODEL* m_prevModel;
std::vector<LIB_PIN*> m_sortedSymbolPins; std::vector<LIB_PIN*> m_sortedSymbolPins;
std::map<SIM_MODEL::DEVICE_TYPE_, SIM_MODEL::TYPE> m_curModelTypeOfDeviceType; std::map<SIM_MODEL::DEVICE_TYPE_, SIM_MODEL::TYPE> m_curModelTypeOfDeviceType;
SIM_MODEL::TYPE m_curModelType; SIM_MODEL::TYPE m_curModelType;
std::shared_ptr<SIM_LIBRARY> m_library;
std::vector<std::unique_ptr<SIM_MODEL>> m_libraryModels;
const SIM_MODEL* m_prevModel;
MODEL_NAME_VALIDATOR m_modelNameValidator; MODEL_NAME_VALIDATOR m_modelNameValidator;
SCINTILLA_TRICKS* m_scintillaTricks; SCINTILLA_TRICKS* m_scintillaTricks;
bool m_wasCodePreviewUpdated; bool m_wasCodePreviewUpdated;

View File

@ -1529,4 +1529,4 @@ std::vector<std::pair<int, double>> KIBIS_WAVEFORM_PRBS::GenerateBitSequence()
} while ( ++bits < m_bits ); } while ( ++bits < m_bits );
return bitSequence; return bitSequence;
} }

View File

@ -35,9 +35,18 @@ SIM_LIB_MGR::SIM_LIB_MGR( const PROJECT& aPrj ) : m_project( aPrj )
} }
void SIM_LIB_MGR::Clear()
{
m_libraries.clear();
m_models.clear();
}
SIM_LIBRARY& SIM_LIB_MGR::CreateLibrary( const std::string& aLibraryPath ) SIM_LIBRARY& SIM_LIB_MGR::CreateLibrary( const std::string& aLibraryPath )
{ {
auto it = m_libraries.try_emplace( aLibraryPath, SIM_LIBRARY::Create( aLibraryPath ) ).first; std::string absolutePath = std::string( m_project.AbsolutePath( aLibraryPath ).ToUTF8() );
auto it = m_libraries.try_emplace( aLibraryPath, SIM_LIBRARY::Create( absolutePath ) ).first;
return *it->second; return *it->second;
} }
@ -56,66 +65,94 @@ SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL& aBaseModel, int aSymbolPin
} }
template <typename T>
SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL& aBaseModel, int aSymbolPinCount,
const std::vector<T>& aFields )
{
m_models.push_back( SIM_MODEL::Create( aBaseModel, aSymbolPinCount, aFields ) );
return *m_models.back();
}
template SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL& aBaseModel, int aSymbolPinCount,
const std::vector<SCH_FIELD>& aFields );
template SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL& aBaseModel, int aSymbolPinCount,
const std::vector<LIB_FIELD>& aFields );
SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( SCH_SYMBOL& aSymbol ) SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( SCH_SYMBOL& aSymbol )
{ {
return CreateModel( aSymbol.GetFields(), static_cast<int>( aSymbol.GetLibPins().size() ) ); return CreateModel( aSymbol.GetFields(), static_cast<int>( aSymbol.GetLibPins().size() ) );
} }
template <typename T>
SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector<T>& aFields, int aSymbolPinCount )
{
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, aSymbolPinCount );
else
{
m_models.push_back( SIM_MODEL::Create( aSymbolPinCount, aFields ) );
return { baseModelName, *m_models.back() };
}
}
template SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector<SCH_FIELD>& aFields, template SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector<SCH_FIELD>& aFields,
int aSymbolPinCount ); int aSymbolPinCount );
template SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector<LIB_FIELD>& aFields, template SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector<LIB_FIELD>& aFields,
int aSymbolPinCount ); int aSymbolPinCount );
template <typename T> template <typename T>
SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector<T>& aFields, int aSymbolPinCount ) SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::string& aLibraryPath,
const std::string& aBaseModelName,
const std::vector<T>& aFields,
int aSymbolPinCount )
{ {
std::string libraryPath = SIM_MODEL::GetFieldValue( &aFields, SIM_LIBRARY::LIBRARY_FIELD ); std::string absolutePath = std::string( m_project.AbsolutePath( aLibraryPath ).ToUTF8() );
std::string baseModelName; SIM_LIBRARY* library = nullptr;
if( libraryPath != "" ) try
{ {
std::string absolutePath = std::string( m_project.AbsolutePath( libraryPath ).ToUTF8() ); auto it = m_libraries.try_emplace( aLibraryPath,
SIM_LIBRARY* library = nullptr; SIM_LIBRARY::Create( absolutePath ) ).first;
library = &*it->second;
try }
{ catch( const IO_ERROR& e )
auto it = m_libraries.try_emplace( libraryPath, {
SIM_LIBRARY::Create( absolutePath ) ).first; THROW_IO_ERROR(
library = &*it->second; wxString::Format( _( "Error loading simulation model library '%s': %s" ),
} absolutePath,
catch( const IO_ERROR& e ) e.What() ) );
{
THROW_IO_ERROR(
wxString::Format( _( "Error loading simulation model library '%s': %s" ),
absolutePath,
e.What() ) );
}
baseModelName = SIM_MODEL::GetFieldValue( &aFields, SIM_LIBRARY::NAME_FIELD );
if( baseModelName == "" )
{
THROW_IO_ERROR( wxString::Format( _( "Error loading simulation model: no '%s' field" ),
SIM_LIBRARY::NAME_FIELD ) );
}
SIM_MODEL* baseModel = library->FindModel( baseModelName );
if( !baseModel )
{
THROW_IO_ERROR(
wxString::Format( _( "Error loading simulation model: could not find base model '%s' in library '%s'" ),
baseModelName,
absolutePath ) );
}
m_models.push_back( SIM_MODEL::Create( *baseModel, aSymbolPinCount, aFields ) );
} }
else
m_models.push_back( SIM_MODEL::Create( aSymbolPinCount, aFields ) );
return { baseModelName, *m_models.back() }; if( aBaseModelName == "" )
{
THROW_IO_ERROR( wxString::Format( _( "Error loading simulation model: no '%s' field" ),
SIM_LIBRARY::NAME_FIELD ) );
}
SIM_MODEL* baseModel = library->FindModel( aBaseModelName );
if( !baseModel )
{
THROW_IO_ERROR(
wxString::Format( _( "Error loading simulation model: could not find base model '%s' in library '%s'" ),
aBaseModelName,
absolutePath ) );
}
m_models.push_back( SIM_MODEL::Create( *baseModel, aSymbolPinCount, aFields ) );
return { aBaseModelName, *m_models.back() };
}
void SIM_LIB_MGR::SetModel( int aIndex, std::unique_ptr<SIM_MODEL> aModel )
{
m_models.at( aIndex ) = std::move( aModel );
} }

View File

@ -43,17 +43,32 @@ public:
SIM_LIB_MGR( const PROJECT& aPrj ); SIM_LIB_MGR( const PROJECT& aPrj );
virtual ~SIM_LIB_MGR() = default; virtual ~SIM_LIB_MGR() = default;
void Clear();
SIM_LIBRARY& CreateLibrary( const std::string& aLibraryPath ); SIM_LIBRARY& CreateLibrary( const std::string& aLibraryPath );
SIM_MODEL& CreateModel( SIM_MODEL::TYPE aType, int aSymbolPinCount ); SIM_MODEL& CreateModel( SIM_MODEL::TYPE aType, int aSymbolPinCount );
SIM_MODEL& CreateModel( const SIM_MODEL& aBaseModel, int aSymbolPinCount ); SIM_MODEL& CreateModel( const SIM_MODEL& aBaseModel, int aSymbolPinCount );
template <typename T>
SIM_MODEL& CreateModel( const SIM_MODEL& aBaseModel, int aSymbolPinCount,
const std::vector<T>& aFields );
// TODO: The argument can be made const. // TODO: The argument can be made const.
SIM_LIBRARY::MODEL CreateModel( SCH_SYMBOL& aSymbol ); SIM_LIBRARY::MODEL CreateModel( SCH_SYMBOL& aSymbol );
template <typename T> template <typename T>
SIM_LIBRARY::MODEL CreateModel( const std::vector<T>& aFields, int aSymbolPinCount ); SIM_LIBRARY::MODEL CreateModel( const std::vector<T>& aFields, int aSymbolPinCount );
template <typename T>
SIM_LIBRARY::MODEL CreateModel( const std::string& aLibraryPath,
const std::string& aBaseModelName,
const std::vector<T>& aFields,
int aSymbolPinCount );
void SetModel( int aIndex, std::unique_ptr<SIM_MODEL> aModel );
std::map<std::string, std::reference_wrapper<const SIM_LIBRARY>> GetLibraries() const; std::map<std::string, std::reference_wrapper<const SIM_LIBRARY>> GetLibraries() const;
std::vector<std::reference_wrapper<SIM_MODEL>> GetModels() const; std::vector<std::reference_wrapper<SIM_MODEL>> GetModels() const;

View File

@ -79,7 +79,7 @@ bool SIM_LIBRARY_KIBIS::InitModel( SIM_MODEL_KIBIS& aModel, wxString aCompName )
} }
bool SIM_LIBRARY_KIBIS::isPinDiff( const std::string& aComp, const std::string& aPinNumber ) bool SIM_LIBRARY_KIBIS::isPinDiff( const std::string& aComp, const std::string& aPinNumber ) const
{ {
for( std::pair<std::string, std::string> aInfo : m_diffPins ) for( std::pair<std::string, std::string> aInfo : m_diffPins )
{ {

View File

@ -44,10 +44,10 @@ public:
void WriteFile( const std::string& aFilePath ) override{}; void WriteFile( const std::string& aFilePath ) override{};
bool InitModel( SIM_MODEL_KIBIS& aModel, wxString aCompName ); bool InitModel( SIM_MODEL_KIBIS& aModel, wxString aCompName );
bool isPinDiff( const std::string& aComp, const std::string& aPinNumber ); bool isPinDiff( const std::string& aComp, const std::string& aPinNumber ) const;
protected: protected:
KIBIS m_kibis; mutable KIBIS m_kibis;
std::vector<std::pair<std::string, std::string>> m_diffPins; std::vector<std::pair<std::string, std::string>> m_diffPins;
}; };

View File

@ -313,7 +313,7 @@ void SIM_MODEL_KIBIS::CreatePins( unsigned aSymbolPinCount )
} }
bool SIM_MODEL_KIBIS::ChangePin( SIM_LIBRARY_KIBIS& aLib, std::string aPinNumber ) bool SIM_MODEL_KIBIS::ChangePin( const SIM_LIBRARY_KIBIS& aLib, std::string aPinNumber )
{ {
KIBIS_COMPONENT* kcomp = aLib.m_kibis.GetComponent( std::string( GetComponentName() ) ); KIBIS_COMPONENT* kcomp = aLib.m_kibis.GetComponent( std::string( GetComponentName() ) );
@ -516,4 +516,4 @@ void SIM_MODEL_KIBIS::ReadDataLibFields( unsigned aSymbolPinCount, const std::ve
SwitchSingleEndedDiff( diffMode ); SwitchSingleEndedDiff( diffMode );
SIM_MODEL::ReadDataLibFields( aSymbolPinCount, aFields ); SIM_MODEL::ReadDataLibFields( aSymbolPinCount, aFields );
} }

View File

@ -88,7 +88,7 @@ public:
/** @brief update the list of available models based on the pin number. /** @brief update the list of available models based on the pin number.
* */ * */
bool ChangePin( SIM_LIBRARY_KIBIS& aLib, std::string aPinNumber ); bool ChangePin( const SIM_LIBRARY_KIBIS& aLib, std::string aPinNumber );
void SetBaseModel( const SIM_MODEL& aBaseModel ) override; void SetBaseModel( const SIM_MODEL& aBaseModel ) override;