When migrating simulation models update value to a reference.

This commit is contained in:
Jeff Young 2022-12-09 20:22:10 +00:00
parent 05b9836f60
commit 60c937186a
2 changed files with 10 additions and 15 deletions

View File

@ -136,12 +136,7 @@ template <typename T_symbol, typename T_field>
bool DIALOG_SIM_MODEL<T_symbol, T_field>::TransferDataToWindow()
{
wxCommandEvent dummyEvent;
wxString value;
// Yes, the Value field is always present, but Coverity doesn't know that...
if( T_field* valueField = m_symbol.FindField( wxT( "Value" ) ) )
value = valueField->GetText();
T_field* valueField = m_symbol.FindField( wxT( "Value" ) );
// Infer RLC models if they aren't specified
if( !m_symbol.FindField( SIM_MODEL::DEVICE_TYPE_FIELD )
@ -149,7 +144,7 @@ bool DIALOG_SIM_MODEL<T_symbol, T_field>::TransferDataToWindow()
{
// pair.first: wxString sim model type
// pair.second: wxString sim model parameters
auto model = SIM_MODEL::InferSimModel( m_symbol.GetPrefix(), value );
auto model = SIM_MODEL::InferSimModel( m_symbol.GetPrefix(), valueField->GetText() );
if( !model.second.IsEmpty() )
{
@ -164,6 +159,8 @@ bool DIALOG_SIM_MODEL<T_symbol, T_field>::TransferDataToWindow()
m_fields.emplace_back( &m_symbol, -1, SIM_MODEL::PARAMS_FIELD );
m_fields.back().SetText( model.second );
m_fields[ VALUE_FIELD ].SetText( wxT( "${SIM.PARAMS}" ) );
}
}

View File

@ -1065,11 +1065,7 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol )
}
wxString prefix = aSymbol.GetPrefix();
wxString value;
// Yes, the Value field is always present, but Coverity doesn't know that...
if( T_field* valueField = aSymbol.FindField( wxT( "Value" ) ) )
value = valueField->GetText();
T_field* valueField = aSymbol.FindField( wxT( "Value" ) );
wxString spiceType;
wxString spiceModel;
@ -1119,7 +1115,8 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol )
}
else
{
spiceModel = value;
spiceModel = valueField->GetText();
valueField->SetText( wxT( "${SIM.PARAMS}" ) );
}
if( T_field* netlistEnabledField = aSymbol.FindField( wxT( "Spice_Netlist_Enabled" ) ) )
@ -1142,7 +1139,8 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol )
}
else if( prefix == wxT( "V" ) || prefix == wxT( "I" ) )
{
spiceModel = value;
spiceModel = valueField->GetText();
valueField->SetText( wxT( "${SIM.PARAMS}" ) );
}
else
{
@ -1166,7 +1164,7 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol )
wxStringSplit( legacyPins->GetText(), pinIndexes, ' ' );
if( SIM_MODEL::InferSimModel( prefix, value ).second.length() )
if( SIM_MODEL::InferSimModel( prefix, valueField->GetText() ).second.length() )
{
if( pinIndexes[0] == wxT( "2" ) )
pins = "1=- 2=+";