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
00bda3c9
Commit
00bda3c9
authored
Sep 21, 2007
by
dickelbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beautification
parent
63cf8c53
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1042 additions
and
918 deletions
+1042
-918
eelibs_read_libraryfiles.cpp
eeschema/eelibs_read_libraryfiles.cpp
+46
-16
load_one_schematic_file.cpp
eeschema/load_one_schematic_file.cpp
+1
-1
netform.cpp
eeschema/netform.cpp
+989
-897
netlist.cpp
eeschema/netlist.cpp
+5
-3
controle.cpp
pcbnew/controle.cpp
+1
-1
No files found.
eeschema/eelibs_read_libraryfiles.cpp
View file @
00bda3c9
...
@@ -136,12 +136,16 @@ void LoadLibraries( WinEDA_DrawFrame* frame )
...
@@ -136,12 +136,16 @@ void LoadLibraries( WinEDA_DrawFrame* frame )
if
(
LibName
.
IsEmpty
()
)
if
(
LibName
.
IsEmpty
()
)
continue
;
continue
;
FullLibName
=
MakeFileName
(
g_RealLibDirBuffer
,
LibName
,
g_LibExtBuffer
);
FullLibName
=
MakeFileName
(
g_RealLibDirBuffer
,
LibName
,
g_LibExtBuffer
);
msg
=
wxT
(
"Loading "
)
+
FullLibName
;
msg
=
wxT
(
"Loading "
)
+
FullLibName
;
if
(
LoadLibraryName
(
frame
,
FullLibName
,
LibName
)
)
if
(
LoadLibraryName
(
frame
,
FullLibName
,
LibName
)
)
msg
+=
wxT
(
" OK"
);
msg
+=
wxT
(
" OK"
);
else
else
msg
+=
wxT
(
" ->Error"
);
msg
+=
wxT
(
" ->Error"
);
frame
->
PrintMsg
(
msg
);
frame
->
PrintMsg
(
msg
);
}
}
...
@@ -159,7 +163,7 @@ void LoadLibraries( WinEDA_DrawFrame* frame )
...
@@ -159,7 +163,7 @@ void LoadLibraries( WinEDA_DrawFrame* frame )
LibraryStruct
**
libs
=
LibraryStruct
**
libs
=
(
LibraryStruct
**
)
MyZMalloc
(
sizeof
(
LibraryStruct
*
)
*
(
NumOfLibs
+
2
)
);
(
LibraryStruct
**
)
MyZMalloc
(
sizeof
(
LibraryStruct
*
)
*
(
NumOfLibs
+
2
)
);
int
jj
=
0
;
int
jj
=
0
;
for
(
ii
=
0
;
ii
<
g_LibName_List
.
GetCount
();
ii
++
)
for
(
ii
=
0
;
ii
<
g_LibName_List
.
GetCount
();
ii
++
)
{
{
if
(
jj
>=
NumOfLibs
)
if
(
jj
>=
NumOfLibs
)
...
@@ -348,7 +352,10 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
...
@@ -348,7 +352,10 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
*/
*/
{
{
int
unused
;
int
unused
;
char
*
p
,
*
Name
,
*
Prefix
=
NULL
;
char
*
p
;
char
*
name
;
char
*
prefix
=
NULL
;
EDA_LibComponentStruct
*
LibEntry
=
NULL
;
EDA_LibComponentStruct
*
LibEntry
=
NULL
;
bool
Res
;
bool
Res
;
wxString
Msg
;
wxString
Msg
;
...
@@ -366,8 +373,8 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
...
@@ -366,8 +373,8 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
char
drawnum
=
0
,
drawname
=
0
;
char
drawnum
=
0
,
drawname
=
0
;
LibEntry
=
new
EDA_LibComponentStruct
(
NULL
);
LibEntry
=
new
EDA_LibComponentStruct
(
NULL
);
if
(
(
N
ame
=
strtok
(
NULL
,
"
\t\n
"
)
)
==
NULL
/* Part name: */
if
(
(
n
ame
=
strtok
(
NULL
,
"
\t\n
"
)
)
==
NULL
/* Part name: */
||
(
P
refix
=
strtok
(
NULL
,
"
\t\n
"
)
)
==
NULL
/* Prefix name: */
||
(
p
refix
=
strtok
(
NULL
,
"
\t\n
"
)
)
==
NULL
/* Prefix name: */
||
(
p
=
strtok
(
NULL
,
"
\t\n
"
)
)
==
NULL
/* NumOfPins: */
||
(
p
=
strtok
(
NULL
,
"
\t\n
"
)
)
==
NULL
/* NumOfPins: */
||
sscanf
(
p
,
"%d"
,
&
unused
)
!=
1
||
sscanf
(
p
,
"%d"
,
&
unused
)
!=
1
||
(
p
=
strtok
(
NULL
,
"
\t\n
"
)
)
==
NULL
/* TextInside: */
||
(
p
=
strtok
(
NULL
,
"
\t\n
"
)
)
==
NULL
/* TextInside: */
...
@@ -394,23 +401,24 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
...
@@ -394,23 +401,24 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
{
{
LibEntry
->
m_DrawPinNum
=
(
drawnum
==
'N'
)
?
FALSE
:
TRUE
;
LibEntry
->
m_DrawPinNum
=
(
drawnum
==
'N'
)
?
FALSE
:
TRUE
;
LibEntry
->
m_DrawPinName
=
(
drawname
==
'N'
)
?
FALSE
:
TRUE
;
LibEntry
->
m_DrawPinName
=
(
drawname
==
'N'
)
?
FALSE
:
TRUE
;
/* Copy part name and prefix. */
/* Copy part name and prefix. */
strupper
(
N
ame
);
strupper
(
n
ame
);
if
(
N
ame
[
0
]
!=
'~'
)
if
(
n
ame
[
0
]
!=
'~'
)
LibEntry
->
m_Name
.
m_Text
=
CONV_FROM_UTF8
(
N
ame
);
LibEntry
->
m_Name
.
m_Text
=
CONV_FROM_UTF8
(
n
ame
);
else
else
{
{
LibEntry
->
m_Name
.
m_Text
=
CONV_FROM_UTF8
(
&
N
ame
[
1
]
);
LibEntry
->
m_Name
.
m_Text
=
CONV_FROM_UTF8
(
&
n
ame
[
1
]
);
LibEntry
->
m_Name
.
m_Attributs
|=
TEXT_NO_VISIBLE
;
LibEntry
->
m_Name
.
m_Attributs
|=
TEXT_NO_VISIBLE
;
}
}
if
(
strcmp
(
P
refix
,
"~"
)
==
0
)
if
(
strcmp
(
p
refix
,
"~"
)
==
0
)
{
{
LibEntry
->
m_Prefix
.
m_Text
.
Empty
();
LibEntry
->
m_Prefix
.
m_Text
.
Empty
();
LibEntry
->
m_Prefix
.
m_Attributs
|=
TEXT_NO_VISIBLE
;
LibEntry
->
m_Prefix
.
m_Attributs
|=
TEXT_NO_VISIBLE
;
}
}
else
else
LibEntry
->
m_Prefix
.
m_Text
=
CONV_FROM_UTF8
(
P
refix
);
LibEntry
->
m_Prefix
.
m_Text
=
CONV_FROM_UTF8
(
p
refix
);
// Copy optional infos
// Copy optional infos
if
(
(
p
=
strtok
(
NULL
,
"
\t\n
"
)
)
!=
NULL
)
// m_UnitSelectionLocked param
if
(
(
p
=
strtok
(
NULL
,
"
\t\n
"
)
)
!=
NULL
)
// m_UnitSelectionLocked param
...
@@ -525,7 +533,10 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
...
@@ -525,7 +533,10 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
&
Arc
->
m_Width
,
chartmp
,
&
startx
,
&
starty
,
&
endx
,
&
endy
);
&
Arc
->
m_Width
,
chartmp
,
&
startx
,
&
starty
,
&
endx
,
&
endy
);
if
(
nbarg
<
8
)
if
(
nbarg
<
8
)
Error
=
TRUE
;
Error
=
TRUE
;
Arc
->
m_Unit
=
Unit
;
Arc
->
m_Convert
=
Convert
;
Arc
->
m_Unit
=
Unit
;
Arc
->
m_Convert
=
Convert
;
if
(
chartmp
[
0
]
==
'F'
)
if
(
chartmp
[
0
]
==
'F'
)
Arc
->
m_Fill
=
FILLED_SHAPE
;
Arc
->
m_Fill
=
FILLED_SHAPE
;
if
(
chartmp
[
0
]
==
'f'
)
if
(
chartmp
[
0
]
==
'f'
)
...
@@ -625,8 +636,11 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
...
@@ -625,8 +636,11 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
Pin
->
m_PinLen
=
ll
;
Pin
->
m_PinLen
=
ll
;
Pin
->
m_Orient
=
chartmp1
[
0
]
&
255
;
Pin
->
m_Orient
=
chartmp1
[
0
]
&
255
;
Pin
->
m_Unit
=
Unit
;
Pin
->
m_Convert
=
Convert
;
Pin
->
m_Unit
=
Unit
;
Pin
->
m_Convert
=
Convert
;
strncpy
(
(
char
*
)
&
Pin
->
m_PinNum
,
PinNum
,
4
);
strncpy
(
(
char
*
)
&
Pin
->
m_PinNum
,
PinNum
,
4
);
Error
=
(
i
!=
11
&&
i
!=
12
);
Error
=
(
i
!=
11
&&
i
!=
12
);
Pin
->
m_PinName
=
CONV_FROM_UTF8
(
BufName
);
Pin
->
m_PinName
=
CONV_FROM_UTF8
(
BufName
);
...
@@ -672,6 +686,7 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
...
@@ -672,6 +686,7 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
}
}
if
(
i
==
12
)
/* Special Symbole defined */
if
(
i
==
12
)
/* Special Symbole defined */
{
for
(
jj
=
strlen
(
Buffer
);
jj
>
0
;
)
for
(
jj
=
strlen
(
Buffer
);
jj
>
0
;
)
{
{
switch
(
Buffer
[
--
jj
]
)
switch
(
Buffer
[
--
jj
]
)
...
@@ -700,6 +715,7 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
...
@@ -700,6 +715,7 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
DisplayError
(
frame
,
MsgLine
);
break
;
DisplayError
(
frame
,
MsgLine
);
break
;
}
}
}
}
}
}
}
break
;
break
;
...
@@ -852,7 +868,8 @@ static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line )
...
@@ -852,7 +868,8 @@ static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line )
if
(
*
line
==
0
)
if
(
*
line
==
0
)
return
0
;
return
0
;
line
++
;
Text
=
line
;
line
++
;
Text
=
line
;
/* recherche fin de texte */
/* recherche fin de texte */
while
(
*
line
&&
(
*
line
!=
'"'
)
)
while
(
*
line
&&
(
*
line
!=
'"'
)
)
...
@@ -860,17 +877,23 @@ static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line )
...
@@ -860,17 +877,23 @@ static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line )
if
(
*
line
==
0
)
if
(
*
line
==
0
)
return
0
;
return
0
;
*
line
=
0
;
line
++
;
*
line
=
0
;
line
++
;
FieldUserName
[
0
]
=
0
;
FieldUserName
[
0
]
=
0
;
nbparam
=
sscanf
(
line
,
" %d %d %d %c %c %c %c"
,
nbparam
=
sscanf
(
line
,
" %d %d %d %c %c %c %c"
,
&
posx
,
&
posy
,
&
size
,
Char1
,
Char2
,
Char3
,
Char4
);
&
posx
,
&
posy
,
&
size
,
Char1
,
Char2
,
Char3
,
Char4
);
orient
=
TEXT_ORIENT_HORIZ
;
if
(
Char1
[
0
]
==
'V'
)
orient
=
TEXT_ORIENT_HORIZ
;
if
(
Char1
[
0
]
==
'V'
)
orient
=
TEXT_ORIENT_VERT
;
orient
=
TEXT_ORIENT_VERT
;
draw
=
TRUE
;
if
(
Char2
[
0
]
==
'I'
)
draw
=
TRUE
;
if
(
Char2
[
0
]
==
'I'
)
draw
=
FALSE
;
draw
=
FALSE
;
hjustify
=
GR_TEXT_HJUSTIFY_CENTER
;
hjustify
=
GR_TEXT_HJUSTIFY_CENTER
;
vjustify
=
GR_TEXT_VJUSTIFY_CENTER
;
vjustify
=
GR_TEXT_VJUSTIFY_CENTER
;
if
(
nbparam
>=
6
)
if
(
nbparam
>=
6
)
{
{
if
(
*
Char3
==
'L'
)
if
(
*
Char3
==
'L'
)
...
@@ -898,6 +921,7 @@ static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line )
...
@@ -898,6 +921,7 @@ static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line )
default
:
default
:
if
(
NumOfField
>=
NUMBER_OF_FIELDS
)
if
(
NumOfField
>=
NUMBER_OF_FIELDS
)
break
;
break
;
Field
=
new
LibDrawField
(
NumOfField
);
Field
=
new
LibDrawField
(
NumOfField
);
Field
->
Pnext
=
LibEntry
->
Fields
;
Field
->
Pnext
=
LibEntry
->
Fields
;
...
@@ -910,15 +934,19 @@ static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line )
...
@@ -910,15 +934,19 @@ static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line )
Field
->
m_Pos
.
x
=
posx
;
Field
->
m_Pos
.
y
=
posy
;
Field
->
m_Pos
.
x
=
posx
;
Field
->
m_Pos
.
y
=
posy
;
Field
->
m_Orient
=
orient
;
Field
->
m_Orient
=
orient
;
if
(
draw
==
FALSE
)
if
(
draw
==
FALSE
)
Field
->
m_Attributs
|=
TEXT_NO_VISIBLE
;
Field
->
m_Attributs
|=
TEXT_NO_VISIBLE
;
Field
->
m_Size
.
x
=
Field
->
m_Size
.
y
=
size
;
Field
->
m_Size
.
x
=
Field
->
m_Size
.
y
=
size
;
Field
->
m_Text
=
CONV_FROM_UTF8
(
Text
);
Field
->
m_Text
=
CONV_FROM_UTF8
(
Text
);
if
(
NumOfField
>=
FIELD1
)
if
(
NumOfField
>=
FIELD1
)
{
{
ReadDelimitedText
(
FieldUserName
,
line
,
sizeof
(
FieldUserName
)
);
ReadDelimitedText
(
FieldUserName
,
line
,
sizeof
(
FieldUserName
)
);
Field
->
m_Name
=
CONV_FROM_UTF8
(
FieldUserName
);
Field
->
m_Name
=
CONV_FROM_UTF8
(
FieldUserName
);
}
}
Field
->
m_HJustify
=
hjustify
;
Field
->
m_HJustify
=
hjustify
;
Field
->
m_VJustify
=
vjustify
;
Field
->
m_VJustify
=
vjustify
;
return
TRUE
;
return
TRUE
;
...
@@ -992,7 +1020,8 @@ int LoadDocLib( WinEDA_DrawFrame* frame, const wxString& FullDocLibName, const w
...
@@ -992,7 +1020,8 @@ int LoadDocLib( WinEDA_DrawFrame* frame, const wxString& FullDocLibName, const w
return
0
;
return
0
;
if
(
GetLine
(
f
,
Line
,
&
LineNum
,
sizeof
(
Line
)
)
==
NULL
)
if
(
GetLine
(
f
,
Line
,
&
LineNum
,
sizeof
(
Line
)
)
==
NULL
)
{
/* pas de lignes utiles */
{
/* pas de lignes utiles */
fclose
(
f
);
fclose
(
f
);
return
0
;
return
0
;
}
}
...
@@ -1100,6 +1129,7 @@ void EDA_LibComponentStruct::SortDrawItems()
...
@@ -1100,6 +1129,7 @@ void EDA_LibComponentStruct::SortDrawItems()
BufentryBase
=
BufentryBase
=
(
LibEDA_BaseStruct
**
)
MyZMalloc
(
(
nbitems
+
1
)
*
sizeof
(
LibEDA_BaseStruct
*
)
);
(
LibEDA_BaseStruct
**
)
MyZMalloc
(
(
nbitems
+
1
)
*
sizeof
(
LibEDA_BaseStruct
*
)
);
/* memorisation du chainage : */
/* memorisation du chainage : */
for
(
Entry
=
m_Drawings
,
ii
=
0
;
Entry
!=
NULL
;
Entry
=
Entry
->
Next
()
)
for
(
Entry
=
m_Drawings
,
ii
=
0
;
Entry
!=
NULL
;
Entry
=
Entry
->
Next
()
)
BufentryBase
[
ii
++
]
=
Entry
;
BufentryBase
[
ii
++
]
=
Entry
;
...
...
eeschema/load_one_schematic_file.cpp
View file @
00bda3c9
...
@@ -440,7 +440,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
...
@@ -440,7 +440,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
screen
->
EEDrawList
=
Phead
;
screen
->
EEDrawList
=
Phead
;
#if defined(DEBUG)
#if
0 &&
defined(DEBUG)
screen->Show( 0, std::cout );
screen->Show( 0, std::cout );
#endif
#endif
...
...
eeschema/netform.cpp
View file @
00bda3c9
/*******************************************************/
/*******************************************************/
/* Module de generation de la Netliste , selon Formats */
/* Module de generation de la Netliste , selon Formats */
/*******************************************************/
/*******************************************************/
#include "fctsys.h"
#include "fctsys.h"
#include "gr_basic.h"
#include "gr_basic.h"
...
@@ -15,999 +15,1091 @@
...
@@ -15,999 +15,1091 @@
/* Routines locales */
/* Routines locales */
static
void
Write_GENERIC_NetList
(
WinEDA_SchematicFrame
*
frame
,
const
wxString
&
FullFileName
);
static
void
Write_GENERIC_NetList
(
WinEDA_SchematicFrame
*
frame
,
const
wxString
&
FullFileName
);
static
void
WriteNetListPCBNEW
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
,
static
void
WriteNetListPCBNEW
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
,
bool
with_pcbnew
);
bool
with_pcbnew
);
static
void
WriteNetListCADSTAR
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
);
static
void
WriteNetListCADSTAR
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
);
static
void
WriteListOfNetsCADSTAR
(
FILE
*
f
,
ObjetNetListStruct
*
ObjNet
);
static
void
WriteListOfNetsCADSTAR
(
FILE
*
f
,
ObjetNetListStruct
*
ObjNet
);
static
void
WriteNetListPspice
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
,
bool
use_netnames
);
static
void
WriteNetListPspice
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
,
bool
use_netnames
);
static
void
WriteGENERICListOfNets
(
FILE
*
f
,
ObjetNetListStruct
*
ObjNet
);
static
void
WriteGENERICListOfNets
(
FILE
*
f
,
ObjetNetListStruct
*
ObjNet
);
static
void
AddPinToComponentPinList
(
EDA_SchComponentStruct
*
Component
,
static
void
AddPinToComponentPinList
(
EDA_SchComponentStruct
*
Component
,
LibDrawPin
*
PinEntry
);
LibDrawPin
*
PinEntry
);
static
void
FindOthersUnits
(
EDA_SchComponentStruct
*
Component
);
static
void
FindOthersUnits
(
EDA_SchComponentStruct
*
Component
);
static
int
SortPinsByNum
(
ObjetNetListStruct
**
Pin1
,
ObjetNetListStruct
**
Pin2
);
static
int
SortPinsByNum
(
ObjetNetListStruct
**
Pin1
,
ObjetNetListStruct
**
Pin2
);
static
void
EraseDuplicatePins
(
ObjetNetListStruct
**
TabPin
,
int
NbrPin
);
static
void
EraseDuplicatePins
(
ObjetNetListStruct
**
TabPin
,
int
NbrPin
);
static
void
ClearUsedFlags
(
WinEDA_SchematicFrame
*
frame
);
static
void
ClearUsedFlags
(
WinEDA_SchematicFrame
*
frame
);
/* Variable locales */
/* Variable locales */
static
int
s_SortedPinCount
;
static
int
s_SortedPinCount
;
static
ObjetNetListStruct
**
s_SortedComponentPinList
;
static
ObjetNetListStruct
**
s_SortedComponentPinList
;
/******************************************************************************/
/******************************************************************************/
void
WriteNetList
(
WinEDA_SchematicFrame
*
frame
,
const
wxString
&
FileNameNL
,
void
WriteNetList
(
WinEDA_SchematicFrame
*
frame
,
const
wxString
&
FileNameNL
,
bool
use_netnames
)
bool
use_netnames
)
/*******************************************************************************/
/*******************************************************************************/
/* Create the netlist file ( Format is given by g_NetFormat )
/* Create the netlist file ( Format is given by g_NetFormat )
bool use_netnames is used only for Spice netlist
*
bool use_netnames is used only for Spice netlist
*/
*/
{
{
FILE
*
f
=
NULL
;
FILE
*
f
=
NULL
;
if
(
g_NetFormat
<
NET_TYPE_CUSTOM1
)
if
(
g_NetFormat
<
NET_TYPE_CUSTOM1
)
{
{
if
((
f
=
wxFopen
(
FileNameNL
,
wxT
(
"wt"
)))
==
NULL
)
if
(
(
f
=
wxFopen
(
FileNameNL
,
wxT
(
"wt"
)
)
)
==
NULL
)
{
{
wxString
msg
=
_
(
"Failed to create file "
)
+
FileNameNL
;
wxString
msg
=
_
(
"Failed to create file "
)
+
FileNameNL
;
DisplayError
(
frame
,
msg
);
DisplayError
(
frame
,
msg
);
return
;
return
;
}
}
}
}
wxBusyCursor
Busy
;
wxBusyCursor
Busy
;
switch
(
g_NetFormat
)
switch
(
g_NetFormat
)
{
{
case
NET_TYPE_PCBNEW
:
case
NET_TYPE_PCBNEW
:
WriteNetListPCBNEW
(
frame
,
f
,
TRUE
);
WriteNetListPCBNEW
(
frame
,
f
,
TRUE
);
fclose
(
f
);
fclose
(
f
);
break
;
break
;
case
NET_TYPE_ORCADPCB2
:
case
NET_TYPE_ORCADPCB2
:
WriteNetListPCBNEW
(
frame
,
f
,
FALSE
);
WriteNetListPCBNEW
(
frame
,
f
,
FALSE
);
fclose
(
f
);
fclose
(
f
);
break
;
break
;
case
NET_TYPE_CADSTAR
:
case
NET_TYPE_CADSTAR
:
WriteNetListCADSTAR
(
frame
,
f
);
WriteNetListCADSTAR
(
frame
,
f
);
fclose
(
f
);
fclose
(
f
);
break
;
break
;
case
NET_TYPE_SPICE
:
case
NET_TYPE_SPICE
:
WriteNetListPspice
(
frame
,
f
,
use_netnames
);
WriteNetListPspice
(
frame
,
f
,
use_netnames
);
fclose
(
f
);
fclose
(
f
);
break
;
break
;
case
NET_TYPE_CUSTOM1
:
case
NET_TYPE_CUSTOM1
:
case
NET_TYPE_CUSTOM2
:
case
NET_TYPE_CUSTOM2
:
case
NET_TYPE_CUSTOM3
:
case
NET_TYPE_CUSTOM3
:
case
NET_TYPE_CUSTOM4
:
case
NET_TYPE_CUSTOM4
:
case
NET_TYPE_CUSTOM5
:
case
NET_TYPE_CUSTOM5
:
case
NET_TYPE_CUSTOM6
:
case
NET_TYPE_CUSTOM6
:
case
NET_TYPE_CUSTOM7
:
case
NET_TYPE_CUSTOM7
:
case
NET_TYPE_CUSTOM8
:
case
NET_TYPE_CUSTOM8
:
Write_GENERIC_NetList
(
frame
,
FileNameNL
);
Write_GENERIC_NetList
(
frame
,
FileNameNL
);
break
;
break
;
default
:
default
:
DisplayError
(
frame
,
wxT
(
"WriteNetList() err: Unknown Netlist Format"
)
);
DisplayError
(
frame
,
wxT
(
"WriteNetList() err: Unknown Netlist Format"
)
);
break
;
break
;
}
}
}
}
/****************************************************************************/
/****************************************************************************/
static
EDA_SchComponentStruct
*
FindNextComponentAndCreatPinList
(
static
EDA_SchComponentStruct
*
FindNextComponentAndCreatPinList
(
EDA_BaseStruct
*
DrawList
)
EDA_BaseStruct
*
DrawList
)
/****************************************************************************/
/****************************************************************************/
/* Find a "suitable" component from the DrawList
build its pin list s_SortedComponentPinList.
The list is sorted by pin num
A suitable component is a "new" real component (power symbols are not considered)
alloc memory for s_SortedComponentPinList if s_SortedComponentPinList == NULL
/* Find a "suitable" component from the DrawList
Must be deallocated by the user
* build its pin list s_SortedComponentPinList.
*/
* The list is sorted by pin num
* A suitable component is a "new" real component (power symbols are not considered)
*
* alloc memory for s_SortedComponentPinList if s_SortedComponentPinList == NULL
* Must be deallocated by the user
*/
{
{
EDA_SchComponentStruct
*
Component
=
NULL
;
EDA_SchComponentStruct
*
Component
=
NULL
;
EDA_LibComponentStruct
*
Entry
;
EDA_LibComponentStruct
*
Entry
;
LibEDA_BaseStruct
*
DEntry
;
LibEDA_BaseStruct
*
DEntry
;
s_SortedPinCount
=
0
;
s_SortedPinCount
=
0
;
for
(
;
DrawList
!=
NULL
;
DrawList
=
DrawList
->
Next
()
)
for
(
;
DrawList
!=
NULL
;
DrawList
=
DrawList
->
Next
()
)
{
{
if
(
DrawList
->
Type
()
!=
DRAW_LIB_ITEM_STRUCT_TYPE
)
continue
;
if
(
DrawList
->
Type
()
!=
DRAW_LIB_ITEM_STRUCT_TYPE
)
Component
=
(
EDA_SchComponentStruct
*
)
DrawList
;
continue
;
Component
=
(
EDA_SchComponentStruct
*
)
DrawList
;
/* already tested ? : */
if
(
Component
->
m_FlagControlMulti
==
1
)
continue
;
/* yes */
/* already tested ? : */
if
(
Component
->
m_FlagControlMulti
==
1
)
Entry
=
FindLibPart
(
Component
->
m_ChipName
.
GetData
(),
wxEmptyString
,
FIND_ROOT
);
continue
;
/* yes */
if
(
Entry
==
NULL
)
continue
;
Entry
=
FindLibPart
(
Component
->
m_ChipName
.
GetData
(),
wxEmptyString
,
FIND_ROOT
);
/* Power symbol and other component which have the reference starting by
if
(
Entry
==
NULL
)
"#" are not included in netlist (pseudo components) */
continue
;
if
(
Component
->
m_Field
[
REFERENCE
].
m_Text
[
0
]
==
'#'
)
continue
;
/* Power symbol and other component which have the reference starting by
/* Create the pin table for this component */
* "#" are not included in netlist (pseudo components) */
int
ii
=
sizeof
(
ObjetNetListStruct
)
*
MAXPIN
;
if
(
Component
->
m_Field
[
REFERENCE
].
m_Text
[
0
]
==
'#'
)
if
(
s_SortedComponentPinList
==
NULL
)
continue
;
s_SortedComponentPinList
=
(
ObjetNetListStruct
**
)
MyMalloc
(
ii
);
memset
(
s_SortedComponentPinList
,
0
,
ii
);
/* Create the pin table for this component */
int
ii
=
sizeof
(
ObjetNetListStruct
)
*
MAXPIN
;
DEntry
=
Entry
->
m_Drawings
;
if
(
s_SortedComponentPinList
==
NULL
)
for
(
;
DEntry
!=
NULL
;
DEntry
=
DEntry
->
Next
())
s_SortedComponentPinList
=
(
ObjetNetListStruct
**
)
MyMalloc
(
ii
);
{
memset
(
s_SortedComponentPinList
,
0
,
ii
);
if
(
DEntry
->
Type
()
!=
COMPONENT_PIN_DRAW_TYPE
)
continue
;
if
(
DEntry
->
m_Unit
&&
DEntry
=
Entry
->
m_Drawings
;
(
DEntry
->
m_Unit
!=
Component
->
m_Multi
)
)
continue
;
for
(
;
DEntry
!=
NULL
;
DEntry
=
DEntry
->
Next
()
)
if
(
DEntry
->
m_Convert
&&
{
(
DEntry
->
m_Convert
!=
Component
->
m_Convert
))
continue
;
if
(
DEntry
->
Type
()
!=
COMPONENT_PIN_DRAW_TYPE
)
{
continue
;
AddPinToComponentPinList
(
Component
,
(
LibDrawPin
*
)
DEntry
);
if
(
DEntry
->
m_Unit
}
&&
(
DEntry
->
m_Unit
!=
Component
->
m_Multi
)
)
}
continue
;
if
(
DEntry
->
m_Convert
Component
->
m_FlagControlMulti
=
1
;
&&
(
DEntry
->
m_Convert
!=
Component
->
m_Convert
)
)
continue
;
if
(
Entry
->
m_UnitCount
>
1
)
FindOthersUnits
(
Component
);
{
AddPinToComponentPinList
(
Component
,
(
LibDrawPin
*
)
DEntry
);
/* Tri sur le numero de Pin de TabListePin */
}
qsort
(
s_SortedComponentPinList
,
s_SortedPinCount
,
sizeof
(
ObjetNetListStruct
*
),
}
(
int
(
*
)(
const
void
*
,
const
void
*
))
SortPinsByNum
);
Component
->
m_FlagControlMulti
=
1
;
/* Elimination des Pins redondantes du s_SortedComponentPinList */
EraseDuplicatePins
(
s_SortedComponentPinList
,
s_SortedPinCount
);
if
(
Entry
->
m_UnitCount
>
1
)
FindOthersUnits
(
Component
);
return
Component
;
}
/* Tri sur le numero de Pin de TabListePin */
qsort
(
s_SortedComponentPinList
,
s_SortedPinCount
,
sizeof
(
ObjetNetListStruct
*
),
return
NULL
;
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
SortPinsByNum
);
/* Elimination des Pins redondantes du s_SortedComponentPinList */
EraseDuplicatePins
(
s_SortedComponentPinList
,
s_SortedPinCount
);
return
Component
;
}
return
NULL
;
}
}
/**************************************************************************************/
/**************************************************************************************/
static
wxString
ReturnPinNetName
(
ObjetNetListStruct
*
Pin
,
static
wxString
ReturnPinNetName
(
ObjetNetListStruct
*
Pin
,
const
wxString
&
DefaultFormatNetname
)
const
wxString
&
DefaultFormatNetname
)
/**************************************************************************************/
/**************************************************************************************/
/* Return the net name for the pin Pin.
/* Return the net name for the pin Pin.
Net name is:
*
Net name is:
"?" if pin not connected
*
"?" if pin not connected
"netname" for global net (like gnd, vcc ..
*
"netname" for global net (like gnd, vcc ..
"netname_sheetnumber" for the usual nets
*
"netname_sheetnumber" for the usual nets
*/
*/
{
{
int
netcode
=
Pin
->
m_NetCode
;
int
netcode
=
Pin
->
m_NetCode
;
wxString
NetName
;
wxString
NetName
;
if
(
(
netcode
==
0
)
||
(
Pin
->
m_FlagOfConnection
!=
CONNECT
)
)
if
(
(
netcode
==
0
)
||
(
Pin
->
m_FlagOfConnection
!=
CONNECT
)
)
{
{
return
NetName
;
return
NetName
;
}
}
else
else
{
{
int
jj
;
int
jj
;
for
(
jj
=
0
;
jj
<
g_NbrObjNet
;
jj
++
)
for
(
jj
=
0
;
jj
<
g_NbrObjNet
;
jj
++
)
{
{
if
(
g_TabObjNet
[
jj
].
m_NetCode
!=
netcode
)
continue
;
if
(
g_TabObjNet
[
jj
].
m_NetCode
!=
netcode
)
if
(
(
g_TabObjNet
[
jj
].
m_Type
!=
NET_GLOBLABEL
)
&&
continue
;
(
g_TabObjNet
[
jj
].
m_Type
!=
NET_LABEL
)
&&
if
(
(
g_TabObjNet
[
jj
].
m_Type
!=
NET_GLOBLABEL
)
(
g_TabObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
)
continue
;
&&
(
g_TabObjNet
[
jj
].
m_Type
!=
NET_LABEL
)
&&
(
g_TabObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
)
NetName
=
*
g_TabObjNet
[
jj
].
m_Label
;
continue
;
break
;
}
NetName
=
*
g_TabObjNet
[
jj
].
m_Label
;
break
;
if
(
!
NetName
.
IsEmpty
()
)
}
{
if
(
g_TabObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
if
(
!
NetName
.
IsEmpty
()
)
NetName
<<
wxT
(
"_"
)
<<
g_TabObjNet
[
jj
].
m_SheetNumber
;
{
}
if
(
g_TabObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
else
NetName
<<
wxT
(
"_"
)
<<
g_TabObjNet
[
jj
].
m_SheetNumber
;
{
}
NetName
.
Printf
(
DefaultFormatNetname
.
GetData
(),
netcode
);
else
}
{
}
NetName
.
Printf
(
DefaultFormatNetname
.
GetData
(),
netcode
);
return
NetName
;
}
}
return
NetName
;
}
}
/***********************************************************************/
/***********************************************************************/
void
Write_GENERIC_NetList
(
WinEDA_SchematicFrame
*
frame
,
void
Write_GENERIC_NetList
(
WinEDA_SchematicFrame
*
frame
,
const
wxString
&
FullFileName
)
const
wxString
&
FullFileName
)
/***********************************************************************/
/***********************************************************************/
/* Create a generic netlist, and call an external netlister
/* Create a generic netlist, and call an external netlister
to change the netlist syntax and create the file
*
to change the netlist syntax and create the file
*/
*/
{
{
wxString
Line
,
FootprintName
;
wxString
Line
,
FootprintName
;
BASE_SCREEN
*
CurrScreen
;
BASE_SCREEN
*
CurrScreen
;
EDA_BaseStruct
*
DrawList
;
EDA_BaseStruct
*
DrawList
;
EDA_SchComponentStruct
*
Component
;
EDA_SchComponentStruct
*
Component
;
wxString
netname
;
wxString
netname
;
int
ii
;
int
ii
;
FILE
*
tmpfile
;
FILE
*
tmpfile
;
wxString
TmpFullFileName
=
FullFileName
;
wxString
TmpFullFileName
=
FullFileName
;
ChangeFileNameExt
(
TmpFullFileName
,
wxT
(
".tmp"
));
ChangeFileNameExt
(
TmpFullFileName
,
wxT
(
".tmp"
)
);
if
((
tmpfile
=
wxFopen
(
TmpFullFileName
,
wxT
(
"wt"
)))
==
NULL
)
if
(
(
tmpfile
=
wxFopen
(
TmpFullFileName
,
wxT
(
"wt"
)
)
)
==
NULL
)
{
{
wxString
msg
=
_
(
"Failed to create file "
)
+
TmpFullFileName
;
wxString
msg
=
_
(
"Failed to create file "
)
+
TmpFullFileName
;
DisplayError
(
frame
,
msg
);
DisplayError
(
frame
,
msg
);
return
;
return
;
}
}
ClearUsedFlags
(
frame
);
/* Reset the flags FlagControlMulti in all schematic files*/
ClearUsedFlags
(
frame
);
/* Reset the flags FlagControlMulti in all schematic files*/
fprintf
(
tmpfile
,
"$BeginNetlist
\n
"
);
fprintf
(
tmpfile
,
"$BeginNetlist
\n
"
);
/* Create netlist module section */
/* Create netlist module section */
fprintf
(
tmpfile
,
"$BeginComponentList
\n
"
);
fprintf
(
tmpfile
,
"$BeginComponentList
\n
"
);
for
(
CurrScreen
=
ScreenSch
;
CurrScreen
!=
NULL
;
CurrScreen
=
(
BASE_SCREEN
*
)
CurrScreen
->
Pnext
)
for
(
CurrScreen
=
ScreenSch
;
CurrScreen
!=
NULL
;
CurrScreen
=
(
BASE_SCREEN
*
)
CurrScreen
->
Pnext
)
{
{
for
(
DrawList
=
CurrScreen
->
EEDrawList
;
DrawList
!=
NULL
;
DrawList
=
DrawList
->
Pnext
)
for
(
DrawList
=
CurrScreen
->
EEDrawList
;
DrawList
!=
NULL
;
DrawList
=
DrawList
->
Pnext
)
{
{
DrawList
=
Component
=
FindNextComponentAndCreatPinList
(
DrawList
);
DrawList
=
Component
=
FindNextComponentAndCreatPinList
(
DrawList
);
if
(
Component
==
NULL
)
break
;
// No component left
if
(
Component
==
NULL
)
break
;
// No component left
FootprintName
.
Empty
();
if
(
!
Component
->
m_Field
[
FOOTPRINT
].
IsVoid
()
)
FootprintName
.
Empty
();
{
if
(
!
Component
->
m_Field
[
FOOTPRINT
].
IsVoid
()
)
FootprintName
=
Component
->
m_Field
[
FOOTPRINT
].
m_Text
;
{
FootprintName
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
));
FootprintName
=
Component
->
m_Field
[
FOOTPRINT
].
m_Text
;
}
FootprintName
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
}
fprintf
(
tmpfile
,
"
\n
$BeginComponent
\n
"
);
fprintf
(
tmpfile
,
"TimeStamp=%8.8lX
\n
"
,
Component
->
m_TimeStamp
);
fprintf
(
tmpfile
,
"
\n
$BeginComponent
\n
"
);
fprintf
(
tmpfile
,
"Footprint=%s
\n
"
,
CONV_TO_UTF8
(
FootprintName
));
fprintf
(
tmpfile
,
"TimeStamp=%8.8lX
\n
"
,
Component
->
m_TimeStamp
);
Line
=
wxT
(
"Reference="
)
+
Component
->
m_Field
[
REFERENCE
].
m_Text
+
wxT
(
"
\n
"
);
fprintf
(
tmpfile
,
"Footprint=%s
\n
"
,
CONV_TO_UTF8
(
FootprintName
)
);
Line
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
));
Line
=
wxT
(
"Reference="
)
+
Component
->
m_Field
[
REFERENCE
].
m_Text
+
wxT
(
"
\n
"
);
fprintf
(
tmpfile
,
CONV_TO_UTF8
(
Line
));
Line
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
fprintf
(
tmpfile
,
CONV_TO_UTF8
(
Line
)
);
Line
=
Component
->
m_Field
[
VALUE
].
m_Text
;
Line
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
));
Line
=
Component
->
m_Field
[
VALUE
].
m_Text
;
fprintf
(
tmpfile
,
"Value=%s
\n
"
,
CONV_TO_UTF8
(
Line
));
Line
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
fprintf
(
tmpfile
,
"Value=%s
\n
"
,
CONV_TO_UTF8
(
Line
)
);
Line
=
Component
->
m_ChipName
;
Line
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
));
Line
=
Component
->
m_ChipName
;
fprintf
(
tmpfile
,
"Libref=%s
\n
"
,
CONV_TO_UTF8
(
Line
));
Line
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
fprintf
(
tmpfile
,
"Libref=%s
\n
"
,
CONV_TO_UTF8
(
Line
)
);
// Write pin list:
fprintf
(
tmpfile
,
"$BeginPinList
\n
"
);
// Write pin list:
for
(
ii
=
0
;
ii
<
s_SortedPinCount
;
ii
++
)
fprintf
(
tmpfile
,
"$BeginPinList
\n
"
);
{
for
(
ii
=
0
;
ii
<
s_SortedPinCount
;
ii
++
)
ObjetNetListStruct
*
Pin
=
s_SortedComponentPinList
[
ii
];
{
if
(
!
Pin
)
continue
;
ObjetNetListStruct
*
Pin
=
s_SortedComponentPinList
[
ii
];
netname
=
ReturnPinNetName
(
Pin
,
wxT
(
"$-%.6d"
));
if
(
!
Pin
)
if
(
netname
.
IsEmpty
()
)
netname
=
wxT
(
"?"
);
continue
;
fprintf
(
tmpfile
,
"%.4s=%s
\n
"
,(
char
*
)
&
Pin
->
m_PinNum
,
netname
=
ReturnPinNetName
(
Pin
,
wxT
(
"$-%.6d"
)
);
CONV_TO_UTF8
(
netname
));
if
(
netname
.
IsEmpty
()
)
}
netname
=
wxT
(
"?"
);
fprintf
(
tmpfile
,
"%.4s=%s
\n
"
,
(
char
*
)
&
Pin
->
m_PinNum
,
fprintf
(
tmpfile
,
"$EndPinList
\n
"
);
CONV_TO_UTF8
(
netname
)
);
fprintf
(
tmpfile
,
"$EndComponent
\n
"
);
}
}
}
fprintf
(
tmpfile
,
"$EndPinList
\n
"
);
fprintf
(
tmpfile
,
"$EndComponent
\n
"
);
MyFree
(
s_SortedComponentPinList
);
}
s_SortedComponentPinList
=
NULL
;
}
fprintf
(
tmpfile
,
"$EndComponentList
\n
"
);
MyFree
(
s_SortedComponentPinList
);
s_SortedComponentPinList
=
NULL
;
fprintf
(
tmpfile
,
"
\n
$BeginNets
\n
"
);
WriteGENERICListOfNets
(
tmpfile
,
g_TabObjNet
);
fprintf
(
tmpfile
,
"$EndComponentList
\n
"
);
fprintf
(
tmpfile
,
"$EndNets
\n
"
);
fprintf
(
tmpfile
,
"
\n
$EndNetlist
\n
"
);
fprintf
(
tmpfile
,
"
\n
$BeginNets
\n
"
);
fclose
(
tmpfile
);
WriteGENERICListOfNets
(
tmpfile
,
g_TabObjNet
);
fprintf
(
tmpfile
,
"$EndNets
\n
"
);
// Call the external module (plug in )
fprintf
(
tmpfile
,
"
\n
$EndNetlist
\n
"
);
fclose
(
tmpfile
);
if
(
g_NetListerCommandLine
.
IsEmpty
()
)
return
;
// Call the external module (plug in )
wxString
CommandFile
;
if
(
wxIsAbsolutePath
(
g_NetListerCommandLine
)
)
if
(
g_NetListerCommandLine
.
IsEmpty
()
)
CommandFile
=
g_NetListerCommandLine
;
return
;
else
CommandFile
=
FindKicadFile
(
g_NetListerCommandLine
);
wxString
CommandFile
;
CommandFile
+=
wxT
(
" "
)
+
TmpFullFileName
;
if
(
wxIsAbsolutePath
(
g_NetListerCommandLine
)
)
CommandFile
+=
wxT
(
" "
)
+
FullFileName
;
CommandFile
=
g_NetListerCommandLine
;
else
wxExecute
(
CommandFile
,
wxEXEC_SYNC
);
CommandFile
=
FindKicadFile
(
g_NetListerCommandLine
);
CommandFile
+=
wxT
(
" "
)
+
TmpFullFileName
;
CommandFile
+=
wxT
(
" "
)
+
FullFileName
;
wxExecute
(
CommandFile
,
wxEXEC_SYNC
);
}
}
/********************************************************/
/********************************************************/
static
void
ClearUsedFlags
(
WinEDA_SchematicFrame
*
frame
)
static
void
ClearUsedFlags
(
WinEDA_SchematicFrame
*
frame
)
/********************************************************/
/********************************************************/
/* Clear flag FlagControlMulti, used in netlist generation */
/* Clear flag FlagControlMulti, used in netlist generation */
{
{
SCH_SCREEN
*
screen
;
SCH_SCREEN
*
screen
;
EDA_BaseStruct
*
DrawList
;
EDA_BaseStruct
*
DrawList
;
EDA_ScreenList
ScreenList
(
NULL
);
EDA_ScreenList
ScreenList
(
NULL
);
for
(
screen
=
ScreenList
.
GetFirst
();
screen
!=
NULL
;
screen
=
ScreenList
.
GetNext
()
)
{
for
(
screen
=
ScreenList
.
GetFirst
();
screen
!=
NULL
;
screen
=
ScreenList
.
GetNext
()
)
DrawList
=
screen
->
EEDrawList
;
{
while
(
DrawList
)
DrawList
=
screen
->
EEDrawList
;
{
while
(
DrawList
)
if
(
DrawList
->
Type
()
==
DRAW_LIB_ITEM_STRUCT_TYPE
)
{
{
if
(
DrawList
->
Type
()
==
DRAW_LIB_ITEM_STRUCT_TYPE
)
EDA_SchComponentStruct
*
Component
=
(
EDA_SchComponentStruct
*
)
DrawList
;
{
Component
->
m_FlagControlMulti
=
0
;
EDA_SchComponentStruct
*
Component
=
(
EDA_SchComponentStruct
*
)
DrawList
;
}
Component
->
m_FlagControlMulti
=
0
;
DrawList
=
DrawList
->
Pnext
;
}
}
DrawList
=
DrawList
->
Pnext
;
}
}
}
}
}
/*************************************************************/
/*************************************************************/
static
void
WriteNetListPspice
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
,
static
void
WriteNetListPspice
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
,
bool
use_netnames
)
bool
use_netnames
)
/*************************************************************/
/*************************************************************/
/* Routine de generation du fichier netliste ( Format PSPICE )
/* Routine de generation du fichier netliste ( Format PSPICE )
si use_netnames = TRUE
*
si use_netnames = TRUE
les nodes sont identifies par le netname
*
les nodes sont identifies par le netname
sinon les nodes sont identifies par le netnumber
*
sinon les nodes sont identifies par le netnumber
*
tous les textes graphiques commenant par [.-+]pspice ou [.-+]gnucap
*
tous les textes graphiques commenant par [.-+]pspice ou [.-+]gnucap
sont considrs comme des commandes a placer dans la netliste
*
sont considrs comme des commandes a placer dans la netliste
[.-]pspice ou gnucap sont en debut
*
[.-]pspice ou gnucap sont en debut
+pspice et +gnucap sont en fin de netliste
+pspice et +gnucap sont en fin de netliste
*/
*/
{
{
char
Line
[
1024
];
char
Line
[
1024
];
SCH_SCREEN
*
screen
;
SCH_SCREEN
*
screen
;
EDA_BaseStruct
*
DrawList
;
EDA_BaseStruct
*
DrawList
;
EDA_SchComponentStruct
*
Component
;
EDA_SchComponentStruct
*
Component
;
int
ii
,
nbitems
;
int
ii
,
nbitems
;
wxString
text
;
wxString
text
;
wxArrayString
SpiceCommandAtBeginFile
,
SpiceCommandAtEndFile
;
wxArrayString
SpiceCommandAtBeginFile
,
SpiceCommandAtEndFile
;
wxString
msg
;
wxString
msg
;
#define BUFYPOS_LEN 4
#define BUFYPOS_LEN 4
wxChar
bufnum
[
BUFYPOS_LEN
+
1
];
wxChar
bufnum
[
BUFYPOS_LEN
+
1
];
DateAndTime
(
Line
);
DateAndTime
(
Line
);
fprintf
(
f
,
"* %s (Spice format) creation date: %s
\n\n
"
,
NETLIST_HEAD_STRING
,
Line
);
fprintf
(
f
,
"* %s (Spice format) creation date: %s
\n\n
"
,
NETLIST_HEAD_STRING
,
Line
);
/* Create text list starting by [.-]pspice , or [.-]gnucap (simulator commands) */
/* Create text list starting by [.-]pspice , or [.-]gnucap (simulator commands) */
/* and create text list starting by [+]pspice , or [+]gnucap (simulator commands) */
/* and create text list starting by [+]pspice , or [+]gnucap (simulator commands) */
bufnum
[
BUFYPOS_LEN
]
=
0
;
bufnum
[
BUFYPOS_LEN
]
=
0
;
EDA_ScreenList
ScreenList
(
NULL
);
EDA_ScreenList
ScreenList
(
NULL
);
for
(
screen
=
ScreenList
.
GetFirst
();
screen
!=
NULL
;
screen
=
ScreenList
.
GetNext
()
)
{
for
(
screen
=
ScreenList
.
GetFirst
();
screen
!=
NULL
;
screen
=
ScreenList
.
GetNext
()
)
for
(
DrawList
=
screen
->
EEDrawList
;
DrawList
!=
NULL
;
DrawList
=
DrawList
->
Pnext
)
{
{
for
(
DrawList
=
screen
->
EEDrawList
;
DrawList
!=
NULL
;
DrawList
=
DrawList
->
Pnext
)
wxChar
ident
;
{
if
(
DrawList
->
Type
()
!=
DRAW_TEXT_STRUCT_TYPE
)
continue
;
wxChar
ident
;
#define DRAWTEXT ((DrawTextStruct *) DrawList)
if
(
DrawList
->
Type
()
!=
DRAW_TEXT_STRUCT_TYPE
)
text
=
DRAWTEXT
->
m_Text
;
if
(
text
.
IsEmpty
()
)
continue
;
continue
;
ident
=
text
.
GetChar
(
0
);
#define DRAWTEXT ( (DrawTextStruct*) DrawList )
if
(
ident
!=
'.'
&&
ident
!=
'-'
&&
ident
!=
'+'
)
continue
;
text
=
DRAWTEXT
->
m_Text
;
if
(
text
.
IsEmpty
()
)
text
.
Remove
(
0
,
1
);
//Remove the first char.
continue
;
text
.
Remove
(
6
);
//text contains 6 char.
ident
=
text
.
GetChar
(
0
);
if
(
(
text
==
wxT
(
"pspice"
)
)
||
(
text
==
wxT
(
"gnucap"
)
)
)
if
(
ident
!=
'.'
&&
ident
!=
'-'
&&
ident
!=
'+'
)
{
continue
;
/* Put the Y position as an ascii string, for sort by vertical position,
text
.
Remove
(
0
,
1
);
//Remove the first char.
using usual sort string by alphabetic value */
text
.
Remove
(
6
);
//text contains 6 char.
int
ypos
=
DRAWTEXT
->
m_Pos
.
y
;
if
(
(
text
==
wxT
(
"pspice"
)
)
||
(
text
==
wxT
(
"gnucap"
)
)
)
for
(
ii
=
0
;
ii
<
BUFYPOS_LEN
;
ii
++
)
{
{
/* Put the Y position as an ascii string, for sort by vertical position,
bufnum
[
BUFYPOS_LEN
-
1
-
ii
]
=
(
ypos
&
63
)
+
' '
;
ypos
>>=
6
;
* using usual sort string by alphabetic value */
}
int
ypos
=
DRAWTEXT
->
m_Pos
.
y
;
text
=
DRAWTEXT
->
m_Text
.
AfterFirst
(
' '
);
for
(
ii
=
0
;
ii
<
BUFYPOS_LEN
;
ii
++
)
msg
.
Printf
(
wxT
(
"%s %s"
),
bufnum
,
text
.
GetData
());
// First BUFYPOS_LEN char are the Y position
{
if
(
ident
==
'+'
)
SpiceCommandAtEndFile
.
Add
(
msg
);
bufnum
[
BUFYPOS_LEN
-
1
-
ii
]
=
(
ypos
&
63
)
+
' '
;
ypos
>>=
6
;
else
SpiceCommandAtBeginFile
.
Add
(
msg
);
}
}
}
text
=
DRAWTEXT
->
m_Text
.
AfterFirst
(
' '
);
}
msg
.
Printf
(
wxT
(
"%s %s"
),
bufnum
,
text
.
GetData
()
);
// First BUFYPOS_LEN char are the Y position
if
(
ident
==
'+'
)
/* Print texts starting by [.-]pspice , ou [.-]gnucap (of course, without the Y position string)*/
SpiceCommandAtEndFile
.
Add
(
msg
);
nbitems
=
SpiceCommandAtBeginFile
.
GetCount
();
else
if
(
nbitems
)
SpiceCommandAtBeginFile
.
Add
(
msg
);
{
}
SpiceCommandAtBeginFile
.
Sort
();
}
for
(
ii
=
0
;
ii
<
nbitems
;
ii
++
)
}
{
SpiceCommandAtBeginFile
[
ii
].
Remove
(
0
,
BUFYPOS_LEN
);
/* Print texts starting by [.-]pspice , ou [.-]gnucap (of course, without the Y position string)*/
SpiceCommandAtBeginFile
[
ii
].
Trim
(
TRUE
);
nbitems
=
SpiceCommandAtBeginFile
.
GetCount
();
SpiceCommandAtBeginFile
[
ii
].
Trim
(
FALSE
);
if
(
nbitems
)
fprintf
(
f
,
"%s
\n
"
,
CONV_TO_UTF8
(
SpiceCommandAtBeginFile
[
ii
])
);
{
}
SpiceCommandAtBeginFile
.
Sort
();
}
for
(
ii
=
0
;
ii
<
nbitems
;
ii
++
)
fprintf
(
f
,
"
\n
"
);
{
SpiceCommandAtBeginFile
[
ii
].
Remove
(
0
,
BUFYPOS_LEN
);
SpiceCommandAtBeginFile
[
ii
].
Trim
(
TRUE
);
/* Create component list */
SpiceCommandAtBeginFile
[
ii
].
Trim
(
FALSE
);
ClearUsedFlags
(
frame
);
/* Reset the flags FlagControlMulti in all schematic files*/
fprintf
(
f
,
"%s
\n
"
,
CONV_TO_UTF8
(
SpiceCommandAtBeginFile
[
ii
]
)
);
for
(
screen
=
ScreenList
.
GetFirst
();
screen
!=
NULL
;
screen
=
ScreenList
.
GetNext
()
)
}
{
}
for
(
DrawList
=
screen
->
EEDrawList
;
DrawList
!=
NULL
;
DrawList
=
DrawList
->
Pnext
)
fprintf
(
f
,
"
\n
"
);
{
DrawList
=
Component
=
FindNextComponentAndCreatPinList
(
DrawList
);
if
(
Component
==
NULL
)
break
;
/* Create component list */
ClearUsedFlags
(
frame
);
/* Reset the flags FlagControlMulti in all schematic files*/
fprintf
(
f
,
"%s "
,
CONV_TO_UTF8
(
Component
->
m_Field
[
REFERENCE
].
m_Text
));
for
(
screen
=
ScreenList
.
GetFirst
();
screen
!=
NULL
;
screen
=
ScreenList
.
GetNext
()
)
{
// Write pin list:
for
(
DrawList
=
screen
->
EEDrawList
;
DrawList
!=
NULL
;
DrawList
=
DrawList
->
Pnext
)
for
(
ii
=
0
;
ii
<
s_SortedPinCount
;
ii
++
)
{
{
DrawList
=
Component
=
FindNextComponentAndCreatPinList
(
DrawList
);
ObjetNetListStruct
*
Pin
=
s_SortedComponentPinList
[
ii
];
if
(
Component
==
NULL
)
if
(
!
Pin
)
continue
;
break
;
wxString
NetName
=
ReturnPinNetName
(
Pin
,
wxT
(
"N-%.6d"
));
if
(
NetName
.
IsEmpty
()
)
NetName
=
wxT
(
"?"
);
fprintf
(
f
,
"%s "
,
CONV_TO_UTF8
(
Component
->
m_Field
[
REFERENCE
].
m_Text
)
);
if
(
use_netnames
)
fprintf
(
f
,
" %s"
,
CONV_TO_UTF8
(
NetName
));
else
// Use number for net names (with net number = 0 for "GND"
// Write pin list:
{
for
(
ii
=
0
;
ii
<
s_SortedPinCount
;
ii
++
)
// NetName = "0" is "GND" net for Spice
{
if
(
NetName
==
wxT
(
"0"
)
||
NetName
==
wxT
(
"GND"
)
)
ObjetNetListStruct
*
Pin
=
s_SortedComponentPinList
[
ii
];
fprintf
(
f
,
" 0"
);
if
(
!
Pin
)
else
fprintf
(
f
,
" %d"
,
Pin
->
m_NetCode
);
continue
;
}
wxString
NetName
=
ReturnPinNetName
(
Pin
,
wxT
(
"N-%.6d"
)
);
}
if
(
NetName
.
IsEmpty
()
)
fprintf
(
f
,
" %s
\n
"
,
CONV_TO_UTF8
(
Component
->
m_Field
[
VALUE
].
m_Text
));
NetName
=
wxT
(
"?"
);
}
if
(
use_netnames
)
}
fprintf
(
f
,
" %s"
,
CONV_TO_UTF8
(
NetName
)
);
else
// Use number for net names (with net number = 0 for "GND"
MyFree
(
s_SortedComponentPinList
);
{
s_SortedComponentPinList
=
NULL
;
// NetName = "0" is "GND" net for Spice
if
(
NetName
==
wxT
(
"0"
)
||
NetName
==
wxT
(
"GND"
)
)
/* Print texts starting by [+]pspice , ou [+]gnucap */
fprintf
(
f
,
" 0"
);
nbitems
=
SpiceCommandAtEndFile
.
GetCount
();
else
if
(
nbitems
)
fprintf
(
f
,
" %d"
,
Pin
->
m_NetCode
);
{
}
fprintf
(
f
,
"
\n
"
);
}
SpiceCommandAtEndFile
.
Sort
();
for
(
ii
=
0
;
ii
<
nbitems
;
ii
++
)
fprintf
(
f
,
" %s
\n
"
,
CONV_TO_UTF8
(
Component
->
m_Field
[
VALUE
].
m_Text
)
);
{
}
SpiceCommandAtEndFile
[
ii
].
Remove
(
0
,
+
BUFYPOS_LEN
);
}
SpiceCommandAtEndFile
[
ii
].
Trim
(
TRUE
);
SpiceCommandAtEndFile
[
ii
].
Trim
(
FALSE
);
MyFree
(
s_SortedComponentPinList
);
fprintf
(
f
,
"%s
\n
"
,
CONV_TO_UTF8
(
SpiceCommandAtEndFile
[
ii
]));
s_SortedComponentPinList
=
NULL
;
}
}
/* Print texts starting by [+]pspice , ou [+]gnucap */
nbitems
=
SpiceCommandAtEndFile
.
GetCount
();
fprintf
(
f
,
"
\n
.end
\n
"
);
if
(
nbitems
)
{
fprintf
(
f
,
"
\n
"
);
SpiceCommandAtEndFile
.
Sort
();
for
(
ii
=
0
;
ii
<
nbitems
;
ii
++
)
{
SpiceCommandAtEndFile
[
ii
].
Remove
(
0
,
+
BUFYPOS_LEN
);
SpiceCommandAtEndFile
[
ii
].
Trim
(
TRUE
);
SpiceCommandAtEndFile
[
ii
].
Trim
(
FALSE
);
fprintf
(
f
,
"%s
\n
"
,
CONV_TO_UTF8
(
SpiceCommandAtEndFile
[
ii
]
)
);
}
}
fprintf
(
f
,
"
\n
.end
\n
"
);
}
}
/*****************************************************************************************/
/*****************************************************************************************/
static
void
WriteNetListPCBNEW
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
,
bool
with_pcbnew
)
static
void
WriteNetListPCBNEW
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
,
bool
with_pcbnew
)
/*****************************************************************************************/
/*****************************************************************************************/
/* Routine de generation du fichier netliste ( Format ORCAD PCB 2 ameliore )
/* Routine de generation du fichier netliste ( Format ORCAD PCB 2 ameliore )
si with_pcbnew = FALSE
*
si with_pcbnew = FALSE
format PCBNEW (OrcadPcb2 + commentaires et liste des nets)
*
format PCBNEW (OrcadPcb2 + commentaires et liste des nets)
si with_pcbnew = FALSE
*
si with_pcbnew = FALSE
Format ORCADPCB2 strict
*
Format ORCADPCB2 strict
*/
*/
{
{
wxString
Line
,
FootprintName
;
wxString
Line
,
FootprintName
;
char
Buf
[
256
];
char
Buf
[
256
];
SCH_SCREEN
*
CurrScreen
;
SCH_SCREEN
*
CurrScreen
;
EDA_BaseStruct
*
DrawList
;
EDA_BaseStruct
*
DrawList
;
EDA_SchComponentStruct
*
Component
;
EDA_SchComponentStruct
*
Component
;
int
ii
;
int
ii
;
EDA_SchComponentStruct
**
CmpList
=
NULL
;
EDA_SchComponentStruct
**
CmpList
=
NULL
;
int
CmpListCount
=
0
,
CmpListSize
=
1000
;
int
CmpListCount
=
0
,
CmpListSize
=
1000
;
DateAndTime
(
Buf
);
DateAndTime
(
Buf
);
if
(
with_pcbnew
)
if
(
with_pcbnew
)
fprintf
(
f
,
"# %s created %s
\n
(
\n
"
,
NETLIST_HEAD_STRING
,
Buf
);
fprintf
(
f
,
"# %s created %s
\n
(
\n
"
,
NETLIST_HEAD_STRING
,
Buf
);
else
fprintf
(
f
,
"( { %s created %s }
\n
"
,
NETLIST_HEAD_STRING
,
Buf
);
else
fprintf
(
f
,
"( { %s created %s }
\n
"
,
NETLIST_HEAD_STRING
,
Buf
);
/* Create netlist module section */
ClearUsedFlags
(
frame
);
/* Reset the flags FlagControlMulti in all schematic files*/
/* Create netlist module section */
ClearUsedFlags
(
frame
);
/* Reset the flags FlagControlMulti in all schematic files*/
EDA_ScreenList
ScreenList
(
NULL
);
for
(
CurrScreen
=
ScreenList
.
GetFirst
();
CurrScreen
!=
NULL
;
CurrScreen
=
ScreenList
.
GetNext
()
)
EDA_ScreenList
ScreenList
(
NULL
);
{
for
(
DrawList
=
CurrScreen
->
EEDrawList
;
DrawList
!=
NULL
;
DrawList
=
DrawList
->
Pnext
)
for
(
CurrScreen
=
ScreenList
.
GetFirst
();
CurrScreen
!=
NULL
;
CurrScreen
=
ScreenList
.
GetNext
()
)
{
{
DrawList
=
Component
=
FindNextComponentAndCreatPinList
(
DrawList
);
for
(
DrawList
=
CurrScreen
->
EEDrawList
;
DrawList
!=
NULL
;
DrawList
=
DrawList
->
Pnext
)
if
(
Component
==
NULL
)
break
;
{
DrawList
=
Component
=
FindNextComponentAndCreatPinList
(
DrawList
);
/* Get the Component FootprintFilter and put the component in CmpList if filter is not void */
if
(
Component
==
NULL
)
EDA_LibComponentStruct
*
Entry
;
break
;
if
(
(
Entry
=
FindLibPart
(
Component
->
m_ChipName
.
GetData
(),
wxEmptyString
,
FIND_ROOT
))
!=
NULL
)
{
/* Get the Component FootprintFilter and put the component in CmpList if filter is not void */
if
(
Entry
->
m_FootprintList
.
GetCount
()
!=
0
)
/* Put in list */
EDA_LibComponentStruct
*
Entry
;
{
if
(
(
Entry
=
FindLibPart
(
Component
->
m_ChipName
.
GetData
(),
wxEmptyString
,
if
(
CmpList
==
NULL
)
FIND_ROOT
)
)
!=
NULL
)
CmpList
=
(
EDA_SchComponentStruct
**
)
MyZMalloc
(
sizeof
(
EDA_SchComponentStruct
*
)
*
CmpListSize
);
{
if
(
CmpListCount
>=
CmpListSize
)
if
(
Entry
->
m_FootprintList
.
GetCount
()
!=
0
)
/* Put in list */
{
{
CmpListSize
+=
1000
;
if
(
CmpList
==
NULL
)
CmpList
=
(
EDA_SchComponentStruct
**
)
realloc
(
CmpList
,
sizeof
(
EDA_SchComponentStruct
*
)
*
CmpListSize
);
CmpList
=
(
EDA_SchComponentStruct
**
)
MyZMalloc
(
sizeof
(
}
EDA_SchComponentStruct
CmpList
[
CmpListCount
]
=
Component
;
*
)
*
CmpListSize
);
CmpListCount
++
;
if
(
CmpListCount
>=
CmpListSize
)
}
{
}
CmpListSize
+=
1000
;
CmpList
=
(
EDA_SchComponentStruct
**
)
realloc
(
if
(
!
Component
->
m_Field
[
FOOTPRINT
].
IsVoid
()
)
CmpList
,
{
sizeof
(
FootprintName
=
Component
->
m_Field
[
FOOTPRINT
].
m_Text
;
EDA_SchComponentStruct
*
)
FootprintName
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
*
CmpListSize
);
}
}
else
FootprintName
=
wxT
(
"$noname"
);
CmpList
[
CmpListCount
]
=
Component
;
CmpListCount
++
;
Line
=
Component
->
m_Field
[
REFERENCE
].
m_Text
;
}
Line
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
}
fprintf
(
f
,
" ( %8.8lX %s"
,
Component
->
m_TimeStamp
,
if
(
!
Component
->
m_Field
[
FOOTPRINT
].
IsVoid
()
)
CONV_TO_UTF8
(
FootprintName
));
{
fprintf
(
f
,
" %s"
,
CONV_TO_UTF8
(
Line
));
FootprintName
=
Component
->
m_Field
[
FOOTPRINT
].
m_Text
;
FootprintName
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
Line
=
Component
->
m_Field
[
VALUE
].
m_Text
;
}
Line
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
else
fprintf
(
f
,
" %s"
,
CONV_TO_UTF8
(
Line
));
FootprintName
=
wxT
(
"$noname"
);
if
(
with_pcbnew
)
// Add the lib name for this component
Line
=
Component
->
m_Field
[
REFERENCE
].
m_Text
;
{
Line
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
Line
=
Component
->
m_ChipName
;
fprintf
(
f
,
" ( %8.8lX %s"
,
Line
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
Component
->
m_TimeStamp
,
fprintf
(
f
,
" {Lib=%s}"
,
CONV_TO_UTF8
(
Line
));
CONV_TO_UTF8
(
FootprintName
)
);
}
fprintf
(
f
,
" %s"
,
CONV_TO_UTF8
(
Line
)
);
fprintf
(
f
,
"
\n
"
);
Line
=
Component
->
m_Field
[
VALUE
].
m_Text
;
// Write pin list:
Line
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
for
(
ii
=
0
;
ii
<
s_SortedPinCount
;
ii
++
)
fprintf
(
f
,
" %s"
,
CONV_TO_UTF8
(
Line
)
);
{
ObjetNetListStruct
*
Pin
=
s_SortedComponentPinList
[
ii
];
if
(
with_pcbnew
)
// Add the lib name for this component
if
(
!
Pin
)
continue
;
{
wxString
netname
=
ReturnPinNetName
(
Pin
,
wxT
(
"N-%.6d"
));
Line
=
Component
->
m_ChipName
;
if
(
netname
.
IsEmpty
()
)
netname
=
wxT
(
" ?"
);
Line
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
fprintf
(
f
,
" ( %4.4s %s )
\n
"
,(
char
*
)
&
Pin
->
m_PinNum
,
fprintf
(
f
,
" {Lib=%s}"
,
CONV_TO_UTF8
(
Line
)
);
CONV_TO_UTF8
(
netname
));
}
}
fprintf
(
f
,
"
\n
"
);
fprintf
(
f
,
" )
\n
"
);
// Write pin list:
}
for
(
ii
=
0
;
ii
<
s_SortedPinCount
;
ii
++
)
}
{
fprintf
(
f
,
")
\n
*
\n
"
);
ObjetNetListStruct
*
Pin
=
s_SortedComponentPinList
[
ii
];
if
(
!
Pin
)
MyFree
(
s_SortedComponentPinList
);
continue
;
s_SortedComponentPinList
=
NULL
;
wxString
netname
=
ReturnPinNetName
(
Pin
,
wxT
(
"N-%.6d"
)
);
if
(
netname
.
IsEmpty
()
)
/* Write the allowed footprint list for each component */
netname
=
wxT
(
" ?"
);
if
(
with_pcbnew
&&
CmpList
)
fprintf
(
f
,
" ( %4.4s %s )
\n
"
,
(
char
*
)
&
Pin
->
m_PinNum
,
{
CONV_TO_UTF8
(
netname
)
);
fprintf
(
f
,
"{ Allowed footprints by component:
\n
"
);
}
EDA_LibComponentStruct
*
Entry
;
for
(
ii
=
0
;
ii
<
CmpListCount
;
ii
++
)
fprintf
(
f
,
" )
\n
"
);
{
}
Component
=
CmpList
[
ii
];
}
Entry
=
FindLibPart
(
Component
->
m_ChipName
.
GetData
(),
wxEmptyString
,
FIND_ROOT
);
Line
=
Component
->
m_Field
[
REFERENCE
].
m_Text
;
fprintf
(
f
,
")
\n
*
\n
"
);
Line
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
fprintf
(
f
,
"$component %s
\n
"
,
CONV_TO_UTF8
(
Line
));
MyFree
(
s_SortedComponentPinList
);
/* Write the footprint list */
s_SortedComponentPinList
=
NULL
;
for
(
unsigned
int
jj
=
0
;
jj
<
Entry
->
m_FootprintList
.
GetCount
();
jj
++
)
{
/* Write the allowed footprint list for each component */
fprintf
(
f
,
" %s
\n
"
,
CONV_TO_UTF8
(
Entry
->
m_FootprintList
[
jj
]));
if
(
with_pcbnew
&&
CmpList
)
}
{
fprintf
(
f
,
"$endlist
\n
"
);
fprintf
(
f
,
"{ Allowed footprints by component:
\n
"
);
}
EDA_LibComponentStruct
*
Entry
;
fprintf
(
f
,
"$endfootprintlist
\n
}
\n
"
);
for
(
ii
=
0
;
ii
<
CmpListCount
;
ii
++
)
}
{
if
(
CmpList
)
free
(
CmpList
);
Component
=
CmpList
[
ii
];
Entry
=
FindLibPart
(
Component
->
m_ChipName
.
GetData
(),
wxEmptyString
,
FIND_ROOT
);
if
(
with_pcbnew
)
Line
=
Component
->
m_Field
[
REFERENCE
].
m_Text
;
{
Line
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
fprintf
(
f
,
"{ Pin List by Nets
\n
"
);
fprintf
(
f
,
"$component %s
\n
"
,
CONV_TO_UTF8
(
Line
)
);
WriteGENERICListOfNets
(
f
,
g_TabObjNet
);
/* Write the footprint list */
fprintf
(
f
,
"}
\n
"
);
for
(
unsigned
int
jj
=
0
;
jj
<
Entry
->
m_FootprintList
.
GetCount
();
jj
++
)
fprintf
(
f
,
"#End
\n
"
);
{
}
fprintf
(
f
,
" %s
\n
"
,
CONV_TO_UTF8
(
Entry
->
m_FootprintList
[
jj
]
)
);
}
fprintf
(
f
,
"$endlist
\n
"
);
}
fprintf
(
f
,
"$endfootprintlist
\n
}
\n
"
);
}
if
(
CmpList
)
free
(
CmpList
);
if
(
with_pcbnew
)
{
fprintf
(
f
,
"{ Pin List by Nets
\n
"
);
WriteGENERICListOfNets
(
f
,
g_TabObjNet
);
fprintf
(
f
,
"}
\n
"
);
fprintf
(
f
,
"#End
\n
"
);
}
}
}
/*************************************************************************************/
/*************************************************************************************/
static
void
AddPinToComponentPinList
(
EDA_SchComponentStruct
*
Component
,
LibDrawPin
*
Pin
)
static
void
AddPinToComponentPinList
(
EDA_SchComponentStruct
*
Component
,
LibDrawPin
*
Pin
)
/*************************************************************************************/
/*************************************************************************************/
/* Add a new pin description in the pin list s_SortedComponentPinList
/* Add a new pin description in the pin list s_SortedComponentPinList
a pin description is a pointer to the corresponding structure
*
a pin description is a pointer to the corresponding structure
created by BuildNetList() in the table g_TabObjNet
*
created by BuildNetList() in the table g_TabObjNet
*/
*/
{
{
int
ii
;
int
ii
;
/* Search the PIN description for Pin in g_TabObjNet*/
/* Search the PIN description for Pin in g_TabObjNet*/
for
(
ii
=
0
;
ii
<
g_NbrObjNet
;
ii
++
)
for
(
ii
=
0
;
ii
<
g_NbrObjNet
;
ii
++
)
{
{
if
(
g_TabObjNet
[
ii
].
m_Type
!=
NET_PIN
)
continue
;
if
(
g_TabObjNet
[
ii
].
m_Type
!=
NET_PIN
)
if
(
g_TabObjNet
[
ii
].
m_Link
!=
Component
)
continue
;
continue
;
if
(
g_TabObjNet
[
ii
].
m_PinNum
!=
Pin
->
m_PinNum
)
continue
;
if
(
g_TabObjNet
[
ii
].
m_Link
!=
Component
)
{
continue
;
s_SortedComponentPinList
[
s_SortedPinCount
]
=
&
g_TabObjNet
[
ii
];
if
(
g_TabObjNet
[
ii
].
m_PinNum
!=
Pin
->
m_PinNum
)
s_SortedPinCount
++
;
continue
;
if
(
s_SortedPinCount
>=
MAXPIN
)
{
{
s_SortedComponentPinList
[
s_SortedPinCount
]
=
&
g_TabObjNet
[
ii
];
/* Log message for Internal error */
s_SortedPinCount
++
;
DisplayError
(
NULL
,
wxT
(
"AddPinToComponentPinList err: MAXPIN reached"
));
return
;
if
(
s_SortedPinCount
>=
MAXPIN
)
}
{
}
/* Log message for Internal error */
}
DisplayError
(
NULL
,
wxT
(
"AddPinToComponentPinList err: MAXPIN reached"
)
);
return
;
}
}
}
}
}
/**********************************************************************/
/**********************************************************************/
static
void
EraseDuplicatePins
(
ObjetNetListStruct
**
TabPin
,
int
NbrPin
)
static
void
EraseDuplicatePins
(
ObjetNetListStruct
**
TabPin
,
int
NbrPin
)
/**********************************************************************/
/**********************************************************************/
/*
/*
Routine qui elimine les Pins de meme Numero de la liste des objets
*
Routine qui elimine les Pins de meme Numero de la liste des objets
(Liste des Pins d'un boitier) passee en entree
*
(Liste des Pins d'un boitier) passee en entree
Ces pins redondantes proviennent des pins (alims... ) communes a plusieurs
*
Ces pins redondantes proviennent des pins (alims... ) communes a plusieurs
elements d'un boitier a multiple parts.
*
elements d'un boitier a multiple parts.
*/
*/
{
{
int
ii
,
jj
;
int
ii
,
jj
;
for
(
ii
=
0
;
ii
<
NbrPin
-
1
;
ii
++
)
for
(
ii
=
0
;
ii
<
NbrPin
-
1
;
ii
++
)
{
{
if
(
TabPin
[
ii
]
==
NULL
)
continue
;
/* Deja supprime */
if
(
TabPin
[
ii
]
==
NULL
)
if
(
TabPin
[
ii
]
->
m_PinNum
!=
TabPin
[
ii
+
1
]
->
m_PinNum
)
continue
;
continue
;
/* Deja supprime */
/* 2 Pins doublees */
if
(
TabPin
[
ii
]
->
m_PinNum
!=
TabPin
[
ii
+
1
]
->
m_PinNum
)
for
(
jj
=
ii
+
1
;
jj
<
NbrPin
;
jj
++
)
continue
;
{
/* 2 Pins doublees */
if
(
TabPin
[
ii
]
->
m_PinNum
!=
TabPin
[
jj
]
->
m_PinNum
)
break
;
for
(
jj
=
ii
+
1
;
jj
<
NbrPin
;
jj
++
)
TabPin
[
jj
]
=
NULL
;
{
}
if
(
TabPin
[
ii
]
->
m_PinNum
!=
TabPin
[
jj
]
->
m_PinNum
)
}
break
;
TabPin
[
jj
]
=
NULL
;
}
}
}
}
/**********************************************************************/
/**********************************************************************/
static
void
FindOthersUnits
(
EDA_SchComponentStruct
*
Component
)
static
void
FindOthersUnits
(
EDA_SchComponentStruct
*
Component
)
/**********************************************************************/
/**********************************************************************/
/* Recherche les autres parts du boitier auquel appartient la part Component,
/* Recherche les autres parts du boitier auquel appartient la part Component,
pour les boitiers a parts multiples.
*
pour les boitiers a parts multiples.
Appelle AddPinToComponentPinList() pour classer les pins des parts trouvees
*
Appelle AddPinToComponentPinList() pour classer les pins des parts trouvees
*/
*/
{
{
EDA_BaseStruct
*
DrawList
;
EDA_BaseStruct
*
DrawList
;
EDA_SchComponentStruct
*
Component2
;
EDA_SchComponentStruct
*
Component2
;
EDA_LibComponentStruct
*
Entry
;
EDA_LibComponentStruct
*
Entry
;
LibEDA_BaseStruct
*
DEntry
;
LibEDA_BaseStruct
*
DEntry
;
SCH_SCREEN
*
screen
;
SCH_SCREEN
*
screen
;
EDA_ScreenList
ScreenList
(
NULL
);
EDA_ScreenList
ScreenList
(
NULL
);
for
(
screen
=
ScreenList
.
GetFirst
();
screen
!=
NULL
;
screen
=
ScreenList
.
GetNext
()
)
{
for
(
screen
=
ScreenList
.
GetFirst
();
screen
!=
NULL
;
screen
=
ScreenList
.
GetNext
()
)
DrawList
=
screen
->
EEDrawList
;
{
while
(
DrawList
)
DrawList
=
screen
->
EEDrawList
;
{
while
(
DrawList
)
switch
(
DrawList
->
Type
()
)
{
{
switch
(
DrawList
->
Type
()
)
case
DRAW_LIB_ITEM_STRUCT_TYPE
:
{
Component2
=
(
EDA_SchComponentStruct
*
)
DrawList
;
case
DRAW_LIB_ITEM_STRUCT_TYPE
:
Component2
=
(
EDA_SchComponentStruct
*
)
DrawList
;
if
(
Component2
->
m_FlagControlMulti
==
1
)
break
;
if
(
Component2
->
m_FlagControlMulti
==
1
)
if
(
Component2
->
m_Field
[
REFERENCE
].
m_Text
.
CmpNoCase
(
break
;
Component
->
m_Field
[
REFERENCE
].
m_Text
)
!=
0
)
break
;
if
(
Component2
->
m_Field
[
REFERENCE
].
m_Text
.
CmpNoCase
(
Component
->
m_Field
[
REFERENCE
].
m_Text
)
!=
0
)
Entry
=
FindLibPart
(
Component2
->
m_ChipName
.
GetData
(),
wxEmptyString
,
FIND_ROOT
);
break
;
if
(
Entry
==
NULL
)
break
;
if
(
Component2
->
m_Field
[
REFERENCE
].
m_Text
[
0
]
==
'#'
)
break
;
Entry
=
FindLibPart
(
Component2
->
m_ChipName
.
GetData
(),
wxEmptyString
,
FIND_ROOT
);
if
(
Entry
==
NULL
)
if
(
Entry
->
m_Drawings
!=
NULL
)
break
;
{
if
(
Component2
->
m_Field
[
REFERENCE
].
m_Text
[
0
]
==
'#'
)
DEntry
=
Entry
->
m_Drawings
;
break
;
for
(
;
DEntry
!=
NULL
;
DEntry
=
DEntry
->
Next
())
{
if
(
Entry
->
m_Drawings
!=
NULL
)
if
(
DEntry
->
Type
()
!=
COMPONENT_PIN_DRAW_TYPE
)
continue
;
{
if
(
DEntry
->
m_Unit
&&
DEntry
=
Entry
->
m_Drawings
;
(
DEntry
->
m_Unit
!=
Component2
->
m_Multi
)
)
continue
;
for
(
;
DEntry
!=
NULL
;
DEntry
=
DEntry
->
Next
()
)
if
(
DEntry
->
m_Convert
&&
{
(
DEntry
->
m_Convert
!=
Component2
->
m_Convert
))
continue
;
if
(
DEntry
->
Type
()
!=
COMPONENT_PIN_DRAW_TYPE
)
{
continue
;
AddPinToComponentPinList
(
Component2
,
(
LibDrawPin
*
)
DEntry
);
if
(
DEntry
->
m_Unit
}
&&
(
DEntry
->
m_Unit
!=
Component2
->
m_Multi
)
)
}
continue
;
}
if
(
DEntry
->
m_Convert
Component2
->
m_FlagControlMulti
=
1
;
&&
(
DEntry
->
m_Convert
!=
Component2
->
m_Convert
)
)
break
;
continue
;
{
default
:
break
;
AddPinToComponentPinList
(
Component2
,
(
LibDrawPin
*
)
DEntry
);
}
}
DrawList
=
DrawList
->
Pnext
;
}
}
}
}
Component2
->
m_FlagControlMulti
=
1
;
break
;
default
:
break
;
}
DrawList
=
DrawList
->
Pnext
;
}
}
}
}
/**************************************************************************/
/**************************************************************************/
static
int
SortPinsByNum
(
ObjetNetListStruct
**
Pin1
,
ObjetNetListStruct
**
Pin2
)
static
int
SortPinsByNum
(
ObjetNetListStruct
**
Pin1
,
ObjetNetListStruct
**
Pin2
)
/**************************************************************************/
/**************************************************************************/
/* Routine de comparaison pour le tri des pins par numero croissant
/* Routine de comparaison pour le tri des pins par numero croissant
du tableau des pins s_SortedComponentPinList par qsort()
*
du tableau des pins s_SortedComponentPinList par qsort()
*/
*/
{
{
ObjetNetListStruct
*
Obj1
,
*
Obj2
;
ObjetNetListStruct
*
Obj1
,
*
Obj2
;
int
Num1
,
Num2
;
int
Num1
,
Num2
;
char
Line
[
5
];
char
Line
[
5
];
Obj1
=
*
Pin1
;
Obj2
=
*
Pin2
;
Obj1
=
*
Pin1
;
Obj2
=
*
Pin2
;
Num1
=
Obj1
->
m_PinNum
;
Num2
=
Obj2
->
m_PinNum
;
Num1
=
Obj1
->
m_PinNum
;
Num2
=
Obj2
->
m_PinNum
;
Line
[
4
]
=
0
;
memcpy
(
Line
,
&
Num1
,
4
);
Num1
=
atoi
(
Line
);
Line
[
4
]
=
0
;
memcpy
(
Line
,
&
Num1
,
4
);
Num1
=
atoi
(
Line
);
memcpy
(
Line
,
&
Num2
,
4
);
Num2
=
atoi
(
Line
);
memcpy
(
Line
,
&
Num2
,
4
);
Num2
=
atoi
(
Line
);
return
(
Num1
-
Num2
)
;
return
Num1
-
Num2
;
}
}
/*************************************************************************/
/*************************************************************************/
static
void
WriteGENERICListOfNets
(
FILE
*
f
,
ObjetNetListStruct
*
ObjNet
)
static
void
WriteGENERICListOfNets
(
FILE
*
f
,
ObjetNetListStruct
*
ObjNet
)
/*************************************************************************/
/*************************************************************************/
/* Ecrit dans le fichier f la liste des nets ( classee par NetCodes ), et des
/* Ecrit dans le fichier f la liste des nets ( classee par NetCodes ), et des
elements qui y sont connectes
*
elements qui y sont connectes
*/
*/
{
{
int
ii
,
jj
;
int
ii
,
jj
;
int
NetCode
,
LastNetCode
=
-
1
;
int
NetCode
,
LastNetCode
=
-
1
;
int
SameNetcodeCount
=
0
;
int
SameNetcodeCount
=
0
;
EDA_SchComponentStruct
*
Cmp
;
EDA_SchComponentStruct
*
Cmp
;
wxString
NetName
,
CmpRef
;
wxString
NetName
,
CmpRef
;
wxString
NetcodeName
;
wxString
NetcodeName
;
char
FirstItemInNet
[
1024
];
char
FirstItemInNet
[
1024
];
for
(
ii
=
0
;
ii
<
g_NbrObjNet
;
ii
++
)
for
(
ii
=
0
;
ii
<
g_NbrObjNet
;
ii
++
)
{
{
if
(
(
NetCode
=
ObjNet
[
ii
].
m_NetCode
)
!=
LastNetCode
)
// New net found, write net id;
if
(
(
NetCode
=
ObjNet
[
ii
].
m_NetCode
)
!=
LastNetCode
)
// New net found, write net id;
{
{
SameNetcodeCount
=
0
;
// Items count for this net
SameNetcodeCount
=
0
;
// Items count for this net
NetName
.
Empty
();
NetName
.
Empty
();
for
(
jj
=
0
;
jj
<
g_NbrObjNet
;
jj
++
)
// Find a label (if exists) for this net
for
(
jj
=
0
;
jj
<
g_NbrObjNet
;
jj
++
)
// Find a label (if exists) for this net
{
{
if
(
ObjNet
[
jj
].
m_NetCode
!=
NetCode
)
continue
;
if
(
ObjNet
[
jj
].
m_NetCode
!=
NetCode
)
if
(
(
ObjNet
[
jj
].
m_Type
!=
NET_GLOBLABEL
)
&&
continue
;
(
ObjNet
[
jj
].
m_Type
!=
NET_LABEL
)
&&
if
(
(
ObjNet
[
jj
].
m_Type
!=
NET_GLOBLABEL
)
(
ObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
)
continue
;
&&
(
ObjNet
[
jj
].
m_Type
!=
NET_LABEL
)
&&
(
ObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
)
NetName
=
*
g_TabObjNet
[
jj
].
m_Label
;
break
;
continue
;
}
NetName
=
*
g_TabObjNet
[
jj
].
m_Label
;
break
;
NetcodeName
.
Printf
(
wxT
(
"Net %d "
),
NetCode
);
}
NetcodeName
+=
wxT
(
"
\"
"
);
if
(
!
NetName
.
IsEmpty
()
)
NetcodeName
.
Printf
(
wxT
(
"Net %d "
),
NetCode
);
{
NetcodeName
+=
wxT
(
"
\"
"
);
NetcodeName
+=
NetName
;
if
(
!
NetName
.
IsEmpty
()
)
if
(
g_TabObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
// usual net name, add it the sheet number
{
NetcodeName
<<
wxT
(
"_"
)
<<
g_TabObjNet
[
jj
].
m_SheetNumber
;
NetcodeName
+=
NetName
;
}
if
(
g_TabObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
// usual net name, add it the sheet number
NetcodeName
+=
wxT
(
"
\"
"
);
NetcodeName
<<
wxT
(
"_"
)
<<
g_TabObjNet
[
jj
].
m_SheetNumber
;
LastNetCode
=
NetCode
;
}
}
NetcodeName
+=
wxT
(
"
\"
"
);
LastNetCode
=
NetCode
;
if
(
ObjNet
[
ii
].
m_Type
!=
NET_PIN
)
continue
;
}
Cmp
=
(
EDA_SchComponentStruct
*
)
ObjNet
[
ii
].
m_Link
;
if
(
ObjNet
[
ii
].
m_Type
!=
NET_PIN
)
CmpRef
=
Cmp
->
m_Field
[
REFERENCE
].
m_Text
;
continue
;
if
(
CmpRef
.
StartsWith
(
wxT
(
"#"
)
)
)
continue
;
// Pseudo component (Like Power symbol)
Cmp
=
(
EDA_SchComponentStruct
*
)
ObjNet
[
ii
].
m_Link
;
// Print the pin list for this net, if 2 or more items are connected:
CmpRef
=
Cmp
->
m_Field
[
REFERENCE
].
m_Text
;
SameNetcodeCount
++
;
if
(
CmpRef
.
StartsWith
(
wxT
(
"#"
)
)
)
if
(
SameNetcodeCount
==
1
)
/* first item for this net found,
continue
;
// Pseudo component (Like Power symbol)
Print this connection, when a second item will be found */
{
// Print the pin list for this net, if 2 or more items are connected:
sprintf
(
FirstItemInNet
,
" %s %.4s
\n
"
,
CONV_TO_UTF8
(
CmpRef
),
SameNetcodeCount
++
;
(
const
char
*
)
&
ObjNet
[
ii
].
m_PinNum
);
if
(
SameNetcodeCount
==
1
)
/* first item for this net found,
}
* Print this connection, when a second item will be found */
if
(
SameNetcodeCount
==
2
)
// Second item for this net found, Print the Net name, and the first item
{
{
sprintf
(
FirstItemInNet
,
" %s %.4s
\n
"
,
CONV_TO_UTF8
(
CmpRef
),
fprintf
(
f
,
"%s
\n
"
,
CONV_TO_UTF8
(
NetcodeName
));
(
const
char
*
)
&
ObjNet
[
ii
].
m_PinNum
);
fputs
(
FirstItemInNet
,
f
);
}
}
if
(
SameNetcodeCount
==
2
)
// Second item for this net found, Print the Net name, and the first item
{
if
(
SameNetcodeCount
>=
2
)
fprintf
(
f
,
"%s
\n
"
,
CONV_TO_UTF8
(
NetcodeName
)
);
fprintf
(
f
,
" %s %.4s
\n
"
,
CONV_TO_UTF8
(
CmpRef
),
fputs
(
FirstItemInNet
,
f
);
(
const
char
*
)
&
ObjNet
[
ii
].
m_PinNum
);
}
}
if
(
SameNetcodeCount
>=
2
)
fprintf
(
f
,
" %s %.4s
\n
"
,
CONV_TO_UTF8
(
CmpRef
),
(
const
char
*
)
&
ObjNet
[
ii
].
m_PinNum
);
}
}
}
/* Generation des netlistes au format CadStar */
/* Generation des netlistes au format CadStar */
wxString
StartLine
(
wxT
(
"."
)
);
wxString
StartLine
(
wxT
(
"."
)
);
/*********************************************************/
/*********************************************************/
static
void
WriteNetListCADSTAR
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
)
static
void
WriteNetListCADSTAR
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
)
/*********************************************************/
/*********************************************************/
/* Routine de generation du fichier netliste ( Format CADSTAR )
/* Routine de generation du fichier netliste ( Format CADSTAR )
Entete:
*
Entete:
..HEA
*
..HEA
..TIM 2004 07 29 16 22 17
*
..TIM 2004 07 29 16 22 17
..APP "Cadstar RINF Output - Version 6.0.2.3"
*
..APP "Cadstar RINF Output - Version 6.0.2.3"
..UNI INCH 1000.0 in
*
..UNI INCH 1000.0 in
..TYP FULL
*
..TYP FULL
*
liste des composants:
*
liste des composants:
..ADD_COM X1 "CNT D41612 (48PTS MC CONTOUR)"
*
..ADD_COM X1 "CNT D41612 (48PTS MC CONTOUR)"
..ADD_COM U2 "74HCT245D" "74HCT245D"
*
..ADD_COM U2 "74HCT245D" "74HCT245D"
*
Connexions:
*
Connexions:
..ADD_TER RR2 6 "$42"
*
..ADD_TER RR2 6 "$42"
..TER U1 100
*
..TER U1 100
CA 6
*
CA 6
*
..ADD_TER U2 6 "$59"
*
..ADD_TER U2 6 "$59"
..TER U7 39
*
..TER U7 39
U6 17
*
U6 17
U1 122
*
U1 122
*
..ADD_TER P2 1 "$9"
*
..ADD_TER P2 1 "$9"
..TER T3 1
*
..TER T3 1
U1 14
*
U1 14
*/
*/
{
{
wxString
StartCmpDesc
=
StartLine
+
wxT
(
"ADD_COM"
);
wxString
StartCmpDesc
=
StartLine
+
wxT
(
"ADD_COM"
);
wxString
msg
;
wxString
msg
;
wxString
FootprintName
;
wxString
FootprintName
;
char
Line
[
1024
];
char
Line
[
1024
];
BASE_SCREEN
*
CurrScreen
;
BASE_SCREEN
*
CurrScreen
;
EDA_BaseStruct
*
DrawList
;
EDA_BaseStruct
*
DrawList
;
EDA_SchComponentStruct
*
Component
;
EDA_SchComponentStruct
*
Component
;
wxString
Title
=
g_Main_Title
+
wxT
(
" "
)
+
GetBuildVersion
();
wxString
Title
=
g_Main_Title
+
wxT
(
" "
)
+
GetBuildVersion
();
fprintf
(
f
,
"%sHEA
\n
"
,
CONV_TO_UTF8
(
StartLine
));
fprintf
(
f
,
"%sHEA
\n
"
,
CONV_TO_UTF8
(
StartLine
)
);
DateAndTime
(
Line
);
DateAndTime
(
Line
);
fprintf
(
f
,
"%sTIM %s
\n
"
,
CONV_TO_UTF8
(
StartLine
),
Line
);
fprintf
(
f
,
"%sTIM %s
\n
"
,
CONV_TO_UTF8
(
StartLine
),
Line
);
fprintf
(
f
,
"%sAPP "
,
CONV_TO_UTF8
(
StartLine
)
);
fprintf
(
f
,
"%sAPP "
,
CONV_TO_UTF8
(
StartLine
)
);
fprintf
(
f
,
"
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
Title
)
);
fprintf
(
f
,
"
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
Title
)
);
fprintf
(
f
,
"
\n
"
);
fprintf
(
f
,
"
\n
"
);
/* Create netlist module section */
/* Create netlist module section */
ClearUsedFlags
(
frame
);
/* Reset the flags FlagControlMulti in all schematic files*/
ClearUsedFlags
(
frame
);
/* Reset the flags FlagControlMulti in all schematic files*/
EDA_ScreenList
ScreenList
(
NULL
);
EDA_ScreenList
ScreenList
(
NULL
);
for
(
CurrScreen
=
ScreenList
.
GetFirst
();
CurrScreen
!=
NULL
;
CurrScreen
=
ScreenList
.
GetNext
()
)
{
for
(
CurrScreen
=
ScreenList
.
GetFirst
();
CurrScreen
!=
NULL
;
CurrScreen
=
ScreenList
.
GetNext
()
)
for
(
DrawList
=
CurrScreen
->
EEDrawList
;
DrawList
!=
NULL
;
DrawList
=
DrawList
->
Pnext
)
{
{
for
(
DrawList
=
CurrScreen
->
EEDrawList
;
DrawList
!=
NULL
;
DrawList
=
DrawList
->
Pnext
)
DrawList
=
Component
=
FindNextComponentAndCreatPinList
(
DrawList
);
{
if
(
Component
==
NULL
)
break
;
DrawList
=
Component
=
FindNextComponentAndCreatPinList
(
DrawList
);
if
(
Component
==
NULL
)
if
(
!
Component
->
m_Field
[
FOOTPRINT
].
IsVoid
()
)
break
;
{
FootprintName
=
Component
->
m_Field
[
FOOTPRINT
].
m_Text
;
if
(
!
Component
->
m_Field
[
FOOTPRINT
].
IsVoid
()
)
FootprintName
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
));
{
}
FootprintName
=
Component
->
m_Field
[
FOOTPRINT
].
m_Text
;
else
FootprintName
=
wxT
(
"$noname"
);
FootprintName
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
}
msg
=
Component
->
m_Field
[
REFERENCE
].
m_Text
;
else
msg
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
));
FootprintName
=
wxT
(
"$noname"
);
fprintf
(
f
,
"%s "
,
CONV_TO_UTF8
(
StartCmpDesc
));
fprintf
(
f
,
"%s"
,
CONV_TO_UTF8
(
msg
));
msg
=
Component
->
m_Field
[
REFERENCE
].
m_Text
;
msg
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
msg
=
Component
->
m_Field
[
VALUE
].
m_Text
;
fprintf
(
f
,
"%s "
,
CONV_TO_UTF8
(
StartCmpDesc
)
);
msg
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
));
fprintf
(
f
,
"%s"
,
CONV_TO_UTF8
(
msg
)
);
fprintf
(
f
,
"
\"
%s
\"
"
,
CONV_TO_UTF8
(
msg
));
fprintf
(
f
,
"
\n
"
);
msg
=
Component
->
m_Field
[
VALUE
].
m_Text
;
msg
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
}
fprintf
(
f
,
"
\"
%s
\"
"
,
CONV_TO_UTF8
(
msg
)
);
}
fprintf
(
f
,
"
\n
"
);
fprintf
(
f
,
"
\n
"
);
}
}
MyFree
(
s_SortedComponentPinList
);
s_SortedComponentPinList
=
NULL
;
fprintf
(
f
,
"
\n
"
);
WriteListOfNetsCADSTAR
(
f
,
g_TabObjNet
);
MyFree
(
s_SortedComponentPinList
);
s_SortedComponentPinList
=
NULL
;
fprintf
(
f
,
"
\n
%sEND
\n
"
,
CONV_TO_UTF8
(
StartLine
)
);
WriteListOfNetsCADSTAR
(
f
,
g_TabObjNet
);
fprintf
(
f
,
"
\n
%sEND
\n
"
,
CONV_TO_UTF8
(
StartLine
)
);
}
}
/*************************************************************************/
/*************************************************************************/
static
void
WriteListOfNetsCADSTAR
(
FILE
*
f
,
ObjetNetListStruct
*
ObjNet
)
static
void
WriteListOfNetsCADSTAR
(
FILE
*
f
,
ObjetNetListStruct
*
ObjNet
)
/*************************************************************************/
/*************************************************************************/
/* Ecrit dans le fichier f la liste des nets ( classee par NetCodes ), et des
/* Ecrit dans le fichier f la liste des nets ( classee par NetCodes ), et des
pins qui y sont connectes
*
pins qui y sont connectes
format:
*
format:
.ADD_TER RR2 6 "$42"
*
.ADD_TER RR2 6 "$42"
.TER U1 100
*
.TER U1 100
CA 6
*
CA 6
*/
*/
{
{
wxString
InitNetDesc
=
StartLine
+
wxT
(
"ADD_TER"
);
wxString
InitNetDesc
=
StartLine
+
wxT
(
"ADD_TER"
);
wxString
StartNetDesc
=
StartLine
+
wxT
(
"TER"
);
wxString
StartNetDesc
=
StartLine
+
wxT
(
"TER"
);
wxString
NetcodeName
,
InitNetDescLine
;
wxString
NetcodeName
,
InitNetDescLine
;
int
ii
,
jj
,
print_ter
=
0
;
int
ii
,
jj
,
print_ter
=
0
;
int
NetCode
,
LastNetCode
=
-
1
;
int
NetCode
,
LastNetCode
=
-
1
;
EDA_SchComponentStruct
*
Cmp
;
EDA_SchComponentStruct
*
Cmp
;
wxString
NetName
;
wxString
NetName
;
for
(
ii
=
0
;
ii
<
g_NbrObjNet
;
ii
++
)
ObjNet
[
ii
].
m_Flag
=
0
;
for
(
ii
=
0
;
ii
<
g_NbrObjNet
;
ii
++
)
ObjNet
[
ii
].
m_Flag
=
0
;
for
(
ii
=
0
;
ii
<
g_NbrObjNet
;
ii
++
)
{
for
(
ii
=
0
;
ii
<
g_NbrObjNet
;
ii
++
)
// Get the NetName of the current net :
{
if
(
(
NetCode
=
ObjNet
[
ii
].
m_NetCode
)
!=
LastNetCode
)
// Get the NetName of the current net :
{
if
(
(
NetCode
=
ObjNet
[
ii
].
m_NetCode
)
!=
LastNetCode
)
NetName
.
Empty
();
{
for
(
jj
=
0
;
jj
<
g_NbrObjNet
;
jj
++
)
NetName
.
Empty
();
{
for
(
jj
=
0
;
jj
<
g_NbrObjNet
;
jj
++
)
if
(
ObjNet
[
jj
].
m_NetCode
!=
NetCode
)
continue
;
{
if
(
(
ObjNet
[
jj
].
m_Type
!=
NET_GLOBLABEL
)
&&
if
(
ObjNet
[
jj
].
m_NetCode
!=
NetCode
)
(
ObjNet
[
jj
].
m_Type
!=
NET_LABEL
)
&&
continue
;
(
ObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
)
continue
;
if
(
(
ObjNet
[
jj
].
m_Type
!=
NET_GLOBLABEL
)
&&
(
ObjNet
[
jj
].
m_Type
!=
NET_LABEL
)
NetName
=
*
ObjNet
[
jj
].
m_Label
;
break
;
&&
(
ObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
)
}
continue
;
NetcodeName
=
wxT
(
"
\"
"
);
if
(
!
NetName
.
IsEmpty
()
)
NetName
=
*
ObjNet
[
jj
].
m_Label
;
break
;
{
}
NetcodeName
+=
NetName
;
if
(
g_TabObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
NetcodeName
=
wxT
(
"
\"
"
);
NetcodeName
<<
wxT
(
"_"
)
<<
g_TabObjNet
[
jj
].
m_SheetNumber
;
if
(
!
NetName
.
IsEmpty
()
)
}
{
else
// this net has no name: create a default name $<net number>
NetcodeName
+=
NetName
;
NetcodeName
<<
wxT
(
"$"
)
<<
NetCode
;
if
(
g_TabObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
NetcodeName
+=
wxT
(
"
\"
"
);
NetcodeName
<<
wxT
(
"_"
)
<<
g_TabObjNet
[
jj
].
m_SheetNumber
;
LastNetCode
=
NetCode
;
}
print_ter
=
0
;
else
// this net has no name: create a default name $<net number>
}
NetcodeName
<<
wxT
(
"$"
)
<<
NetCode
;
NetcodeName
+=
wxT
(
"
\"
"
);
LastNetCode
=
NetCode
;
if
(
ObjNet
[
ii
].
m_Type
!=
NET_PIN
)
continue
;
print_ter
=
0
;
}
if
(
ObjNet
[
ii
].
m_Flag
!=
0
)
continue
;
Cmp
=
(
EDA_SchComponentStruct
*
)
ObjNet
[
ii
].
m_Link
;
if
(
ObjNet
[
ii
].
m_Type
!=
NET_PIN
)
continue
;
if
(
Cmp
->
m_Field
[
REFERENCE
].
m_Text
[
0
]
==
'#'
)
continue
;
// Pseudo composant (symboles d'alims)
if
(
ObjNet
[
ii
].
m_Flag
!=
0
)
continue
;
switch
(
print_ter
)
{
Cmp
=
(
EDA_SchComponentStruct
*
)
ObjNet
[
ii
].
m_Link
;
case
0
:
{
if
(
Cmp
->
m_Field
[
REFERENCE
].
m_Text
[
0
]
==
'#'
)
char
buf
[
5
];
continue
;
// Pseudo composant (symboles d'alims)
wxString
str_pinnum
;
strncpy
(
buf
,
(
char
*
)
&
ObjNet
[
ii
].
m_PinNum
,
4
);
buf
[
4
]
=
0
;
switch
(
print_ter
)
str_pinnum
=
CONV_FROM_UTF8
(
buf
);
{
InitNetDescLine
.
Printf
(
wxT
(
"
\n
%s %s %.4s %s"
),
case
0
:
InitNetDesc
.
GetData
(),
{
Cmp
->
m_Field
[
REFERENCE
].
m_Text
.
GetData
(),
char
buf
[
5
];
str_pinnum
.
GetData
(),
NetcodeName
.
GetData
());
wxString
str_pinnum
;
}
strncpy
(
buf
,
(
char
*
)
&
ObjNet
[
ii
].
m_PinNum
,
4
);
buf
[
4
]
=
0
;
print_ter
++
;
str_pinnum
=
CONV_FROM_UTF8
(
buf
);
break
;
InitNetDescLine
.
Printf
(
wxT
(
"
\n
%s %s %.4s %s"
),
InitNetDesc
.
GetData
(),
case
1
:
Cmp
->
m_Field
[
REFERENCE
].
m_Text
.
GetData
(),
fprintf
(
f
,
"%s
\n
"
,
CONV_TO_UTF8
(
InitNetDescLine
));
str_pinnum
.
GetData
(),
NetcodeName
.
GetData
()
);
fprintf
(
f
,
"%s %s %.4s
\n
"
,
}
CONV_TO_UTF8
(
StartNetDesc
),
print_ter
++
;
CONV_TO_UTF8
(
Cmp
->
m_Field
[
REFERENCE
].
m_Text
),
break
;
(
char
*
)
&
ObjNet
[
ii
].
m_PinNum
);
print_ter
++
;
case
1
:
break
;
fprintf
(
f
,
"%s
\n
"
,
CONV_TO_UTF8
(
InitNetDescLine
)
);
fprintf
(
f
,
"%s %s %.4s
\n
"
,
default
:
CONV_TO_UTF8
(
StartNetDesc
),
fprintf
(
f
,
" %s %.4s
\n
"
,
CONV_TO_UTF8
(
Cmp
->
m_Field
[
REFERENCE
].
m_Text
),
CONV_TO_UTF8
(
Cmp
->
m_Field
[
REFERENCE
].
m_Text
),
(
char
*
)
&
ObjNet
[
ii
].
m_PinNum
);
(
char
*
)
&
ObjNet
[
ii
].
m_PinNum
);
print_ter
++
;
break
;
break
;
}
default
:
ObjNet
[
ii
].
m_Flag
=
1
;
fprintf
(
f
,
" %s %.4s
\n
"
,
// Recherche des pins redondantes et mise a 1 de m_Flag,
CONV_TO_UTF8
(
Cmp
->
m_Field
[
REFERENCE
].
m_Text
),
// pour ne pas generer plusieurs fois la connexion
(
char
*
)
&
ObjNet
[
ii
].
m_PinNum
);
for
(
jj
=
ii
+
1
;
jj
<
g_NbrObjNet
;
jj
++
)
break
;
{
}
if
(
ObjNet
[
jj
].
m_NetCode
!=
NetCode
)
break
;
if
(
ObjNet
[
jj
].
m_Type
!=
NET_PIN
)
continue
;
ObjNet
[
ii
].
m_Flag
=
1
;
EDA_SchComponentStruct
*
tstcmp
=
(
EDA_SchComponentStruct
*
)
ObjNet
[
jj
].
m_Link
;
// Recherche des pins redondantes et mise a 1 de m_Flag,
if
(
Cmp
->
m_Field
[
REFERENCE
].
m_Text
!=
tstcmp
->
m_Field
[
REFERENCE
].
m_Text
)
continue
;
// pour ne pas generer plusieurs fois la connexion
for
(
jj
=
ii
+
1
;
jj
<
g_NbrObjNet
;
jj
++
)
if
(
ObjNet
[
jj
].
m_PinNum
==
ObjNet
[
ii
].
m_PinNum
)
ObjNet
[
jj
].
m_Flag
=
1
;
{
}
if
(
ObjNet
[
jj
].
m_NetCode
!=
NetCode
)
}
break
;
if
(
ObjNet
[
jj
].
m_Type
!=
NET_PIN
)
continue
;
EDA_SchComponentStruct
*
tstcmp
=
(
EDA_SchComponentStruct
*
)
ObjNet
[
jj
].
m_Link
;
if
(
Cmp
->
m_Field
[
REFERENCE
].
m_Text
!=
tstcmp
->
m_Field
[
REFERENCE
].
m_Text
)
continue
;
if
(
ObjNet
[
jj
].
m_PinNum
==
ObjNet
[
ii
].
m_PinNum
)
ObjNet
[
jj
].
m_Flag
=
1
;
}
}
}
}
eeschema/netlist.cpp
View file @
00bda3c9
...
@@ -77,6 +77,8 @@ void ObjetNetListStruct::Show( std::ostream& out, int ndx )
...
@@ -77,6 +77,8 @@ void ObjetNetListStruct::Show( std::ostream& out, int ndx )
if
(
m_Comp
)
if
(
m_Comp
)
m_Comp
->
Show
(
1
,
out
);
m_Comp
->
Show
(
1
,
out
);
else
out
<<
" m_Comp==NULL
\n
"
;
out
<<
"</netItem>
\n
"
;
out
<<
"</netItem>
\n
"
;
}
}
...
@@ -294,7 +296,7 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
...
@@ -294,7 +296,7 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
}
}
#if defined(DEBUG)
#if
0 &&
defined(DEBUG)
std::cout << "after sheet local\n";
std::cout << "after sheet local\n";
dumpNetTable();
dumpNetTable();
#endif
#endif
...
@@ -333,7 +335,7 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
...
@@ -333,7 +335,7 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
}
}
}
}
#if defined(DEBUG)
#if
0 &&
defined(DEBUG)
std::cout << "after sheet global\n";
std::cout << "after sheet global\n";
dumpNetTable();
dumpNetTable();
#endif
#endif
...
@@ -354,7 +356,7 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
...
@@ -354,7 +356,7 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
qsort
(
g_TabObjNet
,
g_NbrObjNet
,
sizeof
(
ObjetNetListStruct
),
TriNetCode
);
qsort
(
g_TabObjNet
,
g_NbrObjNet
,
sizeof
(
ObjetNetListStruct
),
TriNetCode
);
#if defined(DEBUG)
#if
0 &&
defined(DEBUG)
std::cout << "after qsort()\n";
std::cout << "after qsort()\n";
dumpNetTable();
dumpNetTable();
#endif
#endif
...
...
pcbnew/controle.cpp
View file @
00bda3c9
...
@@ -422,7 +422,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay()
...
@@ -422,7 +422,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay()
SetCurItem
(
item
);
SetCurItem
(
item
);
}
}
// If the first item is a pad or moduletext, and the 2nd item is its parent module:
// If the
count is 2, and
first item is a pad or moduletext, and the 2nd item is its parent module:
else
if
(
m_Collector
->
GetCount
()
==
2
&&
else
if
(
m_Collector
->
GetCount
()
==
2
&&
(
(
*
m_Collector
)[
0
]
->
Type
()
==
TYPEPAD
||
(
*
m_Collector
)[
0
]
->
Type
()
==
TYPETEXTEMODULE
)
&&
(
(
*
m_Collector
)[
0
]
->
Type
()
==
TYPEPAD
||
(
*
m_Collector
)[
0
]
->
Type
()
==
TYPETEXTEMODULE
)
&&
(
*
m_Collector
)[
1
]
->
Type
()
==
TYPEMODULE
&&
(
*
m_Collector
)[
0
]
->
GetParent
()
==
(
*
m_Collector
)[
1
]
)
(
*
m_Collector
)[
1
]
->
Type
()
==
TYPEMODULE
&&
(
*
m_Collector
)[
0
]
->
GetParent
()
==
(
*
m_Collector
)[
1
]
)
...
...
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