KiCad PCB EDA Suite
NETLIST_EXPORTER_CADSTAR Class Reference

NETLIST_EXPORTER_CADSTAR generates a netlist compatible with CADSTAR. More...

#include <netlist_exporter_cadstar.h>

Inheritance diagram for NETLIST_EXPORTER_CADSTAR:
NETLIST_EXPORTER

Public Member Functions

 NETLIST_EXPORTER_CADSTAR (SCHEMATIC *aSchematic)
 
bool WriteNetlist (const wxString &aOutFileName, unsigned aNetlistOptions) override
 Function WriteList 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

void CreatePinList (SCH_COMPONENT *aItem, SCH_SHEET_PATH *aSheetPath)
 Function findNextComponentAndCreatePinList finds a component from the DrawList and builds its pin list in m_SortedComponentPinList. More...
 
SCH_COMPONENTfindNextComponent (EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath)
 Checks if the given component should be processed for netlisting. More...
 
void eraseDuplicatePins ()
 Function eraseDuplicatePins erase duplicate Pins from m_SortedComponentPinList (i.e. More...
 
void findAllUnitsOfComponent (SCH_COMPONENT *aComponent, LIB_PART *aEntry, SCH_SHEET_PATH *aSheetPath)
 Function findAllUnitsOfComponent is used for "multiple parts per package" components. More...
 

Protected Attributes

std::vector< PIN_INFOm_SortedComponentPinList
 Used to temporarily store and filter the list of pins of a schematic component when generating schematic component data in netlist (comp section). More...
 
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. More...
 
SCHEMATICm_schematic
 The schematic we're generating a netlist for. More...
 

Private Member Functions

bool writeListOfNets (FILE *f)
 Function writeListOfNetsCADSTAR writes a net list (ranked by Netcode), and pins connected to it. More...
 

Detailed Description

NETLIST_EXPORTER_CADSTAR generates a netlist compatible with CADSTAR.

Definition at line 36 of file netlist_exporter_cadstar.h.

Constructor & Destructor Documentation

◆ NETLIST_EXPORTER_CADSTAR()

NETLIST_EXPORTER_CADSTAR::NETLIST_EXPORTER_CADSTAR ( SCHEMATIC aSchematic)
inline

Definition at line 51 of file netlist_exporter_cadstar.h.

51  :
52  NETLIST_EXPORTER( aSchematic )
53  {
54  }
NETLIST_EXPORTER(SCHEMATIC *aSchematic)
Constructor.

Member Function Documentation

◆ CreatePinList()

void NETLIST_EXPORTER::CreatePinList ( SCH_COMPONENT aItem,
SCH_SHEET_PATH aSheetPath 
)
protectedinherited

Function findNextComponentAndCreatePinList finds a component from the DrawList and builds its pin list in m_SortedComponentPinList.

This list is sorted by pin num. the component is the next actual component after aItem (power symbols and virtual components that have their reference starting by '#'are skipped).

Definition at line 124 of file netlist_exporter.cpp.

125 {
126  wxString ref( comp->GetRef( aSheetPath ) );
127 
128  // Power symbols and other components which have the reference starting
129  // with "#" are not included in netlist (pseudo or virtual components)
130 
131  if( ref[0] == wxChar( '#' ) )
132  return;
133 
134  // if( Component->m_FlagControlMulti == 1 )
135  // continue; /* yes */
136  // removed because with multiple instances of one schematic
137  // (several sheets pointing to 1 screen), this will be erroneously be
138  // toggled.
139 
140  if( !comp->GetPartRef() )
141  return;
142 
143  m_SortedComponentPinList.clear();
144 
145  // If component is a "multi parts per package" type
146  if( comp->GetPartRef()->GetUnitCount() > 1 )
147  {
148  // Collect all pins for this reference designator by searching
149  // the entire design for other parts with the same reference designator.
150  // This is only done once, it would be too expensive otherwise.
151  findAllUnitsOfComponent( comp, comp->GetPartRef().get(), aSheetPath );
152  }
153 
154  else // entry->GetUnitCount() <= 1 means one part per package
155  {
156  for( const auto& pin : comp->GetSchPins( aSheetPath ) )
157  {
158  if( auto conn = pin->Connection( *aSheetPath ) )
159  {
160  const wxString& netName = conn->Name();
161 
162  // Skip unconnected pins
163  CONNECTION_SUBGRAPH* sg =
164  m_schematic->ConnectionGraph()->FindSubgraphByName( netName, *aSheetPath );
165 
166  if( !sg || sg->m_no_connect || sg->m_items.size() < 2 )
167  continue;
168 
169  m_SortedComponentPinList.emplace_back( pin->GetNumber(), netName );
170  }
171  }
172  }
173 
174  // Sort pins in m_SortedComponentPinList by pin number
176 
177  // Remove duplicate Pins in m_SortedComponentPinList
179 
180  // record the usage of this library component entry.
181  m_LibParts.insert( comp->GetPartRef().get() ); // rejects non-unique pointers
182 }
CONNECTION_SUBGRAPH * FindSubgraphByName(const wxString &aNetName, const SCH_SHEET_PATH &aPath)
Returns the subgraph for a given net name on a given sheet.
SCHEMATIC * m_schematic
The schematic we're generating a netlist for.
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:132
void findAllUnitsOfComponent(SCH_COMPONENT *aComponent, LIB_PART *aEntry, SCH_SHEET_PATH *aSheetPath)
Function findAllUnitsOfComponent is used for "multiple parts per package" components.
A subgraph is a set of items that are electrically connected on a single sheet.
std::set< LIB_PART *, LIB_PART_LESS_THAN > m_LibParts
unique library parts used.
std::vector< SCH_ITEM * > m_items
std::vector< PIN_INFO > m_SortedComponentPinList
Used to temporarily store and filter the list of pins of a schematic component when generating schema...
static bool sortPinsByNum(PIN_INFO &aPin1, PIN_INFO &aPin2)
Comparison routine for sorting by pin numbers.
SCH_ITEM * m_no_connect
No-connect item in graph, if any.
void eraseDuplicatePins()
Function eraseDuplicatePins erase duplicate Pins from m_SortedComponentPinList (i....

References SCHEMATIC::ConnectionGraph(), NETLIST_EXPORTER::eraseDuplicatePins(), NETLIST_EXPORTER::findAllUnitsOfComponent(), CONNECTION_GRAPH::FindSubgraphByName(), SCH_COMPONENT::GetPartRef(), SCH_COMPONENT::GetRef(), SCH_COMPONENT::GetSchPins(), CONNECTION_SUBGRAPH::m_items, NETLIST_EXPORTER::m_LibParts, CONNECTION_SUBGRAPH::m_no_connect, NETLIST_EXPORTER::m_schematic, NETLIST_EXPORTER::m_SortedComponentPinList, and sortPinsByNum().

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

◆ eraseDuplicatePins()

void NETLIST_EXPORTER::eraseDuplicatePins ( )
protectedinherited

Function eraseDuplicatePins erase duplicate Pins from m_SortedComponentPinList (i.e.

set pointer in this list to NULL). (This is a list of pins found in the whole schematic, for a single component.) These duplicate pins were put in list because some pins (powers... ) are found more than one time when we have a multiple parts per package component. For instance, a 74ls00 has 4 parts, and therefore the VCC pin and GND pin appears 4 times in the list. Note: this list MUST be sorted by pin number (.m_PinNum member value) Also set the m_Flag member of "removed" NETLIST_OBJECT pin item to 1

Definition at line 185 of file netlist_exporter.cpp.

186 {
187  for( unsigned ii = 0; ii < m_SortedComponentPinList.size(); ii++ )
188  {
189  if( m_SortedComponentPinList[ii].num.empty() ) /* already deleted */
190  continue;
191 
192  /* Search for duplicated pins
193  * If found, remove duplicates. The priority is to keep connected pins
194  * and remove unconnected
195  * - So this allows (for instance when using multi op amps per package
196  * - to connect only one op amp to power
197  * Because the pin list is sorted by m_PinNum value, duplicated pins
198  * are necessary successive in list
199  */
200  int idxref = ii;
201 
202  for( unsigned jj = ii + 1; jj < m_SortedComponentPinList.size(); jj++ )
203  {
204  if( m_SortedComponentPinList[jj].num.empty() ) // Already removed
205  continue;
206 
207  // if other pin num, stop search,
208  // because all pins having the same number are consecutive in list.
209  if( m_SortedComponentPinList[idxref].num != m_SortedComponentPinList[jj].num )
210  break;
211 
212  m_SortedComponentPinList[jj].num.clear();
213  }
214  }
215 }
std::vector< PIN_INFO > m_SortedComponentPinList
Used to temporarily store and filter the list of pins of a schematic component when generating schema...

References NETLIST_EXPORTER::m_SortedComponentPinList.

Referenced by NETLIST_EXPORTER::CreatePinList().

◆ findAllUnitsOfComponent()

void NETLIST_EXPORTER::findAllUnitsOfComponent ( SCH_COMPONENT aComponent,
LIB_PART aEntry,
SCH_SHEET_PATH aSheetPath 
)
protectedinherited

Function findAllUnitsOfComponent is used for "multiple parts per package" components.

Search the entire design for all units of aComponent based on matching reference designator, and for each unit, add all its pins to the temporary sorted pin list, m_SortedComponentPinList.

Definition at line 218 of file netlist_exporter.cpp.

220 {
221  wxString ref = aComponent->GetRef( aSheetPath );
222  wxString ref2;
223 
224  SCH_SHEET_LIST sheetList = m_schematic->GetSheets();
225 
226  for( unsigned i = 0; i < sheetList.size(); i++ )
227  {
228  for( auto item : sheetList[i].LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
229  {
230  SCH_COMPONENT* comp2 = static_cast<SCH_COMPONENT*>( item );
231 
232  ref2 = comp2->GetRef( &sheetList[i] );
233 
234  if( ref2.CmpNoCase( ref ) != 0 )
235  continue;
236 
237  for( const auto& pin : comp2->GetSchPins( aSheetPath ) )
238  {
239  if( auto conn = pin->Connection( *aSheetPath ) )
240  {
241  const wxString& netName = conn->Name();
242 
243  // Skip unconnected pins
245  netName, *aSheetPath );
246 
247  if( !sg || sg->m_no_connect || sg->m_items.size() < 2 )
248  continue;
249 
250  m_SortedComponentPinList.emplace_back( pin->GetNumber(), netName );
251  }
252  }
253  }
254  }
255 }
CONNECTION_SUBGRAPH * FindSubgraphByName(const wxString &aNetName, const SCH_SHEET_PATH &aPath)
Returns the subgraph for a given net name on a given sheet.
SCH_SHEET_LIST.
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:92
SCHEMATIC * m_schematic
The schematic we're generating a netlist for.
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:132
A subgraph is a set of items that are electrically connected on a single sheet.
std::vector< SCH_ITEM * > m_items
std::vector< PIN_INFO > m_SortedComponentPinList
Used to temporarily store and filter the list of pins of a schematic component when generating schema...
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
SCH_ITEM * m_no_connect
No-connect item in graph, if any.
SCH_PIN_PTRS GetSchPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieves a list of the SCH_PINs for the given sheet path.

References SCHEMATIC::ConnectionGraph(), CONNECTION_GRAPH::FindSubgraphByName(), SCH_COMPONENT::GetRef(), SCH_COMPONENT::GetSchPins(), SCHEMATIC::GetSheets(), CONNECTION_SUBGRAPH::m_items, CONNECTION_SUBGRAPH::m_no_connect, NETLIST_EXPORTER::m_schematic, NETLIST_EXPORTER::m_SortedComponentPinList, and SCH_COMPONENT_T.

Referenced by NETLIST_EXPORTER::CreatePinList().

◆ findNextComponent()

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

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.
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:193

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

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

◆ MakeCommandLine()

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

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

◆ writeListOfNets()

bool NETLIST_EXPORTER_CADSTAR::writeListOfNets ( FILE *  f)
private

Function writeListOfNetsCADSTAR writes a net list (ranked by Netcode), and pins connected to it.

Format:

  • ADD_TER RR2 6 "$42"
  • B U1 100
  • 6 CA

Definition at line 112 of file netlist_exporter_cadstar.cpp.

113 {
114  int ret = 0;
115  int print_ter = 0;
116 
117  wxString InitNetDesc = StartLine + wxT( "ADD_TER" );
118  wxString StartNetDesc = StartLine + wxT( "TER" );
119  wxString InitNetDescLine;
120  wxString netName;
121 
122  for( const auto& it : m_schematic->ConnectionGraph()->GetNetMap() )
123  {
124  auto subgraphs = it.second;
125 
126  netName.Printf( wxT( "\"%s\"" ), it.first.first );
127 
128  std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>> sorted_items;
129 
130  for( auto subgraph : subgraphs )
131  {
132  auto sheet = subgraph->m_sheet;
133 
134  for( auto item : subgraph->m_items )
135  if( item->Type() == SCH_PIN_T )
136  sorted_items.emplace_back(
137  std::make_pair( static_cast<SCH_PIN*>( item ), sheet ) );
138  }
139 
140  // Netlist ordering: Net name, then ref des, then pin name
141  std::sort( sorted_items.begin(), sorted_items.end(),
142  []( auto a, auto b )
143  {
144  wxString ref_a = a.first->GetParentComponent()->GetRef( &a.second );
145  wxString ref_b = b.first->GetParentComponent()->GetRef( &b.second );
146 
147  if( ref_a == ref_b )
148  return a.first->GetNumber() < b.first->GetNumber();
149 
150  return ref_a < ref_b;
151  } );
152 
153  // Some duplicates can exist, for example on multi-unit parts with duplicated
154  // pins across units. If the user connects the pins on each unit, they will
155  // appear on separate subgraphs. Remove those here:
156  sorted_items.erase( std::unique( sorted_items.begin(), sorted_items.end(),
157  []( auto a, auto b )
158  {
159  auto ref_a = a.first->GetParentComponent()->GetRef( &a.second );
160  auto ref_b = b.first->GetParentComponent()->GetRef( &b.second );
161 
162  return ref_a == ref_b && a.first->GetNumber() == b.first->GetNumber();
163  } ),
164  sorted_items.end() );
165 
166  print_ter = 0;
167 
168  for( const auto& pair : sorted_items )
169  {
170  SCH_PIN* pin = pair.first;
171  SCH_SHEET_PATH sheet = pair.second;
172 
173  wxString refText = pin->GetParentComponent()->GetRef( &sheet );
174  wxString pinText = pin->GetNumber();
175 
176  // Skip power symbols and virtual components
177  if( refText[0] == wxChar( '#' ) )
178  continue;
179 
180  switch( print_ter )
181  {
182  case 0:
183  {
184  InitNetDescLine.Printf( wxT( "\n%s %s %.4s %s" ),
185  GetChars( InitNetDesc ),
186  GetChars( refText ),
187  GetChars( pinText ),
188  GetChars( netName ) );
189  }
190  print_ter++;
191  break;
192 
193  case 1:
194  ret |= fprintf( f, "%s\n", TO_UTF8( InitNetDescLine ) );
195  ret |= fprintf( f, "%s %s %.4s\n",
196  TO_UTF8( StartNetDesc ),
197  TO_UTF8( refText ),
198  TO_UTF8( pinText ) );
199  print_ter++;
200  break;
201 
202  default:
203  ret |= fprintf( f, " %s %.4s\n",
204  TO_UTF8( refText ),
205  TO_UTF8( pinText ) );
206  break;
207  }
208  }
209  }
210 
211  return ret >= 0;
212 }
SCHEMATIC * m_schematic
The schematic we're generating a netlist for.
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:132
const wxString & GetNumber() const
Definition: sch_pin.h:106
const NET_MAP & GetNetMap() const
SCH_SHEET_PATH.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false)
Return the reference for the given sheet path.
static wxString StartLine(wxT("."))
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:153
#define TO_UTF8(wxstring)
SCH_COMPONENT * GetParentComponent() const
Definition: sch_pin.cpp:81

References SCHEMATIC::ConnectionGraph(), GetChars(), CONNECTION_GRAPH::GetNetMap(), SCH_PIN::GetNumber(), SCH_PIN::GetParentComponent(), SCH_COMPONENT::GetRef(), NETLIST_EXPORTER::m_schematic, SCH_PIN_T, StartLine(), and TO_UTF8.

Referenced by WriteNetlist().

◆ WriteNetlist()

bool NETLIST_EXPORTER_CADSTAR::WriteNetlist ( const wxString &  aOutFileName,
unsigned  aNetlistOptions 
)
overridevirtual

Function WriteList writes to specified output file.

Reimplemented from NETLIST_EXPORTER.

Definition at line 39 of file netlist_exporter_cadstar.cpp.

40 {
41  (void)aNetlistOptions; //unused
42  int ret = 0;
43  FILE* f = NULL;
44 
45  if( ( f = wxFopen( aOutFileName, wxT( "wt" ) ) ) == NULL )
46  {
47  wxString msg;
48  msg.Printf( _( "Failed to create file \"%s\"" ),
49  GetChars( aOutFileName ) );
50  DisplayError( NULL, msg );
51  return false;
52  }
53 
54  wxString StartCmpDesc = StartLine + wxT( "ADD_COM" );
55  wxString msg;
56  wxString footprint;
57  SCH_COMPONENT* component;
58  wxString title = wxT( "Eeschema " ) + GetBuildVersion();
59 
60  ret |= fprintf( f, "%sHEA\n", TO_UTF8( StartLine ) );
61  ret |= fprintf( f, "%sTIM %s\n", TO_UTF8( StartLine ), TO_UTF8( DateAndTime() ) );
62  ret |= fprintf( f, "%sAPP ", TO_UTF8( StartLine ) );
63  ret |= fprintf( f, "\"%s\"\n", TO_UTF8( title ) );
64  ret |= fprintf( f, ".TYP FULL\n\n" );
65 
66  // Create netlist module section
68 
69  SCH_SHEET_LIST sheetList = m_schematic->GetSheets();
70 
71  for( unsigned i = 0; i < sheetList.size(); i++ )
72  {
73  std::vector<SCH_COMPONENT*> cmps;
74 
75  for( auto item : sheetList[i].LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
76  {
77  component = findNextComponent( item, &sheetList[i] );
78 
79  if( !component )
80  continue;
81 
82  if( !component->GetField( FOOTPRINT )->IsVoid() )
83  footprint = component->GetField( FOOTPRINT )->GetText();
84  else
85  footprint = "$noname";
86 
87  msg = component->GetRef( &sheetList[i] );
88  ret |= fprintf( f, "%s ", TO_UTF8( StartCmpDesc ) );
89  ret |= fprintf( f, "%s", TO_UTF8( msg ) );
90 
91  msg = component->GetField( VALUE )->GetText();
92  msg.Replace( wxT( " " ), wxT( "_" ) );
93  ret |= fprintf( f, " \"%s\"", TO_UTF8( msg ) );
94  ret |= fprintf( f, " \"%s\"", TO_UTF8( footprint ) );
95  ret |= fprintf( f, "\n" );
96  }
97  }
98 
99  ret |= fprintf( f, "\n" );
100 
101  if( ! writeListOfNets( f ) )
102  ret = -1; // set error
103 
104  ret |= fprintf( f, "\n%sEND\n", TO_UTF8( StartLine ) );
105 
106  fclose( f );
107 
108  return ret >= 0;
109 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
SCH_SHEET_LIST.
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:92
UNIQUE_STRINGS m_ReferencesAlreadyFound
Used for "multi parts per package" components, avoids processing a lib component more than once.
SCHEMATIC * m_schematic
The schematic we're generating a netlist for.
void Clear()
Function Clear erases the record.
SCH_COMPONENT * findNextComponent(EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath)
Checks if the given component should be processed for netlisting.
Field Name Module PCB, i.e. "16DIP300".
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
Definition: sch_field.cpp:311
#define NULL
wxString GetBuildVersion()
Get the full KiCad version string.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false)
Return the reference for the given sheet path.
static wxString StartLine(wxT("."))
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
Field Value of part, i.e. "3.3K".
bool writeListOfNets(FILE *f)
Function writeListOfNetsCADSTAR writes a net list (ranked by Netcode), and pins connected to it.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:153
#define _(s)
Definition: 3d_actions.cpp:33
Schematic symbol object.
Definition: sch_component.h:88
#define TO_UTF8(wxstring)
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:127
wxString DateAndTime()
Definition: string.cpp:373

References _, UNIQUE_STRINGS::Clear(), DateAndTime(), DisplayError(), NETLIST_EXPORTER::findNextComponent(), FOOTPRINT, GetBuildVersion(), GetChars(), SCH_COMPONENT::GetField(), SCH_COMPONENT::GetRef(), SCHEMATIC::GetSheets(), EDA_TEXT::GetText(), SCH_FIELD::IsVoid(), NETLIST_EXPORTER::m_ReferencesAlreadyFound, NETLIST_EXPORTER::m_schematic, NULL, SCH_COMPONENT_T, StartLine(), TO_UTF8, VALUE, and writeListOfNets().

Member Data Documentation

◆ m_LibParts

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

◆ m_ReferencesAlreadyFound

UNIQUE_STRINGS NETLIST_EXPORTER::m_ReferencesAlreadyFound
protectedinherited

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

Definition at line 110 of file netlist_exporter.h.

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

◆ m_schematic

◆ m_SortedComponentPinList

std::vector<PIN_INFO> NETLIST_EXPORTER::m_SortedComponentPinList
protectedinherited

Used to temporarily store and filter the list of pins of a schematic component when generating schematic component data in netlist (comp section).

No ownership of members. TODO(snh): Descope this object

Definition at line 106 of file netlist_exporter.h.

Referenced by NETLIST_EXPORTER::CreatePinList(), NETLIST_EXPORTER::eraseDuplicatePins(), NETLIST_EXPORTER::findAllUnitsOfComponent(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().


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