From 8a916a610afd5dbc876eafc79ef2d6793eac8325 Mon Sep 17 00:00:00 2001 From: Ronald Sousa Date: Sun, 8 Feb 2015 10:54:35 +0000 Subject: [PATCH 1/6] -update XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() so that the net file now outputs project information. For example: - Company name - Project title - issue date - Revision - Comment 1 to 4 - updated bom2csv.xsl plugin to take advatage of the extra project information that the net file now outputs. Overall this improvement will make it easier to automatically make controlled and traceable documents. --- eeschema/netform.cpp | 22 ++++++++- eeschema/plugins/bom2csv.xsl | 86 ++++++++++++++++++++++++++++-------- 2 files changed, 89 insertions(+), 19 deletions(-) diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index a87dec87f3..d184e71803 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -47,6 +47,7 @@ #include // also nests: #include #include +#include #define INTERMEDIATE_NETLIST_EXT wxT("xml") @@ -652,16 +653,35 @@ static XNODE* node( const wxString& aName, const wxString& aTextualContent = wxE XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() { + SCH_SCREEN* screen; + SCH_SCREENS ScreenList; + screen = ScreenList.GetFirst(); XNODE* xdesign = node( wxT("design") ); // the root sheet is a special sheet, call it source xdesign->AddChild( node( wxT( "source" ), g_RootSheet->GetScreen()->GetFileName() ) ); - xdesign->AddChild( node( wxT( "date" ), DateAndTime() ) ); + xdesign->AddChild( node( wxT( "generatedDate" ), DateAndTime() ) ); // which Eeschema tool xdesign->AddChild( node( wxT( "tool" ), wxT( "Eeschema " ) + GetBuildVersion() ) ); + // export project information + if( screen != NULL ) + { + + TITLE_BLOCK tb2 = screen->GetTitleBlock(); + + xdesign->AddChild( node( wxT( "title" ), tb2.GetTitle() )); + xdesign->AddChild( node( wxT( "company" ), tb2.GetCompany())); + xdesign->AddChild( node( wxT( "revision" ), tb2.GetRevision())); + xdesign->AddChild( node( wxT( "issueDate" ), tb2.GetDate())); + xdesign->AddChild( node( wxT( "comment1" ), tb2.GetComment1())); + xdesign->AddChild( node( wxT( "comment2" ), tb2.GetComment2())); + xdesign->AddChild( node( wxT( "comment3" ), tb2.GetComment3())); + xdesign->AddChild( node( wxT( "comment4" ), tb2.GetComment4())); + } + /* @todo might do a list of schematic pages diff --git a/eeschema/plugins/bom2csv.xsl b/eeschema/plugins/bom2csv.xsl index 1991d4953e..0e58462b05 100644 --- a/eeschema/plugins/bom2csv.xsl +++ b/eeschema/plugins/bom2csv.xsl @@ -4,11 +4,8 @@ Functionality: Generation of csv table with table head of all existing field names - and correct assigned cell entries + and correct assigned cell entries. - How to use this is explained in eeschema.pdf chapter 14. You enter a command line into the - netlist exporter using a new (custom) tab in the netlist export dialog. The command is - similar to on Windows: xsltproc -o "%O.csv" "C:\Program Files (x86)\KiCad\bin\plugins\bom2csv.xsl" "%I" on Linux: @@ -21,10 +18,22 @@ - Reference, Value, Footprint, Datasheet + + Source: &nl; + Kicad Rev: &nl; + Generated Date: &nl; + &nl; + Document Title: &nl; + Company: &nl; + Revision: &nl; + Issue Date: &nl; - - - , - - - &nl; + + + Comment: &nl; + + + + + + Comment: &nl; + + + + + + Comment: &nl; + + + + + + Comment: &nl; + + + + &nl; + + + Reference, Value, + + + , + + Library, Library Ref + &nl; @@ -57,12 +102,17 @@ , , - , - + &nl; + + + , + + + @@ -72,7 +122,6 @@ - , @@ -87,6 +136,7 @@ Every non-blank entry is assigned to its proper column. --> + , From ef20a2bb9e4fa58406953830aff21b7020635730 Mon Sep 17 00:00:00 2001 From: Ronald Sousa Date: Mon, 9 Feb 2015 07:39:06 +0000 Subject: [PATCH 2/6] - Renamed tb2 to tb - corrected the code that violated the code policy. i.e. added the extra space to make the code more readable - Restored bom2csv.xsl to its original form - Added bom_with_title_block_2_csv.xsl which has the new BOM generator. --- eeschema/netform.cpp | 18 +-- eeschema/plugins/bom2csv.xsl | 86 +++-------- .../plugins/bom_with_title_block_2_csv.xsl | 134 ++++++++++++++++++ 3 files changed, 161 insertions(+), 77 deletions(-) create mode 100644 eeschema/plugins/bom_with_title_block_2_csv.xsl diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index d184e71803..40796e0e06 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -670,16 +670,16 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() if( screen != NULL ) { - TITLE_BLOCK tb2 = screen->GetTitleBlock(); + TITLE_BLOCK tb = screen->GetTitleBlock(); - xdesign->AddChild( node( wxT( "title" ), tb2.GetTitle() )); - xdesign->AddChild( node( wxT( "company" ), tb2.GetCompany())); - xdesign->AddChild( node( wxT( "revision" ), tb2.GetRevision())); - xdesign->AddChild( node( wxT( "issueDate" ), tb2.GetDate())); - xdesign->AddChild( node( wxT( "comment1" ), tb2.GetComment1())); - xdesign->AddChild( node( wxT( "comment2" ), tb2.GetComment2())); - xdesign->AddChild( node( wxT( "comment3" ), tb2.GetComment3())); - xdesign->AddChild( node( wxT( "comment4" ), tb2.GetComment4())); + xdesign->AddChild( node( wxT( "title" ), tb.GetTitle() ) ); + xdesign->AddChild( node( wxT( "company" ), tb.GetCompany() ) ); + xdesign->AddChild( node( wxT( "revision" ), tb.GetRevision() ) ); + xdesign->AddChild( node( wxT( "issueDate" ), tb.GetDate() ) ); + xdesign->AddChild( node( wxT( "comment1" ), tb.GetComment1() ) ); + xdesign->AddChild( node( wxT( "comment2" ), tb.GetComment2() ) ); + xdesign->AddChild( node( wxT( "comment3" ), tb.GetComment3() ) ); + xdesign->AddChild( node( wxT( "comment4" ), tb.GetComment4() ) ); } /* @todo might do a list of schematic pages diff --git a/eeschema/plugins/bom2csv.xsl b/eeschema/plugins/bom2csv.xsl index 0e58462b05..1991d4953e 100644 --- a/eeschema/plugins/bom2csv.xsl +++ b/eeschema/plugins/bom2csv.xsl @@ -4,8 +4,11 @@ Functionality: Generation of csv table with table head of all existing field names - and correct assigned cell entries. + and correct assigned cell entries + How to use this is explained in eeschema.pdf chapter 14. You enter a command line into the + netlist exporter using a new (custom) tab in the netlist export dialog. The command is + similar to on Windows: xsltproc -o "%O.csv" "C:\Program Files (x86)\KiCad\bin\plugins\bom2csv.xsl" "%I" on Linux: @@ -18,22 +21,10 @@ - - Source: &nl; - Kicad Rev: &nl; - Generated Date: &nl; - &nl; - Document Title: &nl; - Company: &nl; - Revision: &nl; - Issue Date: &nl; + Reference, Value, Footprint, Datasheet - - - Comment: &nl; - - - - - - Comment: &nl; - - - - - - Comment: &nl; - - - - - - Comment: &nl; - - - - &nl; - - - Reference, Value, - - - , - - Library, Library Ref - &nl; + + + , + + + &nl; @@ -102,17 +57,12 @@ , , + , + - &nl; - - - , - - - @@ -122,6 +72,7 @@ + , @@ -136,7 +87,6 @@ Every non-blank entry is assigned to its proper column. --> - , diff --git a/eeschema/plugins/bom_with_title_block_2_csv.xsl b/eeschema/plugins/bom_with_title_block_2_csv.xsl new file mode 100644 index 0000000000..3e7e848e59 --- /dev/null +++ b/eeschema/plugins/bom_with_title_block_2_csv.xsl @@ -0,0 +1,134 @@ + + + +]> + + + + + + + + + + + + Source: &nl; + Kicad Rev: &nl; + Generated Date: &nl; + &nl; + Document Title: &nl; + Company: &nl; + Revision: &nl; + Issue Date: &nl; + + + + Comment: &nl; + + + + + + Comment: &nl; + + + + + + Comment: &nl; + + + + + + Comment: &nl; + + + + &nl; + + + Reference, Value, + + + , + + Library, Library Ref + &nl; + + + + + + + + , + , + + + &nl; + + + + + , + + + + + + + + + + + + + + + + + + + + + + + + , + + + + From 534a3c1f787671bebccd6532e8009100227265b4 Mon Sep 17 00:00:00 2001 From: Ronald Sousa Date: Tue, 10 Feb 2015 08:35:37 +0000 Subject: [PATCH 3/6] - changed generatedDate back to date. this should keep compatibly - the net file now has all project sheet title block using node 'sheets' and 'sheet' - Updated bom_with_title_block_2_csv. Note, its only going to output the root title block. --- eeschema/netform.cpp | 33 ++-- .../plugins/bom_with_title_block_2_csv.xsl | 145 ++++++++++++------ 2 files changed, 114 insertions(+), 64 deletions(-) diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 40796e0e06..5ca5fb2836 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -654,32 +654,37 @@ static XNODE* node( const wxString& aName, const wxString& aTextualContent = wxE XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() { SCH_SCREEN* screen; - SCH_SCREENS ScreenList; - screen = ScreenList.GetFirst(); + SCH_SCREENS screenList; + screen = screenList.GetFirst(); XNODE* xdesign = node( wxT("design") ); + XNODE* xsheetNode; + XNODE* xsheetInfo; // the root sheet is a special sheet, call it source xdesign->AddChild( node( wxT( "source" ), g_RootSheet->GetScreen()->GetFileName() ) ); - xdesign->AddChild( node( wxT( "generatedDate" ), DateAndTime() ) ); + xdesign->AddChild( node( wxT( "date" ), DateAndTime() ) ); // which Eeschema tool xdesign->AddChild( node( wxT( "tool" ), wxT( "Eeschema " ) + GetBuildVersion() ) ); - // export project information - if( screen != NULL ) - { + xdesign->AddChild( xsheetNode = node( wxT( "sheets" ) ) ); + for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() ) + { + TITLE_BLOCK tb = screen->GetTitleBlock(); - xdesign->AddChild( node( wxT( "title" ), tb.GetTitle() ) ); - xdesign->AddChild( node( wxT( "company" ), tb.GetCompany() ) ); - xdesign->AddChild( node( wxT( "revision" ), tb.GetRevision() ) ); - xdesign->AddChild( node( wxT( "issueDate" ), tb.GetDate() ) ); - xdesign->AddChild( node( wxT( "comment1" ), tb.GetComment1() ) ); - xdesign->AddChild( node( wxT( "comment2" ), tb.GetComment2() ) ); - xdesign->AddChild( node( wxT( "comment3" ), tb.GetComment3() ) ); - xdesign->AddChild( node( wxT( "comment4" ), tb.GetComment4() ) ); + xsheetNode->AddChild( xsheetInfo = node( wxT( "sheet" ) ) ); + + xsheetInfo->AddChild( node( wxT( "title" ), tb.GetTitle() ) ); + xsheetInfo->AddChild( node( wxT( "company" ), tb.GetCompany() ) ); + xsheetInfo->AddChild( node( wxT( "revision" ), tb.GetRevision() ) ); + xsheetInfo->AddChild( node( wxT( "issueDate" ), tb.GetDate() ) ); + xsheetInfo->AddChild( node( wxT( "comment1" ), tb.GetComment1() ) ); + xsheetInfo->AddChild( node( wxT( "comment2" ), tb.GetComment2() ) ); + xsheetInfo->AddChild( node( wxT( "comment3" ), tb.GetComment3() ) ); + xsheetInfo->AddChild( node( wxT( "comment4" ), tb.GetComment4() ) ); } /* @todo might do a list of schematic pages diff --git a/eeschema/plugins/bom_with_title_block_2_csv.xsl b/eeschema/plugins/bom_with_title_block_2_csv.xsl index 3e7e848e59..e4583fa063 100644 --- a/eeschema/plugins/bom_with_title_block_2_csv.xsl +++ b/eeschema/plugins/bom_with_title_block_2_csv.xsl @@ -3,7 +3,11 @@ EESCHEMA BOM plugin. Creates BOM CSV files from the project net file. Based on Stefan Helmert bom2csv.xsl - Arthur: Ronald Sousa HashDefineElectronics.com + 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: @@ -12,16 +16,18 @@ xsltproc -o "%O.csv" /usr/local/lib/kicad/plugins/bom2csv.xsl "%I" Ouput Example: - Kicad Rev: working director and file source - Generated Date: date this file was generated - Document Title: the project tile - Company: the project company - Revision: the project revision - Issue Date: project issue date - Comment: This is comment 1 - Comment: This is comment 2 - Comment: This is comment 3 - Comment: This is comment 4 + 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 + Revision, 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 @@ -31,7 +37,6 @@ ]> - @@ -40,55 +45,95 @@ - - Source: &nl; - Kicad Rev: &nl; - Generated Date: &nl; + Source,&nl; + Kicad Rev,&nl; + Generated Date,&nl; + &nl; - Document Title: &nl; - Company: &nl; - Revision: &nl; - Issue Date: &nl; - - - - Comment: &nl; - - - - - - Comment: &nl; - - - - - - Comment: &nl; - - - - - - Comment: &nl; - - - - &nl; - + + + + + &nl; + - Reference, Value, + Reference,Value, - , + , - Library, Library Ref + Library,Library Ref &nl; + + + + + + + Title,&nl; + + + Title,Not Set&nl; + + + + + + + Company,&nl; + + + Company,Not Set&nl; + + + + + + Revision,&nl; + + + Revision,Not Set&nl; + + + + + + Date Issue,&nl; + + + Date Issue,Not Set&nl; + + + + + Comment,&nl; + + + + + + Comment,&nl; + + + + + + Comment,&nl; + + + + + + Comment,&nl; + + + + , From 7392f04b75ace9ebad917e4981f02769d746e9b9 Mon Sep 17 00:00:00 2001 From: Ronald Sousa Date: Wed, 11 Feb 2015 11:11:05 +0000 Subject: [PATCH 4/6] - Added sheet information to the net file. i.e. sheet number, human path name and timestamp - update bom_with_title_block_2_csv.xsl --- eeschema/netform.cpp | 64 +++++++++---------- .../plugins/bom_with_title_block_2_csv.xsl | 44 +++++-------- eeschema/sch_sheet_path.h | 6 ++ 3 files changed, 54 insertions(+), 60 deletions(-) diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 5ca5fb2836..f65fe71fa8 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -653,12 +653,15 @@ static XNODE* node( const wxString& aName, const wxString& aTextualContent = wxE XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() { - SCH_SCREEN* screen; SCH_SCREENS screenList; - screen = screenList.GetFirst(); + SCH_SCREEN* screen; XNODE* xdesign = node( wxT("design") ); - XNODE* xsheetNode; XNODE* xsheetInfo; + XNODE* xcommentNode; + XNODE* xpagesNode; + XNODE* xpageNode; + wxString sheetNumTxt; + wxString sheetNumTxtFormat = wxT( "%d" ); // the root sheet is a special sheet, call it source xdesign->AddChild( node( wxT( "source" ), g_RootSheet->GetScreen()->GetFileName() ) ); @@ -668,46 +671,43 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() // which Eeschema tool xdesign->AddChild( node( wxT( "tool" ), wxT( "Eeschema " ) + GetBuildVersion() ) ); - xdesign->AddChild( xsheetNode = node( wxT( "sheets" ) ) ); + /* + Export the sheets information + */ + SCH_SHEET_LIST sheetList; + xdesign->AddChild( xpagesNode = node( wxT( "sheets" ) ) ); - for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() ) + for( SCH_SHEET_PATH* sheet = sheetList.GetFirst(); sheet; sheet = sheetList.GetNext() ) { + xpagesNode->AddChild( xpageNode = 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 + sheetNumTxt.Printf( sheetNumTxtFormat, ( sheetList.GetIndex() + 1 ) ); + + xpageNode->AddChild( node( wxT( "number" ), sheetNumTxt ) ); + xpageNode->AddChild( node( wxT( "names" ), sheet->PathHumanReadable() ) ); + xpageNode->AddChild( node( wxT( "tstamps" ), sheet->Path() ) ); + screen = sheet->LastScreen(); TITLE_BLOCK tb = screen->GetTitleBlock(); - xsheetNode->AddChild( xsheetInfo = node( wxT( "sheet" ) ) ); - + xpageNode->AddChild( xsheetInfo = node( wxT( "page" ) ) ); + xsheetInfo->AddChild( node( wxT( "title" ), tb.GetTitle() ) ); xsheetInfo->AddChild( node( wxT( "company" ), tb.GetCompany() ) ); xsheetInfo->AddChild( node( wxT( "revision" ), tb.GetRevision() ) ); xsheetInfo->AddChild( node( wxT( "issueDate" ), tb.GetDate() ) ); - xsheetInfo->AddChild( node( wxT( "comment1" ), tb.GetComment1() ) ); - xsheetInfo->AddChild( node( wxT( "comment2" ), tb.GetComment2() ) ); - xsheetInfo->AddChild( node( wxT( "comment3" ), tb.GetComment3() ) ); - xsheetInfo->AddChild( node( wxT( "comment4" ), tb.GetComment4() ) ); - } + xsheetInfo->AddChild( node( wxT( "source" ), screen->GetFileName() ) ); - /* @todo might do a list of schematic pages + xsheetInfo->AddChild( xcommentNode = node( wxT( "comments" ) ) ); + xcommentNode->AddChild( node( wxT( "comment" ), tb.GetComment1() ) ); + xcommentNode->AddChild( node( wxT( "comment" ), tb.GetComment2() ) ); + xcommentNode->AddChild( node( wxT( "comment" ), tb.GetComment3() ) ); + xcommentNode->AddChild( node( wxT( "comment" ), tb.GetComment4() ) ); - - - <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> - */ + } return xdesign; } diff --git a/eeschema/plugins/bom_with_title_block_2_csv.xsl b/eeschema/plugins/bom_with_title_block_2_csv.xsl index e4583fa063..5e192af3de 100644 --- a/eeschema/plugins/bom_with_title_block_2_csv.xsl +++ b/eeschema/plugins/bom_with_title_block_2_csv.xsl @@ -73,8 +73,8 @@ <xsl:template match="/export/design/sheets/sheet[1]"> <xsl:choose> - <xsl:when test="title !=''"> - <xsl:text>Title,</xsl:text><xsl:value-of select="title"/><xsl:text>&nl;</xsl:text> + <xsl:when test="page/title !=''"> + <xsl:text>Title,</xsl:text><xsl:value-of select="page/title"/><xsl:text>&nl;</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>Title,Not Set</xsl:text><xsl:text>&nl;</xsl:text> @@ -83,8 +83,8 @@ <xsl:choose> - <xsl:when test="company !=''"> - <xsl:text>Company,</xsl:text><xsl:value-of select="company"/><xsl:text>&nl;</xsl:text> + <xsl:when test="page/company !=''"> + <xsl:text>Company,</xsl:text><xsl:value-of select="page/company"/><xsl:text>&nl;</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>Company,Not Set</xsl:text><xsl:text>&nl;</xsl:text> @@ -92,8 +92,8 @@ </xsl:choose> <xsl:choose> - <xsl:when test="revision !=''"> - <xsl:text>Revision,</xsl:text><xsl:value-of select="revision"/><xsl:text>&nl;</xsl:text> + <xsl:when test="page/revision !=''"> + <xsl:text>Revision,</xsl:text><xsl:value-of select="page/revision"/><xsl:text>&nl;</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>Revision,Not Set</xsl:text><xsl:text>&nl;</xsl:text> @@ -101,39 +101,27 @@ </xsl:choose> <xsl:choose> - <xsl:when test="issueDate !=''"> - <xsl:text>Date Issue,</xsl:text><xsl:value-of select="issueDate"/><xsl:text>&nl;</xsl:text> + <xsl:when test="page/issueDate !=''"> + <xsl:text>Date Issue,</xsl:text><xsl:value-of select="page/issueDate"/><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="page/comments/comment"/><xsl:text>&nl;</xsl:text> + </xsl:template> + + <xsl:template match="page/comments/comment"> <xsl:choose> - <xsl:when test="comment1 !=''"> - <xsl:text>Comment,</xsl:text><xsl:value-of select="comment1"/><xsl:text>&nl;</xsl:text> - </xsl:when> - </xsl:choose> - - <xsl:choose> - <xsl:when test="comment2 !=''"> - <xsl:text>Comment,</xsl:text><xsl:value-of select="comment2"/><xsl:text>&nl;</xsl:text> - </xsl:when> - </xsl:choose> - - <xsl:choose> - <xsl:when test="comment3 !=''"> - <xsl:text>Comment,</xsl:text><xsl:value-of select="comment3"/><xsl:text>&nl;</xsl:text> - </xsl:when> - </xsl:choose> - - <xsl:choose> - <xsl:when test="comment4 !=''"> - <xsl:text>Comment,</xsl:text><xsl:value-of select="comment4"/><xsl:text>&nl;</xsl:text> + <xsl:when test=". !=''"> + <xsl:text>Comment,</xsl:text><xsl:value-of select="."/><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> diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index 365680a430..d5bb231d83 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -324,6 +324,12 @@ public: */ int GetCount() const { return m_count; } + /** + * Function GetIndex + * @return the last selected screen index. + */ + int GetIndex() const { return m_index; } + /** * Function GetFirst * @return the first item (sheet) in m_List and prepare calls to GetNext() From d4135f5d2bafc8833485ffdc5e3be6cff836af32 Mon Sep 17 00:00:00 2001 From: Ronald Sousa <Ronald.sousa@hashdefineelectronics.com> Date: Wed, 11 Feb 2015 13:04:42 +0000 Subject: [PATCH 5/6] - Minor naming changes and code clean up --- eeschema/netform.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index f65fe71fa8..16b00e8b39 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -653,7 +653,6 @@ static XNODE* node( const wxString& aName, const wxString& aTextualContent = wxE XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() { - SCH_SCREENS screenList; SCH_SCREEN* screen; XNODE* xdesign = node( wxT("design") ); XNODE* xsheetInfo; @@ -687,7 +686,7 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() sheetNumTxt.Printf( sheetNumTxtFormat, ( sheetList.GetIndex() + 1 ) ); xpageNode->AddChild( node( wxT( "number" ), sheetNumTxt ) ); - xpageNode->AddChild( node( wxT( "names" ), sheet->PathHumanReadable() ) ); + xpageNode->AddChild( node( wxT( "name" ), sheet->PathHumanReadable() ) ); xpageNode->AddChild( node( wxT( "tstamps" ), sheet->Path() ) ); screen = sheet->LastScreen(); From 64507e397c7110aa77baca73dc10ac3f79029efd Mon Sep 17 00:00:00 2001 From: Ronald Sousa <Ronald.sousa@hashdefineelectronics.com> Date: Sun, 15 Feb 2015 10:45:43 +0000 Subject: [PATCH 6/6] - changes sheet number, path, and timestamp from nodes to attributes - changes comment number and value from nodes to attibutes - UPdate bom_with_title_block_2_csv to use the changes made for sheet and comment --- eeschema/netform.cpp | 71 +++++++++++-------- .../plugins/bom_with_title_block_2_csv.xsl | 31 ++++---- 2 files changed, 59 insertions(+), 43 deletions(-) diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 16b00e8b39..c08954952a 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -197,12 +197,13 @@ class NETLIST_EXPORT_TOOL * 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 * or in XML if we put the tree built here into a wxXmlDocument. + * @return XNODE* - the root nodes */ XNODE* makeGenericRoot(); /** * Function makeGenericComponents - * returns a sub-tree holding all the schematic components. + * @return XNODE* - returns a sub-tree holding all the schematic components. */ XNODE* makeGenericComponents(); @@ -216,12 +217,14 @@ class NETLIST_EXPORT_TOOL /** * Function makeGenericLibParts * fills out an XML node with the unique library parts and returns it. + * @return XNODE* - the library parts nodes */ XNODE* makeGenericLibParts(); /** * Function makeGenericListOfNets * fills out an XML node with a list of nets and returns it. + * @return XNODE* - the list of nets nodes */ XNODE* makeGenericListOfNets(); @@ -229,6 +232,7 @@ class NETLIST_EXPORT_TOOL * Function makeGenericLibraries * fills out an XML node with a list of used libraries and returns it. * Must have called makeGenericLibParts() before this function. + * @return XNODE* - the library nodes */ XNODE* makeGenericLibraries(); @@ -654,13 +658,12 @@ static XNODE* node( const wxString& aName, const wxString& aTextualContent = wxE XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() { SCH_SCREEN* screen; - XNODE* xdesign = node( wxT("design") ); - XNODE* xsheetInfo; - XNODE* xcommentNode; - XNODE* xpagesNode; - XNODE* xpageNode; - wxString sheetNumTxt; - wxString sheetNumTxtFormat = wxT( "%d" ); + 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 xdesign->AddChild( node( wxT( "source" ), g_RootSheet->GetScreen()->GetFileName() ) ); @@ -674,39 +677,51 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() Export the sheets information */ SCH_SHEET_LIST sheetList; - xdesign->AddChild( xpagesNode = node( wxT( "sheets" ) ) ); for( SCH_SHEET_PATH* sheet = sheetList.GetFirst(); sheet; sheet = sheetList.GetNext() ) { - xpagesNode->AddChild( xpageNode = node( wxT( "sheet" ) ) ); + 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 - sheetNumTxt.Printf( sheetNumTxtFormat, ( sheetList.GetIndex() + 1 ) ); + sheetTxt.Printf( wxT( "%d" ), ( sheetList.GetIndex() + 1 ) ); + xsheet->AddAttribute( wxT( "number" ), sheetTxt ); + xsheet->AddAttribute( wxT( "name" ), sheet->PathHumanReadable() ); + xsheet->AddAttribute( wxT( "tstamps" ), sheet->Path() ); - xpageNode->AddChild( node( wxT( "number" ), sheetNumTxt ) ); - xpageNode->AddChild( node( wxT( "name" ), sheet->PathHumanReadable() ) ); - xpageNode->AddChild( node( wxT( "tstamps" ), sheet->Path() ) ); - - screen = sheet->LastScreen(); + TITLE_BLOCK tb = screen->GetTitleBlock(); - xpageNode->AddChild( xsheetInfo = node( wxT( "page" ) ) ); + xsheet->AddChild( xtitleBlock = node( wxT( "title_block" ) ) ); - xsheetInfo->AddChild( node( wxT( "title" ), tb.GetTitle() ) ); - xsheetInfo->AddChild( node( wxT( "company" ), tb.GetCompany() ) ); - xsheetInfo->AddChild( node( wxT( "revision" ), tb.GetRevision() ) ); - xsheetInfo->AddChild( node( wxT( "issueDate" ), tb.GetDate() ) ); - xsheetInfo->AddChild( node( wxT( "source" ), screen->GetFileName() ) ); + 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() ) ); - xsheetInfo->AddChild( xcommentNode = node( wxT( "comments" ) ) ); - xcommentNode->AddChild( node( wxT( "comment" ), tb.GetComment1() ) ); - xcommentNode->AddChild( node( wxT( "comment" ), tb.GetComment2() ) ); - xcommentNode->AddChild( node( wxT( "comment" ), tb.GetComment3() ) ); - xcommentNode->AddChild( node( wxT( "comment" ), tb.GetComment4() ) ); + // 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; } diff --git a/eeschema/plugins/bom_with_title_block_2_csv.xsl b/eeschema/plugins/bom_with_title_block_2_csv.xsl index 5e192af3de..5dd2ba0efc 100644 --- a/eeschema/plugins/bom_with_title_block_2_csv.xsl +++ b/eeschema/plugins/bom_with_title_block_2_csv.xsl @@ -22,7 +22,7 @@ Title, the project's tile Company, the project's company - Revision, the project's revision + Rev, the project's revision Date Source, project's issue date Comment, This is comment 1 Comment, This is comment 2 @@ -52,7 +52,7 @@ <xsl:text>&nl;</xsl:text> <!-- Ouput Root sheet project information --> - <xsl:apply-templates select="/export/design/sheets/sheet[1]"/> + <xsl:apply-templates select="/export/design/sheet[1]"/> <xsl:text>&nl;</xsl:text> @@ -70,11 +70,11 @@ </xsl:template> <!-- generate the Root sheet project information --> - <xsl:template match="/export/design/sheets/sheet[1]"> + <xsl:template match="/export/design/sheet[1]"> <xsl:choose> - <xsl:when test="page/title !=''"> - <xsl:text>Title,</xsl:text><xsl:value-of select="page/title"/><xsl:text>&nl;</xsl:text> + <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> @@ -83,8 +83,8 @@ <xsl:choose> - <xsl:when test="page/company !=''"> - <xsl:text>Company,</xsl:text><xsl:value-of select="page/company"/><xsl:text>&nl;</xsl:text> + <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> @@ -92,8 +92,8 @@ </xsl:choose> <xsl:choose> - <xsl:when test="page/revision !=''"> - <xsl:text>Revision,</xsl:text><xsl:value-of select="page/revision"/><xsl:text>&nl;</xsl:text> + <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> @@ -101,21 +101,22 @@ </xsl:choose> <xsl:choose> - <xsl:when test="page/issueDate !=''"> - <xsl:text>Date Issue,</xsl:text><xsl:value-of select="page/issueDate"/><xsl:text>&nl;</xsl:text> + <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="page/comments/comment"/><xsl:text>&nl;</xsl:text> + <xsl:apply-templates select="title_block/comment"/> + </xsl:template> - <xsl:template match="page/comments/comment"> + <xsl:template match="title_block/comment"> <xsl:choose> - <xsl:when test=". !=''"> - <xsl:text>Comment,</xsl:text><xsl:value-of select="."/><xsl:text>&nl;</xsl:text> + <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>