KiCad PCB EDA Suite
NETLIST_EXPORTER Class Reference

NETLIST_EXPORTER is a abstract class used for the netlist exporters that eeschema supports. More...

#include <netlist_exporter.h>

Inheritance diagram for NETLIST_EXPORTER:
NETLIST_EXPORTER_CADSTAR NETLIST_EXPORTER_GENERIC NETLIST_EXPORTER_ORCADPCB2 NETLIST_EXPORTER_PSPICE NETLIST_EXPORTER_KICAD NETLIST_EXPORTER_PSPICE_SIM

Public Member Functions

 NETLIST_EXPORTER (SCHEMATIC *aSchematic)
 Constructor. More...
 
virtual ~NETLIST_EXPORTER ()
 
virtual bool WriteNetlist (const wxString &aOutFileName, unsigned aNetlistOptions)
 Function WriteNetlist writes to specified output file. More...
 

Static Public Member Functions

static wxString MakeCommandLine (const wxString &aFormatString, const wxString &aNetlistFile, const wxString &aFinalFile, const wxString &aProjectDirectory)
 Function MakeCommandLine builds up a string that describes a command line for executing a child process. More...
 

Protected Member Functions

SCH_COMPONENTfindNextComponent (EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath)
 Checks if the given component should be processed for netlisting. More...
 

Protected Attributes

UNIQUE_STRINGS m_ReferencesAlreadyFound
 Used for "multi parts per package" components, avoids processing a lib component more than once. More...
 
std::set< LIB_PART *, LIB_PART_LESS_THANm_LibParts
 unique library parts used. LIB_PART items are sorted by names More...
 
SCHEMATICm_schematic
 The schematic we're generating a netlist for. More...
 

Detailed Description

NETLIST_EXPORTER is a abstract class used for the netlist exporters that eeschema supports.

Definition at line 88 of file netlist_exporter.h.

Constructor & Destructor Documentation

◆ NETLIST_EXPORTER()

NETLIST_EXPORTER::NETLIST_EXPORTER ( SCHEMATIC aSchematic)
inline

Constructor.

Parameters
aMasterListwe take ownership of this here.
aLibTableis the symbol library table of the project.

Definition at line 117 of file netlist_exporter.h.

117  :
118  m_schematic( aSchematic )
119  {
120  wxASSERT( aSchematic );
121  }
SCHEMATIC * m_schematic
The schematic we're generating a netlist for.

◆ ~NETLIST_EXPORTER()

virtual NETLIST_EXPORTER::~NETLIST_EXPORTER ( )
inlinevirtual

Definition at line 123 of file netlist_exporter.h.

124  {
125  }

Member Function Documentation

◆ findNextComponent()

SCH_COMPONENT * NETLIST_EXPORTER::findNextComponent ( EDA_ITEM aItem,
SCH_SHEET_PATH aSheetPath 
)
protected

Checks if the given component should be processed for netlisting.

Prevents processing multi-unit components more than once, etc.

Parameters
aItemis a component to check
aSheetPathis the sheet to check the component for
Returns
the component if it should be processed, or nullptr

Definition at line 75 of file netlist_exporter.cpp.

76 {
77  wxString ref;
78 
79  if( aItem->Type() != SCH_COMPONENT_T )
80  return nullptr;
81 
82  // found next component
83  SCH_COMPONENT* comp = (SCH_COMPONENT*) aItem;
84 
85  // Power symbols and other components which have the reference starting
86  // with "#" are not included in netlist (pseudo or virtual components)
87  ref = comp->GetRef( aSheetPath );
88 
89  if( ref[0] == wxChar( '#' ) )
90  return nullptr;
91 
92  // if( Component->m_FlagControlMulti == 1 )
93  // continue; /* yes */
94  // removed because with multiple instances of one schematic
95  // (several sheets pointing to 1 screen), this will be erroneously be
96  // toggled.
97 
98  if( !comp->GetPartRef() )
99  return nullptr;
100 
101  // If component is a "multi parts per package" type
102  if( comp->GetPartRef()->GetUnitCount() > 1 )
103  {
104  // test if this reference has already been processed, and if so skip
105  if( m_ReferencesAlreadyFound.Lookup( ref ) )
106  return nullptr;
107  }
108 
109  // record the usage of this library component entry.
110  m_LibParts.insert( comp->GetPartRef().get() ); // rejects non-unique pointers
111 
112  return comp;
113 }
bool Lookup(const wxString &aString)
Function Lookup returns true if aString already exists in the set, otherwise returns false and adds a...
UNIQUE_STRINGS m_ReferencesAlreadyFound
Used for "multi parts per package" components, avoids processing a lib component more than once.
std::set< LIB_PART *, LIB_PART_LESS_THAN > m_LibParts
unique library parts used. LIB_PART items are sorted by names
std::unique_ptr< LIB_PART > & GetPartRef()
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false)
Return the reference for the given sheet path.
Schematic symbol object.
Definition: sch_component.h:88
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197

