Fix default pin assignment for subcircuit sim models

Instead of using a linear order that incorrectly starts from 0, have all
pins unassigned by default.
This commit is contained in:
Mikolaj Wielgus 2022-08-24 00:06:16 +02:00
parent 5475d46bc5
commit ffab57ffd0
3 changed files with 18 additions and 5 deletions

View File

@ -64,7 +64,6 @@ namespace SIM_MODEL_SPICE_PARSER
{
using namespace SPICE_GRAMMAR;
template <typename Rule> struct spiceUnitSelector : std::false_type {};
template <> struct spiceUnitSelector<dotModel> : std::true_type {};
@ -1567,17 +1566,17 @@ wxString SIM_MODEL::generatePinsField() const
wxString result = "";
bool isFirst = true;
for( int pinIndex = 0; pinIndex < GetPinCount(); ++pinIndex )
for( const PIN& pin : GetPins() )
{
if( isFirst )
isFirst = false;
else
result << " ";
if( GetPin( pinIndex ).symbolPinNumber == "" )
if( pin.symbolPinNumber == "" )
result << "~";
else
result << GetPin( pinIndex ).symbolPinNumber; // Note that it's numbered from 1.
result << pin.symbolPinNumber; // Note that it's numbered from 1.
}
return result;

View File

@ -81,7 +81,7 @@ void SIM_MODEL_SUBCKT::ReadSpiceCode( const wxString& aSpiceCode )
}
else if( subnode->is_type<SIM_MODEL_SUBCKT_SPICE_PARSER::dotSubcktPinName>() )
{
AddPin( { subnode->string(), wxString::FromCDouble( GetPinCount() ) } );
AddPin( { subnode->string(), wxString::FromCDouble( GetPinCount() + 1 ) } );
}
else if( !hadParamValuePairs
&& subnode->is_type<SIM_MODEL_SUBCKT_SPICE_PARSER::paramValuePairs>() )
@ -160,3 +160,14 @@ void SIM_MODEL_SUBCKT::SetBaseModel( const SIM_MODEL& aBaseModel )
for( const PARAM& param : GetBaseModel()->GetParams() )
AddParam( param.info );
}
void SIM_MODEL_SUBCKT::CreatePins( unsigned aSymbolPinCount )
{
SIM_MODEL::CreatePins( aSymbolPinCount );
// Reset the pins to Not Connected. Linear order is not as common, and reordering the pins is
// more effort in the GUI than assigning them from scratch.
for( int pinIndex = 0; pinIndex < GetPinCount(); ++pinIndex )
SetPinSymbolPinNumber( pinIndex, "" );
}

View File

@ -38,6 +38,9 @@ public:
std::vector<wxString> GenerateSpiceCurrentNames( const wxString& aRefName ) const override;
void SetBaseModel( const SIM_MODEL& aBaseModel ) override;
protected:
void CreatePins( unsigned aSymbolPinCount ) override;
private:
bool requiresSpiceModel() const override { return true; }