2007-09-21 13:23:51 +00:00
|
|
|
|
/*******************************************************/
|
|
|
|
|
/* Module de generation de la Netliste , selon Formats */
|
|
|
|
|
/*******************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
#include "program.h"
|
|
|
|
|
#include "libcmp.h"
|
|
|
|
|
#include "general.h"
|
|
|
|
|
#include "netlist.h"
|
|
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
/* Routines locales */
|
2007-09-21 13:23:51 +00:00
|
|
|
|
static void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, const wxString& FullFileName );
|
|
|
|
|
static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f,
|
|
|
|
|
bool with_pcbnew );
|
|
|
|
|
static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f );
|
|
|
|
|
static void WriteListOfNetsCADSTAR( FILE* f, ObjetNetListStruct* ObjNet );
|
|
|
|
|
static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, bool use_netnames );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-09-21 13:23:51 +00:00
|
|
|
|
static void WriteGENERICListOfNets( FILE* f, ObjetNetListStruct* ObjNet );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
static void AddPinToComponentPinList( SCH_COMPONENT* Component,
|
|
|
|
|
DrawSheetPath* sheet,
|
2007-09-21 13:23:51 +00:00
|
|
|
|
LibDrawPin* PinEntry );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
static void FindOthersUnits( SCH_COMPONENT* Component, DrawSheetPath* Sheet_in);
|
2007-09-21 13:23:51 +00:00
|
|
|
|
static int SortPinsByNum( ObjetNetListStruct** Pin1, ObjetNetListStruct** Pin2 );
|
|
|
|
|
static void EraseDuplicatePins( ObjetNetListStruct** TabPin, int NbrPin );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-09-21 13:23:51 +00:00
|
|
|
|
static void ClearUsedFlags( WinEDA_SchematicFrame* frame );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Variable locales */
|
|
|
|
|
static int s_SortedPinCount;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
static ObjetNetListStruct** s_SortedComponentPinList;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
void WriteNetList( WinEDA_SchematicFrame* frame, const wxString& FileNameNL,
|
|
|
|
|
bool use_netnames )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*******************************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Create the netlist file ( Format is given by g_NetFormat )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* bool use_netnames is used only for Spice netlist
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-09-21 13:23:51 +00:00
|
|
|
|
FILE* f = NULL;
|
|
|
|
|
|
|
|
|
|
if( g_NetFormat < NET_TYPE_CUSTOM1 )
|
|
|
|
|
{
|
|
|
|
|
if( ( f = wxFopen( FileNameNL, wxT( "wt" ) ) ) == NULL )
|
|
|
|
|
{
|
|
|
|
|
wxString msg = _( "Failed to create file " ) + FileNameNL;
|
|
|
|
|
DisplayError( frame, msg );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wxBusyCursor Busy;
|
|
|
|
|
|
|
|
|
|
switch( g_NetFormat )
|
|
|
|
|
{
|
|
|
|
|
case NET_TYPE_PCBNEW:
|
|
|
|
|
WriteNetListPCBNEW( frame, f, TRUE );
|
|
|
|
|
fclose( f );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case NET_TYPE_ORCADPCB2:
|
|
|
|
|
WriteNetListPCBNEW( frame, f, FALSE );
|
|
|
|
|
fclose( f );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case NET_TYPE_CADSTAR:
|
|
|
|
|
WriteNetListCADSTAR( frame, f );
|
|
|
|
|
fclose( f );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case NET_TYPE_SPICE:
|
|
|
|
|
WriteNetListPspice( frame, f, use_netnames );
|
|
|
|
|
fclose( f );
|
|
|
|
|
break;
|
|
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
|
default:
|
|
|
|
|
Write_GENERIC_NetList( frame, FileNameNL );
|
2007-09-21 13:23:51 +00:00
|
|
|
|
break;
|
2007-11-10 14:35:04 +00:00
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
|
static SCH_COMPONENT* FindNextComponentAndCreatPinList(
|
|
|
|
|
EDA_BaseStruct* DrawList, DrawSheetPath* sheet)
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/****************************************************************************/
|
|
|
|
|
|
2007-09-21 13:23:51 +00:00
|
|
|
|
/* 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)
|
2008-03-20 01:50:21 +00:00
|
|
|
|
*
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* alloc memory for s_SortedComponentPinList if s_SortedComponentPinList == NULL
|
|
|
|
|
* Must be deallocated by the user
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
|
SCH_COMPONENT* Component = NULL;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
|
LibEDA_BaseStruct* DEntry;
|
|
|
|
|
|
|
|
|
|
s_SortedPinCount = 0;
|
|
|
|
|
|
|
|
|
|
for( ; DrawList != NULL; DrawList = DrawList->Next() )
|
|
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
|
if( DrawList->Type() != TYPE_SCH_COMPONENT )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
continue;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
Component = (SCH_COMPONENT*) DrawList;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
|
|
|
|
/* already tested ? : */
|
2008-03-20 01:50:21 +00:00
|
|
|
|
bool found = false;
|
|
|
|
|
for(unsigned int i =0; i<Component->m_UsedOnSheets.GetCount(); i++){
|
|
|
|
|
if( Component->m_UsedOnSheets.Item(i) == *sheet ){
|
|
|
|
|
found = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if( found ) continue;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
//if( Component->m_FlagControlMulti == 1 )
|
|
|
|
|
// continue; /* yes */
|
2008-03-20 01:50:21 +00:00
|
|
|
|
// removed because with multiple instances of one schematic
|
|
|
|
|
// (several sheets pointing to 1 screen), this will be erroneously be toggled.
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
|
|
|
|
Entry = FindLibPart( Component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
|
|
|
|
if( Entry == NULL )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* Power symbol and other component which have the reference starting by
|
|
|
|
|
* "#" are not included in netlist (pseudo components) */
|
2008-03-20 01:50:21 +00:00
|
|
|
|
wxString str = Component->GetRef(sheet);
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if( str[0] == '#' )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* Create the pin table for this component */
|
2008-02-12 21:12:46 +00:00
|
|
|
|
int ii = sizeof(ObjetNetListStruct*) * MAXPIN;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
if( s_SortedComponentPinList == NULL )
|
|
|
|
|
s_SortedComponentPinList = (ObjetNetListStruct**) MyMalloc( ii );
|
|
|
|
|
memset( s_SortedComponentPinList, 0, ii );
|
|
|
|
|
|
|
|
|
|
DEntry = Entry->m_Drawings;
|
|
|
|
|
for( ; DEntry != NULL; DEntry = DEntry->Next() )
|
|
|
|
|
{
|
|
|
|
|
if( DEntry->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
|
|
|
|
if( DEntry->m_Unit
|
|
|
|
|
&& (DEntry->m_Unit != Component->m_Multi) )
|
|
|
|
|
continue;
|
|
|
|
|
if( DEntry->m_Convert
|
|
|
|
|
&& (DEntry->m_Convert != Component->m_Convert) )
|
|
|
|
|
continue;
|
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
AddPinToComponentPinList( Component, sheet, (LibDrawPin*) DEntry );
|
2007-09-21 13:23:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
//Component->m_FlagControlMulti = 1;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
Component->m_UsedOnSheets.Add(*sheet);
|
|
|
|
|
|
2007-09-21 13:23:51 +00:00
|
|
|
|
if( Entry->m_UnitCount > 1 )
|
2008-02-12 21:12:46 +00:00
|
|
|
|
FindOthersUnits( Component, sheet);
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
|
|
|
|
/* Tri sur le numero de Pin de TabListePin */
|
|
|
|
|
qsort( s_SortedComponentPinList, s_SortedPinCount, sizeof(ObjetNetListStruct*),
|
|
|
|
|
( int( * ) ( const void*, const void* ) )SortPinsByNum );
|
|
|
|
|
|
|
|
|
|
/* Elimination des Pins redondantes du s_SortedComponentPinList */
|
|
|
|
|
EraseDuplicatePins( s_SortedComponentPinList, s_SortedPinCount );
|
|
|
|
|
|
|
|
|
|
return Component;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**************************************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
static wxString ReturnPinNetName( ObjetNetListStruct* Pin,
|
|
|
|
|
const wxString& DefaultFormatNetname )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**************************************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Return the net name for the pin Pin.
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* Net name is:
|
|
|
|
|
* "?" if pin not connected
|
|
|
|
|
* "netname" for global net (like gnd, vcc ..
|
|
|
|
|
* "netname_sheetnumber" for the usual nets
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
|
int netcode = Pin->GetNet();
|
2007-09-21 13:23:51 +00:00
|
|
|
|
wxString NetName;
|
|
|
|
|
|
2008-01-05 17:30:56 +00:00
|
|
|
|
if( (netcode == 0 ) || ( Pin->m_FlagOfConnection != PAD_CONNECT ) )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
{
|
|
|
|
|
return NetName;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int jj;
|
|
|
|
|
for( jj = 0; jj < g_NbrObjNet; jj++ )
|
|
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
|
if( g_TabObjNet[jj].GetNet() != netcode )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
continue;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if( ( g_TabObjNet[jj].m_Type != NET_HIERLABEL)
|
2007-09-21 13:23:51 +00:00
|
|
|
|
&& ( g_TabObjNet[jj].m_Type != NET_LABEL)
|
2008-03-20 01:50:21 +00:00
|
|
|
|
&& ( g_TabObjNet[jj].m_Type != NET_PINLABEL) )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
NetName = *g_TabObjNet[jj].m_Label;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !NetName.IsEmpty() )
|
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if( g_TabObjNet[jj].m_Type != NET_PINLABEL ){
|
2008-03-20 01:50:21 +00:00
|
|
|
|
NetName = g_TabObjNet[jj].m_SheetList.PathHumanReadable()
|
|
|
|
|
+ NetName;
|
|
|
|
|
}
|
2008-02-12 21:12:46 +00:00
|
|
|
|
//NetName << wxT("_") << g_TabObjNet[jj].m_SheetList.PathHumanReadable();
|
2007-09-21 13:23:51 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NetName.Printf( DefaultFormatNetname.GetData(), netcode );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NetName;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
|
|
|
|
|
const wxString& FullFileName )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/***********************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Create a generic netlist, and call an external netlister
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* to change the netlist syntax and create the file
|
2008-03-20 01:50:21 +00:00
|
|
|
|
* -- does this still work?
|
2007-09-21 13:23:51 +00:00
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-09-21 13:23:51 +00:00
|
|
|
|
wxString Line, FootprintName;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
DrawSheetPath* sheet;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
EDA_BaseStruct* DrawList;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
SCH_COMPONENT* Component;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
wxString netname;
|
|
|
|
|
int ii;
|
|
|
|
|
FILE* tmpfile;
|
|
|
|
|
wxString TmpFullFileName = FullFileName;
|
|
|
|
|
|
|
|
|
|
ChangeFileNameExt( TmpFullFileName, wxT( ".tmp" ) );
|
|
|
|
|
|
|
|
|
|
if( ( tmpfile = wxFopen( TmpFullFileName, wxT( "wt" ) ) ) == NULL )
|
|
|
|
|
{
|
|
|
|
|
wxString msg = _( "Failed to create file " ) + TmpFullFileName;
|
|
|
|
|
DisplayError( frame, msg );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClearUsedFlags( frame ); /* Reset the flags FlagControlMulti in all schematic files*/
|
|
|
|
|
fprintf( tmpfile, "$BeginNetlist\n" );
|
|
|
|
|
|
|
|
|
|
/* Create netlist module section */
|
|
|
|
|
fprintf( tmpfile, "$BeginComponentList\n" );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
EDA_SheetList SheetList( NULL );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
|
|
|
|
|
{
|
|
|
|
|
for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Pnext )
|
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
DrawList = Component = FindNextComponentAndCreatPinList( DrawList, sheet );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
|
2007-09-21 13:23:51 +00:00
|
|
|
|
if( Component == NULL )
|
|
|
|
|
break; // No component left
|
|
|
|
|
|
|
|
|
|
FootprintName.Empty();
|
|
|
|
|
if( !Component->m_Field[FOOTPRINT].IsVoid() )
|
|
|
|
|
{
|
|
|
|
|
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, "Footprint=%s\n", CONV_TO_UTF8( FootprintName ) );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
Line = wxT( "Reference=" ) + Component->GetPath(sheet) + wxT( "\n" );
|
2007-09-21 13:23:51 +00:00
|
|
|
|
Line.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
fprintf( tmpfile, CONV_TO_UTF8( Line ) );
|
|
|
|
|
|
|
|
|
|
Line = Component->m_Field[VALUE].m_Text;
|
|
|
|
|
Line.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
fprintf( tmpfile, "Value=%s\n", CONV_TO_UTF8( Line ) );
|
|
|
|
|
|
|
|
|
|
Line = Component->m_ChipName;
|
|
|
|
|
Line.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
fprintf( tmpfile, "Libref=%s\n", CONV_TO_UTF8( Line ) );
|
|
|
|
|
|
|
|
|
|
// Write pin list:
|
|
|
|
|
fprintf( tmpfile, "$BeginPinList\n" );
|
|
|
|
|
for( ii = 0; ii < s_SortedPinCount; ii++ )
|
|
|
|
|
{
|
|
|
|
|
ObjetNetListStruct* Pin = s_SortedComponentPinList[ii];
|
|
|
|
|
if( !Pin )
|
|
|
|
|
continue;
|
|
|
|
|
netname = ReturnPinNetName( Pin, wxT( "$-%.6d" ) );
|
|
|
|
|
if( netname.IsEmpty() )
|
|
|
|
|
netname = wxT( "?" );
|
|
|
|
|
fprintf( tmpfile, "%.4s=%s\n", (char*) &Pin->m_PinNum,
|
|
|
|
|
CONV_TO_UTF8( netname ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf( tmpfile, "$EndPinList\n" );
|
|
|
|
|
fprintf( tmpfile, "$EndComponent\n" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyFree( s_SortedComponentPinList );
|
|
|
|
|
s_SortedComponentPinList = NULL;
|
|
|
|
|
|
|
|
|
|
fprintf( tmpfile, "$EndComponentList\n" );
|
|
|
|
|
|
|
|
|
|
fprintf( tmpfile, "\n$BeginNets\n" );
|
|
|
|
|
WriteGENERICListOfNets( tmpfile, g_TabObjNet );
|
|
|
|
|
fprintf( tmpfile, "$EndNets\n" );
|
|
|
|
|
fprintf( tmpfile, "\n$EndNetlist\n" );
|
|
|
|
|
fclose( tmpfile );
|
|
|
|
|
|
|
|
|
|
// Call the external module (plug in )
|
|
|
|
|
|
|
|
|
|
if( g_NetListerCommandLine.IsEmpty() )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
wxString CommandFile;
|
|
|
|
|
if( wxIsAbsolutePath( g_NetListerCommandLine ) )
|
|
|
|
|
CommandFile = g_NetListerCommandLine;
|
|
|
|
|
else
|
|
|
|
|
CommandFile = FindKicadFile( g_NetListerCommandLine );
|
|
|
|
|
|
|
|
|
|
CommandFile += wxT( " " ) + TmpFullFileName;
|
|
|
|
|
CommandFile += wxT( " " ) + FullFileName;
|
|
|
|
|
|
|
|
|
|
wxExecute( CommandFile, wxEXEC_SYNC );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
static void ClearUsedFlags( WinEDA_SchematicFrame* frame )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/********************************************************/
|
2008-04-12 18:39:20 +00:00
|
|
|
|
/* Clear flag list, used in netlist generation */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-09-21 13:23:51 +00:00
|
|
|
|
SCH_SCREEN* screen;
|
|
|
|
|
EDA_BaseStruct* DrawList;
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
EDA_ScreenList ScreenList;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
|
|
|
|
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
|
|
|
|
|
{
|
|
|
|
|
DrawList = screen->EEDrawList;
|
|
|
|
|
while( DrawList )
|
|
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
|
if( DrawList->Type() == TYPE_SCH_COMPONENT )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
|
SCH_COMPONENT* Component = (SCH_COMPONENT*) DrawList;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
//Component->m_FlagControlMulti = 0;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
Component->m_UsedOnSheets.Clear();
|
2007-09-21 13:23:51 +00:00
|
|
|
|
}
|
|
|
|
|
DrawList = DrawList->Pnext;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
|
|
|
|
|
bool use_netnames )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Routine de generation du fichier netliste ( Format PSPICE )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* si use_netnames = TRUE
|
|
|
|
|
* les nodes sont identifies par le netname
|
|
|
|
|
* sinon les nodes sont identifies par le netnumber
|
2008-03-20 01:50:21 +00:00
|
|
|
|
*
|
2008-02-12 21:12:46 +00:00
|
|
|
|
* tous les textes graphiques commen<EFBFBD>ant par [.-+]pspice ou [.-+]gnucap
|
|
|
|
|
* sont consid<EFBFBD>r<EFBFBD>s comme des commandes a placer dans la netliste
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* [.-]pspice ou gnucap sont en debut
|
|
|
|
|
+pspice et +gnucap sont en fin de netliste
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-09-21 13:23:51 +00:00
|
|
|
|
char Line[1024];
|
2008-02-28 19:27:25 +00:00
|
|
|
|
DrawSheetPath* sheet;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
EDA_BaseStruct* DrawList;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
SCH_COMPONENT* Component;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
int ii, nbitems;
|
|
|
|
|
wxString text;
|
|
|
|
|
wxArrayString SpiceCommandAtBeginFile, SpiceCommandAtEndFile;
|
|
|
|
|
wxString msg;
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
#define BUFYPOS_LEN 4
|
2007-09-21 13:23:51 +00:00
|
|
|
|
wxChar bufnum[BUFYPOS_LEN + 1];
|
|
|
|
|
|
|
|
|
|
DateAndTime( 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) */
|
|
|
|
|
/* and create text list starting by [+]pspice , or [+]gnucap (simulator commands) */
|
|
|
|
|
bufnum[BUFYPOS_LEN] = 0;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
EDA_SheetList SheetList( NULL );
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Pnext )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
{
|
|
|
|
|
wxChar ident;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
if( DrawList->Type() != TYPE_SCH_TEXT )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
continue;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
#define DRAWTEXT ( (SCH_TEXT*) DrawList )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
text = DRAWTEXT->m_Text; if( text.IsEmpty() )
|
|
|
|
|
continue;
|
|
|
|
|
ident = text.GetChar( 0 );
|
|
|
|
|
if( ident != '.' && ident != '-' && ident != '+' )
|
|
|
|
|
continue;
|
|
|
|
|
text.Remove( 0, 1 ); //Remove the first char.
|
|
|
|
|
text.Remove( 6 ); //text contains 6 char.
|
|
|
|
|
if( ( text == wxT( "pspice" ) ) || ( text == wxT( "gnucap" ) ) )
|
|
|
|
|
{
|
|
|
|
|
/* Put the Y position as an ascii string, for sort by vertical position,
|
|
|
|
|
* using usual sort string by alphabetic value */
|
|
|
|
|
int ypos = DRAWTEXT->m_Pos.y;
|
|
|
|
|
for( ii = 0; ii < BUFYPOS_LEN; ii++ )
|
|
|
|
|
{
|
|
|
|
|
bufnum[BUFYPOS_LEN - 1 - ii] = (ypos & 63) + ' '; ypos >>= 6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
text = DRAWTEXT->m_Text.AfterFirst( ' ' );
|
|
|
|
|
msg.Printf( wxT( "%s %s" ), bufnum, text.GetData() ); // First BUFYPOS_LEN char are the Y position
|
|
|
|
|
if( ident == '+' )
|
|
|
|
|
SpiceCommandAtEndFile.Add( msg );
|
|
|
|
|
else
|
|
|
|
|
SpiceCommandAtBeginFile.Add( msg );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print texts starting by [.-]pspice , ou [.-]gnucap (of course, without the Y position string)*/
|
|
|
|
|
nbitems = SpiceCommandAtBeginFile.GetCount();
|
|
|
|
|
if( nbitems )
|
|
|
|
|
{
|
|
|
|
|
SpiceCommandAtBeginFile.Sort();
|
|
|
|
|
for( ii = 0; ii < nbitems; ii++ )
|
|
|
|
|
{
|
|
|
|
|
SpiceCommandAtBeginFile[ii].Remove( 0, BUFYPOS_LEN );
|
|
|
|
|
SpiceCommandAtBeginFile[ii].Trim( TRUE );
|
|
|
|
|
SpiceCommandAtBeginFile[ii].Trim( FALSE );
|
|
|
|
|
fprintf( f, "%s\n", CONV_TO_UTF8( SpiceCommandAtBeginFile[ii] ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fprintf( f, "\n" );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Create component list */
|
|
|
|
|
ClearUsedFlags( frame ); /* Reset the flags FlagControlMulti in all schematic files*/
|
2008-02-12 21:12:46 +00:00
|
|
|
|
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Pnext )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
DrawList = Component = FindNextComponentAndCreatPinList( DrawList, sheet );
|
2007-09-21 13:23:51 +00:00
|
|
|
|
if( Component == NULL )
|
|
|
|
|
break;
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
fprintf( f, "%s ", CONV_TO_UTF8( Component->GetRef( sheet ) ) );
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
|
|
|
|
// Write pin list:
|
|
|
|
|
for( ii = 0; ii < s_SortedPinCount; ii++ )
|
|
|
|
|
{
|
|
|
|
|
ObjetNetListStruct* Pin = s_SortedComponentPinList[ii];
|
|
|
|
|
if( !Pin )
|
|
|
|
|
continue;
|
|
|
|
|
wxString NetName = ReturnPinNetName( Pin, wxT( "N-%.6d" ) );
|
|
|
|
|
if( NetName.IsEmpty() )
|
|
|
|
|
NetName = wxT( "?" );
|
|
|
|
|
if( use_netnames )
|
|
|
|
|
fprintf( f, " %s", CONV_TO_UTF8( NetName ) );
|
|
|
|
|
else // Use number for net names (with net number = 0 for "GND"
|
|
|
|
|
{
|
|
|
|
|
// NetName = "0" is "GND" net for Spice
|
|
|
|
|
if( NetName == wxT( "0" ) || NetName == wxT( "GND" ) )
|
|
|
|
|
fprintf( f, " 0" );
|
|
|
|
|
else
|
2007-10-13 06:18:44 +00:00
|
|
|
|
fprintf( f, " %d", Pin->GetNet() );
|
2007-09-21 13:23:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf( f, " %s\n", CONV_TO_UTF8( Component->m_Field[VALUE].m_Text ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyFree( s_SortedComponentPinList );
|
|
|
|
|
s_SortedComponentPinList = NULL;
|
|
|
|
|
|
|
|
|
|
/* Print texts starting by [+]pspice , ou [+]gnucap */
|
|
|
|
|
nbitems = SpiceCommandAtEndFile.GetCount();
|
|
|
|
|
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" );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*****************************************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with_pcbnew )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*****************************************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Routine de generation du fichier netliste ( Format ORCAD PCB 2 ameliore )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* si with_pcbnew = FALSE
|
|
|
|
|
* format PCBNEW (OrcadPcb2 + commentaires et liste des nets)
|
|
|
|
|
* si with_pcbnew = FALSE
|
|
|
|
|
* Format ORCADPCB2 strict
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-09-21 13:23:51 +00:00
|
|
|
|
wxString Line, FootprintName;
|
|
|
|
|
char Buf[256];
|
2008-02-28 19:27:25 +00:00
|
|
|
|
DrawSheetPath* sheet;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
EDA_BaseStruct* DrawList;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
SCH_COMPONENT* Component;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
int ii;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
ListComponent* CmpList = NULL;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
int CmpListCount = 0, CmpListSize = 1000;
|
|
|
|
|
|
|
|
|
|
DateAndTime( Buf );
|
|
|
|
|
if( with_pcbnew )
|
|
|
|
|
fprintf( f, "# %s created %s\n(\n", NETLIST_HEAD_STRING, Buf );
|
|
|
|
|
else
|
|
|
|
|
fprintf( f, "( { %s created %s }\n", NETLIST_HEAD_STRING, Buf );
|
|
|
|
|
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
/* Create netlist module section */
|
2007-09-21 13:23:51 +00:00
|
|
|
|
ClearUsedFlags( frame ); /* Reset the flags FlagControlMulti in all schematic files*/
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
EDA_SheetList SheetList( NULL );
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Pnext )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
DrawList = Component = FindNextComponentAndCreatPinList( DrawList, sheet);
|
2007-09-21 13:23:51 +00:00
|
|
|
|
if( Component == NULL )
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* Get the Component FootprintFilter and put the component in CmpList if filter is not void */
|
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
|
if( ( Entry = FindLibPart( Component->m_ChipName.GetData(), wxEmptyString,
|
|
|
|
|
FIND_ROOT ) ) != NULL )
|
|
|
|
|
{
|
|
|
|
|
if( Entry->m_FootprintList.GetCount() != 0 ) /* Put in list */
|
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if( CmpList == NULL ){
|
2008-03-20 01:50:21 +00:00
|
|
|
|
CmpList = (ListComponent*)
|
|
|
|
|
MyZMalloc( sizeof(ListComponent) * CmpListSize );
|
|
|
|
|
}
|
2007-09-21 13:23:51 +00:00
|
|
|
|
if( CmpListCount >= CmpListSize )
|
|
|
|
|
{
|
|
|
|
|
CmpListSize += 1000;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
CmpList = (ListComponent*) realloc(
|
2007-09-21 13:23:51 +00:00
|
|
|
|
CmpList,
|
2008-03-20 01:50:21 +00:00
|
|
|
|
sizeof(ListComponent) * CmpListSize );
|
2007-09-21 13:23:51 +00:00
|
|
|
|
}
|
2008-02-12 21:12:46 +00:00
|
|
|
|
CmpList[CmpListCount].m_Comp = Component;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
strcpy(CmpList[CmpListCount].m_Ref, Component->GetRef( sheet ).mb_str());
|
2007-09-21 13:23:51 +00:00
|
|
|
|
CmpListCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !Component->m_Field[FOOTPRINT].IsVoid() )
|
|
|
|
|
{
|
|
|
|
|
FootprintName = Component->m_Field[FOOTPRINT].m_Text;
|
|
|
|
|
FootprintName.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
FootprintName = wxT( "$noname" );
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
Line = Component->GetRef(sheet);
|
2008-02-12 21:12:46 +00:00
|
|
|
|
fprintf( f, " ( %s %s",
|
|
|
|
|
CONV_TO_UTF8(Component->GetPath(sheet)),
|
2007-09-21 13:23:51 +00:00
|
|
|
|
CONV_TO_UTF8( FootprintName ) );
|
|
|
|
|
fprintf( f, " %s", CONV_TO_UTF8( Line ) );
|
|
|
|
|
|
|
|
|
|
Line = Component->m_Field[VALUE].m_Text;
|
|
|
|
|
Line.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
fprintf( f, " %s", CONV_TO_UTF8( Line ) );
|
|
|
|
|
|
|
|
|
|
if( with_pcbnew ) // Add the lib name for this component
|
|
|
|
|
{
|
|
|
|
|
Line = Component->m_ChipName;
|
|
|
|
|
Line.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
fprintf( f, " {Lib=%s}", CONV_TO_UTF8( Line ) );
|
|
|
|
|
}
|
|
|
|
|
fprintf( f, "\n" );
|
|
|
|
|
|
|
|
|
|
// Write pin list:
|
|
|
|
|
for( ii = 0; ii < s_SortedPinCount; ii++ )
|
|
|
|
|
{
|
|
|
|
|
ObjetNetListStruct* Pin = s_SortedComponentPinList[ii];
|
|
|
|
|
if( !Pin )
|
|
|
|
|
continue;
|
|
|
|
|
wxString netname = ReturnPinNetName( Pin, wxT( "N-%.6d" ) );
|
|
|
|
|
if( netname.IsEmpty() )
|
|
|
|
|
netname = wxT( " ?" );
|
|
|
|
|
fprintf( f, " ( %4.4s %s )\n", (char*) &Pin->m_PinNum,
|
|
|
|
|
CONV_TO_UTF8( netname ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf( f, " )\n" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf( f, ")\n*\n" );
|
|
|
|
|
|
|
|
|
|
MyFree( s_SortedComponentPinList );
|
|
|
|
|
s_SortedComponentPinList = NULL;
|
|
|
|
|
|
|
|
|
|
/* Write the allowed footprint list for each component */
|
|
|
|
|
if( with_pcbnew && CmpList )
|
|
|
|
|
{
|
|
|
|
|
fprintf( f, "{ Allowed footprints by component:\n" );
|
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
|
for( ii = 0; ii < CmpListCount; ii++ )
|
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
Component = CmpList[ii].m_Comp;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
Entry = FindLibPart( Component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
//Line.Printf(_("%s"), CmpList[ii].m_Ref);
|
2008-02-12 21:12:46 +00:00
|
|
|
|
//Line.Replace( wxT( " " ), wxT( "_" ) );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
unsigned int i;
|
|
|
|
|
for(i=0; i<sizeof(CmpList[ii].m_Ref) && CmpList[ii].m_Ref[i]; i++){
|
|
|
|
|
if(CmpList[ii].m_Ref[i] == ' ')
|
|
|
|
|
CmpList[ii].m_Ref[i] = '_';
|
|
|
|
|
}
|
2008-02-12 21:12:46 +00:00
|
|
|
|
fprintf( f, "$component %s\n", CmpList[ii].m_Ref );
|
2007-09-21 13:23:51 +00:00
|
|
|
|
/* Write the footprint list */
|
|
|
|
|
for( unsigned int jj = 0; jj < Entry->m_FootprintList.GetCount(); jj++ )
|
|
|
|
|
{
|
|
|
|
|
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" );
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
|
static void AddPinToComponentPinList( SCH_COMPONENT* Component,
|
|
|
|
|
DrawSheetPath* sheetlist, LibDrawPin* Pin )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*************************************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Add a new pin description in the pin list s_SortedComponentPinList
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* a pin description is a pointer to the corresponding structure
|
|
|
|
|
* created by BuildNetList() in the table g_TabObjNet
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-09-21 13:23:51 +00:00
|
|
|
|
int ii;
|
|
|
|
|
|
|
|
|
|
/* Search the PIN description for Pin in g_TabObjNet*/
|
|
|
|
|
for( ii = 0; ii < g_NbrObjNet; ii++ )
|
|
|
|
|
{
|
|
|
|
|
if( g_TabObjNet[ii].m_Type != NET_PIN )
|
|
|
|
|
continue;
|
|
|
|
|
if( g_TabObjNet[ii].m_Link != Component )
|
|
|
|
|
continue;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
if( g_TabObjNet[ii].m_SheetList != *sheetlist )
|
|
|
|
|
continue;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
if( g_TabObjNet[ii].m_PinNum != Pin->m_PinNum )
|
|
|
|
|
continue;
|
|
|
|
|
{
|
|
|
|
|
s_SortedComponentPinList[s_SortedPinCount] = &g_TabObjNet[ii];
|
|
|
|
|
s_SortedPinCount++;
|
|
|
|
|
if( s_SortedPinCount >= MAXPIN )
|
|
|
|
|
{
|
|
|
|
|
/* Log message for Internal error */
|
|
|
|
|
DisplayError( NULL, wxT( "AddPinToComponentPinList err: MAXPIN reached" ) );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
static void EraseDuplicatePins( ObjetNetListStruct** TabPin, int NbrPin )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**********************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* Routine qui elimine les Pins de meme Numero de la liste des objets
|
|
|
|
|
* (Liste des Pins d'un boitier) passee en entree
|
|
|
|
|
* Ces pins redondantes proviennent des pins (alims... ) communes a plusieurs
|
|
|
|
|
* elements d'un boitier a multiple parts.
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-09-21 13:23:51 +00:00
|
|
|
|
int ii, jj;
|
|
|
|
|
|
|
|
|
|
for( ii = 0; ii < NbrPin - 1; ii++ )
|
|
|
|
|
{
|
|
|
|
|
if( TabPin[ii] == NULL )
|
|
|
|
|
continue; /* Deja supprime */
|
|
|
|
|
if( TabPin[ii]->m_PinNum != TabPin[ii + 1]->m_PinNum )
|
|
|
|
|
continue;
|
|
|
|
|
/* 2 Pins doublees */
|
|
|
|
|
for( jj = ii + 1; jj < NbrPin; jj++ )
|
|
|
|
|
{
|
|
|
|
|
if( TabPin[ii]->m_PinNum != TabPin[jj]->m_PinNum )
|
|
|
|
|
break;
|
|
|
|
|
TabPin[jj] = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
|
static void FindOthersUnits( SCH_COMPONENT* Component_in, DrawSheetPath* Sheet_in)
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**********************************************************************/
|
|
|
|
|
|
|
|
|
|
/* Recherche les autres parts du boitier auquel appartient la part Component,
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* pour les boitiers a parts multiples.
|
|
|
|
|
* Appelle AddPinToComponentPinList() pour classer les pins des parts trouvees
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-09-21 13:23:51 +00:00
|
|
|
|
EDA_BaseStruct* DrawList;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
SCH_COMPONENT* Component2;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
|
LibEDA_BaseStruct* DEntry;
|
2008-02-28 19:27:25 +00:00
|
|
|
|
DrawSheetPath* sheet;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
wxString str;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
EDA_SheetList SheetList( NULL );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
unsigned int i;
|
|
|
|
|
bool found;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
DrawList = sheet->LastDrawList();
|
2007-09-21 13:23:51 +00:00
|
|
|
|
while( DrawList )
|
|
|
|
|
{
|
|
|
|
|
switch( DrawList->Type() )
|
|
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
|
case TYPE_SCH_COMPONENT:
|
|
|
|
|
Component2 = (SCH_COMPONENT*) DrawList;
|
|
|
|
|
|
|
|
|
|
found = false;
|
|
|
|
|
for( i =0; i<Component2->m_UsedOnSheets.GetCount(); i++){
|
|
|
|
|
if( Component2->m_UsedOnSheets.Item(i) == *Sheet_in ){
|
|
|
|
|
found = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if( found ) break;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
//if( Component2->m_FlagControlMulti == 1 ) //has it been used? (on this sheet?)
|
|
|
|
|
// break;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
str = Component2->GetRef(sheet);
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if( str.CmpNoCase( Component_in->GetRef(Sheet_in) ) != 0 )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
Entry = FindLibPart( Component2->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
|
|
|
|
if( Entry == NULL )
|
|
|
|
|
break;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if( str[0] == '#' )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if( Entry->m_Drawings != NULL )
|
|
|
|
|
{
|
|
|
|
|
DEntry = Entry->m_Drawings;
|
|
|
|
|
for( ; DEntry != NULL; DEntry = DEntry->Next() )
|
|
|
|
|
{
|
|
|
|
|
if( DEntry->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
|
|
|
|
if( DEntry->m_Unit
|
|
|
|
|
&& (DEntry->m_Unit != Component2->m_Multi) )
|
|
|
|
|
continue;
|
|
|
|
|
if( DEntry->m_Convert
|
|
|
|
|
&& (DEntry->m_Convert != Component2->m_Convert) )
|
|
|
|
|
continue;
|
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
AddPinToComponentPinList( Component2, sheet, (LibDrawPin*) DEntry );
|
2007-09-21 13:23:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-03-20 01:50:21 +00:00
|
|
|
|
Component2->m_UsedOnSheets.Add(*Sheet_in);
|
|
|
|
|
//Component2->m_FlagControlMulti = 1; //mark it as used..
|
2007-09-21 13:23:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawList = DrawList->Pnext;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
static int SortPinsByNum( ObjetNetListStruct** Pin1, ObjetNetListStruct** Pin2 )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**************************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Routine de comparaison pour le tri des pins par numero croissant
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* du tableau des pins s_SortedComponentPinList par qsort()
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
|
ObjetNetListStruct* Obj1, * Obj2;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
int Num1, Num2;
|
|
|
|
|
char Line[5];
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
Obj1 = *Pin1; Obj2 = *Pin2;
|
|
|
|
|
Num1 = Obj1->m_PinNum; Num2 = Obj2->m_PinNum;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
Line[4] = 0; memcpy( Line, &Num1, 4 ); Num1 = atoi( Line );
|
|
|
|
|
memcpy( Line, &Num2, 4 ); Num2 = atoi( Line );
|
|
|
|
|
return Num1 - Num2;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*************************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
static void WriteGENERICListOfNets( FILE* f, ObjetNetListStruct* ObjNet )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*************************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Ecrit dans le fichier f la liste des nets ( classee par NetCodes ), et des
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* elements qui y sont connectes
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-09-21 13:23:51 +00:00
|
|
|
|
int ii, jj;
|
|
|
|
|
int NetCode, LastNetCode = -1;
|
|
|
|
|
int SameNetcodeCount = 0;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
SCH_COMPONENT* Cmp;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
wxString NetName, CmpRef;
|
|
|
|
|
wxString NetcodeName;
|
|
|
|
|
char FirstItemInNet[1024];
|
|
|
|
|
|
|
|
|
|
for( ii = 0; ii < g_NbrObjNet; ii++ )
|
|
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
|
if( (NetCode = ObjNet[ii].GetNet()) != LastNetCode ) // New net found, write net id;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
{
|
|
|
|
|
SameNetcodeCount = 0; // Items count for this net
|
|
|
|
|
NetName.Empty();
|
|
|
|
|
for( jj = 0; jj < g_NbrObjNet; jj++ ) // Find a label (if exists) for this net
|
|
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
|
if( ObjNet[jj].GetNet() != NetCode )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
continue;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if( ( ObjNet[jj].m_Type != NET_HIERLABEL)
|
2007-09-21 13:23:51 +00:00
|
|
|
|
&& ( ObjNet[jj].m_Type != NET_LABEL)
|
|
|
|
|
&& ( ObjNet[jj].m_Type != NET_PINLABEL) )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
NetName = *g_TabObjNet[jj].m_Label; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetcodeName.Printf( wxT( "Net %d " ), NetCode );
|
|
|
|
|
NetcodeName += wxT( "\"" );
|
|
|
|
|
if( !NetName.IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
NetcodeName += NetName;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
if( g_TabObjNet[jj].m_Type != NET_PINLABEL ){
|
|
|
|
|
// usual net name, add in the sheet path
|
|
|
|
|
NetcodeName = g_TabObjNet[jj].m_SheetList.PathHumanReadable()
|
|
|
|
|
+ NetcodeName;
|
|
|
|
|
//NetcodeName << wxT("_") <<
|
|
|
|
|
// g_TabObjNet[jj].m_SheetList.PathHumanReadable();
|
|
|
|
|
}
|
2007-09-21 13:23:51 +00:00
|
|
|
|
}
|
|
|
|
|
NetcodeName += wxT( "\"" );
|
|
|
|
|
LastNetCode = NetCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( ObjNet[ii].m_Type != NET_PIN )
|
|
|
|
|
continue;
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
Cmp = (SCH_COMPONENT*) ObjNet[ii].m_Link;
|
|
|
|
|
CmpRef = Cmp->GetRef(&ObjNet[ii].m_SheetList); //is this correct?
|
2007-09-21 13:23:51 +00:00
|
|
|
|
if( CmpRef.StartsWith( wxT( "#" ) ) )
|
|
|
|
|
continue; // Pseudo component (Like Power symbol)
|
|
|
|
|
|
|
|
|
|
// Print the pin list for this net, if 2 or more items are connected:
|
|
|
|
|
SameNetcodeCount++;
|
|
|
|
|
if( SameNetcodeCount == 1 ) /* first item for this net found,
|
|
|
|
|
* Print this connection, when a second item will be found */
|
|
|
|
|
{
|
|
|
|
|
sprintf( FirstItemInNet, " %s %.4s\n", CONV_TO_UTF8( CmpRef ),
|
|
|
|
|
(const char*) &ObjNet[ii].m_PinNum );
|
|
|
|
|
}
|
|
|
|
|
if( SameNetcodeCount == 2 ) // Second item for this net found, Print the Net name, and the first item
|
|
|
|
|
{
|
|
|
|
|
fprintf( f, "%s\n", CONV_TO_UTF8( NetcodeName ) );
|
|
|
|
|
fputs( FirstItemInNet, f );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( SameNetcodeCount >= 2 )
|
|
|
|
|
fprintf( f, " %s %.4s\n", CONV_TO_UTF8( CmpRef ),
|
|
|
|
|
(const char*) &ObjNet[ii].m_PinNum );
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Generation des netlistes au format CadStar */
|
2007-09-21 13:23:51 +00:00
|
|
|
|
wxString StartLine( wxT( "." ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
/*********************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*********************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Routine de generation du fichier netliste ( Format CADSTAR )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* Entete:
|
|
|
|
|
* ..HEA
|
|
|
|
|
* ..TIM 2004 07 29 16 22 17
|
|
|
|
|
* ..APP "Cadstar RINF Output - Version 6.0.2.3"
|
|
|
|
|
* ..UNI INCH 1000.0 in
|
|
|
|
|
* ..TYP FULL
|
2008-03-20 01:50:21 +00:00
|
|
|
|
*
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* liste des composants:
|
|
|
|
|
* ..ADD_COM X1 "CNT D41612 (48PTS MC CONTOUR)"
|
|
|
|
|
* ..ADD_COM U2 "74HCT245D" "74HCT245D"
|
2008-03-20 01:50:21 +00:00
|
|
|
|
*
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* Connexions:
|
|
|
|
|
* ..ADD_TER RR2 6 "$42"
|
|
|
|
|
* ..TER U1 100
|
|
|
|
|
* CA 6
|
2008-03-20 01:50:21 +00:00
|
|
|
|
*
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* ..ADD_TER U2 6 "$59"
|
|
|
|
|
* ..TER U7 39
|
|
|
|
|
* U6 17
|
|
|
|
|
* U1 122
|
2008-03-20 01:50:21 +00:00
|
|
|
|
*
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* ..ADD_TER P2 1 "$9"
|
|
|
|
|
* ..TER T3 1
|
|
|
|
|
* U1 14
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-09-21 13:23:51 +00:00
|
|
|
|
wxString StartCmpDesc = StartLine + wxT( "ADD_COM" );
|
|
|
|
|
wxString msg;
|
|
|
|
|
wxString FootprintName;
|
|
|
|
|
char Line[1024];
|
2008-02-28 19:27:25 +00:00
|
|
|
|
DrawSheetPath* sheet;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
EDA_BaseStruct* DrawList;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
SCH_COMPONENT* Component;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
|
|
|
|
|
|
|
|
|
|
fprintf( f, "%sHEA\n", CONV_TO_UTF8( StartLine ) );
|
|
|
|
|
DateAndTime( Line );
|
|
|
|
|
fprintf( f, "%sTIM %s\n", CONV_TO_UTF8( StartLine ), Line );
|
|
|
|
|
fprintf( f, "%sAPP ", CONV_TO_UTF8( StartLine ) );
|
|
|
|
|
fprintf( f, "\"%s\"\n", CONV_TO_UTF8( Title ) );
|
|
|
|
|
fprintf( f, "\n" );
|
|
|
|
|
|
|
|
|
|
/* Create netlist module section */
|
|
|
|
|
ClearUsedFlags( frame ); /* Reset the flags FlagControlMulti in all schematic files*/
|
2008-02-12 21:12:46 +00:00
|
|
|
|
EDA_SheetList SheetList( NULL );
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Pnext )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
DrawList = Component = FindNextComponentAndCreatPinList( DrawList, sheet);
|
2007-09-21 13:23:51 +00:00
|
|
|
|
if( Component == NULL )
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if( !Component->m_Field[FOOTPRINT].IsVoid() )
|
|
|
|
|
{
|
|
|
|
|
FootprintName = Component->m_Field[FOOTPRINT].m_Text;
|
|
|
|
|
FootprintName.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
FootprintName = wxT( "$noname" );
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
msg = Component->GetRef(sheet);
|
2007-09-21 13:23:51 +00:00
|
|
|
|
fprintf( f, "%s ", CONV_TO_UTF8( StartCmpDesc ) );
|
|
|
|
|
fprintf( f, "%s", CONV_TO_UTF8( msg ) );
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
WriteListOfNetsCADSTAR( f, g_TabObjNet );
|
|
|
|
|
|
|
|
|
|
fprintf( f, "\n%sEND\n", CONV_TO_UTF8( StartLine ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*************************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
static void WriteListOfNetsCADSTAR( FILE* f, ObjetNetListStruct* ObjNet )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*************************************************************************/
|
2007-09-21 13:23:51 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Ecrit dans le fichier f la liste des nets ( classee par NetCodes ), et des
|
2007-09-21 13:23:51 +00:00
|
|
|
|
* pins qui y sont connectes
|
|
|
|
|
* format:
|
|
|
|
|
* .ADD_TER RR2 6 "$42"
|
|
|
|
|
* .TER U1 100
|
|
|
|
|
* CA 6
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-09-21 13:23:51 +00:00
|
|
|
|
wxString InitNetDesc = StartLine + wxT( "ADD_TER" );
|
|
|
|
|
wxString StartNetDesc = StartLine + wxT( "TER" );
|
|
|
|
|
wxString NetcodeName, InitNetDescLine;
|
|
|
|
|
int ii, jj, print_ter = 0;
|
|
|
|
|
int NetCode, LastNetCode = -1;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
SCH_COMPONENT* Cmp;
|
2007-09-21 13:23:51 +00:00
|
|
|
|
wxString NetName;
|
|
|
|
|
|
|
|
|
|
for( ii = 0; ii < g_NbrObjNet; ii++ )
|
|
|
|
|
ObjNet[ii].m_Flag = 0;
|
|
|
|
|
|
|
|
|
|
for( ii = 0; ii < g_NbrObjNet; ii++ )
|
|
|
|
|
{
|
|
|
|
|
// Get the NetName of the current net :
|
2007-10-13 06:18:44 +00:00
|
|
|
|
if( (NetCode = ObjNet[ii].GetNet()) != LastNetCode )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
{
|
|
|
|
|
NetName.Empty();
|
|
|
|
|
for( jj = 0; jj < g_NbrObjNet; jj++ )
|
|
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
|
if( ObjNet[jj].GetNet() != NetCode )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
continue;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if( ( ObjNet[jj].m_Type != NET_HIERLABEL)
|
2007-09-21 13:23:51 +00:00
|
|
|
|
&& ( ObjNet[jj].m_Type != NET_LABEL)
|
|
|
|
|
&& ( ObjNet[jj].m_Type != NET_PINLABEL) )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
NetName = *ObjNet[jj].m_Label; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetcodeName = wxT( "\"" );
|
|
|
|
|
if( !NetName.IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
NetcodeName += NetName;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if( g_TabObjNet[jj].m_Type != NET_PINLABEL ){
|
2008-03-20 01:50:21 +00:00
|
|
|
|
NetcodeName = g_TabObjNet[jj].m_SheetList.PathHumanReadable()
|
|
|
|
|
+ NetcodeName;
|
|
|
|
|
//NetcodeName << wxT("_") <<
|
|
|
|
|
// g_TabObjNet[jj].m_SheetList.PathHumanReadable();
|
|
|
|
|
}
|
2007-09-21 13:23:51 +00:00
|
|
|
|
}
|
|
|
|
|
else // this net has no name: create a default name $<net number>
|
|
|
|
|
NetcodeName << wxT( "$" ) << NetCode;
|
|
|
|
|
NetcodeName += wxT( "\"" );
|
|
|
|
|
LastNetCode = NetCode;
|
|
|
|
|
print_ter = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( ObjNet[ii].m_Type != NET_PIN )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if( ObjNet[ii].m_Flag != 0 )
|
|
|
|
|
continue;
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
Cmp = (SCH_COMPONENT*) ObjNet[ii].m_Link;
|
|
|
|
|
wxString refstr = Cmp->GetRef(&(ObjNet[ii].m_SheetList));
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if( refstr[0] == '#' )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
continue; // Pseudo composant (symboles d'alims)
|
|
|
|
|
|
|
|
|
|
switch( print_ter )
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
{
|
|
|
|
|
char buf[5];
|
|
|
|
|
wxString str_pinnum;
|
|
|
|
|
strncpy( buf, (char*) &ObjNet[ii].m_PinNum, 4 ); buf[4] = 0;
|
|
|
|
|
str_pinnum = CONV_FROM_UTF8( buf );
|
|
|
|
|
InitNetDescLine.Printf( wxT( "\n%s %s %.4s %s" ),
|
|
|
|
|
InitNetDesc.GetData(),
|
2008-02-12 21:12:46 +00:00
|
|
|
|
refstr.GetData(),
|
2007-09-21 13:23:51 +00:00
|
|
|
|
str_pinnum.GetData(), NetcodeName.GetData() );
|
|
|
|
|
}
|
|
|
|
|
print_ter++;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
fprintf( f, "%s\n", CONV_TO_UTF8( InitNetDescLine ) );
|
|
|
|
|
fprintf( f, "%s %s %.4s\n",
|
|
|
|
|
CONV_TO_UTF8( StartNetDesc ),
|
2008-02-12 21:12:46 +00:00
|
|
|
|
CONV_TO_UTF8( refstr ),
|
2007-09-21 13:23:51 +00:00
|
|
|
|
(char*) &ObjNet[ii].m_PinNum );
|
|
|
|
|
print_ter++;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
fprintf( f, " %s %.4s\n",
|
2008-02-12 21:12:46 +00:00
|
|
|
|
CONV_TO_UTF8( refstr ),
|
2007-09-21 13:23:51 +00:00
|
|
|
|
(char*) &ObjNet[ii].m_PinNum );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ObjNet[ii].m_Flag = 1;
|
|
|
|
|
|
|
|
|
|
// Recherche des pins redondantes et mise a 1 de m_Flag,
|
|
|
|
|
// pour ne pas generer plusieurs fois la connexion
|
|
|
|
|
for( jj = ii + 1; jj < g_NbrObjNet; jj++ )
|
|
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
|
if( ObjNet[jj].GetNet() != NetCode )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
break;
|
|
|
|
|
if( ObjNet[jj].m_Type != NET_PIN )
|
|
|
|
|
continue;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
SCH_COMPONENT* tstcmp =
|
|
|
|
|
(SCH_COMPONENT*) ObjNet[jj].m_Link;
|
|
|
|
|
wxString p = Cmp->GetPath( &( ObjNet[ii].m_SheetList ) );
|
|
|
|
|
wxString tstp = tstcmp->GetPath( &( ObjNet[jj].m_SheetList ) );
|
|
|
|
|
if( p.Cmp(tstp) != 0 )
|
2007-09-21 13:23:51 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if( ObjNet[jj].m_PinNum == ObjNet[ii].m_PinNum )
|
|
|
|
|
ObjNet[jj].m_Flag = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|