KiCad PCB EDA Suite
NETLIST_EXPORTER_CADSTAR Class Reference

Generate a netlist compatible with CADSTAR. More...

#include <netlist_exporter_cadstar.h>

Inheritance diagram for NETLIST_EXPORTER_CADSTAR:
NETLIST_EXPORTER_BASE

Public Member Functions

 NETLIST_EXPORTER_CADSTAR (SCHEMATIC *aSchematic)
 
bool WriteNetlist (const wxString &aOutFileName, unsigned aNetlistOptions, REPORTER &aReporter) override
 Write to specified output file. More...
 

Static Public Member Functions

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

Protected Member Functions

std::vector< PIN_INFOCreatePinList (SCH_SYMBOL *aSymbol, SCH_SHEET_PATH *aSheetPath, bool aKeepUnconnectedPins)
 Find a symbol from the DrawList and builds its pin list. More...
 
SCH_SYMBOLfindNextSymbol (EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath)
 Check if the given symbol should be processed for netlisting. More...
 
void eraseDuplicatePins (std::vector< PIN_INFO > &pins)
 Erase duplicate pins. More...
 
void findAllUnitsOfSymbol (SCH_SYMBOL *aSchSymbol, SCH_SHEET_PATH *aSheetPath, std::vector< PIN_INFO > &aPins, bool aKeepUnconnectedPins)
 Find all units for symbols with multiple symbols per package. More...
 

Protected Attributes

UNIQUE_STRINGS m_referencesAlreadyFound
 Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than once. More...
 
std::set< LIB_SYMBOL *, LIB_SYMBOL_LESS_THANm_libParts
 unique library symbols used. LIB_SYMBOL items are sorted by names More...
 
SCHEMATIC_IFACEm_schematic
 The schematic we're generating a netlist for. More...
 

Private Member Functions

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

Detailed Description

Generate a netlist compatible with CADSTAR.

Definition at line 35 of file netlist_exporter_cadstar.h.

Constructor & Destructor Documentation

◆ NETLIST_EXPORTER_CADSTAR()

NETLIST_EXPORTER_CADSTAR::NETLIST_EXPORTER_CADSTAR ( SCHEMATIC aSchematic)
inline

Definition at line 38 of file netlist_exporter_cadstar.h.

38 :
39 NETLIST_EXPORTER_BASE( aSchematic )
40 {
41 }
NETLIST_EXPORTER_BASE(SCHEMATIC_IFACE *aSchematic)

Member Function Documentation

◆ CreatePinList()

std::vector< PIN_INFO > NETLIST_EXPORTER_BASE::CreatePinList ( SCH_SYMBOL aSymbol,
SCH_SHEET_PATH aSheetPath,
bool  aKeepUnconnectedPins 
)
protectedinherited

Find a symbol from the DrawList and builds its pin list.

This list is sorted by pin number. The symbol is the next actual symbol after aSymbol. Power symbols and virtual symbols that have their reference designators starting with '#' are skipped. if aKeepUnconnectedPins = false, unconnected pins will be removed from list but usually we need all pins in netlists.

Definition at line 116 of file netlist_exporter_base.cpp.

119{
120 wxString ref( aSymbol->GetRef( aSheetPath ) );
121 std::vector<PIN_INFO> pins;
122
123 // Power symbols and other symbols which have the reference starting with "#" are not
124 // included in netlist (pseudo or virtual symbols)
125
126 if( ref[0] == wxChar( '#' ) )
127 return pins;
128
129 // if( aSymbol->m_FlagControlMulti == 1 )
130 // continue; /* yes */
131 // removed because with multiple instances of one schematic (several sheets pointing to
132 // 1 screen), this will be erroneously be toggled.
133
134 if( !aSymbol->GetLibSymbolRef() )
135 return pins;
136
137 // If symbol is a "multi parts per package" type
138 if( aSymbol->GetLibSymbolRef()->GetUnitCount() > 1 )
139 {
140 // Collect all pins for this reference designator by searching the entire design for
141 // other parts with the same reference designator.
142 // This is only done once, it would be too expensive otherwise.
143 findAllUnitsOfSymbol( aSymbol, aSheetPath, pins, aKeepUnconnectedPins );
144 }
145
146 else // GetUnitCount() <= 1 means one part per package
147 {
149
150 for( const SCH_PIN* pin : aSymbol->GetPins( aSheetPath ) )
151 {
152 if( SCH_CONNECTION* conn = pin->Connection( aSheetPath ) )
153 {
154 const wxString& netName = conn->Name();
155
156 if( !aKeepUnconnectedPins ) // Skip unconnected pins if requested
157 {
158 CONNECTION_SUBGRAPH* sg = graph->FindSubgraphByName( netName, *aSheetPath );
159
160 if( !sg || sg->GetNoConnect() || sg->GetItems().size() < 2 )
161 continue;
162 }
163
164 pins.emplace_back( pin->GetShownNumber(), netName );
165 }
166 }
167 }
168
169 // Sort pins in m_SortedSymbolPinList by pin number
170 std::sort( pins.begin(), pins.end(),
171 []( const PIN_INFO& lhs, const PIN_INFO& rhs )
172 {
173 return StrNumCmp( lhs.num, rhs.num, true ) < 0;
174 } );
175
176 // Remove duplicate Pins in m_SortedSymbolPinList
177 eraseDuplicatePins( pins );
178
179 // record the usage of this library symbol
180 m_libParts.insert( aSymbol->GetLibSymbolRef().get() ); // rejects non-unique pointers
181
182 return pins;
183}
Calculates the connectivity of a schematic and generates netlists.
CONNECTION_SUBGRAPH * FindSubgraphByName(const wxString &aNetName, const SCH_SHEET_PATH &aPath)
Returns the subgraph for a given net name on a given sheet.
A subgraph is a set of items that are electrically connected on a single sheet.
const std::vector< SCH_ITEM * > & GetItems() const
Provides a read-only reference to the items in the subgraph.
const SCH_ITEM * GetNoConnect() const
void findAllUnitsOfSymbol(SCH_SYMBOL *aSchSymbol, SCH_SHEET_PATH *aSheetPath, std::vector< PIN_INFO > &aPins, bool aKeepUnconnectedPins)
Find all units for symbols with multiple symbols per package.
std::set< LIB_SYMBOL *, LIB_SYMBOL_LESS_THAN > m_libParts
unique library symbols used. LIB_SYMBOL items are sorted by names
void eraseDuplicatePins(std::vector< PIN_INFO > &pins)
Erase duplicate pins.
SCHEMATIC_IFACE * m_schematic
The schematic we're generating a netlist for.
virtual CONNECTION_GRAPH * ConnectionGraph() const =0
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:674
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:192

References SCHEMATIC_IFACE::ConnectionGraph(), NETLIST_EXPORTER_BASE::eraseDuplicatePins(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), CONNECTION_GRAPH::FindSubgraphByName(), CONNECTION_SUBGRAPH::GetItems(), SCH_SYMBOL::GetLibSymbolRef(), CONNECTION_SUBGRAPH::GetNoConnect(), SCH_SYMBOL::GetPins(), SCH_SYMBOL::GetRef(), NETLIST_EXPORTER_BASE::m_libParts, NETLIST_EXPORTER_BASE::m_schematic, and pin.

Referenced by NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().

◆ eraseDuplicatePins()

void NETLIST_EXPORTER_BASE::eraseDuplicatePins ( std::vector< PIN_INFO > &  pins)
protectedinherited

Erase duplicate pins.

(This is a list of pins found in the whole schematic, for a single symbol.) These duplicate pins were put in list because some pins (power pins...) are found more than once when in "multiple symbols per package" symbols. For instance, a 74ls00 has 4 symbols, 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 186 of file netlist_exporter_base.cpp.

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

Referenced by NETLIST_EXPORTER_BASE::CreatePinList().

◆ findAllUnitsOfSymbol()

void NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol ( SCH_SYMBOL aSchSymbol,
SCH_SHEET_PATH aSheetPath,
std::vector< PIN_INFO > &  aPins,
bool  aKeepUnconnectedPins 
)
protectedinherited

Find all units for symbols with multiple symbols per package.

Search the entire design for all units of aSymbol based on matching reference designator, and for each unit, add all its pins to the sorted pin list. if aKeepUnconnectedPins = false, unconnected pins will be removed from list but usually we need all pins in netlists.

Definition at line 219 of file netlist_exporter_base.cpp.

