Sim: Universally initialize enum parameters with their default values
This commit is contained in:
parent
39cd9f8980
commit
e39c0b20ea
|
@ -650,6 +650,10 @@ int SIM_MODEL::FindModelPinIndex( const std::string& aSymbolPinNumber )
|
|||
void SIM_MODEL::AddParam( const PARAM::INFO& aInfo, bool aIsOtherVariant )
|
||||
{
|
||||
m_params.emplace_back( aInfo, aIsOtherVariant );
|
||||
|
||||
// Enums are initialized with their default values.
|
||||
if( aInfo.enumValues.size() >= 1 )
|
||||
m_params.back().value->FromString( aInfo.defaultValue );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -94,19 +94,9 @@ std::vector<std::reference_wrapper<const SIM_MODEL::PIN>> SPICE_GENERATOR_SWITCH
|
|||
}
|
||||
|
||||
|
||||
std::string SIM_SERDE_SWITCH::GenerateParamValuePair( const SIM_MODEL::PARAM& aParam ) const
|
||||
{
|
||||
if( aParam.info.name == "ic" && aParam.value->ToString() == "none" )
|
||||
return "";
|
||||
|
||||
return SIM_SERDE::GenerateParamValuePair( aParam );
|
||||
}
|
||||
|
||||
|
||||
SIM_MODEL_SWITCH::SIM_MODEL_SWITCH( TYPE aType ) :
|
||||
SIM_MODEL( aType,
|
||||
std::make_unique<SPICE_GENERATOR_SWITCH>( *this ),
|
||||
std::make_unique<SIM_SERDE_SWITCH>( *this ) )
|
||||
std::make_unique<SPICE_GENERATOR_SWITCH>( *this ) )
|
||||
{
|
||||
static std::vector<PARAM::INFO> vsw = makeSwVParamInfos();
|
||||
static std::vector<PARAM::INFO> isw = makeSwIParamInfos();
|
||||
|
@ -127,8 +117,6 @@ SIM_MODEL_SWITCH::SIM_MODEL_SWITCH( TYPE aType ) :
|
|||
wxFAIL_MSG( "Unhandled SIM_MODEL type in SIM_MODEL_SWITCH" );
|
||||
break;
|
||||
}
|
||||
|
||||
SetParamValue( "ic", "none" );
|
||||
}
|
||||
|
||||
|
||||
|
@ -185,7 +173,7 @@ const std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SWITCH::makeSwVParamInfos()
|
|||
paramInfo.type = SIM_VALUE::TYPE_STRING;
|
||||
paramInfo.unit = "";
|
||||
paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
|
||||
paramInfo.defaultValue = "1";
|
||||
paramInfo.defaultValue = "none";
|
||||
paramInfo.description = "Initial state";
|
||||
paramInfo.isSpiceInstanceParam = true;
|
||||
paramInfo.spiceModelName = "";
|
||||
|
|
|
@ -41,16 +41,6 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class SIM_SERDE_SWITCH : public SIM_SERDE
|
||||
{
|
||||
public:
|
||||
using SIM_SERDE::SIM_SERDE;
|
||||
|
||||
protected:
|
||||
std::string GenerateParamValuePair( const SIM_MODEL::PARAM& aParam ) const override;
|
||||
};
|
||||
|
||||
|
||||
class SIM_MODEL_SWITCH : public SIM_MODEL
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -94,6 +94,10 @@ std::string SIM_SERDE::GenerateParams() const
|
|||
continue;
|
||||
}
|
||||
|
||||
// If the parameter is an enum and the value is default, don't write anything.
|
||||
if( param.info.enumValues.size() >= 1 && param.value->ToString() == param.info.defaultValue )
|
||||
continue;
|
||||
|
||||
std::string paramValuePair = GenerateParamValuePair( param );
|
||||
|
||||
if( paramValuePair == "" )
|
||||
|
|
Loading…
Reference in New Issue