Sim: Remove pins field in all inferred models with linear pin mapping

This commit is contained in:
Mikolaj Wielgus 2022-10-25 08:49:41 +02:00
parent 80c426f577
commit 3e0f4a47b0
1 changed files with 12 additions and 4 deletions

View File

@ -1005,13 +1005,21 @@ template void SIM_MODEL::WriteInferredDataFields( std::vector<LIB_FIELD>& aField
template <typename T>
void SIM_MODEL::WriteInferredDataFields( std::vector<T>& aFields, const std::string& aValue ) const
{
if( GetPinCount() == 2
&& GetPin( 0 ).symbolPinNumber == "1"
&& GetPin( 1 ).symbolPinNumber == "2" )
bool removePinsField = true;
// Only write Sim_Pins field if the pins are not in the canonical order.
for( int i = 0; i < GetPinCount(); ++i )
{
SetFieldValue( aFields, PINS_FIELD, "" );
if( GetPin( i ).symbolPinNumber != fmt::format( "{}", i + 1 ) )
{
removePinsField = false;
break;
}
}
if( removePinsField )
SetFieldValue( aFields, PINS_FIELD, "" );
SetFieldValue( aFields, VALUE_FIELD, aValue );
SetFieldValue( aFields, DEVICE_TYPE_FIELD, "" );
SetFieldValue( aFields, TYPE_FIELD, "" );