You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
4.4 KiB

  1. /*************************************************************************************/
  2. /* Class NETLIST_OBJECT to handle 1 item connected (in netlist and erc calculations) */
  3. /*************************************************************************************/
  4. #include "fctsys.h"
  5. #include "common.h"
  6. #include "program.h"
  7. #include "general.h"
  8. #include "class_netlist_object.h"
  9. #if defined(DEBUG)
  10. #include <iostream>
  11. const char* ShowType( NetObjetType aType )
  12. {
  13. const char* ret;
  14. switch( aType )
  15. {
  16. case NET_SEGMENT:
  17. ret = "segment"; break;
  18. case NET_BUS:
  19. ret = "bus"; break;
  20. case NET_JONCTION:
  21. ret = "junction"; break;
  22. case NET_LABEL:
  23. ret = "label"; break;
  24. case NET_HIERLABEL:
  25. ret = "hierlabel"; break;
  26. case NET_GLOBLABEL:
  27. ret = "glabel"; break;
  28. case NET_BUSLABELMEMBER:
  29. ret = "buslblmember"; break;
  30. case NET_HIERBUSLABELMEMBER:
  31. ret = "hierbuslblmember"; break;
  32. case NET_GLOBBUSLABELMEMBER:
  33. ret = "gbuslblmember"; break;
  34. case NET_SHEETBUSLABELMEMBER:
  35. ret = "sbuslblmember"; break;
  36. case NET_SHEETLABEL:
  37. ret = "sheetlabel"; break;
  38. case NET_PINLABEL:
  39. ret = "pinlabel"; break;
  40. case NET_PIN:
  41. ret = "pin"; break;
  42. case NET_NOCONNECT:
  43. ret = "noconnect"; break;
  44. default:
  45. ret = "??"; break;
  46. }
  47. return ret;
  48. }
  49. void NETLIST_OBJECT::Show( std::ostream& out, int ndx )
  50. {
  51. wxString path = m_SheetList.PathHumanReadable();
  52. out << "<netItem ndx=\"" << ndx << '"' <<
  53. " type=\"" << ShowType( m_Type ) << '"' <<
  54. " netCode=\"" << GetNet() << '"' <<
  55. " sheet=\"" << CONV_TO_UTF8( path ) << '"' <<
  56. ">\n";
  57. out << " <start " << m_Start << "/> <end " << m_End << "/>\n";
  58. if( !m_Label.IsEmpty() )
  59. out << " <label>" << m_Label.mb_str() << "</label>\n";
  60. out << " <sheetpath>" << m_SheetList.PathHumanReadable().mb_str() << "</sheetpath>\n";
  61. switch( m_Type )
  62. {
  63. case NET_PIN:
  64. out << " <refOfComp>" << ((SCH_COMPONENT*)m_Link)->GetRef(&m_SheetList).mb_str() << "</refOfComp>\n";
  65. if( m_Comp )
  66. m_Comp->Show( 1, out );
  67. break;
  68. default:
  69. // not all the m_Comp classes have working Show functions.
  70. ;
  71. }
  72. /* was segfault-ing
  73. if( m_Comp )
  74. m_Comp->Show( 1, out ); // labels may not have good Show() funcs?
  75. else
  76. out << " m_Comp==NULL\n";
  77. */
  78. out << "</netItem>\n";
  79. }
  80. #endif
  81. NETLIST_OBJECT::NETLIST_OBJECT()
  82. {
  83. m_Type = NET_ITEM_UNSPECIFIED; /* Type of this item (see NetObjetType enum) */
  84. m_Comp = NULL; /* Pointer on the library item that created this net object
  85. * (the parent)*/
  86. m_Link = NULL; /* For SCH_SHEET_PIN:
  87. * Pointer to the hierarchy sheet that contains this
  88. * SCH_SHEET_PIN For Pins: pointer to the component that
  89. * contains this pin
  90. */
  91. m_Flag = 0; /* flag used in calculations */
  92. m_ElectricalType = 0; /* Has meaning only for Pins and hierachical pins: electrical
  93. * type */
  94. m_NetCode = 0; /* net code for all items except BUS labels because a BUS
  95. * label has as many net codes as bus members
  96. */
  97. m_BusNetCode = 0; /* Used for BUS connections */
  98. m_Member = 0; /* for labels type NET_BUSLABELMEMBER ( bus member created
  99. * from the BUS label ) member number
  100. */
  101. m_FlagOfConnection = UNCONNECTED;
  102. m_PinNum = 0; /* pin number ( 1 long = 4 bytes -> 4 ascii codes) */
  103. m_NetNameCandidate = NULL; /* a pointer to a NETLIST_OBJECT type label connected to this
  104. * object used to give a name to the net
  105. */
  106. }
  107. // Copy constructor
  108. NETLIST_OBJECT::NETLIST_OBJECT( NETLIST_OBJECT& aSource )
  109. {
  110. *this = aSource;
  111. }
  112. NETLIST_OBJECT::~NETLIST_OBJECT()
  113. {
  114. }