Transmit pin electrical types through to pads.

This commit is contained in:
Jeff Young 2021-01-21 21:46:03 +00:00
parent 274fc60fe9
commit f5e35af1a5
11 changed files with 65 additions and 18 deletions

View File

@ -28,6 +28,7 @@ part
pin
pins
pinfunction
pintype
property
ref
sheetpath

View File

@ -50,15 +50,15 @@ const wxString LIB_PIN::GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType
{
wxT( "input" ),
wxT( "output" ),
wxT( "BiDi" ),
wxT( "3state" ),
wxT( "bidirectional" ),
wxT( "tri_state" ),
wxT( "passive" ),
wxT( "unspc" ),
wxT( "unspecified" ),
wxT( "power_in" ),
wxT( "power_out" ),
wxT( "openCol" ),
wxT( "openEm" ),
wxT( "NotConnected" )
wxT( "open_collector" ),
wxT( "open_emitter" ),
wxT( "unconnected" )
};
return msgPinElectricType[static_cast<int>( aType )];

View File

@ -678,9 +678,6 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
{
netCodeTxt.Printf( "%d", i + 1 );
if( net_record->first == "no_connect_" )
net_record->first += netCodeTxt;
xnets->AddChild( xnet = node( "net" ) );
xnet->AddAttribute( "code", netCodeTxt );
xnet->AddAttribute( "name", net_record->first );
@ -699,6 +696,8 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
if( !pinName.IsEmpty() )
xnode->AddAttribute( "pinfunction", pinName );
xnode->AddAttribute( "pintype", pin->GetCanonicalElectricalTypeName() );
}
}

View File

@ -118,6 +118,11 @@ public:
ELECTRICAL_PINTYPE GetType() const;
wxString GetCanonicalElectricalTypeName() const
{
return LIB_PIN::GetCanonicalElectricalTypeName( GetType() );
}
GRAPHIC_PINSHAPE GetShape() const;
int GetOrientation() const;

View File

@ -523,7 +523,10 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
const wxString& netname = pad->GetShortNetname();
if( !netname.IsEmpty() )
component->AddNet( pad->GetName(), netname, wxEmptyString );
{
component->AddNet( pad->GetName(), netname, pad->GetPinFunction(),
pad->GetPinType() );
}
}
netlist.AddComponent( component );

View File

@ -363,9 +363,13 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
const COMPONENT_NET& net = aNewComponent->GetNet( pad->GetName() );
wxString pinFunction;
wxString pinType;
if( net.IsValid() ) // i.e. the pad has a name
{
pinFunction = net.GetPinFunction();
pinType = net.GetPinType();
}
if( !m_isDryRun )
{
@ -374,6 +378,12 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
changed = true;
pad->SetPinFunction( pinFunction );
}
if( pad->GetPinType() != pinType )
{
changed = true;
pad->SetPinType( pinType );
}
}
else
cachePinFunction( pad, pinFunction );

View File

@ -189,6 +189,7 @@ void KICAD_NETLIST_PARSER::parseNet()
wxString reference;
wxString pin_number;
wxString pin_function;
wxString pin_type;
// The token net was read, so the next data is (code <number>)
while( (token = NextTok() ) != T_EOF )
@ -213,7 +214,9 @@ void KICAD_NETLIST_PARSER::parseNet()
break;
case T_node:
pin_function.Clear(); // By default: no pin function.
// By default: no pin function or type.
pin_function.Clear();
pin_type.Clear();
while( (token = NextTok() ) != T_EOF )
{
@ -242,6 +245,12 @@ void KICAD_NETLIST_PARSER::parseNet()
NeedRIGHT();
break;
case T_pintype:
NeedSYMBOLorNUMBER();
pin_type = FROM_UTF8( CurText() );
NeedRIGHT();
break;
default:
skipCurrent();
break;
@ -265,7 +274,7 @@ void KICAD_NETLIST_PARSER::parseNet()
m_lineReader->LineNumber(), m_lineReader->Length() );
}
component->AddNet( pin_number, name, pin_function );
component->AddNet( pin_number, name, pin_function, pin_type );
}
break;

