30#include <wx/filename.h>
31#include <wx/xml/xml.h>
49 for( wxXmlNode* child = parent->GetChildren(); child; child = child->GetNext() )
51 if( child->GetName() ==
name )
63 netFile.SetName( netFile.GetName() + aSuffix );
64 netFile.SetExt( wxT(
"xml" ) );
66 if( wxFileExists( netFile.GetFullPath() ) )
67 wxRemoveFile( netFile.GetFullPath() );
70 std::unique_ptr<NETLIST_EXPORTER_XML> exporter = std::make_unique<NETLIST_EXPORTER_XML>( aSch,
nullptr );
72 bool ok = exporter->WriteNetlist( netFile.GetFullPath(), aOptions,
reporter )
78 bool loaded = aDoc.Load( netFile.GetFullPath() );
79 wxRemoveFile( netFile.GetFullPath() );
91 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
99 if( sig && sig->GetNets().size() == 4 )
101 candidate = sig.get();
106 BOOST_REQUIRE_MESSAGE( candidate,
"fixture must produce a 4-net potential chain" );
114 BOOST_CHECK_MESSAGE(
find_child( xdoc.GetRoot(), wxT(
"net_chains" ) ) ==
nullptr,
115 "Generic XML export must not contain <net_chains>" );
124 wxXmlNode* netChains =
find_child( xdoc.GetRoot(), wxT(
"net_chains" ) );
125 BOOST_REQUIRE_MESSAGE( netChains,
126 "KiCad-internal export must contain <net_chains>" );
128 bool foundCommitted =
false;
130 for( wxXmlNode* xchain = netChains->GetChildren(); xchain; xchain = xchain->GetNext() )
132 if( xchain->GetName() != wxT(
"net_chain" ) )
135 if( xchain->GetAttribute( wxT(
"name" ), wxEmptyString ) == wxT(
"SIG_GATING" ) )
137 foundCommitted =
true;
142 BOOST_CHECK_MESSAGE( foundCommitted,
143 "KiCad-internal export must list the committed chain" );
156 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
161 "fresh fixture must have no committed chains" );
163 wxXmlDocument xdocGeneric;
166 BOOST_CHECK(
find_child( xdocGeneric.GetRoot(), wxT(
"net_chains" ) ) ==
nullptr );
168 wxXmlDocument xdocKicad;
172 BOOST_CHECK_MESSAGE(
find_child( xdocKicad.GetRoot(), wxT(
"net_chains" ) ) ==
nullptr,
173 "Empty chain set must not produce a stray <net_chains/> element" );
Calculate the connectivity of a schematic and generate netlists.
SCH_NETCHAIN * CreateNetChainFromPotential(SCH_NETCHAIN *aPotential, const wxString &aName)
Promote a potential net chain to an actual user net chain with the provided name.
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Update the connection graph for the given list of sheets.
const std::vector< std::unique_ptr< SCH_NETCHAIN > > & GetPotentialNetChains() const
Potential net chains are inferred groupings produced by RebuildNetChains() but not yet user-committed...
const std::vector< std::unique_ptr< SCH_NETCHAIN > > & GetCommittedNetChains() const
Return user-created (committed) net chains (legacy accessor retained under net-chain API).
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Holds all the data relating to one schematic.
PROJECT & Project() const
Return a reference to the project this schematic is part of.
A net chain is a collection of nets that are connected together through passive components.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
A wrapper for reporting to a wxString object.
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
std::vector< FAB_LAYER_COLOR > dummy
SETTINGS_MANAGER m_settingsManager
XML_NETCHAIN_GATING_FIXTURE()=default
std::unique_ptr< SCHEMATIC > m_schematic
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
IbisParser parser & reporter
static wxXmlNode * find_child(wxXmlNode *parent, const wxString &name)
static bool writeAndLoad(SCHEMATIC *aSch, const wxString &aSuffix, unsigned aOptions, wxXmlDocument &aDoc)
BOOST_FIXTURE_TEST_CASE(NetlistExporterXML_NetChainsAbsentForGenericFormat, XML_NETCHAIN_GATING_FIXTURE)