Improved Spice library parser
Now the parser filters out models placed inside .subckt sections.
This commit is contained in:
parent
65b615bc4b
commit
acbe30af51
|
@ -265,7 +265,7 @@ bool DIALOG_SPICE_MODEL::TransferDataToWindow()
|
||||||
{
|
{
|
||||||
const wxString& libFile = m_semiLib->GetValue();
|
const wxString& libFile = m_semiLib->GetValue();
|
||||||
m_fieldsTmp[SF_LIB_FILE] = libFile;
|
m_fieldsTmp[SF_LIB_FILE] = libFile;
|
||||||
updateFromFile( m_semiModel, libFile, ".model" );
|
updateFromFile( m_semiModel, libFile );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ bool DIALOG_SPICE_MODEL::TransferDataToWindow()
|
||||||
{
|
{
|
||||||
const wxString& libFile = m_icLib->GetValue();
|
const wxString& libFile = m_icLib->GetValue();
|
||||||
m_fieldsTmp[SF_LIB_FILE] = libFile;
|
m_fieldsTmp[SF_LIB_FILE] = libFile;
|
||||||
updateFromFile( m_icModel, libFile, ".subckt" );
|
updateFromFile( m_icModel, libFile );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -615,12 +615,11 @@ bool DIALOG_SPICE_MODEL::generatePowerSource( wxString& aTarget ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_SPICE_MODEL::updateFromFile( wxComboBox* aComboBox,
|
void DIALOG_SPICE_MODEL::updateFromFile( wxComboBox* aComboBox, const wxString& aFilePath )
|
||||||
const wxString& aFilePath, const wxString& aKeyword )
|
|
||||||
{
|
{
|
||||||
wxString curValue = aComboBox->GetValue();
|
wxString curValue = aComboBox->GetValue();
|
||||||
const wxString keyword( aKeyword.Lower() );
|
|
||||||
wxFileName filePath( aFilePath );
|
wxFileName filePath( aFilePath );
|
||||||
|
bool in_subckt = false; // flag indicating that the parser is inside a .subckt section
|
||||||
|
|
||||||
if( !filePath.Exists() )
|
if( !filePath.Exists() )
|
||||||
{
|
{
|
||||||
|
@ -642,9 +641,29 @@ void DIALOG_SPICE_MODEL::updateFromFile( wxComboBox* aComboBox,
|
||||||
|
|
||||||
while( tokenizer.HasMoreTokens() )
|
while( tokenizer.HasMoreTokens() )
|
||||||
{
|
{
|
||||||
|
bool model_found = false;
|
||||||
wxString token = tokenizer.GetNextToken().Lower();
|
wxString token = tokenizer.GetNextToken().Lower();
|
||||||
|
|
||||||
if( token == keyword )
|
// some subckts contain .model clauses inside,
|
||||||
|
// skip them as they are a part of the subckt, not another model
|
||||||
|
if( token == ".model" && !in_subckt )
|
||||||
|
{
|
||||||
|
model_found = true;
|
||||||
|
}
|
||||||
|
else if( token == ".subckt" )
|
||||||
|
{
|
||||||
|
wxASSERT( !in_subckt );
|
||||||
|
in_subckt = true;
|
||||||
|
model_found = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if( token == ".ends" )
|
||||||
|
{
|
||||||
|
wxASSERT( in_subckt );
|
||||||
|
in_subckt = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( model_found )
|
||||||
{
|
{
|
||||||
token = tokenizer.GetNextToken();
|
token = tokenizer.GetNextToken();
|
||||||
|
|
||||||
|
@ -727,7 +746,7 @@ void DIALOG_SPICE_MODEL::onSemiSelectLib( wxCommandEvent& event )
|
||||||
else
|
else
|
||||||
m_semiLib->SetValue( openDlg.GetPath() );
|
m_semiLib->SetValue( openDlg.GetPath() );
|
||||||
|
|
||||||
updateFromFile( m_semiModel, openDlg.GetPath(), ".model" );
|
updateFromFile( m_semiModel, openDlg.GetPath() );
|
||||||
m_semiModel->Popup();
|
m_semiModel->Popup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,7 +773,7 @@ void DIALOG_SPICE_MODEL::onSelectIcLib( wxCommandEvent& event )
|
||||||
else
|
else
|
||||||
m_icLib->SetValue( openDlg.GetPath() );
|
m_icLib->SetValue( openDlg.GetPath() );
|
||||||
|
|
||||||
updateFromFile( m_icModel, openDlg.GetPath(), ".subckt" );
|
updateFromFile( m_icModel, openDlg.GetPath() );
|
||||||
m_icModel->Popup();
|
m_icModel->Popup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,12 +54,12 @@ private:
|
||||||
bool generatePowerSource( wxString& aTarget ) const;
|
bool generatePowerSource( wxString& aTarget ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a list of components from a file and adds them to a combo box.
|
* Loads a list of components (.model and .subckt) from a spice library
|
||||||
|
* file and adds them to a combo box.
|
||||||
* @param aComboBox is the target combo box
|
* @param aComboBox is the target combo box
|
||||||
* @param aFilePath is the file to be processed
|
* @param aFilePath is path to the library file
|
||||||
* @param aKeyword is the keyword to select the type of components (e.g. "subckt" or "model")
|
|
||||||
*/
|
*/
|
||||||
void updateFromFile( wxComboBox* aComboBox, const wxString& aFilePath, const wxString& aKeyword );
|
void updateFromFile( wxComboBox* aComboBox, const wxString& aFilePath );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns or creates a field in the edited schematic fields vector.
|
* Returns or creates a field in the edited schematic fields vector.
|
||||||
|
|
Loading…
Reference in New Issue