View File

@ -205,7 +205,7 @@ void LEGACY_NETLIST_READER::loadNet( char* aText, COMPONENT* aComponent )
if( (char) netName[0] == '?' ) // ? indicates no net connected to pin.
netName = wxEmptyString;
aComponent->AddNet( pinName, netName, wxEmptyString );
aComponent->AddNet( pinName, netName, wxEmptyString, wxEmptyString );
}

View File

@ -46,19 +46,24 @@ class COMPONENT_NET
wxString m_pinName;
wxString m_netName;
wxString m_pinFunction;
wxString m_pinType;
public:
COMPONENT_NET() {}
COMPONENT_NET( const wxString& aPinName, const wxString& aNetName,
const wxString& aPinFunction ) :
m_pinName( aPinName ), m_netName( aNetName ), m_pinFunction( aPinFunction )
const wxString& aPinFunction, const wxString& aPinType ) :
m_pinName( aPinName ),
m_netName( aNetName ),
m_pinFunction( aPinFunction ),
m_pinType( aPinType )
{
}
const wxString& GetPinName() const { return m_pinName; }
const wxString& GetNetName() const { return m_netName; }
const wxString& GetPinFunction() const { return m_pinFunction; }
const wxString& GetPinType() const { return m_pinType; }
bool IsValid() const { return !m_pinName.IsEmpty(); }
@ -125,9 +130,10 @@ public:
virtual ~COMPONENT() { };
void AddNet( const wxString& aPinName, const wxString& aNetName, const wxString& aPinFunction )
void AddNet( const wxString& aPinName, const wxString& aNetName, const wxString& aPinFunction,
const wxString& aPinType )
{
m_nets.push_back( COMPONENT_NET( aPinName, aNetName, aPinFunction ) );
m_nets.push_back( COMPONENT_NET( aPinName, aNetName, aPinFunction, aPinType ) );
}
unsigned GetNetCount() const { return m_nets.size(); }

View File

@ -868,6 +868,9 @@ void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>&
if( !GetPinFunction().IsEmpty() )
aList.emplace_back( _( "Pin Name" ), GetPinFunction() );
if( !GetPinType().IsEmpty() )
aList.emplace_back( _( "Pin Type" ), GetPinType() );
aList.emplace_back( _( "Net" ), UnescapeString( GetNetname() ) );
aList.emplace_back( _( "NetClass" ), UnescapeString( GetNetClass()->GetName() ) );
@ -1433,6 +1436,10 @@ static struct PAD_DESC
propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Pad Number" ),
&PAD::SetName, &PAD::GetName ) );
propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Pin Name" ),
&PAD::SetPinFunction, &PAD::GetPinFunction ) );
propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Pin Type" ),
&PAD::SetPinType, &PAD::GetPinType ) );
propMgr.AddProperty( new PROPERTY<PAD, double>( _HKI( "Orientation" ),
&PAD::SetOrientationDegrees, &PAD::GetOrientationDegrees,
PROPERTY_DISPLAY::DEGREE ) );

View File

@ -135,6 +135,12 @@ public:
void SetPinFunction( const wxString& aName ) { m_pinFunction = aName; }
const wxString& GetPinFunction() const { return m_pinFunction; }
/**
* Set the pad electrical type
*/
void SetPinType( const wxString& aType ) { m_pinType = aType; }
const wxString& GetPinType() const { return m_pinType; }
/**
* Before we had custom pad shapes it was common to have multiple overlapping pads to
* represent a more complex shape.
@ -663,7 +669,8 @@ private:
private:
wxString m_name; // Pad name (pin number in schematic)
wxString m_pinFunction; // Pin function in schematic
wxString m_pinFunction; // Pin name in schematic
wxString m_pinType; // Pin electrical type in schematic
wxPoint m_pos; // Pad Position on board