KiCad PCB EDA Suite
NETLIST_OBJECT Class Reference

#include <class_netlist_object.h>

Public Member Functions

 NETLIST_OBJECT ()
 
 NETLIST_OBJECT (NETLIST_OBJECT &aSource)
 
 ~NETLIST_OBJECT ()
 
void SetNet (int aNetCode)
 
int GetNet () const
 
void SetConnectionType (NET_CONNECTION_T aFlg=UNCONNECTED)
 Set the item connection type: UNCONNECTED Pin or Label not connected (error) NOCONNECT_SYMBOL_PRESENT Pin not connected but have a NoConnect symbol on it (no error) PAD_CONNECT Normal connection (no error) More...
 
NET_CONNECTION_T GetConnectionType () const
 
void SetNetNameCandidate (NETLIST_OBJECT *aCandidate)
 Set m_netNameCandidate to a connected item which will be used to calcule the net name of the item Obviously the candidate can be only a label when there is no label on the net a pad which will used to build a net name (something like Cmp<REF>_Pad<PAD_NAME> More...
 
bool HasNetNameCandidate ()
 
wxString GetPinNumText ()
 Function GetPinNum returns a pin number in wxString form. More...
 
SCH_COMPONENTGetComponentParent () const
 For Pins (NET_PINS): More...
 
bool IsLabelConnected (NETLIST_OBJECT *aNetItem)
 Function IsLabelConnected tests if the net list object is a hierarchical label or sheet label and is connected to an associated hierarchical label or sheet label of aNetItem. More...
 
bool IsLabelGlobal () const
 Function IsLabelGlobal. More...
 
bool IsLabelBusMemberType () const
 Function IsLabelBusMemberType. More...
 
bool IsLabelType () const
 Function IsLabelType. More...
 
wxString GetNetName (bool adoptTimestamp=false) const
 Function GetNetName. More...
 
wxString GetShortNetName (bool adoptTimestamp=false) const
 Function GetShortNetName. More...
 
void ConvertBusToNetListItems (NETLIST_OBJECT_LIST &aNetListItems)
 Function ConvertBusToNetListItems breaks the text of a bus label type net list object into as many members as it contains and creates a NETLIST_OBJECT for each label and adds it to aNetListItems. More...
 

Public Attributes

NETLIST_ITEM_T m_Type
 
EDA_ITEMm_Comp
 
SCH_ITEMm_Link
 
int m_Flag
 
SCH_SHEET_PATH m_SheetPath
 
SCH_SHEET_PATH m_SheetPathInclude
 
ELECTRICAL_PINTYPE m_ElectricalPinType
 
int m_BusNetCode
 
int m_Member
 
NET_CONNECTION_T m_ConnectionType
 
long m_PinNum
 
wxString m_Label
 
wxPoint m_Start
 
wxPoint m_End
 

Private Attributes

int m_netCode
 
NETLIST_OBJECTm_netNameCandidate
 

Detailed Description

Definition at line 92 of file class_netlist_object.h.

Constructor & Destructor Documentation

NETLIST_OBJECT::NETLIST_OBJECT ( )

Definition at line 165 of file class_netlist_object.cpp.

References m_BusNetCode, m_Comp, m_ConnectionType, m_ElectricalPinType, m_Flag, m_Link, m_Member, m_netCode, m_netNameCandidate, m_PinNum, m_Type, NET_ITEM_UNSPECIFIED, PIN_INPUT, and UNCONNECTED.

Referenced by ConvertBusToNetListItems().

166 {
167  m_Type = NET_ITEM_UNSPECIFIED; /* Type of this item (see NETLIST_ITEM_T enum) */
168  m_Comp = NULL; /* Pointer on the library item that created this net object
169  * (the parent)*/
170  m_Link = NULL; /* For SCH_SHEET_PIN:
171  * Pointer to the hierarchy sheet that contains this
172  * SCH_SHEET_PIN For Pins: pointer to the component that
173  * contains this pin
174  */
175  m_Flag = 0; /* flag used in calculations */
176  m_ElectricalPinType = PIN_INPUT; /* Has meaning only for Pins: electrical type of the pin
177  * used to detect conflicts between pins in ERC
178  */
179  m_netCode = 0; /* net code for all items except BUS labels because a BUS
180  * label has as many net codes as bus members
181  */
182  m_BusNetCode = 0; /* Used for BUS connections */
183  m_Member = 0; /* for labels type NET_BUSLABELMEMBER ( bus member created
184  * from the BUS label ) member number
185  */
187  m_PinNum = 0; /* pin number ( 1 long = 4 bytes -> 4 ascii codes) */
188  m_netNameCandidate = NULL; /* a pointer to a NETLIST_OBJECT type label connected to this
189  * object used to give a name to the net
190  */
191 }
NETLIST_OBJECT * m_netNameCandidate
NET_CONNECTION_T m_ConnectionType
ELECTRICAL_PINTYPE m_ElectricalPinType
NETLIST_ITEM_T m_Type
NETLIST_OBJECT::NETLIST_OBJECT ( NETLIST_OBJECT aSource)

Definition at line 195 of file class_netlist_object.cpp.

196 {
197  *this = aSource;
198 }
NETLIST_OBJECT::~NETLIST_OBJECT ( )

Definition at line 201 of file class_netlist_object.cpp.

202 {
203 }

Member Function Documentation

void NETLIST_OBJECT::ConvertBusToNetListItems ( NETLIST_OBJECT_LIST aNetListItems)

Function ConvertBusToNetListItems breaks the text of a bus label type net list object into as many members as it contains and creates a NETLIST_OBJECT for each label and adds it to aNetListItems.

Parameters
aNetListItemsA reference to vector of NETLIST_OBJECT pointers to add the bus label NETLIST_OBJECTs.

Definition at line 242 of file class_netlist_object.cpp.

References busLabelRe(), IsBusLabel(), m_Label, m_Member, m_Type, NET_BUSLABELMEMBER, NET_GLOBBUSLABELMEMBER, NET_GLOBLABEL, NET_HIERBUSLABELMEMBER, NET_HIERLABEL, NET_LABEL, NET_SHEETBUSLABELMEMBER, NET_SHEETLABEL, and NETLIST_OBJECT().

Referenced by SCH_TEXT::GetNetListItem(), and SCH_SHEET::GetNetListItem().

243 {
244  wxCHECK_RET( IsBusLabel( m_Label ),
245  wxT( "<" ) + m_Label + wxT( "> is not a valid bus label." ) );
246 
247  if( m_Type == NET_HIERLABEL )
249  else if( m_Type == NET_GLOBLABEL )
251  else if( m_Type == NET_SHEETLABEL )
253  else if( m_Type == NET_LABEL )
255  else
256  wxCHECK_RET( false, wxT( "Net list object type is not valid." ) );
257 
258  unsigned i;
259  wxString tmp, busName, busNumber;
260  long begin, end, member;
261 
262  busName = busLabelRe.GetMatch( m_Label, 1 );
263  busNumber = busLabelRe.GetMatch( m_Label, 2 );
264 
265  /* Search for '[' because a bus label is like "busname[nn..mm]" */
266  i = busNumber.Find( '[' );
267  i++;
268 
269  while( i < busNumber.Len() && busNumber[i] != '.' )
270  {
271  tmp.Append( busNumber[i] );
272  i++;
273  }
274 
275  tmp.ToLong( &begin );
276 
277  while( i < busNumber.Len() && busNumber[i] == '.' )
278  i++;
279 
280  tmp.Empty();
281 
282  while( i < busNumber.Len() && busNumber[i] != ']' )
283  {
284  tmp.Append( busNumber[i] );
285  i++;
286  }
287 
288  tmp.ToLong( &end );
289 
290  if( begin < 0 )
291  begin = 0;
292 
293  if( end < 0 )
294  end = 0;
295 
296  if( begin > end )
297  std::swap( begin, end );
298 
299  member = begin;
300  tmp = busName;
301  tmp << member;
302  m_Label = tmp;
303  m_Member = member;
304 
305  for( member++; member <= end; member++ )
306  {
307  NETLIST_OBJECT* item = new NETLIST_OBJECT( *this );
308 
309  // Conversion of bus label to the root name + the current member id.
310  tmp = busName;
311  tmp << member;
312  item->m_Label = tmp;
313  item->m_Member = member;
314 
315  aNetListItems.push_back( item );
316  }
317 }
bool IsBusLabel(const wxString &aLabel)
Function IsBusLabel test if aLabel has a bus notation.
NETLIST_ITEM_T m_Type
static wxRegEx busLabelRe(wxT("^([^[:space:]]+)(\\[[\\d]+\\.+[\\d]+\\])$"), wxRE_ADVANCED)
The regular expression string for label bus notation.
SCH_COMPONENT* NETLIST_OBJECT::GetComponentParent ( ) const
inline

For Pins (NET_PINS):

Returns
the schematic component which contains this pin (Note: this is the schematic component, not the library component for others items: return NULL

Definition at line 196 of file class_netlist_object.h.

References m_Link, SCH_COMPONENT_T, and EDA_ITEM::Type().

Referenced by Diagnose(), NETLIST_OBJECT_LIST::findBestNetNameForEachNet(), GetShortNetName(), NETLIST_EXPORTER_GENERIC::makeListOfNets(), and NETLIST_EXPORTER_CADSTAR::writeListOfNets().

197  {
198  if( m_Link && m_Link->Type() == SCH_COMPONENT_T )
199  return (SCH_COMPONENT*) m_Link;
200 
201  return NULL;
202  }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:68
NET_CONNECTION_T NETLIST_OBJECT::GetConnectionType ( ) const
inline

Definition at line 159 of file class_netlist_object.h.

References m_ConnectionType.

Referenced by NETLIST_OBJECT_LIST::GetConnectionType(), and NETLIST_EXPORTER::sprintPinNetName().

160  {
161  return m_ConnectionType;
162  }
NET_CONNECTION_T m_ConnectionType
wxString NETLIST_OBJECT::GetNetName ( bool  adoptTimestamp = false) const

Function GetNetName.

Parameters
adoptTimestampif annotation is not done (i.e. GetRef returns something with an ? at the end)
Returns
the full net name of the item, i.e. the net name from the "best" label, prefixed by the sheet path

Definition at line 348 of file class_netlist_object.cpp.

References GetShortNetName(), IsLabelGlobal(), m_Label, m_netNameCandidate, m_SheetPath, m_Type, NET_PIN, and SCH_SHEET_PATH::PathHumanReadable().

Referenced by NETLIST_EXPORTER_PSPICE::Format(), NETLIST_EXPORTER_GENERIC::makeListOfNets(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), NETLIST_EXPORTER::sprintPinNetName(), and NETLIST_EXPORTER_CADSTAR::writeListOfNets().

349 {
350  if( m_netNameCandidate == NULL )
351  return wxEmptyString;
352 
353  wxString netName;
354 
356  return GetShortNetName( adoptTimestamp );
357 
359  {
360  // usual net name, prefix it by the sheet path
362  }
363 
364  netName += m_netNameCandidate->m_Label;
365 
366  return netName;
367 }
bool IsLabelGlobal() const
Function IsLabelGlobal.
NETLIST_OBJECT * m_netNameCandidate
SCH_SHEET_PATH m_SheetPath
NETLIST_ITEM_T m_Type
wxString PathHumanReadable() const
Function PathHumanReadable returns the sheet path in a human readable form, i.e.
wxString GetShortNetName(bool adoptTimestamp=false) const
Function GetShortNetName.
wxString NETLIST_OBJECT::GetPinNumText ( )
inline

Function GetPinNum returns a pin number in wxString form.

Pin numbers are not always numbers. "A23" would be a valid pin number.

Definition at line 185 of file class_netlist_object.h.

References LIB_PIN::PinStringNum().

Referenced by NETLIST_EXPORTER_GENERIC::makeListOfNets(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), and sortPinsByNum().

186  {
187  // hide the ugliness in here, but do it inline.
189  }
void PinStringNum(wxString &aStringBuffer) const
Fill a string buffer with pin number.
Definition: lib_pin.cpp:1886
wxString NETLIST_OBJECT::GetShortNetName ( bool  adoptTimestamp = false) const

Function GetShortNetName.

return the short net name of the item i.e.

Parameters
adoptTimestampif annotation is not done (i.e. GetRef returns something with an ? at the end)
Returns
the short net name of the item i.e. the net name from the "best" label without any prefix. 2 different nets can have the same short name

the net name from the "best" label without any prefix. 2 different nets can have the same short name

Definition at line 374 of file class_netlist_object.cpp.

References GetComponentParent(), SCH_COMPONENT::GetRef(), EDA_ITEM::GetTimeStamp(), m_Label, m_netNameCandidate, m_PinNum, m_SheetPath, m_Type, NET_PIN, and LIB_PIN::PinStringNum().

Referenced by NETLIST_OBJECT_LIST::findBestNetNameForEachNet(), and GetNetName().

375 {
376  if( m_netNameCandidate == NULL )
377  return wxEmptyString;
378 
379  wxString netName;
380 
382  {
384  if( link ) // Should be always true
385  {
386  netName = wxT("Net-(");
387  netName << link->GetRef( &m_netNameCandidate->m_SheetPath );
388 
389  if( adoptTimestamp && netName.Last() == '?' )
390  netName << link->GetTimeStamp();
391 
392  netName << wxT("-Pad")
394  << wxT(")");
395  }
396  }
397  else
398  netName = m_netNameCandidate->m_Label;
399 
400  return netName;
401 }
NETLIST_OBJECT * m_netNameCandidate
SCH_SHEET_PATH m_SheetPath
NETLIST_ITEM_T m_Type
SCH_COMPONENT * GetComponentParent() const
For Pins (NET_PINS):
time_t GetTimeStamp() const
Definition: base_struct.h:204
const wxString GetRef(const SCH_SHEET_PATH *sheet)
Function GetRef returns the reference, for the given sheet path.
void PinStringNum(wxString &aStringBuffer) const
Fill a string buffer with pin number.
Definition: lib_pin.cpp:1886
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:68
bool NETLIST_OBJECT::HasNetNameCandidate ( )
inline
Returns
true if an item has already a net name candidate and false if not ( m_netNameCandidate == NULL )

Definition at line 178 of file class_netlist_object.h.

Referenced by NETLIST_OBJECT_LIST::findBestNetNameForEachNet().

178 { return m_netNameCandidate != NULL; }
NETLIST_OBJECT * m_netNameCandidate
bool NETLIST_OBJECT::IsLabelBusMemberType ( ) const

Function IsLabelBusMemberType.

Returns
true if the object is a bus label member build from a schematic bus label (like label[xx..yy], xx and yy are the first and last bus member id) bus label members have specific properties: they do not live in schematic they have specific properties in connections: 2 bus label members can be connected connected only if they have the same member value.

Definition at line 331 of file class_netlist_object.cpp.

References m_Type, NET_BUSLABELMEMBER, NET_GLOBBUSLABELMEMBER, NET_HIERBUSLABELMEMBER, and NET_SHEETBUSLABELMEMBER.

Referenced by NETLIST_OBJECT_LIST::connectBusLabels().

332 {
333  // return true if the object is a bus label member build from a
334  // schematic bus label (like label[xx..yy)
335  // They are labels with very specific properties, especially for connection
336  // between them: 2 bus label members can be connected only
337  // if they have the same member value.
338  return ( m_Type == NET_SHEETBUSLABELMEMBER ) ||
339  ( m_Type == NET_BUSLABELMEMBER ) ||
342 }
NETLIST_ITEM_T m_Type
bool NETLIST_OBJECT::IsLabelConnected ( NETLIST_OBJECT aNetItem)

Function IsLabelConnected tests if the net list object is a hierarchical label or sheet label and is connected to an associated hierarchical label or sheet label of aNetItem.

Parameters
aNetItemA pointer to a NETLIST_OBJECT to test against.
Returns
A bool value of true if there is a connection with aNetItem or false if no connection to aNetItem.

Definition at line 216 of file class_netlist_object.cpp.

References m_Label, m_SheetPath, m_SheetPathInclude, m_Type, NET_GLOBLABEL, NET_HIERBUSLABELMEMBER, NET_HIERLABEL, NET_SHEETBUSLABELMEMBER, and NET_SHEETLABEL.

217 {
218  if( aNetItem == this ) // Don't compare the same net list object.
219  return false;
220 
221  int at = m_Type;
222  int bt = aNetItem->m_Type;
223 
224  if( ( at == NET_HIERLABEL || at == NET_HIERBUSLABELMEMBER )
225  && ( bt == NET_SHEETLABEL || bt == NET_SHEETBUSLABELMEMBER ) )
226  {
227  if( m_SheetPath == aNetItem->m_SheetPathInclude )
228  {
229  return true; //connected!
230  }
231  }
232  else if( ( at == NET_GLOBLABEL ) && ( bt == NET_GLOBLABEL ) )
233  {
234  if( m_Label == aNetItem->m_Label )
235  return true; //connected!
236  }
237 
238  return false; //these two are unconnected
239 }
SCH_SHEET_PATH m_SheetPathInclude
SCH_SHEET_PATH m_SheetPath
NETLIST_ITEM_T m_Type
bool NETLIST_OBJECT::IsLabelGlobal ( ) const

Function IsLabelGlobal.

Returns
true if the object is a global label (i.e. an real global label or a pin label coming from a power pin invisible

Definition at line 320 of file class_netlist_object.cpp.

References m_Type, NET_GLOBBUSLABELMEMBER, NET_GLOBLABEL, and NET_PINLABEL.

Referenced by countIndenticalLabels(), evalLabelsPriority(), GetNetName(), SimilarLabelsDiagnose(), and NETLIST_OBJECT_LIST::TestforSimilarLabels().

321 {
322  // return true if the object is a global label
323  // * a actual global label
324  // * a pin label coming from a invisible power pin
325  return ( m_Type == NET_PINLABEL ) ||
326  ( m_Type == NET_GLOBLABEL ) ||
328 }
NETLIST_ITEM_T m_Type
void NETLIST_OBJECT::SetConnectionType ( NET_CONNECTION_T  aFlg = UNCONNECTED)
inline

Set the item connection type: UNCONNECTED Pin or Label not connected (error) NOCONNECT_SYMBOL_PRESENT Pin not connected but have a NoConnect symbol on it (no error) PAD_CONNECT Normal connection (no error)

Definition at line 154 of file class_netlist_object.h.

Referenced by NETLIST_OBJECT_LIST::ResetConnectionsType(), and NETLIST_OBJECT_LIST::SetConnectionType().

155  {
156  m_ConnectionType = aFlg;
157  }
NET_CONNECTION_T m_ConnectionType
void NETLIST_OBJECT::SetNetNameCandidate ( NETLIST_OBJECT aCandidate)

Set m_netNameCandidate to a connected item which will be used to calcule the net name of the item Obviously the candidate can be only a label when there is no label on the net a pad which will used to build a net name (something like Cmp<REF>_Pad<PAD_NAME>

Set m_netNameCandidate to a connected item which will be used to calcule the net name of the item Obviously the candidate can be only a label If there is no label on the net, a pad name will be used to build a net name (something like Cmp<REF>_Pad<PAD_NAME>

Parameters
aCandidate= the connected item candidate

Definition at line 411 of file class_netlist_object.cpp.

References m_netNameCandidate, m_Type, NET_GLOBBUSLABELMEMBER, NET_GLOBLABEL, NET_HIERLABEL, NET_LABEL, NET_PIN, NET_PINLABEL, and NET_SHEETBUSLABELMEMBER.

Referenced by NETLIST_OBJECT_LIST::findBestNetNameForEachNet().

412 {
413  switch( aCandidate->m_Type )
414  {
415  case NET_HIERLABEL:
416  case NET_LABEL:
417  case NET_PINLABEL:
418  case NET_GLOBLABEL:
421  case NET_PIN:
422  m_netNameCandidate = aCandidate;
423  break;
424 
425  default:
426  break;
427  }
428 }
NETLIST_OBJECT * m_netNameCandidate
NETLIST_ITEM_T m_Type

Member Data Documentation

NET_CONNECTION_T NETLIST_OBJECT::m_ConnectionType
ELECTRICAL_PINTYPE NETLIST_OBJECT::m_ElectricalPinType
int NETLIST_OBJECT::m_Member
int NETLIST_OBJECT::m_netCode
private

Definition at line 120 of file class_netlist_object.h.

Referenced by GetNet(), and NETLIST_OBJECT().

NETLIST_OBJECT* NETLIST_OBJECT::m_netNameCandidate
private

The documentation for this class was generated from the following files: