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 ()
 
const wxString & GetPinNumText () const
 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
 
wxString 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_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_netNameCandidate = NULL; /* a pointer to a NETLIST_OBJECT type label connected to this
188  * object used to give a name to the net
189  */
190 }
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 194 of file class_netlist_object.cpp.

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

Definition at line 200 of file class_netlist_object.cpp.

201 {
202 }

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 241 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().

242 {
243  wxCHECK_RET( IsBusLabel( m_Label ),
244  wxT( "<" ) + m_Label + wxT( "> is not a valid bus label." ) );
245 
246  if( m_Type == NET_HIERLABEL )
248  else if( m_Type == NET_GLOBLABEL )
250  else if( m_Type == NET_SHEETLABEL )
252  else if( m_Type == NET_LABEL )
254  else
255  wxCHECK_RET( false, wxT( "Net list object type is not valid." ) );
256 
257  unsigned i;
258  wxString tmp, busName, busNumber;
259  long begin, end, member;
260 
261  busName = busLabelRe.GetMatch( m_Label, 1 );
262  busNumber = busLabelRe.GetMatch( m_Label, 2 );
263 
264  /* Search for '[' because a bus label is like "busname[nn..mm]" */
265  i = busNumber.Find( '[' );
266  i++;
267 
268  while( i < busNumber.Len() && busNumber[i] != '.' )
269  {
270  tmp.Append( busNumber[i] );
271  i++;
272  }
273 
274  tmp.ToLong( &begin );
275 
276  while( i < busNumber.Len() && busNumber[i] == '.' )
277  i++;
278 
279  tmp.Empty();
280 
281  while( i < busNumber.Len() && busNumber[i] != ']' )
282  {
283  tmp.Append( busNumber[i] );
284  i++;
285  }
286 
287  tmp.ToLong( &end );
288 
289  if( begin < 0 )
290  begin = 0;
291 
292  if( end < 0 )
293  end = 0;
294 
295  if( begin > end )
296  std::swap( begin, end );
297 
298  member = begin;
299  tmp = busName;
300  tmp << member;
301  m_Label = tmp;
302  m_Member = member;
303 
304  for( member++; member <= end; member++ )
305  {
306  NETLIST_OBJECT* item = new NETLIST_OBJECT( *this );
307 
308  // Conversion of bus label to the root name + the current member id.
309  tmp = busName;
310  tmp << member;
311  item->m_Label = tmp;
312  item->m_Member = member;
313 
314  aNetListItems.push_back( item );
315  }
316 }
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 195 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().

196  {
197  if( m_Link && m_Link->Type() == SCH_COMPONENT_T )
198  return (SCH_COMPONENT*) m_Link;
199 
200  return NULL;
201  }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
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 347 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().

348 {
349  if( m_netNameCandidate == NULL )
350  return wxEmptyString;
351 
352  wxString netName;
353 
355  return GetShortNetName( adoptTimestamp );
356 
358  {
359  // usual net name, prefix it by the sheet path
361  }
362 
363  netName += m_netNameCandidate->m_Label;
364 
365  return netName;
366 }
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.
const wxString& NETLIST_OBJECT::GetPinNumText ( ) const
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 m_PinNum.

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

186  {
187  return m_PinNum;
188  }
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 373 of file class_netlist_object.cpp.

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

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

374 {
375  if( m_netNameCandidate == NULL )
376  return wxEmptyString;
377 
378  wxString netName;
379 
381  {
383  if( link ) // Should be always true
384  {
385  netName = wxT("Net-(");
386  netName << link->GetRef( &m_netNameCandidate->m_SheetPath );
387 
388  if( adoptTimestamp && netName.Last() == '?' )
389  netName << link->GetTimeStamp();
390 
391  netName << wxT("-Pad") << m_netNameCandidate->m_PinNum << wxT(")");
392  }
393  }
394  else
395  netName = m_netNameCandidate->m_Label;
396 
397  return netName;
398 }
NETLIST_OBJECT * m_netNameCandidate
SCH_SHEET_PATH m_SheetPath
NETLIST_ITEM_T m_Type
const wxString GetRef(const SCH_SHEET_PATH *aSheet)
Return the reference for the given sheet path.
SCH_COMPONENT * GetComponentParent() const
For Pins (NET_PINS):
time_t GetTimeStamp() const
Definition: base_struct.h:218
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
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 330 of file class_netlist_object.cpp.

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

Referenced by NETLIST_OBJECT_LIST::connectBusLabels().

331 {
332  // return true if the object is a bus label member build from a
333  // schematic bus label (like label[xx..yy)
334  // They are labels with very specific properties, especially for connection
335  // between them: 2 bus label members can be connected only
336  // if they have the same member value.
337  return ( m_Type == NET_SHEETBUSLABELMEMBER ) ||
338  ( m_Type == NET_BUSLABELMEMBER ) ||
341 }
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 215 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.

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

320 {
321  // return true if the object is a global label
322  // * a actual global label
323  // * a pin label coming from a invisible power pin
324  return ( m_Type == NET_PINLABEL ) ||
325  ( m_Type == NET_GLOBLABEL ) ||
327 }
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 408 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().

409 {
410  switch( aCandidate->m_Type )
411  {
412  case NET_HIERLABEL:
413  case NET_LABEL:
414  case NET_PINLABEL:
415  case NET_GLOBLABEL:
418  case NET_PIN:
419  m_netNameCandidate = aCandidate;
420  break;
421 
422  default:
423  break;
424  }
425 }
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: