From f5e35af1a5a900d7125404a4763adb946da4bca2 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 21 Jan 2021 21:46:03 +0000 Subject: [PATCH] Transmit pin electrical types through to pads. --- common/netlist.keywords | 1 + eeschema/lib_pin.cpp | 12 ++++++------ .../netlist_exporters/netlist_exporter_xml.cpp | 5 ++--- eeschema/sch_pin.h | 5 +++++ pcbnew/cross-probing.cpp | 5 ++++- pcbnew/netlist_reader/board_netlist_updater.cpp | 10 ++++++++++ pcbnew/netlist_reader/kicad_netlist_reader.cpp | 13 +++++++++++-- pcbnew/netlist_reader/legacy_netlist_reader.cpp | 2 +- pcbnew/netlist_reader/pcb_netlist.h | 14 ++++++++++---- pcbnew/pad.cpp | 7 +++++++ pcbnew/pad.h | 9 ++++++++- 11 files changed, 65 insertions(+), 18 deletions(-) diff --git a/common/netlist.keywords b/common/netlist.keywords index edabd96803..e9c23b9b70 100644 --- a/common/netlist.keywords +++ b/common/netlist.keywords @@ -28,6 +28,7 @@ part pin pins pinfunction +pintype property ref sheetpath diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index a69c314e41..03523859b3 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -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( aType )]; diff --git a/eeschema/netlist_exporters/netlist_exporter_xml.cpp b/eeschema/netlist_exporters/netlist_exporter_xml.cpp index 2e36bc70af..fa438d8323 100644 --- a/eeschema/netlist_exporters/netlist_exporter_xml.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_xml.cpp @@ -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() ); } } diff --git a/eeschema/sch_pin.h b/eeschema/sch_pin.h index cb5a191d60..62d9b86b0f 100644 --- a/eeschema/sch_pin.h +++ b/eeschema/sch_pin.h @@ -118,6 +118,11 @@ public: ELECTRICAL_PINTYPE GetType() const; + wxString GetCanonicalElectricalTypeName() const + { + return LIB_PIN::GetCanonicalElectricalTypeName( GetType() ); + } + GRAPHIC_PINSHAPE GetShape() const; int GetOrientation() const; diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index 049ec47251..5bed6e8e55 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -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 ); diff --git a/pcbnew/netlist_reader/board_netlist_updater.cpp b/pcbnew/netlist_reader/board_netlist_updater.cpp index 06d6a77862..c4b86a3660 100644 --- a/pcbnew/netlist_reader/board_netlist_updater.cpp +++ b/pcbnew/netlist_reader/board_netlist_updater.cpp @@ -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 ); diff --git a/pcbnew/netlist_reader/kicad_netlist_reader.cpp b/pcbnew/netlist_reader/kicad_netlist_reader.cpp index f378113f61..655b115feb 100644 --- a/pcbnew/netlist_reader/kicad_netlist_reader.cpp +++ b/pcbnew/netlist_reader/kicad_netlist_reader.cpp @@ -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 ) 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; diff --git a/pcbnew/netlist_reader/legacy_netlist_reader.cpp b/pcbnew/netlist_reader/legacy_netlist_reader.cpp index 9dd607a96e..158aef1bd8 100644 --- a/pcbnew/netlist_reader/legacy_netlist_reader.cpp +++ b/pcbnew/netlist_reader/legacy_netlist_reader.cpp @@ -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 ); } diff --git a/pcbnew/netlist_reader/pcb_netlist.h b/pcbnew/netlist_reader/pcb_netlist.h index 03a99dfaa9..b492195d20 100644 --- a/pcbnew/netlist_reader/pcb_netlist.h +++ b/pcbnew/netlist_reader/pcb_netlist.h @@ -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(); } diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index cfa399d618..e93bdfd2cd 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -868,6 +868,9 @@ void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& 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( _HKI( "Pad Number" ), &PAD::SetName, &PAD::GetName ) ); + propMgr.AddProperty( new PROPERTY( _HKI( "Pin Name" ), + &PAD::SetPinFunction, &PAD::GetPinFunction ) ); + propMgr.AddProperty( new PROPERTY( _HKI( "Pin Type" ), + &PAD::SetPinType, &PAD::GetPinType ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Orientation" ), &PAD::SetOrientationDegrees, &PAD::GetOrientationDegrees, PROPERTY_DISPLAY::DEGREE ) ); diff --git a/pcbnew/pad.h b/pcbnew/pad.h index d123d1ab38..1e806fd05e 100644 --- a/pcbnew/pad.h +++ b/pcbnew/pad.h @@ -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