References SCH_COMPONENT::GetPartRef(), SCH_COMPONENT::GetRef(), UNIQUE_STRINGS::Lookup(), m_LibParts, m_ReferencesAlreadyFound, SCH_COMPONENT_T, and EDA_ITEM::Type().

Referenced by NETLIST_EXPORTER_GENERIC::makeComponents(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

◆ MakeCommandLine()

wxString NETLIST_EXPORTER::MakeCommandLine ( const wxString &  aFormatString,
const wxString &  aNetlistFile,
const wxString &  aFinalFile,
const wxString &  aProjectDirectory 
)
static

Function MakeCommandLine builds up a string that describes a command line for executing a child process.

The input and output file names along with any options to the executable are all possibly in the returned string.

Parameters
aFormatStringholds:
  • the name of the external program
  • any options needed by that program
  • formatting sequences, see below.
aNetlistFileis the name of the input file for the external program, that is a intermediate netlist file in xml format.
aFinalFileis the name of the output file that the user expects.
aProjectDirectoryis used for P replacement, it should omit the trailing '/'.

Supported formatting sequences and their meaning:

  • B => base filename of selected output file, minus path and extension.
  • I => complete filename and path of the temporary input file.
  • O => complete filename and path of the user chosen output file.
  • P => project directory, without name and without trailing '/'

Definition at line 41 of file netlist_exporter.cpp.

43 {
44  // Expand format symbols in the command line:
45  // %B => base filename of selected output file, minus path and extension.
46  // %P => project directory name, without trailing '/' or '\'.
47  // %I => full filename of the input file (the intermediate net file).
48  // %O => complete filename and path (but without extension) of the user chosen output file.
49 
50  wxString ret = aFormatString;
51  wxFileName in = aNetlistFile;
52  wxFileName out = aFinalFile;
53  wxString str_out = out.GetFullPath();
54 
55  ret.Replace( "%P", aProjectPath, true );
56  ret.Replace( "%B", out.GetName(), true );
57  ret.Replace( "%I", in.GetFullPath(), true );
58 
59 #ifdef __WINDOWS__
60  // A ugly hack to run xsltproc that has a serious bug on Window since a long time:
61  // the filename given after -o option (output filename) cannot use '\' in filename
62  // so replace if by '/' if possible (I mean if the filename does not start by "\\"
63  // that is a filename on a Windows server)
64 
65  if( !str_out.StartsWith( "\\\\" ) )
66  str_out.Replace( "\\", "/" );
67 #endif
68 
69  ret.Replace( "%O", str_out, true );
70 
71  return ret;
72 }

Referenced by SCH_EDIT_FRAME::WriteNetListFile().

◆ WriteNetlist()

virtual bool NETLIST_EXPORTER::WriteNetlist ( const wxString &  aOutFileName,
unsigned  aNetlistOptions 
)
inlinevirtual

Function WriteNetlist writes to specified output file.

Reimplemented in NETLIST_EXPORTER_PSPICE, NETLIST_EXPORTER_GENERIC, NETLIST_EXPORTER_CADSTAR, NETLIST_EXPORTER_KICAD, and NETLIST_EXPORTER_ORCADPCB2.

Definition at line 131 of file netlist_exporter.h.

132  {
133  return false;
134  }

Referenced by SCH_EDIT_FRAME::WriteNetListFile().

Member Data Documentation

◆ m_LibParts

std::set<LIB_PART*, LIB_PART_LESS_THAN> NETLIST_EXPORTER::m_LibParts
protected

◆ m_ReferencesAlreadyFound

UNIQUE_STRINGS NETLIST_EXPORTER::m_ReferencesAlreadyFound
protected

Used for "multi parts per package" components, avoids processing a lib component more than once.

Definition at line 93 of file netlist_exporter.h.

Referenced by findNextComponent(), NETLIST_EXPORTER_GENERIC::makeComponents(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

◆ m_schematic


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