223{
224 wxString ref = aSchSymbol->GetRef( aSheetPath );
225 wxString ref2;
226
227 SCH_SHEET_LIST sheetList = m_schematic->GetSheets();
229
230 for( unsigned i = 0; i < sheetList.size(); i++ )
231 {
232 SCH_SHEET_PATH& sheet = sheetList[i];
233
234 for( SCH_ITEM* item : sheetList[i].LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
235 {
236 SCH_SYMBOL* comp2 = static_cast<SCH_SYMBOL*>( item );
237
238 ref2 = comp2->GetRef( &sheet );
239
240 if( ref2.CmpNoCase( ref ) != 0 )
241 continue;
242
243 for( const SCH_PIN* pin : comp2->GetPins( &sheet ) )
244 {
245 if( SCH_CONNECTION* conn = pin->Connection( &sheet ) )
246 {
247 const wxString& netName = conn->Name();
248
249 if( !aKeepUnconnectedPins ) // Skip unconnected pins if requested
250 {
251 CONNECTION_SUBGRAPH* sg = graph->FindSubgraphByName( netName, sheet );
252
253 if( !sg || sg->GetNoConnect() || sg->GetItems().size() < 2 )
254 continue;
255 }
256
257 aPins.emplace_back( pin->GetShownNumber(), netName );
258 }
259 }
260 }
261 }
262}
virtual SCH_SHEET_LIST GetSheets() const =0
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition: sch_symbol.h:81
@ SCH_SYMBOL_T
Definition: typeinfo.h:156

References SCHEMATIC_IFACE::ConnectionGraph(), CONNECTION_GRAPH::FindSubgraphByName(), CONNECTION_SUBGRAPH::GetItems(), CONNECTION_SUBGRAPH::GetNoConnect(), SCH_SYMBOL::GetPins(), SCH_SYMBOL::GetRef(), SCHEMATIC_IFACE::GetSheets(), NETLIST_EXPORTER_BASE::m_schematic, pin, and SCH_SYMBOL_T.

Referenced by NETLIST_EXPORTER_BASE::CreatePinList().

◆ findNextSymbol()

SCH_SYMBOL * NETLIST_EXPORTER_BASE::findNextSymbol ( EDA_ITEM aItem,
SCH_SHEET_PATH aSheetPath 
)
protectedinherited

Check if the given symbol should be processed for netlisting.

Prevent processing multi-unit symbols more than once, etc.

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

Definition at line 73 of file netlist_exporter_base.cpp.

74{
75 wxCHECK( aItem, nullptr );
76 wxCHECK( aSheetPath, nullptr );
77
78 wxString ref;
79
80 if( aItem->Type() != SCH_SYMBOL_T )
81 return nullptr;
82
83 // found next symbol
84 SCH_SYMBOL* symbol = (SCH_SYMBOL*) aItem;
85
86 // Power symbols and other symbols which have the reference starting with "#" are not
87 // included in netlist (pseudo or virtual symbols)
88 ref = symbol->GetRef( aSheetPath );
89
90 if( ref[0] == wxChar( '#' ) )
91 return nullptr;
92
93 SCH_SCREEN* screen = aSheetPath->LastScreen();
94
95 wxCHECK( screen, nullptr );
96
97 LIB_SYMBOL* libSymbol = screen->GetLibSymbols()[ symbol->GetSchSymbolLibraryName() ];
98
99 wxCHECK( libSymbol, nullptr );
100
101 // If symbol is a "multi parts per package" type
102 if( libSymbol->GetUnitCount() > 1 )
103 {
104 // test if this reference has already been processed, and if so skip
106 return nullptr;
107 }
108
109 // record the usage of this library symbol entry.
110 m_libParts.insert( libSymbol ); // rejects non-unique pointers
111
112 return symbol;
113}
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
Define a library symbol object.
Definition: lib_symbol.h:99
int GetUnitCount() const override
For items with units, return the number of units.
UNIQUE_STRINGS m_referencesAlreadyFound
Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than once.
std::map< wxString, LIB_SYMBOL * > & GetLibSymbols()
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition: sch_screen.h:481
SCH_SCREEN * LastScreen()
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:294
bool Lookup(const wxString &aString)

References SCH_SCREEN::GetLibSymbols(), SCH_SYMBOL::GetRef(), SCH_SYMBOL::GetSchSymbolLibraryName(), LIB_SYMBOL::GetUnitCount(), SCH_SHEET_PATH::LastScreen(), UNIQUE_STRINGS::Lookup(), NETLIST_EXPORTER_BASE::m_libParts, NETLIST_EXPORTER_BASE::m_referencesAlreadyFound, SCH_SYMBOL_T, and EDA_ITEM::Type().

Referenced by NETLIST_EXPORTER_XML::makeSymbols(), NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries(), WriteNetlist(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().

◆ MakeCommandLine()

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

Build 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 37 of file netlist_exporter_base.cpp.

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

Referenced by SCH_EDIT_FRAME::WriteNetListFile().

◆ writeListOfNets()

bool NETLIST_EXPORTER_CADSTAR::writeListOfNets ( FILE *  f)
private

Write 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& [ key, subgraphs ] : m_schematic->ConnectionGraph()->GetNetMap() )
123 {
124 netName.Printf( wxT( "\"%s\"" ), key.Name );
125
126 std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>> sorted_items;
127
128 for( CONNECTION_SUBGRAPH* subgraph : subgraphs )
129 {
130 SCH_SHEET_PATH sheet = subgraph->GetSheet();
131
132 for( SCH_ITEM* item : subgraph->GetItems() )
133 {
134 if( item->Type() == SCH_PIN_T )
135 sorted_items.emplace_back( static_cast<SCH_PIN*>( item ), sheet );
136 }
137 }
138
139 // Netlist ordering: Net name, then ref des, then pin name
140 std::sort( sorted_items.begin(), sorted_items.end(),
141 []( std::pair<SCH_PIN*, SCH_SHEET_PATH> a, std::pair<SCH_PIN*, SCH_SHEET_PATH> b )
142 {
143 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
144 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
145
146 if( ref_a == ref_b )
147 return a.first->GetShownNumber() < b.first->GetShownNumber();
148
149 return ref_a < ref_b;
150 } );
151
152 // Some duplicates can exist, for example on multi-unit parts with duplicated
153 // pins across units. If the user connects the pins on each unit, they will
154 // appear on separate subgraphs. Remove those here:
155 sorted_items.erase( std::unique( sorted_items.begin(), sorted_items.end(),
156 []( std::pair<SCH_PIN*, SCH_SHEET_PATH> a, std::pair<SCH_PIN*, SCH_SHEET_PATH> b )
157 {
158 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
159 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
160
161 return ref_a == ref_b && a.first->GetShownNumber() == b.first->GetShownNumber();
162 } ),
163 sorted_items.end() );
164
165 print_ter = 0;
166
167 for( const std::pair<SCH_PIN*, SCH_SHEET_PATH>& pair : sorted_items )
168 {
169 SCH_PIN* pin = pair.first;
170 SCH_SHEET_PATH sheet = pair.second;
171
172 wxString refText = pin->GetParentSymbol()->GetRef( &sheet );
173 wxString pinText = pin->GetShownNumber();
174
175 // Skip power symbols and virtual symbols
176 if( refText[0] == wxChar( '#' ) )
177 continue;
178
179 switch( print_ter )
180 {
181 case 0:
182 InitNetDescLine.Printf( wxT( "\n%s %s %.4s %s" ),
183 InitNetDesc,
184 refText,
185 pinText,
186 netName );
187 print_ter++;
188 break;
189
190 case 1:
191 ret |= fprintf( f, "%s\n", TO_UTF8( InitNetDescLine ) );
192 ret |= fprintf( f, "%s %s %.4s\n",
193 TO_UTF8( StartNetDesc ),
194 TO_UTF8( refText ),
195 TO_UTF8( pinText ) );
196 print_ter++;
197 break;
198
199 default:
200 ret |= fprintf( f, " %s %.4s\n",
201 TO_UTF8( refText ),
202 TO_UTF8( pinText ) );
203 break;
204 }
205 }
206 }
207
208 return ret >= 0;
209}
const NET_MAP & GetNetMap() const
const SCH_SHEET * GetSheet(unsigned aIndex) const
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
static wxString StartLine(wxT("."))
@ SCH_PIN_T
Definition: typeinfo.h:159

