Must do pin swap in model pins, not item pins.
Item pins might not be in the same order. Fixes https://gitlab.com/kicad/code/kicad/issues/13741
This commit is contained in:
parent
71002dce28
commit
ab0c4dd292
|
@ -41,17 +41,34 @@ std::string SPICE_GENERATOR_R_POT::ModelLine( const SPICE_ITEM& aItem ) const
|
|||
}
|
||||
|
||||
|
||||
std::string SPICE_GENERATOR_R_POT::ItemLine( const SPICE_ITEM& aItem ) const
|
||||
std::string SPICE_GENERATOR_R_POT::ItemPins( const SPICE_ITEM& aItem ) const
|
||||
{
|
||||
// Swap pin order so that pos=1 is all +, and pos=0 is all -.
|
||||
SPICE_ITEM item = aItem;
|
||||
std::string result;
|
||||
int ncCounter = 0;
|
||||
|
||||
// FIXME: This `if` is there because Preview() calls this function with empty pinNetNames vector.
|
||||
// This shouldn't be necessary.
|
||||
if( item.pinNetNames.size() >= 3 )
|
||||
std::swap( item.pinNetNames.at( 0 ), item.pinNetNames.at( 2 ) );
|
||||
wxCHECK( GetPins().size() == 3, "" );
|
||||
|
||||
return SPICE_GENERATOR::ItemLine( item );
|
||||
// Swap pin order so that pos=1 is +, and pos=0 is -.
|
||||
std::vector<std::reference_wrapper<const SIM_MODEL::PIN>> inverted( GetPins() );
|
||||
std::swap( inverted[0], inverted[2] );
|
||||
|
||||
for( const SIM_MODEL::PIN& pin : GetPins() )
|
||||
{
|
||||
auto it = std::find( aItem.pinNumbers.begin(), aItem.pinNumbers.end(),
|
||||
pin.symbolPinNumber );
|
||||
|
||||
if( it != aItem.pinNumbers.end() )
|
||||
{
|
||||
long symbolPinIndex = std::distance( aItem.pinNumbers.begin(), it );
|
||||
result.append( fmt::format( " {}", aItem.pinNetNames.at( symbolPinIndex ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append( fmt::format( " NC-{}-{}", aItem.refName, ncCounter++ ) );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
using SPICE_GENERATOR::SPICE_GENERATOR;
|
||||
|
||||
std::string ModelLine( const SPICE_ITEM& aItem ) const override;
|
||||
std::string ItemLine( const SPICE_ITEM& aItem ) const override;
|
||||
std::string ItemPins( const SPICE_ITEM& aItem ) const override;
|
||||
std::string TunerCommand( const SPICE_ITEM& aItem, const SIM_VALUE_FLOAT& aValue ) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ std::string SPICE_GENERATOR_RAW_SPICE::ItemName( const SPICE_ITEM& aItem ) const
|
|||
std::string SPICE_GENERATOR_RAW_SPICE::ItemPins( const SPICE_ITEM& aItem ) const
|
||||
{
|
||||
std::string result;
|
||||
int ncCounter = 0;
|
||||
|
||||
if( !GetPins().empty() )
|
||||
{
|
||||
|
@ -73,6 +74,10 @@ std::string SPICE_GENERATOR_RAW_SPICE::ItemPins( const SPICE_ITEM& aItem ) const
|
|||
long symbolPinIndex = std::distance( aItem.pinNumbers.begin(), it );
|
||||
result.append( fmt::format( " {}", aItem.pinNetNames.at( symbolPinIndex ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append( fmt::format( " NC-{}-{}", aItem.refName, ncCounter++ ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue