Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
c0d39da5
Commit
c0d39da5
authored
Jan 28, 2012
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New netlist format: Cvpcb: code cleaning. Pcbew: minor enhancements
parent
72ab5174
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
161 additions
and
147 deletions
+161
-147
class_cvpcb.cpp
cvpcb/class_cvpcb.cpp
+0
-41
cvpcb.h
cvpcb/cvpcb.h
+12
-26
readschematicnetlist.cpp
cvpcb/readschematicnetlist.cpp
+2
-18
writenetlistpcbnew.cpp
cvpcb/writenetlistpcbnew.cpp
+0
-43
netlist.cpp
pcbnew/netlist.cpp
+7
-0
netlist_reader.h
pcbnew/netlist_reader.h
+37
-0
netlist_reader_firstformat.cpp
pcbnew/netlist_reader_firstformat.cpp
+90
-16
netlist_reader_kicad.cpp
pcbnew/netlist_reader_kicad.cpp
+13
-3
No files found.
cvpcb/class_cvpcb.cpp
View file @
c0d39da5
...
...
@@ -9,53 +9,12 @@
#include <footprint_info.h>
PIN
::
PIN
()
{
m_Index
=
0
;
/* Variable used by types of netlists. */
m_Type
=
0
;
/* Electrical type. */
}
bool
operator
<
(
const
PIN
&
item1
,
const
PIN
&
item2
)
{
return
StrNumCmp
(
item1
.
m_Number
,
item2
.
m_Number
,
4
,
true
)
<
0
;
}
bool
operator
==
(
const
PIN
&
item1
,
const
PIN
&
item2
)
{
return
(
item1
.
m_Number
==
item2
.
m_Number
);
}
bool
same_pin_number
(
const
PIN
*
item1
,
const
PIN
*
item2
)
{
wxASSERT
(
item1
!=
NULL
&&
item2
!=
NULL
);
return
(
item1
->
m_Number
==
item2
->
m_Number
);
}
bool
same_pin_net
(
const
PIN
*
item1
,
const
PIN
*
item2
)
{
wxASSERT
(
item1
!=
NULL
&&
item2
!=
NULL
);
return
(
item1
->
m_Net
==
item2
->
m_Net
);
}
COMPONENT
::
COMPONENT
()
{
m_Num
=
0
;
m_Multi
=
0
;
}
COMPONENT
::~
COMPONENT
()
{
}
bool
operator
<
(
const
COMPONENT
&
item1
,
const
COMPONENT
&
item2
)
{
return
StrNumCmp
(
item1
.
m_Reference
,
item2
.
m_Reference
,
INT_MAX
,
true
)
<
0
;
...
...
cvpcb/cvpcb.h
View file @
c0d39da5
...
...
@@ -22,14 +22,12 @@
class
PIN
{
public
:
int
m_Index
;
/* Type of net list. */
int
m_Type
;
/* Electrical connection type. */
wxString
m_Net
;
/* Name of net. */
wxString
m_Number
;
wxString
m_Name
;
wxString
m_Repere
;
/* Formats used by net lister. */
PIN
();
PIN
()
{};
~
PIN
()
{};
};
typedef
boost
::
ptr_vector
<
PIN
>
PIN_LIST
;
...
...
@@ -37,29 +35,19 @@ typedef boost::ptr_vector< PIN > PIN_LIST;
/* PIN object list sort function. */
extern
bool
operator
<
(
const
PIN
&
item1
,
const
PIN
&
item2
);
/* PIN uniqueness test function. */
extern
bool
operator
==
(
const
PIN
&
item1
,
const
PIN
&
item2
);
extern
bool
same_pin_number
(
const
PIN
*
item1
,
const
PIN
*
item2
);
extern
bool
same_pin_net
(
const
PIN
*
item1
,
const
PIN
*
item2
);
class
COMPONENT
{
public
:
int
m_Num
;
/* Component number. */
int
m_Multi
;
/* Part if component has multiple parts. */
PIN_LIST
m_Pins
;
/* List of component pins. */
wxString
m_Reference
;
/* Reference designator: U3, R5 ... */
wxString
m_Value
;
/* Value: 7400, 47K ... */
wxString
m_TimeStamp
;
/* Time stamp ("00000000" if absent) */
wxString
m_Module
;
/* Footprint (module) name. */
wxString
m_Repere
;
/* Net list format */
wxArrayString
m_FootprintFilter
;
/* List of allowed footprints (wildcards
* allowed ). If empty: no filtering */
COMPONENT
();
~
COMPONENT
();
wxString
m_Reference
;
// Reference designator: U3, R5
wxString
m_Value
;
// Value: 7400, 47K
wxString
m_TimeStamp
;
// Time stamp ( default value = "00000000")
wxString
m_Module
;
// Footprint (module) name.
wxArrayString
m_FootprintFilter
;
// List of allowed footprints (wildcards
// allowed ). If empty: no filtering
PIN_LIST
m_Pins
;
// List of component pins.
COMPONENT
()
{};
~
COMPONENT
()
{};
};
typedef
boost
::
ptr_vector
<
COMPONENT
>
COMPONENT_LIST
;
...
...
@@ -77,6 +65,4 @@ extern const wxString FootprintAliasFileWildcard;
extern
const
wxString
titleLibLoadError
;
void
Plume
(
int
state
);
#endif
/* __CVPCB_H__ */
cvpcb/readschematicnetlist.cpp
View file @
c0d39da5
...
...
@@ -16,9 +16,6 @@
#include <richio.h>
#define SEPARATEUR '|'
/* Separator character in NetList */
static
int
ReadPinConnection
(
FILE_LINE_READER
&
aNetlistReader
,
COMPONENT
*
CurrentCmp
);
static
int
ReadFootprintFilterList
(
FILE_LINE_READER
&
aNetlistReader
,
COMPONENT_LIST
&
aComponentsList
);
...
...
@@ -83,8 +80,7 @@ static int ReadFootprintFilterList( FILE_LINE_READER& aNetlistReader, COMPONENT_
*/
int
CVPCB_MAINFRAME
::
ReadSchematicNetlist
()
{
char
alim
[
1024
];
int
idx
,
jj
,
k
,
l
;
int
idx
,
jj
,
k
;
char
cbuffer
[
BUFFER_CHAR_SIZE
];
/* temporary storage */
char
*
ptchar
;
COMPONENT
*
Cmp
;
...
...
@@ -203,8 +199,6 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
for
(
jj
=
0
;
idx
<
k
;
idx
++
)
{
if
(
Line
[
idx
]
==
SEPARATEUR
)
break
;
cbuffer
[
jj
++
]
=
Line
[
idx
];
}
cbuffer
[
jj
]
=
0
;
...
...
@@ -212,15 +206,6 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
if
(
m_isEESchemaNetlist
&&
strnicmp
(
cbuffer
,
"$noname"
,
7
)
!=
0
)
Cmp
->
m_Module
=
FROM_UTF8
(
cbuffer
);
if
(
(
Line
[
++
idx
]
==
'('
)
&&
(
Line
[
k
-
1
]
==
')'
)
)
{
idx
++
;
l
=
0
;
while
(
k
-
1
>
idx
)
alim
[
l
++
]
=
Line
[
idx
++
];
}
else
idx
=
k
;
/* Search component reference */
while
(
Line
[
idx
]
!=
' '
&&
Line
[
idx
]
)
idx
++
;
...
...
@@ -243,8 +228,7 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
while
(
Line
[
idx
]
==
' '
&&
Line
[
idx
]
)
idx
++
;
/** goto beginning of value */
// goto beginning of value
for
(
jj
=
0
;
;
idx
++
)
{
if
(
(
Line
[
idx
]
==
' '
)
||
(
Line
[
idx
]
==
'\n'
)
||
(
Line
[
idx
]
==
'\r'
)
||
Line
[
idx
]
==
0
)
...
...
cvpcb/writenetlistpcbnew.cpp
View file @
c0d39da5
...
...
@@ -15,48 +15,6 @@
static
void
WriteFootprintFilterInfos
(
FILE
*
dest
,
COMPONENT_LIST
&
list
);
static
void
RemoveDuplicatePins
(
COMPONENT
&
component
)
{
PIN_LIST
::
iterator
i
;
PIN
*
pin1
,
*
pin2
;
wxString
msg
;
if
(
component
.
m_Pins
.
size
()
<=
1
)
return
;
i
=
component
.
m_Pins
.
begin
();
pin1
=
&
(
*
i
);
++
i
;
while
(
i
!=
component
.
m_Pins
.
end
()
)
{
pin2
=
&
(
*
i
);
wxASSERT
(
pin2
!=
NULL
);
if
(
!
same_pin_number
(
pin1
,
pin2
)
)
{
pin1
=
pin2
;
++
i
;
continue
;
}
if
(
!
same_pin_net
(
pin1
,
pin2
)
)
{
msg
.
Printf
(
_
(
"Component %s %s pin %s : Different Nets"
),
GetChars
(
component
.
m_Reference
),
GetChars
(
component
.
m_Value
),
pin1
->
m_Number
.
GetData
()
);
DisplayError
(
NULL
,
msg
,
60
);
}
pin1
=
pin2
;
i
=
component
.
m_Pins
.
erase
(
i
);
delete
pin2
;
}
}
/**
* Create KiCad net list file.
*
...
...
@@ -88,7 +46,6 @@ int CVPCB_MAINFRAME::GenNetlistPcbnew( FILE* file,bool isEESchemaNetlist )
fprintf
(
file
,
"%s
\n
"
,
TO_UTF8
(
component
.
m_Value
)
);
component
.
m_Pins
.
sort
();
RemoveDuplicatePins
(
component
);
BOOST_FOREACH
(
PIN
&
pin
,
component
.
m_Pins
)
{
...
...
pcbnew/netlist.cpp
View file @
c0d39da5
...
...
@@ -166,6 +166,7 @@ bool PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFullFilename,
netList_Reader
.
m_UseTimeStamp
=
aSelect_By_Timestamp
;
netList_Reader
.
m_ChangeFootprints
=
aChangeFootprint
;
netList_Reader
.
m_UseCmpFile
=
useCmpfile
;
netList_Reader
.
ReadFootprintFilterSetOpt
(
true
);
netList_Reader
.
SetFilesnames
(
aNetlistFullFilename
,
aCmpFullFileName
);
bool
success
=
netList_Reader
.
ReadNetList
(
netfile
);
...
...
@@ -277,6 +278,9 @@ bool NETLIST_READER::InitializeModules()
readModuleComponentLinkfile
();
}
if
(
m_pcbframe
==
NULL
)
return
true
;
for
(
unsigned
ii
=
0
;
ii
<
m_modulesInNetlist
.
size
();
ii
++
)
{
MODULE_INFO
*
currmod_info
=
m_modulesInNetlist
[
ii
];
...
...
@@ -326,6 +330,9 @@ bool NETLIST_READER::InitializeModules()
void
NETLIST_READER
::
TestFootprintsMatchingAndExchange
()
{
if
(
m_pcbframe
==
NULL
)
return
;
for
(
MODULE
*
module
=
m_pcbframe
->
GetBoard
()
->
m_Modules
;
module
;
module
=
module
->
Next
()
)
{
// Search for the corresponding module info
...
...
pcbnew/netlist_reader.h
View file @
c0d39da5
...
...
@@ -53,6 +53,7 @@ public:
wxString
m_Reference
;
wxString
m_Value
;
wxString
m_TimeStamp
;
wxArrayString
m_FootprintFilter
;
public
:
MODULE_INFO
(
const
wxString
&
libname
,
const
wxString
&
cmpname
,
...
...
@@ -95,6 +96,7 @@ private:
// (must be loaded from libraries)
bool
m_buildModuleListOnly
;
// if true read netlist, populates m_modulesInNetlist
// but do not read and change nets and modules on board
bool
m_readFootprintFilter
;
// if true read footprint filter section
enum
typenetlist
m_typeNetlist
;
// type opt the netlist currently read
public
:
...
...
@@ -113,6 +115,7 @@ public: NETLIST_READER( PCB_EDIT_FRAME* aFrame, wxTextCtrl* aMessageWindow = NUL
m_ChangeFootprints
=
false
;
m_UseCmpFile
=
true
;
m_buildModuleListOnly
=
false
;
m_readFootprintFilter
=
false
;
m_typeNetlist
=
NETLIST_TYPE_UNSPECIFIED
;
}
...
...
@@ -141,6 +144,19 @@ public: NETLIST_READER( PCB_EDIT_FRAME* aFrame, wxTextCtrl* aMessageWindow = NUL
m_modulesInNetlist
.
push_back
(
aModInfo
);
}
/**
* Function ReadFootprintFilterSetOpt
* Set to true or false the read footprint filter option
* When this option is false, the footprint filter section is ignored
* When this option is true, the footprint filter section is read,
* an filter strings are stored in module info
* @param aOpt = the value of option
*/
void
ReadFootprintFilterSetOpt
(
bool
aOpt
)
{
m_readFootprintFilter
=
aOpt
;
}
/**
* Function BuildModuleListOnlySetOpt
* Set to true or false the Build Module List Only option
...
...
@@ -218,6 +234,27 @@ public: NETLIST_READER( PCB_EDIT_FRAME* aFrame, wxTextCtrl* aMessageWindow = NUL
*/
bool
ReadOldFmtdNetList
(
FILE
*
aFile
);
/**
* Function ReadOldFmtFootprintFilterList
* Read the section "Allowed footprints" like:
* { Allowed footprints by component:
* $component R11
* R?
* SM0603
* SM0805
* R?-*
* SM1206
* $endlist
* $endfootprintlist
* }
*
* And add the strings giving the footprint filter to m_FootprintFilter
* of the corresponding module info
* <p>This section is used by CvPcb, and is not useful in Pcbnew,
* therefore it it not always read </p>
*/
bool
ReadOldFmtFootprintFilterList
(
FILE_LINE_READER
&
aNetlistReader
);
/**
* Function ReadKicadNetList
* The main function to read a netlist (new netlist format, using S expressions),
...
...
pcbnew/netlist_reader_firstformat.cpp
View file @
c0d39da5
/**
* @file pcbnew/netlist_reader_firstformat.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
...
...
@@ -43,6 +44,7 @@
#include <pcbnew.h>
#include <netlist_reader.h>
#include <boost/foreach.hpp>
// constants used by ReadOldFmtNetlistModuleDescr():
#define BUILDLIST true
...
...
@@ -77,6 +79,7 @@ bool NETLIST_READER::ReadOldFmtdNetList( FILE* aFile )
/* First, read the netlist: Build the list of footprints found in netlist
*/
// netlineReader dtor will close aFile
FILE_LINE_READER
netlineReader
(
aFile
,
m_netlistFullName
);
...
...
@@ -92,10 +95,15 @@ bool NETLIST_READER::ReadOldFmtdNetList( FILE* aFile )
is_comment
=
false
;
}
if
(
*
line
==
'{'
)
// Start Comment
if
(
*
line
==
'{'
)
// Start Comment
or Pcbnew info section
{
is_comment
=
true
;
if
(
m_readFootprintFilter
&&
state
==
0
&&
(
strnicmp
(
line
,
"{ Allowed footprints"
,
20
)
==
0
)
)
{
ReadOldFmtFootprintFilterList
(
netlineReader
);
continue
;
}
if
(
(
line
=
strchr
(
line
,
'}'
)
)
==
NULL
)
continue
;
}
...
...
@@ -124,8 +132,8 @@ bool NETLIST_READER::ReadOldFmtdNetList( FILE* aFile )
// Load new footprints
bool
success
=
InitializeModules
();
if
(
!
success
)
wxMessageBox
(
_
(
"Some footprints are not found in libraries"
)
);
if
(
!
success
)
wxMessageBox
(
_
(
"Some footprints are not found in libraries"
)
);
TestFootprintsMatchingAndExchange
();
...
...
@@ -184,7 +192,7 @@ bool NETLIST_READER::ReadOldFmtdNetList( FILE* aFile )
/* Function ReadOldFmtNetlistModuleDescr
* Read the beginning of a footprint description, from the netlist
* and add a module info to m_modulesInNetlist
* Analyze
lines
like:
* Analyze
the first line of a component description in netlist
like:
* ( /40C08647 $noname R20 4.7K {Lib=R}
* (1 VCC)
* (2 MODB_1)
...
...
@@ -242,7 +250,7 @@ MODULE* NETLIST_READER::ReadOldFmtNetlistModuleDescr( char* aText, bool aBuildLi
}
// search the module loaded on board
// reference and time stamps are already updated so we can use
d search by reference
// reference and time stamps are already updated so we can use
search by reference only
MODULE
*
module
=
m_pcbframe
->
GetBoard
()
->
FindModuleByReference
(
cmpReference
);
if
(
module
==
NULL
)
{
...
...
@@ -313,3 +321,69 @@ bool NETLIST_READER::SetPadNetName( char* aText )
return
found
;
}
/*
* Read the section "Allowed footprints" like:
* { Allowed footprints by component:
* $component R11
* R?
* SM0603
* SM0805
* R?-*
* SM1206
* $endlist
* $endfootprintlist
* }
*
* And add the strings giving the footprint filter to m_FootprintFilter
* of the corresponding module info
* This section is used by CvPcb, and is not useful in Pcbnew,
* therefore it it not always read
*/
bool
NETLIST_READER
::
ReadOldFmtFootprintFilterList
(
FILE_LINE_READER
&
aNetlistReader
)
{
wxString
cmpRef
;
MODULE_INFO
*
mod_info
=
NULL
;
while
(
aNetlistReader
.
ReadLine
()
)
{
const
char
*
Line
=
aNetlistReader
.
Line
();
if
(
strnicmp
(
Line
,
"$endlist"
,
8
)
==
0
)
// end of list for the current component
{
mod_info
=
NULL
;
continue
;
}
if
(
strnicmp
(
Line
,
"$endfootprintlist"
,
4
)
==
0
)
// End of this section
return
0
;
if
(
strnicmp
(
Line
,
"$component"
,
10
)
==
0
)
// New component reference found
{
cmpRef
=
FROM_UTF8
(
Line
+
11
);
cmpRef
.
Trim
(
true
);
cmpRef
.
Trim
(
false
);
// Search the current component in module info list:
BOOST_FOREACH
(
MODULE_INFO
*
&
component
,
m_modulesInNetlist
)
{
if
(
component
->
m_Reference
==
cmpRef
)
{
mod_info
=
component
;
break
;
}
}
}
else
if
(
mod_info
)
{
// Add new filter to list
wxString
fp
=
FROM_UTF8
(
Line
+
1
);
fp
.
Trim
(
false
);
fp
.
Trim
(
true
);
mod_info
->
m_FootprintFilter
.
Add
(
fp
);
}
}
return
true
;
}
pcbnew/netlist_reader_kicad.cpp
View file @
c0d39da5
...
...
@@ -81,16 +81,26 @@ public:
bool
NETLIST_READER
::
ReadKicadNetList
(
FILE
*
aFile
)
{
bool
success
=
true
;
BOARD
*
brd
=
m_pcbframe
->
GetBoard
();
// netlineReader dtor will close aFile
FILE_LINE_READER
netlineReader
(
aFile
,
m_netlistFullName
);
NETLIST_READER_KICAD_PARSER
netlist_parser
(
&
netlineReader
,
this
);
try
{
netlist_parser
.
Parse
(
brd
);
}
catch
(
IO_ERROR
&
ioe
)
{
ioe
.
errorText
+=
'\n'
;
ioe
.
errorText
+=
_
(
"Netlist error."
);
wxMessageBox
(
ioe
.
errorText
);
return
false
;
}
return
success
;
return
true
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment