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 pin
pins pins
pinfunction pinfunction
pintype
property property
ref ref
sheetpath sheetpath

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -189,6 +189,7 @@ void KICAD_NETLIST_PARSER::parseNet()
wxString reference; wxString reference;
wxString pin_number; wxString pin_number;
wxString pin_function; wxString pin_function;
wxString pin_type;
// The token net was read, so the next data is (code <number>) // The token net was read, so the next data is (code <number>)
while( (token = NextTok() ) != T_EOF ) while( (token = NextTok() ) != T_EOF )
@ -213,7 +214,9 @@ void KICAD_NETLIST_PARSER::parseNet()
break; break;
case T_node: 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 ) while( (token = NextTok() ) != T_EOF )
{ {
@ -242,6 +245,12 @@ void KICAD_NETLIST_PARSER::parseNet()
NeedRIGHT(); NeedRIGHT();
break; break;
case T_pintype:
NeedSYMBOLorNUMBER();
pin_type = FROM_UTF8( CurText() );
NeedRIGHT();
break;
default: default:
skipCurrent(); skipCurrent();
break; break;
@ -265,7 +274,7 @@ void KICAD_NETLIST_PARSER::parseNet()
m_lineReader->LineNumber(), m_lineReader->Length() ); m_lineReader->LineNumber(), m_lineReader->Length() );
} }
component->AddNet( pin_number, name, pin_function ); component->AddNet( pin_number, name, pin_function, pin_type );
} }
break; 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. if( (char) netName[0] == '?' ) // ? indicates no net connected to pin.
netName = wxEmptyString; 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_pinName;
wxString m_netName; wxString m_netName;
wxString m_pinFunction; wxString m_pinFunction;
wxString m_pinType;
public: public:
COMPONENT_NET() {} COMPONENT_NET() {}
COMPONENT_NET( const wxString& aPinName, const wxString& aNetName, COMPONENT_NET( const wxString& aPinName, const wxString& aNetName,
const wxString& aPinFunction ) : const wxString& aPinFunction, const wxString& aPinType ) :
m_pinName( aPinName ), m_netName( aNetName ), m_pinFunction( aPinFunction ) m_pinName( aPinName ),
m_netName( aNetName ),
m_pinFunction( aPinFunction ),
m_pinType( aPinType )
{ {
} }
const wxString& GetPinName() const { return m_pinName; } const wxString& GetPinName() const { return m_pinName; }
const wxString& GetNetName() const { return m_netName; } const wxString& GetNetName() const { return m_netName; }
const wxString& GetPinFunction() const { return m_pinFunction; } const wxString& GetPinFunction() const { return m_pinFunction; }
const wxString& GetPinType() const { return m_pinType; }
bool IsValid() const { return !m_pinName.IsEmpty(); } bool IsValid() const { return !m_pinName.IsEmpty(); }
@ -125,9 +130,10 @@ public:
virtual ~COMPONENT() { }; 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(); } 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() ) if( !GetPinFunction().IsEmpty() )
aList.emplace_back( _( "Pin Name" ), GetPinFunction() ); aList.emplace_back( _( "Pin Name" ), GetPinFunction() );
if( !GetPinType().IsEmpty() )
aList.emplace_back( _( "Pin Type" ), GetPinType() );
aList.emplace_back( _( "Net" ), UnescapeString( GetNetname() ) ); aList.emplace_back( _( "Net" ), UnescapeString( GetNetname() ) );
aList.emplace_back( _( "NetClass" ), UnescapeString( GetNetClass()->GetName() ) ); aList.emplace_back( _( "NetClass" ), UnescapeString( GetNetClass()->GetName() ) );
@ -1433,6 +1436,10 @@ static struct PAD_DESC
propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Pad Number" ), propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Pad Number" ),
&PAD::SetName, &PAD::GetName ) ); &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" ), propMgr.AddProperty( new PROPERTY<PAD, double>( _HKI( "Orientation" ),
&PAD::SetOrientationDegrees, &PAD::GetOrientationDegrees, &PAD::SetOrientationDegrees, &PAD::GetOrientationDegrees,
PROPERTY_DISPLAY::DEGREE ) ); PROPERTY_DISPLAY::DEGREE ) );

View File

@ -135,6 +135,12 @@ public:
void SetPinFunction( const wxString& aName ) { m_pinFunction = aName; } void SetPinFunction( const wxString& aName ) { m_pinFunction = aName; }
const wxString& GetPinFunction() const { return m_pinFunction; } 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 * Before we had custom pad shapes it was common to have multiple overlapping pads to
* represent a more complex shape. * represent a more complex shape.
@ -663,7 +669,8 @@ private:
private: private:
wxString m_name; // Pad name (pin number in schematic) 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 wxPoint m_pos; // Pad Position on board