7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-18 16:29:18 +00:00

Add number of pulses parameter to pulsed voltage/current sources.

Also don't suppress writing "0" valued parameters.

Fixes https://gitlab.com/kicad/code/kicad/issues/13401

Fixes https://gitlab.com/kicad/code/kicad/issues/13402
This commit is contained in:
Jeff Young 2023-01-06 13:44:45 +00:00
parent 2cbb66d70d
commit 4d7642a26c
4 changed files with 9 additions and 47 deletions

View File

@ -98,7 +98,7 @@ std::string SIM_MODEL_SERIALIZER::GenerateParams() const
if( param.info.enumValues.size() >= 1 && param.value->ToString() == param.info.defaultValue )
continue;
std::string paramValuePair = GenerateParamValuePair( param );
std::string paramValuePair = generateParamValuePair( param );
if( paramValuePair == "" )
continue; // Prevent adding empty spaces.
@ -155,22 +155,6 @@ std::string SIM_MODEL_SERIALIZER::GenerateEnable() const
}
SIM_MODEL::TYPE SIM_MODEL_SERIALIZER::ParseDeviceAndType( const std::string& aDevice,
const std::string& aType )
{
for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() )
{
if( aType == SIM_MODEL::TypeInfo( type ).fieldValue
&& aDevice == SIM_MODEL::DeviceInfo( SIM_MODEL::TypeInfo( type ).deviceType ).fieldValue )
{
return type;
}
}
return SIM_MODEL::TYPE::NONE;
}
void SIM_MODEL_SERIALIZER::ParseValue( const std::string& aValue )
{
try
@ -310,7 +294,7 @@ void SIM_MODEL_SERIALIZER::ParseEnable( const std::string& aEnable )
}
std::string SIM_MODEL_SERIALIZER::GenerateParamValuePair( const SIM_MODEL::PARAM& aParam ) const
std::string SIM_MODEL_SERIALIZER::generateParamValuePair( const SIM_MODEL::PARAM& aParam ) const
{
std::string name = aParam.info.name;

View File

@ -117,12 +117,6 @@ public:
static constexpr auto REFERENCE_FIELD = "Reference";
static constexpr auto VALUE_FIELD = "Value";
static constexpr auto DEVICE_TYPE_FIELD = "Sim.Device";
static constexpr auto TYPE_FIELD = "Sim.Type";
static constexpr auto PINS_FIELD = "Sim.Pins";
static constexpr auto PARAMS_FIELD = "Sim.Params";
static constexpr auto ENABLE_FIELD = "Sim.Enable";
virtual ~SIM_MODEL_SERIALIZER() = default;
SIM_MODEL_SERIALIZER( SIM_MODEL& aModel ) : m_model( aModel ) {}
@ -133,15 +127,13 @@ public:
std::string GeneratePins() const;
std::string GenerateEnable() const;
SIM_MODEL::TYPE ParseDeviceAndType( const std::string& aDevice,
const std::string& aType );
void ParseValue( const std::string& aValue );
bool ParseParams( const std::string& aParams );
void ParsePins( const std::string& aPins );
void ParseEnable( const std::string& aEnable );
protected:
virtual std::string GenerateParamValuePair( const SIM_MODEL::PARAM& aParam ) const;
std::string generateParamValuePair( const SIM_MODEL::PARAM& aParam ) const;
private:
SIM_MODEL& m_model;

View File

@ -212,15 +212,6 @@ std::string SPICE_GENERATOR_SOURCE::getParamValueString( const std::string& aPar
}
std::string SIM_MODEL_SOURCE_SERIALIZER::GenerateParamValuePair( const SIM_MODEL::PARAM& aParam ) const
{
if( aParam.value->ToString() == "0" )
return "";
return SIM_MODEL_SERIALIZER::GenerateParamValuePair( aParam );
}
SIM_MODEL_SOURCE::SIM_MODEL_SOURCE( TYPE aType ) :
SIM_MODEL( aType, std::make_unique<SPICE_GENERATOR_SOURCE>( *this ),
std::make_unique<SIM_MODEL_SOURCE_SERIALIZER>( *this ) )
@ -483,15 +474,13 @@ std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makePulseParamInfos( std::
paramInfo.description = "Period";
paramInfos.push_back( paramInfo );
// "phase" is not needed. "td" is enough.
/*paramInfo.name = "phase";
paramInfo.type = SIM_VALUE::TYPE_FLOAT;
paramInfo.unit = "°";
paramInfo.name = "np";
paramInfo.type = SIM_VALUE::TYPE_INT;
paramInfo.unit = "";
paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
paramInfo.defaultValue = "0";
paramInfo.description = "Phase";
paramInfos.push_back( paramInfo );*/
paramInfo.defaultValue = "";
paramInfo.description = "Number of pulses";
paramInfos.push_back( paramInfo );
appendAcParamInfos( paramInfos, aUnit );
return paramInfos;

View File

@ -63,9 +63,6 @@ class SIM_MODEL_SOURCE_SERIALIZER : public SIM_MODEL_SERIALIZER
{
public:
using SIM_MODEL_SERIALIZER::SIM_MODEL_SERIALIZER;
protected:
std::string GenerateParamValuePair( const SIM_MODEL::PARAM& aParam ) const override;
};