![]() |
KiCad PCB EDA Suite
|
Generate the KiCad netlist format supported by Pcbnew. More...
#include <netlist_exporter_kicad.h>
Public Member Functions | |
NETLIST_EXPORTER_KICAD (SCHEMATIC *aSchematic) | |
bool | WriteNetlist (const wxString &aOutFileName, unsigned aNetlistOptions) override |
Write netlist to aOutFileName. More... | |
void | Format (OUTPUTFORMATTER *aOutputFormatter, int aCtl) |
Output this s-expression netlist into aOutputFormatter. 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 | |
XNODE * | node (const wxString &aName, const wxString &aTextualContent=wxEmptyString) |
A convenience function that creates a new XNODE with an optional textual child. More... | |
XNODE * | makeRoot (unsigned aCtl=GNL_ALL) |
Build the entire document tree for the generic export. More... | |
XNODE * | makeSymbols (unsigned aCtl) |
XNODE * | makeDesignHeader () |
Fills out a project "design" header into an XML node. More... | |
XNODE * | makeLibParts () |
Fill out an XML node with the unique library parts and returns it. More... | |
XNODE * | makeListOfNets (unsigned aCtl) |
Fill out an XML node with a list of nets and returns it. More... | |
XNODE * | makeLibraries () |
Fill out an XML node with a list of used libraries and returns it. More... | |
void | addSymbolFields (XNODE *aNode, SCH_COMPONENT *aSymbol, SCH_SHEET_PATH *aSheet) |
void | CreatePinList (SCH_COMPONENT *aSymbol, SCH_SHEET_PATH *aSheetPath) |
Function findNextSymbolAndCreatePinList finds a symbol from the DrawList and builds its pin list in m_sortedSymbolPinList. More... | |
SCH_COMPONENT * | findNextSymbol (EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath) |
Checks if the given symbol should be processed for netlisting. More... | |
void | eraseDuplicatePins () |
Function eraseDuplicatePins erase duplicate Pins from m_sortedSymbolPinList (i.e. More... | |
void | findAllUnitsOfSymbol (SCH_COMPONENT *aSymbol, LIB_PART *aPart, SCH_SHEET_PATH *aSheetPath) |
Function findAllUnitsOfSymbol is used for "multiple parts per package" symbols. More... | |
Protected Attributes | |
bool | m_resolveTextVars |
std::vector< PIN_INFO > | m_sortedSymbolPinList |
Used to temporarily store and filter the list of pins of a schematic symbol when generating schematic symbol data in netlist (comp section). More... | |
UNIQUE_STRINGS | m_referencesAlreadyFound |
Used for "multiple parts per package" symbols to avoid processing a lib part more than once. More... | |
std::set< LIB_PART *, LIB_PART_LESS_THAN > | m_libParts |
unique library parts used. LIB_PART items are sorted by names More... | |
SCHEMATIC * | m_schematic |
The schematic we're generating a netlist for. More... | |
SCH_SHEET_PATH | m_savedCurrentSheet |
The schematic's CurrentSheet when we entered. Restore on exiting. More... | |
Generate the KiCad netlist format supported by Pcbnew.
It is basically the XML netlist just formatted slightly different.
Definition at line 37 of file netlist_exporter_kicad.h.
|
inline |
Definition at line 40 of file netlist_exporter_kicad.h.
References NETLIST_EXPORTER_XML::m_resolveTextVars.
|
protectedinherited |
Definition at line 89 of file netlist_exporter_xml.cpp.
References COMP_FIELDS::datasheet, DATASHEET_FIELD, COMP_FIELDS::f, COMP_FIELDS::footprint, SCH_COMPONENT::GetField(), SCH_COMPONENT::GetFieldCount(), SCH_COMPONENT::GetFootprint(), SCH_FIELD::GetName(), SCH_COMPONENT::GetRef(), SCHEMATIC::GetSheets(), SCH_FIELD::GetShownText(), EDA_TEXT::GetText(), SCH_COMPONENT::GetUnit(), SCH_COMPONENT::GetUnitCount(), SCH_COMPONENT::GetValue(), SCH_FIELD::IsVoid(), NETLIST_EXPORTER_XML::m_resolveTextVars, NETLIST_EXPORTER_BASE::m_schematic, MANDATORY_FIELDS, NETLIST_EXPORTER_XML::node(), SCH_COMPONENT_T, and COMP_FIELDS::value.
Referenced by NETLIST_EXPORTER_XML::makeSymbols().
|
protectedinherited |
Function findNextSymbolAndCreatePinList finds a symbol from the DrawList and builds its pin list in m_sortedSymbolPinList.
This list is sorted by pin num. The symbol is the next actual symbol after aSymbol.
Power symbols and virtual symbols that have their reference designators starting with '#' are skipped.
Definition at line 122 of file netlist_exporter_base.cpp.
References SCHEMATIC::ConnectionGraph(), NETLIST_EXPORTER_BASE::eraseDuplicatePins(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), CONNECTION_GRAPH::FindSubgraphByName(), SCH_COMPONENT::GetPartRef(), SCH_COMPONENT::GetPins(), SCH_COMPONENT::GetRef(), CONNECTION_SUBGRAPH::m_items, NETLIST_EXPORTER_BASE::m_libParts, CONNECTION_SUBGRAPH::m_no_connect, NETLIST_EXPORTER_BASE::m_schematic, NETLIST_EXPORTER_BASE::m_sortedSymbolPinList, and sortPinsByNum().
Referenced by NETLIST_EXPORTER_PSPICE::ProcessNetlist(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().
|
protectedinherited |
Function eraseDuplicatePins erase duplicate Pins from m_sortedSymbolPinList (i.e.
set pointer in this list to NULL). (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 parts per package" symbols. 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 183 of file netlist_exporter_base.cpp.
References NETLIST_EXPORTER_BASE::m_sortedSymbolPinList.
Referenced by NETLIST_EXPORTER_BASE::CreatePinList().
|
protectedinherited |
Function findAllUnitsOfSymbol is used for "multiple parts per package" symbols.
Search the entire design for all units of aSymbol based on matching reference designator, and for each unit, add all its pins to the temporary sorted pin list, m_sortedSymbolPinList.
Definition at line 216 of file netlist_exporter_base.cpp.
References SCHEMATIC::ConnectionGraph(), CONNECTION_GRAPH::FindSubgraphByName(), SCH_COMPONENT::GetPins(), SCH_COMPONENT::GetRef(), SCHEMATIC::GetSheets(), CONNECTION_SUBGRAPH::m_items, CONNECTION_SUBGRAPH::m_no_connect, NETLIST_EXPORTER_BASE::m_schematic, NETLIST_EXPORTER_BASE::m_sortedSymbolPinList, and SCH_COMPONENT_T.
Referenced by NETLIST_EXPORTER_BASE::CreatePinList().
|
protectedinherited |
Checks if the given symbol should be processed for netlisting.
Prevents processing multi-unit symbols more than once, etc.
aItem | is a symbol to check |
aSheetPath | is the sheet to check the symbol for |
Definition at line 74 of file netlist_exporter_base.cpp.
References SCH_COMPONENT::GetPartRef(), SCH_COMPONENT::GetRef(), UNIQUE_STRINGS::Lookup(), NETLIST_EXPORTER_BASE::m_libParts, NETLIST_EXPORTER_BASE::m_referencesAlreadyFound, SCH_COMPONENT_T, and EDA_ITEM::Type().
Referenced by NETLIST_EXPORTER_XML::makeSymbols(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().
void NETLIST_EXPORTER_KICAD::Format | ( | OUTPUTFORMATTER * | aOutputFormatter, |
int | aCtl | ||
) |
Output this s-expression netlist into aOutputFormatter.
aOutputFormatter | is the destination of the serialization to text. |
aCtl | is bit set composed by OR-ing together enum GNL bits, it allows outputting a subset of the full document model. |
IO_ERROR | if any problems. |
Definition at line 56 of file netlist_exporter_kicad.cpp.
References NETLIST_EXPORTER_XML::makeRoot().
Referenced by SCH_EDIT_FRAME::KiwayMailIn(), SCH_EDIT_FRAME::sendNetlistToCvpcb(), and WriteNetlist().
|
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.
aFormatString | holds:
|
aNetlistFile | is the name of the input file for the external program, that is a intermediate netlist file in xml format. |
aFinalFile | is the name of the output file that the user expects. |
aProjectDirectory | is used for P replacement, it should omit the trailing '/'. |
Supported formatting sequences and their meaning:
Definition at line 38 of file netlist_exporter_base.cpp.
Referenced by SCH_EDIT_FRAME::WriteNetListFile().
|
protectedinherited |
Fills out a project "design" header into an XML node.
Definition at line 334 of file netlist_exporter_xml.cpp.
References DateAndTime(), ExpandTextVars(), GetBuildVersion(), TITLE_BLOCK::GetComment(), TITLE_BLOCK::GetCompany(), TITLE_BLOCK::GetDate(), SCHEMATIC::GetFileName(), SCH_SCREEN::GetFileName(), TITLE_BLOCK::GetRevision(), SCHEMATIC::GetSheets(), PROJECT::GetTextVars(), TITLE_BLOCK::GetTitle(), SCH_SCREEN::GetTitleBlock(), NETLIST_EXPORTER_BASE::m_schematic, NETLIST_EXPORTER_XML::node(), and SCHEMATIC::Prj().
Referenced by NETLIST_EXPORTER_XML::makeRoot().
|
protectedinherited |
Fill out an XML node with the unique library parts and returns it.
Definition at line 459 of file netlist_exporter_xml.cpp.
References NETLIST_EXPORTER_BASE::m_libParts, NETLIST_EXPORTER_XML::m_libraries, NETLIST_EXPORTER_XML::node(), and sortPinsByNumber().
Referenced by NETLIST_EXPORTER_XML::makeRoot().
|
protectedinherited |
Fill out an XML node with a list of used libraries and returns it.
Must have called makeGenericLibParts() before this function.
Definition at line 435 of file netlist_exporter_xml.cpp.
References LIB_TABLE::GetFullURI(), LIB_TABLE::HasLibrary(), NETLIST_EXPORTER_XML::m_libraries, NETLIST_EXPORTER_BASE::m_schematic, NETLIST_EXPORTER_XML::node(), and SCHEMATIC::Prj().
Referenced by NETLIST_EXPORTER_XML::makeRoot().
|
protectedinherited |
Fill out an XML node with a list of nets and returns it.
Definition at line 563 of file netlist_exporter_xml.cpp.
References SCHEMATIC::ConnectionGraph(), SCH_COMPONENT::GetIncludeInBom(), SCH_COMPONENT::GetIncludeOnBoard(), SCH_PIN::GetName(), CONNECTION_GRAPH::GetNetMap(), SCH_PIN::GetNumber(), SCH_PIN::GetParentSymbol(), SCH_COMPONENT::GetRef(), GNL_OPT_BOM, GNL_OPT_KICAD, NETLIST_EXPORTER_BASE::m_schematic, NETLIST_EXPORTER_XML::node(), SCH_PIN_T, StrNumCmp(), and EDA_ITEM::Type().
Referenced by NETLIST_EXPORTER_XML::makeRoot().
Build the entire document tree for the generic export.
This is factored out here so we can write the tree in either S-expression file format or in XML if we put the tree built here into a wxXmlDocument.
aCtl | - a bitset or-ed together from GNL_ENUM values |
Definition at line 51 of file netlist_exporter_xml.cpp.
References GNL_COMPONENTS, GNL_HEADER, GNL_LIBRARIES, GNL_NETS, GNL_PARTS, NETLIST_EXPORTER_XML::makeDesignHeader(), NETLIST_EXPORTER_XML::makeLibParts(), NETLIST_EXPORTER_XML::makeLibraries(), NETLIST_EXPORTER_XML::makeListOfNets(), NETLIST_EXPORTER_XML::makeSymbols(), and NETLIST_EXPORTER_XML::node().
Referenced by Format(), and NETLIST_EXPORTER_XML::WriteNetlist().
|
protectedinherited |
Definition at line 216 of file netlist_exporter_xml.cpp.
References NETLIST_EXPORTER_XML::addSymbolFields(), KIID::AsString(), UNIQUE_STRINGS::Clear(), NETLIST_EXPORTER_BASE::findNextSymbol(), SCH_COMPONENT::GetDescription(), SCH_SHEET::GetFields(), SCH_COMPONENT::GetFields(), SCH_COMPONENT::GetIncludeInBom(), SCH_COMPONENT::GetIncludeOnBoard(), SCH_COMPONENT::GetLibId(), LIB_ID::GetLibItemName(), SCH_COMPONENT::GetPartRef(), SCH_COMPONENT::GetRef(), SCHEMATIC::GetSheets(), SCH_COMPONENT::GetUnit(), GNL_OPT_BOM, GNL_OPT_KICAD, SCH_SCREEN::Items(), SCH_SHEET_PATH::Last(), SCH_SHEET_PATH::LastScreen(), NETLIST_EXPORTER_BASE::m_libParts, NETLIST_EXPORTER_BASE::m_referencesAlreadyFound, NETLIST_EXPORTER_BASE::m_schematic, EDA_ITEM::m_Uuid, MANDATORY_FIELDS, NETLIST_EXPORTER_XML::node(), EE_RTREE::OfType(), SCH_SHEET_PATH::PathAsString(), SCH_SHEET_PATH::PathHumanReadable(), UTIL::RefDesStringCompare(), SCH_COMPONENT_T, and SCHEMATIC::SetCurrentSheet().
Referenced by NETLIST_EXPORTER_XML::makeRoot().
|
protectedinherited |
A convenience function that creates a new XNODE with an optional textual child.
It also provides some insulation from a possible change in XML library.
aName | is the name to associate with a new node of type wxXML_ELEMENT_NODE. |
aTextualContent | is optional, and if given is the text to include in a child of the returned node, and has type wxXML_TEXT_NODE. |
Definition at line 712 of file netlist_exporter_xml.cpp.
Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), NETLIST_EXPORTER_XML::makeDesignHeader(), NETLIST_EXPORTER_XML::makeLibParts(), NETLIST_EXPORTER_XML::makeLibraries(), NETLIST_EXPORTER_XML::makeListOfNets(), NETLIST_EXPORTER_XML::makeRoot(), and NETLIST_EXPORTER_XML::makeSymbols().
|
overridevirtual |
Write netlist to aOutFileName.
Generate the KiCad netlist format supported by Pcbnew.
It is basically the XML netlist just formatted slightly different.
Reimplemented from NETLIST_EXPORTER_BASE.
Definition at line 38 of file netlist_exporter_kicad.cpp.
References DisplayError(), Format(), GNL_ALL, GNL_OPT_KICAD, NULL, and IO_ERROR::What().
|
protectedinherited |
unique library parts used. LIB_PART items are sorted by names
Definition at line 109 of file netlist_exporter_base.h.
Referenced by NETLIST_EXPORTER_BASE::CreatePinList(), NETLIST_EXPORTER_BASE::findNextSymbol(), NETLIST_EXPORTER_XML::makeLibParts(), NETLIST_EXPORTER_XML::makeSymbols(), and NETLIST_EXPORTER_PSPICE::ProcessNetlist().
|
protectedinherited |
Used for "multiple parts per package" symbols to avoid processing a lib part more than once.
Definition at line 106 of file netlist_exporter_base.h.
Referenced by NETLIST_EXPORTER_BASE::findNextSymbol(), NETLIST_EXPORTER_XML::makeSymbols(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().
|
protectedinherited |
Definition at line 68 of file netlist_exporter_xml.h.
Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), and NETLIST_EXPORTER_KICAD().
|
protectedinherited |
The schematic's CurrentSheet when we entered. Restore on exiting.
Definition at line 115 of file netlist_exporter_base.h.
Referenced by NETLIST_EXPORTER_BASE::NETLIST_EXPORTER_BASE(), and NETLIST_EXPORTER_BASE::~NETLIST_EXPORTER_BASE().
|
protectedinherited |
The schematic we're generating a netlist for.
Definition at line 112 of file netlist_exporter_base.h.
Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), NETLIST_EXPORTER_BASE::CreatePinList(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), NETLIST_EXPORTER_PSPICE::Format(), NETLIST_EXPORTER_XML::makeDesignHeader(), NETLIST_EXPORTER_XML::makeLibraries(), NETLIST_EXPORTER_XML::makeListOfNets(), NETLIST_EXPORTER_XML::makeSymbols(), NETLIST_EXPORTER_BASE::NETLIST_EXPORTER_BASE(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), NETLIST_EXPORTER_PSPICE::UpdateDirectives(), NETLIST_EXPORTER_CADSTAR::writeListOfNets(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), NETLIST_EXPORTER_CADSTAR::WriteNetlist(), and NETLIST_EXPORTER_BASE::~NETLIST_EXPORTER_BASE().
|
protectedinherited |
Used to temporarily store and filter the list of pins of a schematic symbol when generating schematic symbol data in netlist (comp section).
No ownership of members. TODO(snh): Descope this object
Definition at line 102 of file netlist_exporter_base.h.
Referenced by NETLIST_EXPORTER_BASE::CreatePinList(), NETLIST_EXPORTER_BASE::eraseDuplicatePins(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().