Fix bug in tuning when value is stored in Value field.

This commit is contained in:
Jeff Young 2022-12-23 17:26:16 +00:00
parent e2f2f3518b
commit 604d7a72d6
2 changed files with 15 additions and 1 deletions

View File

@ -138,6 +138,7 @@ bool DIALOG_SIM_MODEL<T_symbol, T_field>::TransferDataToWindow()
wxString modelType;
wxString modelParams;
wxString pinMap;
bool storeInValue = false;
// Infer RLC and VI models if they aren't specified
if( SIM_MODEL::InferSimModel( m_symbol, &m_fields, false, SIM_VALUE_GRAMMAR::NOTATION::SI,
@ -158,6 +159,10 @@ bool DIALOG_SIM_MODEL<T_symbol, T_field>::TransferDataToWindow()
m_fields.emplace_back( &m_symbol, -1, SIM_MODEL::PINS_FIELD );
m_fields.back().SetText( pinMap );
storeInValue = true;
// In case the storeInValue checkbox is turned off (if it's left on then we'll overwrite
// this field with the actual value):
m_fields[ VALUE_FIELD ].SetText( wxT( "${SIM.PARAMS}" ) );
}
@ -269,6 +274,8 @@ bool DIALOG_SIM_MODEL<T_symbol, T_field>::TransferDataToWindow()
m_curModelTypeOfDeviceType[deviceTypeT] = type;
}
curModel().SetIsStoredInValue( storeInValue );
m_saveInValueCheckbox->SetValue( curModel().IsStoredInValue() );
m_excludeCheckbox->SetValue( !curModel().IsEnabled() );

View File

@ -201,6 +201,7 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S
wxString modelType;
wxString modelParams;
wxString pinMap;
bool storeInValue = false;
// Infer RLC and VI models if they aren't specified
if( SIM_MODEL::InferSimModel( aSymbol, &fields, true, SIM_VALUE_GRAMMAR::NOTATION::SI,
@ -220,6 +221,8 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S
fields.emplace_back( &aSymbol, -1, SIM_MODEL::PINS_FIELD );
fields.back().SetText( pinMap );
storeInValue = true;
}
std::vector<LIB_PIN*> sourcePins = aSymbol.GetAllLibPins();
@ -230,7 +233,11 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S
return StrNumCmp( lhs->GetNumber(), rhs->GetNumber(), true ) < 0;
} );
return CreateModel( fields, sourcePins );
SIM_LIBRARY::MODEL model = CreateModel( fields, sourcePins );
model.model.SetIsStoredInValue( storeInValue );
return model;
}