Add title block information to Eeschema BOM generator.
This commit is contained in:
commit
534ed58f02
|
@ -48,6 +48,7 @@
|
||||||
#include <xnode.h> // also nests: <wx/xml/xml.h>
|
#include <xnode.h> // also nests: <wx/xml/xml.h>
|
||||||
#include <build_version.h>
|
#include <build_version.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <sch_base_frame.h>
|
||||||
|
|
||||||
#define INTERMEDIATE_NETLIST_EXT wxT( "xml" )
|
#define INTERMEDIATE_NETLIST_EXT wxT( "xml" )
|
||||||
|
|
||||||
|
@ -197,12 +198,13 @@ class NETLIST_EXPORT_TOOL
|
||||||
* builds the entire document tree for the generic export. This is factored
|
* builds 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
|
* 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.
|
* or in XML if we put the tree built here into a wxXmlDocument.
|
||||||
|
* @return XNODE* - the root nodes
|
||||||
*/
|
*/
|
||||||
XNODE* makeGenericRoot();
|
XNODE* makeGenericRoot();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function makeGenericComponents
|
* Function makeGenericComponents
|
||||||
* returns a sub-tree holding all the schematic components.
|
* @return XNODE* - returns a sub-tree holding all the schematic components.
|
||||||
*/
|
*/
|
||||||
XNODE* makeGenericComponents();
|
XNODE* makeGenericComponents();
|
||||||
|
|
||||||
|
@ -216,12 +218,14 @@ class NETLIST_EXPORT_TOOL
|
||||||
/**
|
/**
|
||||||
* Function makeGenericLibParts
|
* Function makeGenericLibParts
|
||||||
* fills out an XML node with the unique library parts and returns it.
|
* fills out an XML node with the unique library parts and returns it.
|
||||||
|
* @return XNODE* - the library parts nodes
|
||||||
*/
|
*/
|
||||||
XNODE* makeGenericLibParts();
|
XNODE* makeGenericLibParts();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function makeGenericListOfNets
|
* Function makeGenericListOfNets
|
||||||
* fills out an XML node with a list of nets and returns it.
|
* fills out an XML node with a list of nets and returns it.
|
||||||
|
* @return XNODE* - the list of nets nodes
|
||||||
*/
|
*/
|
||||||
XNODE* makeGenericListOfNets();
|
XNODE* makeGenericListOfNets();
|
||||||
|
|
||||||
|
@ -229,6 +233,7 @@ class NETLIST_EXPORT_TOOL
|
||||||
* Function makeGenericLibraries
|
* Function makeGenericLibraries
|
||||||
* fills out an XML node with a list of used libraries and returns it.
|
* fills out an XML node with a list of used libraries and returns it.
|
||||||
* Must have called makeGenericLibParts() before this function.
|
* Must have called makeGenericLibParts() before this function.
|
||||||
|
* @return XNODE* - the library nodes
|
||||||
*/
|
*/
|
||||||
XNODE* makeGenericLibraries();
|
XNODE* makeGenericLibraries();
|
||||||
|
|
||||||
|
@ -637,7 +642,13 @@ static XNODE* node( const wxString& aName, const wxString& aTextualContent = wxE
|
||||||
|
|
||||||
XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader()
|
XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader()
|
||||||
{
|
{
|
||||||
|
SCH_SCREEN* screen;
|
||||||
XNODE* xdesign = node( wxT("design") );
|
XNODE* xdesign = node( wxT("design") );
|
||||||
|
XNODE* xtitleBlock;
|
||||||
|
XNODE* xsheet;
|
||||||
|
XNODE* xcomment;
|
||||||
|
wxString sheetTxt;
|
||||||
|
wxFileName sourceFileName;
|
||||||
|
|
||||||
// the root sheet is a special sheet, call it source
|
// the root sheet is a special sheet, call it source
|
||||||
xdesign->AddChild( node( wxT( "source" ), g_RootSheet->GetScreen()->GetFileName() ) );
|
xdesign->AddChild( node( wxT( "source" ), g_RootSheet->GetScreen()->GetFileName() ) );
|
||||||
|
@ -647,27 +658,55 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader()
|
||||||
// which Eeschema tool
|
// which Eeschema tool
|
||||||
xdesign->AddChild( node( wxT( "tool" ), wxT( "Eeschema " ) + GetBuildVersion() ) );
|
xdesign->AddChild( node( wxT( "tool" ), wxT( "Eeschema " ) + GetBuildVersion() ) );
|
||||||
|
|
||||||
/* @todo might do a list of schematic pages
|
/*
|
||||||
|
Export the sheets information
|
||||||
<page name="">
|
|
||||||
<title/>
|
|
||||||
<revision/>
|
|
||||||
<company/>
|
|
||||||
<comments>
|
|
||||||
<comment>blah</comment> <!-- comment1 -->
|
|
||||||
<comment>blah</comment> <!-- comment2 -->
|
|
||||||
</comments>
|
|
||||||
<pagesize/>
|
|
||||||
</page>
|
|
||||||
:
|
|
||||||
|
|
||||||
and a sheet hierarchy report here
|
|
||||||
<sheets>
|
|
||||||
<sheet name="sheetname1" page="pagenameA">
|
|
||||||
<sheet name="sheetname2" page="pagenameB"/> use recursion to output?
|
|
||||||
</sheet>
|
|
||||||
</sheets>
|
|
||||||
*/
|
*/
|
||||||
|
SCH_SHEET_LIST sheetList;
|
||||||
|
|
||||||
|
for( SCH_SHEET_PATH* sheet = sheetList.GetFirst(); sheet; sheet = sheetList.GetNext() )
|
||||||
|
{
|
||||||
|
screen = sheet->LastScreen();
|
||||||
|
|
||||||
|
xdesign->AddChild( xsheet = node( wxT( "sheet" ) ) );
|
||||||
|
|
||||||
|
// get the string representation of the sheet index number.
|
||||||
|
// Note that sheet->GetIndex() is zero index base and we need to increment the number by one to make
|
||||||
|
// human readable
|
||||||
|
sheetTxt.Printf( wxT( "%d" ), ( sheetList.GetIndex() + 1 ) );
|
||||||
|
xsheet->AddAttribute( wxT( "number" ), sheetTxt );
|
||||||
|
xsheet->AddAttribute( wxT( "name" ), sheet->PathHumanReadable() );
|
||||||
|
xsheet->AddAttribute( wxT( "tstamps" ), sheet->Path() );
|
||||||
|
|
||||||
|
|
||||||
|
TITLE_BLOCK tb = screen->GetTitleBlock();
|
||||||
|
|
||||||
|
xsheet->AddChild( xtitleBlock = node( wxT( "title_block" ) ) );
|
||||||
|
|
||||||
|
xtitleBlock->AddChild( node( wxT( "title" ), tb.GetTitle() ) );
|
||||||
|
xtitleBlock->AddChild( node( wxT( "company" ), tb.GetCompany() ) );
|
||||||
|
xtitleBlock->AddChild( node( wxT( "rev" ), tb.GetRevision() ) );
|
||||||
|
xtitleBlock->AddChild( node( wxT( "date" ), tb.GetDate() ) );
|
||||||
|
|
||||||
|
// We are going to remove the fileName directories.
|
||||||
|
sourceFileName = wxFileName( screen->GetFileName() );
|
||||||
|
xtitleBlock->AddChild( node( wxT( "source" ), sourceFileName.GetFullName() ) );
|
||||||
|
|
||||||
|
xtitleBlock->AddChild( xcomment = node( wxT( "comment" ) ) );
|
||||||
|
xcomment->AddAttribute( wxT("number"), wxT("1") );
|
||||||
|
xcomment->AddAttribute( wxT( "value" ), tb.GetComment1() );
|
||||||
|
|
||||||
|
xtitleBlock->AddChild( xcomment = node( wxT( "comment" ) ) );
|
||||||
|
xcomment->AddAttribute( wxT("number"), wxT("2") );
|
||||||
|
xcomment->AddAttribute( wxT( "value" ), tb.GetComment2() );
|
||||||
|
|
||||||
|
xtitleBlock->AddChild( xcomment = node( wxT( "comment" ) ) );
|
||||||
|
xcomment->AddAttribute( wxT("number"), wxT("3") );
|
||||||
|
xcomment->AddAttribute( wxT( "value" ), tb.GetComment3() );
|
||||||
|
|
||||||
|
xtitleBlock->AddChild( xcomment = node( wxT( "comment" ) ) );
|
||||||
|
xcomment->AddAttribute( wxT("number"), wxT("4") );
|
||||||
|
xcomment->AddAttribute( wxT( "value" ), tb.GetComment4() );
|
||||||
|
}
|
||||||
|
|
||||||
return xdesign;
|
return xdesign;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ set( xsl_lst
|
||||||
netlist_form_cadstar.xsl
|
netlist_form_cadstar.xsl
|
||||||
netlist_form_OrcadPcb2.xsl
|
netlist_form_OrcadPcb2.xsl
|
||||||
netlist_form_pads-pcb.xsl
|
netlist_form_pads-pcb.xsl
|
||||||
|
bom_with_title_block_2_csv.xsl
|
||||||
)
|
)
|
||||||
|
|
||||||
install( FILES ${xsl_lst}
|
install( FILES ${xsl_lst}
|
||||||
|
|
|
@ -0,0 +1,168 @@
|
||||||
|
<!--
|
||||||
|
@package
|
||||||
|
EESCHEMA BOM plugin. Creates BOM CSV files from the project net file.
|
||||||
|
Based on Stefan Helmert bom2csv.xsl
|
||||||
|
|
||||||
|
Note:
|
||||||
|
The project infomation (i.e title, company and revision) is taken from and the root sheet.
|
||||||
|
|
||||||
|
Arthur:
|
||||||
|
Ronald Sousa HashDefineElectronics.com
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
on Windows:
|
||||||
|
xsltproc -o "%O.csv" "C:\Program Files (x86)\KiCad\bin\plugins\bom2csv.xsl" "%I"
|
||||||
|
on Linux:
|
||||||
|
xsltproc -o "%O.csv" /usr/local/lib/kicad/plugins/bom2csv.xsl "%I"
|
||||||
|
|
||||||
|
Ouput Example:
|
||||||
|
Source,
|
||||||
|
Kicad Rev, working director and file source
|
||||||
|
Generated Date, date this file was generated
|
||||||
|
|
||||||
|
Title, the project's tile
|
||||||
|
Company, the project's company
|
||||||
|
Rev, the project's revision
|
||||||
|
Date Source, project's issue date
|
||||||
|
Comment, This is comment 1
|
||||||
|
Comment, This is comment 2
|
||||||
|
Comment, This is comment 3
|
||||||
|
Comment, This is comment 4
|
||||||
|
|
||||||
|
Reference, Value, Fields[n], Library, Library Ref
|
||||||
|
U1, PIC32MX, Fields[n], KicadLib, PIC
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!DOCTYPE xsl:stylesheet [
|
||||||
|
<!ENTITY nl "
"> <!--new line CR, LF, or LF, your choice -->
|
||||||
|
]>
|
||||||
|
|
||||||
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||||
|
<xsl:output method="text"/>
|
||||||
|
|
||||||
|
<!-- for table head and empty table fields-->
|
||||||
|
<xsl:key name="headentr" match="field" use="@name"/>
|
||||||
|
|
||||||
|
<!-- main part -->
|
||||||
|
<xsl:template match="/export">
|
||||||
|
<xsl:text>Source,</xsl:text><xsl:value-of select="design/source"/><xsl:text>&nl;</xsl:text>
|
||||||
|
<xsl:text>Kicad Rev,</xsl:text><xsl:value-of select="design/tool"/><xsl:text>&nl;</xsl:text>
|
||||||
|
<xsl:text>Generated Date,</xsl:text><xsl:value-of select="design/date"/><xsl:text>&nl;</xsl:text>
|
||||||
|
|
||||||
|
<xsl:text>&nl;</xsl:text>
|
||||||
|
|
||||||
|
<!-- Ouput Root sheet project information -->
|
||||||
|
<xsl:apply-templates select="/export/design/sheet[1]"/>
|
||||||
|
|
||||||
|
<xsl:text>&nl;</xsl:text>
|
||||||
|
|
||||||
|
<!-- Output table header -->
|
||||||
|
<xsl:text>Reference,Value,</xsl:text>
|
||||||
|
<xsl:for-each select="components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
|
||||||
|
<xsl:value-of select="@name"/>
|
||||||
|
<xsl:text>,</xsl:text>
|
||||||
|
</xsl:for-each>
|
||||||
|
<xsl:text>Library,Library Ref</xsl:text>
|
||||||
|
<xsl:text>&nl;</xsl:text>
|
||||||
|
|
||||||
|
<!-- all table entries -->
|
||||||
|
<xsl:apply-templates select="components/comp"/>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- generate the Root sheet project information -->
|
||||||
|
<xsl:template match="/export/design/sheet[1]">
|
||||||
|
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="title_block/title !=''">
|
||||||
|
<xsl:text>Title,</xsl:text><xsl:value-of select="title_block/title"/><xsl:text>&nl;</xsl:text>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:text>Title,Not Set</xsl:text><xsl:text>&nl;</xsl:text>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
|
||||||
|
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="title_block/company !=''">
|
||||||
|
<xsl:text>Company,</xsl:text><xsl:value-of select="title_block/company"/><xsl:text>&nl;</xsl:text>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:text>Company,Not Set</xsl:text><xsl:text>&nl;</xsl:text>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="title_block/rev !=''">
|
||||||
|
<xsl:text>Revision,</xsl:text><xsl:value-of select="title_block/rev"/><xsl:text>&nl;</xsl:text>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:text>Revision,Not Set</xsl:text><xsl:text>&nl;</xsl:text>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="title_block/date !=''">
|
||||||
|
<xsl:text>Date Issue,</xsl:text><xsl:value-of select="title_block/date"/><xsl:text>&nl;</xsl:text>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:text>Date Issue,Not Set</xsl:text><xsl:text>&nl;</xsl:text>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
|
||||||
|
<xsl:apply-templates select="title_block/comment"/>
|
||||||
|
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="title_block/comment">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="@value !=''">
|
||||||
|
<xsl:text>Comment,</xsl:text><xsl:value-of select="@value"/><xsl:text>&nl;</xsl:text>
|
||||||
|
</xsl:when>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- the table entries -->
|
||||||
|
<xsl:template match="components/comp">
|
||||||
|
<xsl:value-of select="@ref"/><xsl:text>,</xsl:text>
|
||||||
|
<xsl:value-of select="value"/><xsl:text>,</xsl:text>
|
||||||
|
<xsl:apply-templates select="fields"/>
|
||||||
|
<xsl:apply-templates select="libsource"/>
|
||||||
|
<xsl:text>&nl;</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- the library selection -->
|
||||||
|
<xsl:template match="libsource">
|
||||||
|
<xsl:value-of select="@lib"/><xsl:text>,</xsl:text>
|
||||||
|
<xsl:value-of select="@part"/>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- table entries with dynamic table head -->
|
||||||
|
<xsl:template match="fields">
|
||||||
|
|
||||||
|
<!-- remember current fields section -->
|
||||||
|
<xsl:variable name="fieldvar" select="field"/>
|
||||||
|
|
||||||
|
<!-- for all existing head entries -->
|
||||||
|
<xsl:for-each select="/export/components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
|
||||||
|
<xsl:variable name="allnames" select="@name"/>
|
||||||
|
|
||||||
|
<!-- for all field entries in the remembered fields section -->
|
||||||
|
<xsl:for-each select="$fieldvar">
|
||||||
|
|
||||||
|
<!-- only if this field entry exists in this fields section -->
|
||||||
|
<xsl:if test="@name=$allnames">
|
||||||
|
<!-- content of the field -->
|
||||||
|
<xsl:value-of select="."/>
|
||||||
|
</xsl:if>
|
||||||
|
<!--
|
||||||
|
If it does not exist, use an empty cell in output for this row.
|
||||||
|
Every non-blank entry is assigned to its proper column.
|
||||||
|
-->
|
||||||
|
</xsl:for-each>
|
||||||
|
<xsl:text>,</xsl:text>
|
||||||
|
</xsl:for-each>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
|
@ -324,6 +324,12 @@ public:
|
||||||
*/
|
*/
|
||||||
int GetCount() const { return m_count; }
|
int GetCount() const { return m_count; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function GetIndex
|
||||||
|
* @return the last selected screen index.
|
||||||
|
*/
|
||||||
|
int GetIndex() const { return m_index; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetFirst
|
* Function GetFirst
|
||||||
* @return the first item (sheet) in m_List and prepare calls to GetNext()
|
* @return the first item (sheet) in m_List and prepare calls to GetNext()
|
||||||
|
|
Loading…
Reference in New Issue