diff --git a/eeschema/sim/sim_model.cpp b/eeschema/sim/sim_model.cpp index f5ee250e90..e57af8de13 100644 --- a/eeschema/sim/sim_model.cpp +++ b/eeschema/sim/sim_model.cpp @@ -1003,12 +1003,12 @@ void SIM_MODEL::createPins( const std::vector& aSymbolPins ) { // Default pin sequence: model pins are the same as symbol pins. // Excess model pins are set as Not Connected. - // Note that intentionally nothing is added if `getPinNames()` returns an empty vector. + // Note that intentionally nothing is added if `GetPinNames()` returns an empty vector. // SIM_MODEL pins must be ordered by symbol pin numbers -- this is assumed by the code that // accesses them. - std::vector pinNames = getPinNames(); + std::vector pinNames = GetPinNames(); for( unsigned modelPinIndex = 0; modelPinIndex < pinNames.size(); ++modelPinIndex ) { diff --git a/eeschema/sim/sim_model.h b/eeschema/sim/sim_model.h index 0c53bb10fb..762c83104b 100644 --- a/eeschema/sim/sim_model.h +++ b/eeschema/sim/sim_model.h @@ -475,6 +475,8 @@ public: m_baseModel = &aBaseModel; } + virtual std::vector GetPinNames() const { return {}; } + int GetPinCount() const { return static_cast( m_pins.size() ); } const PIN& GetPin( unsigned aIndex ) const { return m_pins.at( aIndex ); } @@ -553,8 +555,6 @@ private: virtual bool requiresSpiceModelLine() const; - virtual std::vector getPinNames() const { return {}; } - protected: std::vector m_params; std::vector m_pins; diff --git a/eeschema/sim/sim_model_behavioral.h b/eeschema/sim/sim_model_behavioral.h index 2773f44d22..9a03d5f2b3 100644 --- a/eeschema/sim/sim_model_behavioral.h +++ b/eeschema/sim/sim_model_behavioral.h @@ -45,9 +45,10 @@ class SIM_MODEL_BEHAVIORAL : public SIM_MODEL public: SIM_MODEL_BEHAVIORAL( TYPE aType ); + std::vector GetPinNames() const override { return { "+", "-" }; } + private: bool parseValueField( const std::string& aValueField ); - std::vector getPinNames() const override { return { "+", "-" }; } static PARAM::INFO makeParams( std::string aName, std::string aDescription, std::string aUnit ); }; diff --git a/eeschema/sim/sim_model_ideal.h b/eeschema/sim/sim_model_ideal.h index 2cd57d2a8a..dc3d778427 100644 --- a/eeschema/sim/sim_model_ideal.h +++ b/eeschema/sim/sim_model_ideal.h @@ -49,9 +49,9 @@ public: const PARAM* GetTunerParam() const override { return &GetParam( 0 ); } bool HasPrimaryValue() const override { return true; } -private: - std::vector getPinNames() const override { return { "+", "-" }; } + std::vector GetPinNames() const override { return { "+", "-" }; } +private: static PARAM::INFO makeParamInfo( std::string aName, std::string aDescription, std::string aUnit ); }; diff --git a/eeschema/sim/sim_model_ngspice.cpp b/eeschema/sim/sim_model_ngspice.cpp index 566c2767a7..24acb80e85 100644 --- a/eeschema/sim/sim_model_ngspice.cpp +++ b/eeschema/sim/sim_model_ngspice.cpp @@ -217,7 +217,7 @@ bool SIM_MODEL_NGSPICE::canSilentlyIgnoreParam( const std::string& aParamName ) } -std::vector SIM_MODEL_NGSPICE::getPinNames() const +std::vector SIM_MODEL_NGSPICE::GetPinNames() const { return ModelInfo( getModelType() ).pinNames; } diff --git a/eeschema/sim/sim_model_ngspice.h b/eeschema/sim/sim_model_ngspice.h index bbd169350b..d6b21521d5 100644 --- a/eeschema/sim/sim_model_ngspice.h +++ b/eeschema/sim/sim_model_ngspice.h @@ -49,6 +49,8 @@ public: void SetParamFromSpiceCode( const std::string& aParamName, const std::string& aValue, SIM_VALUE_GRAMMAR::NOTATION aNotation ) override; + std::vector GetPinNames() const override; + // Protected because it's accessed by QA tests. protected: DEFINE_ENUM_CLASS_WITH_ITERATOR( MODEL_TYPE, @@ -111,8 +113,6 @@ private: bool canSilentlyIgnoreParam( const std::string& aParamName ); - std::vector getPinNames() const override; - MODEL_TYPE getModelType() const; bool getIsOtherVariant(); }; diff --git a/eeschema/sim/sim_model_r_pot.h b/eeschema/sim/sim_model_r_pot.h index d5de651116..f7f992f95d 100644 --- a/eeschema/sim/sim_model_r_pot.h +++ b/eeschema/sim/sim_model_r_pot.h @@ -48,9 +48,9 @@ public: const PARAM* GetTunerParam() const override { return FindParam( "pos" ); } bool HasPrimaryValue() const override { return true; } -private: - std::vector getPinNames() const override { return { "+", "wiper", "-" }; } + std::vector GetPinNames() const override { return { "+", "wiper", "-" }; } +private: static const std::vector makeParamInfos(); }; diff --git a/eeschema/sim/sim_model_source.h b/eeschema/sim/sim_model_source.h index 232be03049..2b98ed90e5 100644 --- a/eeschema/sim/sim_model_source.h +++ b/eeschema/sim/sim_model_source.h @@ -76,9 +76,9 @@ public: bool HasAutofill() const override { return true; } bool HasPrimaryValue() const override { return GetType() == TYPE::V || GetType() == TYPE::I; } -private: - std::vector getPinNames() const override { return { "+", "-" }; } + std::vector GetPinNames() const override { return { "+", "-" }; } +private: static const std::vector& makeParamInfos( TYPE aType ); static std::vector makeDcParamInfos( std::string aPrefix, std::string aUnit ); diff --git a/eeschema/sim/sim_model_spice_fallback.cpp b/eeschema/sim/sim_model_spice_fallback.cpp index f0cea1995a..6098413677 100644 --- a/eeschema/sim/sim_model_spice_fallback.cpp +++ b/eeschema/sim/sim_model_spice_fallback.cpp @@ -35,16 +35,22 @@ SIM_MODEL_SPICE_FALLBACK::SIM_MODEL_SPICE_FALLBACK( TYPE aType, const std::strin void SIM_MODEL_SPICE_FALLBACK::SetPinSymbolPinNumber( const std::string& aPinName, const std::string& aSymbolPinNumber ) { - for( PIN& pin : m_pins ) + try { - if( pin.name == aPinName ) - { - pin.symbolPinNumber = aSymbolPinNumber; - return; - } + SIM_MODEL::SetPinSymbolPinNumber( aPinName, aSymbolPinNumber ); + } + catch( IO_ERROR& ) + { + // This is a fall-back, so we won't necessarily know the pin names. If we didn't find + // it, then just create a new pin. + m_pins.push_back( { aPinName, aSymbolPinNumber } ); } - - m_pins.push_back( { aPinName, aSymbolPinNumber } ); } +std::vector SIM_MODEL_SPICE_FALLBACK::GetPinNames() const +{ + // If we're a fall-back for a paticular model type, then return its pin names + std::unique_ptr model = SIM_MODEL::Create( GetType() ); + return model->GetPinNames(); +} \ No newline at end of file diff --git a/eeschema/sim/sim_model_spice_fallback.h b/eeschema/sim/sim_model_spice_fallback.h index c428da5d43..c5b5bbaafa 100644 --- a/eeschema/sim/sim_model_spice_fallback.h +++ b/eeschema/sim/sim_model_spice_fallback.h @@ -34,6 +34,8 @@ public: void SetPinSymbolPinNumber( const std::string& aPinName, const std::string& aSymbolPinNumber ) override; + + std::vector GetPinNames() const override; }; #endif // SIM_MODEL_SPICE_FALLBACK_H diff --git a/eeschema/sim/sim_model_switch.h b/eeschema/sim/sim_model_switch.h index 7c4d6fd512..eac9dfe15f 100644 --- a/eeschema/sim/sim_model_switch.h +++ b/eeschema/sim/sim_model_switch.h @@ -45,12 +45,12 @@ class SIM_MODEL_SWITCH : public SIM_MODEL public: SIM_MODEL_SWITCH( TYPE aType ); -private: - std::vector getPinNames() const override + std::vector GetPinNames() const override { return { "ctrl+", "ctrl-", "no+", "no-" }; } +private: bool requiresSpiceModelLine() const override { return true; } static const std::vector makeSwVParamInfos(); diff --git a/eeschema/sim/sim_model_tline.h b/eeschema/sim/sim_model_tline.h index 6764aca542..ccd6dd37f7 100644 --- a/eeschema/sim/sim_model_tline.h +++ b/eeschema/sim/sim_model_tline.h @@ -43,9 +43,9 @@ class SIM_MODEL_TLINE : public SIM_MODEL public: SIM_MODEL_TLINE( TYPE aType ); -private: - std::vector getPinNames() const override { return { "1+", "1-", "2+", "2-" }; } + std::vector GetPinNames() const override { return { "1+", "1-", "2+", "2-" }; } +private: static std::vector makeZ0ParamInfos(); static std::vector makeRlgcParamInfos(); };