31#include <wx/filename.h>
32#include <wx/xml/xml.h>
38struct UNIT_FIELDS_FIXTURE
46 void AddField(
int aUnit,
const wxString& aName,
const wxString& aText )
50 for(
const SCH_SHEET_PATH& sheet : m_schematic->Hierarchy() )
52 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType(
SCH_SYMBOL_T ) )
64 field.SetText( aText );
68 wxString ExportedField(
const wxString& aName )
70 wxFileName netFile = m_schematic->Project().GetProjectFullName();
71 netFile.
SetName( netFile.GetName() + wxT(
"_unit_fields" ) );
72 netFile.SetExt( wxT(
"xml" ) );
75 NETLIST_EXPORTER_XML exporter( m_schematic.get(),
nullptr );
81 wxRemoveFile( netFile.GetFullPath() );
83 wxXmlNode*
comp = doc.GetRoot()->GetChildren();
85 while(
comp &&
comp->GetName() != wxT(
"components" ) )
92 if(
comp->GetAttribute( wxT(
"ref" ) ) != wxT(
"U4" ) )
95 for( wxXmlNode* fields =
comp->GetChildren(); fields; fields = fields->GetNext() )
97 if( fields->GetName() != wxT(
"fields" ) )
100 for( wxXmlNode* field = fields->GetChildren(); field; field = field->GetNext() )
102 if( field->GetAttribute( wxT(
"name" ) ) == aName )
103 return field->GetNodeContent();
108 BOOST_FAIL(
"U4 exports no " + aName.ToStdString() );
109 return wxEmptyString;
112 SETTINGS_MANAGER m_settingsManager;
113 std::unique_ptr<SCHEMATIC> m_schematic;
121 AddField( 1, wxS(
"Maker" ), wxEmptyString );
122 AddField( 3, wxS(
"Maker" ), wxS(
"Acme" ) );
130 AddField( 3, wxS(
"Page" ), wxS(
"${SHEETNAME}" ) );
132 BOOST_CHECK_EQUAL( ExportedField( wxS(
"Page" ) ), wxS(
"F28P65x OSC, RESET AND DEBUG" ) );
void SetName(const wxString &aName)
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
@ SCH_SYMBOL
one item stream of a Schematic Symbol Library
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
@ USER
The field ID hasn't been set yet; field is invalid.
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
IbisParser parser & reporter
BOOST_FIXTURE_TEST_CASE(NetlistExporterXML_BlankUnitFieldDoesNotHideText, UNIT_FIELDS_FIXTURE)
BOOST_CHECK_EQUAL(result, "25.4")