References SCHEMATIC_IFACE::ConnectionGraph(), CONNECTION_GRAPH::GetNetMap(), SCH_SHEET_PATH::GetSheet(), NETLIST_EXPORTER_BASE::m_schematic, pin, SCH_PIN_T, StartLine(), and TO_UTF8.

Referenced by WriteNetlist().

◆ WriteNetlist()

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

Write to specified output file.

Reimplemented from NETLIST_EXPORTER_BASE.

Definition at line 39 of file netlist_exporter_cadstar.cpp.

42{
43 int ret = 0;
44 FILE* f = nullptr;
45
46 if( ( f = wxFopen( aOutFileName, wxT( "wt" ) ) ) == nullptr )
47 {
48 wxString msg = wxString::Format( _( "Failed to create file '%s'." ), aOutFileName );
49 aReporter.Report( msg, RPT_SEVERITY_ERROR );
50 return false;
51 }
52
53 wxString StartCmpDesc = StartLine + wxT( "ADD_COM" );
54 wxString msg;
55 wxString footprint;
56 SCH_SYMBOL* symbol;
57 wxString title = wxT( "Eeschema " ) + GetBuildVersion();
58
59 ret |= fprintf( f, "%sHEA\n", TO_UTF8( StartLine ) );
60 ret |= fprintf( f, "%sTIM %s\n", TO_UTF8( StartLine ), TO_UTF8( DateAndTime() ) );
61 ret |= fprintf( f, "%sAPP ", TO_UTF8( StartLine ) );
62 ret |= fprintf( f, "\"%s\"\n", TO_UTF8( title ) );
63 ret |= fprintf( f, ".TYP FULL\n\n" );
64
65 // Create netlist footprints section
67
69
70 for( unsigned i = 0; i < sheetList.size(); i++ )
71 {
72 for( SCH_ITEM* item : sheetList[i].LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
73 {
74 symbol = findNextSymbol( item, &sheetList[ i ] );
75
76 if( !symbol )
77 continue;
78
79 if( !symbol->GetIncludeOnBoard() )
80 continue;
81
82 footprint = symbol->GetFootprintFieldText( true );
83
84 if( footprint.IsEmpty() )
85 footprint = "$noname";
86
87 msg = symbol->GetRef( &sheetList[i] );
88 ret |= fprintf( f, "%s ", TO_UTF8( StartCmpDesc ) );
89 ret |= fprintf( f, "%s", TO_UTF8( msg ) );
90
91 msg = symbol->GetValueFieldText( true );
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}
wxString GetBuildVersion()
Get the full KiCad version string.
SCH_SYMBOL * findNextSymbol(EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath)
Check if the given symbol should be processed for netlisting.
bool writeListOfNets(FILE *f)
Write a net list (ranked by Netcode), and pins connected to it.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
bool GetIncludeOnBoard() const
Definition: sch_symbol.h:750
const wxString GetFootprintFieldText(bool aResolve) const
Definition: sch_symbol.cpp:850
const wxString GetValueFieldText(bool aResolve) const
Definition: sch_symbol.cpp:835
void Clear()
Erase the record.
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
@ RPT_SEVERITY_ERROR
wxString DateAndTime()

References _, UNIQUE_STRINGS::Clear(), DateAndTime(), NETLIST_EXPORTER_BASE::findNextSymbol(), Format(), GetBuildVersion(), SCH_SYMBOL::GetFootprintFieldText(), SCH_SYMBOL::GetIncludeOnBoard(), SCH_SYMBOL::GetRef(), SCHEMATIC_IFACE::GetSheets(), SCH_SYMBOL::GetValueFieldText(), NETLIST_EXPORTER_BASE::m_referencesAlreadyFound, NETLIST_EXPORTER_BASE::m_schematic, REPORTER::Report(), RPT_SEVERITY_ERROR, SCH_SYMBOL_T, StartLine(), TO_UTF8, and writeListOfNets().

Member Data Documentation

◆ m_libParts

std::set<LIB_SYMBOL*, LIB_SYMBOL_LESS_THAN> NETLIST_EXPORTER_BASE::m_libParts
protectedinherited

◆ m_referencesAlreadyFound

UNIQUE_STRINGS NETLIST_EXPORTER_BASE::m_referencesAlreadyFound
protectedinherited

Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than once.

Definition at line 197 of file netlist_exporter_base.h.

Referenced by NETLIST_EXPORTER_BASE::findNextSymbol(), NETLIST_EXPORTER_XML::makeSymbols(), NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries(), WriteNetlist(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().

◆ m_schematic


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