Commit c0d39da5 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

New netlist format: Cvpcb: code cleaning. Pcbew: minor enhancements

parent 72ab5174
Loading
Loading
Loading
Loading
+0 −41
Original line number Diff line number Diff line
@@ -9,53 +9,12 @@
#include <footprint_info.h>


PIN::PIN()
{
    m_Index = 0;         /* Variable used by types of netlists. */
    m_Type = 0;          /* Electrical type. */
}


bool operator<( const PIN& item1, const PIN& item2 )
{
    return StrNumCmp( item1.m_Number, item2.m_Number, 4, true ) < 0;
}


bool operator==( const PIN& item1, const PIN& item2 )
{
    return ( item1.m_Number == item2.m_Number );
}


bool same_pin_number( const PIN* item1, const PIN* item2 )
{
    wxASSERT( item1 != NULL && item2 != NULL );

    return ( item1->m_Number == item2->m_Number );
}


bool same_pin_net( const PIN* item1, const PIN* item2 )
{
    wxASSERT( item1 != NULL && item2 != NULL );

    return ( item1->m_Net == item2->m_Net );
}


COMPONENT::COMPONENT()
{
    m_Num = 0;
    m_Multi = 0;
}


COMPONENT::~COMPONENT()
{
}


bool operator<( const COMPONENT& item1, const COMPONENT& item2 )
{
    return StrNumCmp( item1.m_Reference, item2.m_Reference, INT_MAX, true ) < 0;
+12 −26
Original line number Diff line number Diff line
@@ -22,14 +22,12 @@
class PIN
{
public:
    int       m_Index;     /* Type of net list. */
    int       m_Type;      /* Electrical connection type. */
    wxString  m_Net;       /* Name of net. */
    wxString  m_Number;
    wxString  m_Name;
    wxString  m_Repere;    /* Formats used by net lister. */

    PIN();
    PIN() {};
    ~PIN() {};
};

typedef boost::ptr_vector< PIN > PIN_LIST;
@@ -37,29 +35,19 @@ typedef boost::ptr_vector< PIN > PIN_LIST;
/* PIN object list sort function. */
extern bool operator<( const PIN& item1, const PIN& item2 );

/* PIN uniqueness test function. */
extern bool operator==( const PIN& item1, const PIN& item2 );

extern bool same_pin_number( const PIN* item1, const PIN* item2 );
extern bool same_pin_net( const PIN* item1, const PIN* item2 );


class COMPONENT
{
public:
    int           m_Num;       /* Component number. */
    int           m_Multi;     /* Part if component has multiple parts. */
    PIN_LIST      m_Pins;      /* List of component pins. */
    wxString      m_Reference; /* Reference designator: U3, R5  ... */
    wxString      m_Value;     /* Value: 7400, 47K ... */
    wxString      m_TimeStamp; /* Time stamp ("00000000" if absent) */
    wxString      m_Module;    /* Footprint (module) name. */
    wxString      m_Repere;    /* Net list format */
    wxArrayString m_FootprintFilter;  /* List of allowed footprints (wildcards
                                       * allowed ). If empty: no filtering */

    COMPONENT();
    ~COMPONENT();
    wxString      m_Reference;      // Reference designator: U3, R5
    wxString      m_Value;          // Value: 7400, 47K
    wxString      m_TimeStamp;      // Time stamp ( default value = "00000000")
    wxString      m_Module;         // Footprint (module) name.
    wxArrayString m_FootprintFilter;// List of allowed footprints (wildcards
                                    // allowed ). If empty: no filtering
    PIN_LIST      m_Pins;           // List of component pins.

    COMPONENT() {};
    ~COMPONENT() {};
};

typedef boost::ptr_vector< COMPONENT > COMPONENT_LIST;
@@ -77,6 +65,4 @@ extern const wxString FootprintAliasFileWildcard;

extern const wxString titleLibLoadError;

void Plume( int state );

#endif /* __CVPCB_H__ */
+2 −18
Original line number Diff line number Diff line
@@ -16,9 +16,6 @@
#include <richio.h>


#define SEPARATEUR '|'  /* Separator character in NetList */


static int ReadPinConnection( FILE_LINE_READER& aNetlistReader, COMPONENT* CurrentCmp );
static int ReadFootprintFilterList( FILE_LINE_READER& aNetlistReader, COMPONENT_LIST& aComponentsList );

@@ -83,8 +80,7 @@ static int ReadFootprintFilterList( FILE_LINE_READER& aNetlistReader, COMPONENT_
 */
int CVPCB_MAINFRAME::ReadSchematicNetlist()
{
    char       alim[1024];
    int        idx, jj, k, l;
    int        idx, jj, k;
    char       cbuffer[BUFFER_CHAR_SIZE];      /* temporary storage */
    char*      ptchar;
    COMPONENT* Cmp;
@@ -203,8 +199,6 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()

        for( jj = 0; idx < k; idx++ )
        {
            if( Line[idx] == SEPARATEUR )
                break;
            cbuffer[jj++] = Line[idx];
        }
        cbuffer[jj] = 0;
@@ -212,15 +206,6 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
        if( m_isEESchemaNetlist &&  strnicmp( cbuffer, "$noname", 7 ) != 0 )
            Cmp->m_Module = FROM_UTF8(cbuffer);

        if( (Line[++idx] == '(') && (Line[k - 1] == ')' ) )
        {
            idx++; l = 0;
            while( k - 1 > idx )
                alim[l++] = Line[idx++];
        }
        else
            idx = k;

        /* Search component reference */
        while( Line[idx] != ' ' && Line[idx] )
            idx++;
@@ -243,8 +228,7 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
        while( Line[idx] == ' ' && Line[idx] )
            idx++;

        /** goto beginning of value */

        // goto beginning of value
        for( jj = 0 ; ; idx++ )
        {
            if( (Line[idx] == ' ') || (Line[idx] == '\n') || (Line[idx] == '\r') || Line[idx] == 0)
+0 −43
Original line number Diff line number Diff line
@@ -15,48 +15,6 @@

static void WriteFootprintFilterInfos( FILE* dest, COMPONENT_LIST& list );


static void RemoveDuplicatePins( COMPONENT& component )
{
    PIN_LIST::iterator i;
    PIN *pin1, *pin2;
    wxString msg;

    if( component.m_Pins.size() <= 1 )
        return;

    i = component.m_Pins.begin();
    pin1 = &(*i);
    ++i;

    while( i != component.m_Pins.end() )
    {
        pin2 = &(*i);

        wxASSERT( pin2 != NULL );

        if( !same_pin_number( pin1, pin2 ) )
        {
            pin1 = pin2;
            ++i;
            continue;
        }

        if( !same_pin_net( pin1, pin2 ) )
        {
            msg.Printf( _( "Component %s %s pin %s : Different Nets" ),
                        GetChars( component.m_Reference ),
                        GetChars( component.m_Value ),
                        pin1->m_Number.GetData() );
            DisplayError( NULL, msg, 60 );
        }
        pin1 = pin2;
        i = component.m_Pins.erase( i );
        delete pin2;
    }
}


/**
 * Create KiCad net list file.
 *
@@ -88,7 +46,6 @@ int CVPCB_MAINFRAME::GenNetlistPcbnew( FILE* file,bool isEESchemaNetlist )
        fprintf( file, "%s\n", TO_UTF8( component.m_Value ) );

        component.m_Pins.sort();
        RemoveDuplicatePins( component );

        BOOST_FOREACH( PIN& pin, component.m_Pins )
        {
+7 −0
Original line number Diff line number Diff line
@@ -166,6 +166,7 @@ bool PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFullFilename,
    netList_Reader.m_UseTimeStamp     = aSelect_By_Timestamp;
    netList_Reader.m_ChangeFootprints = aChangeFootprint;
    netList_Reader.m_UseCmpFile = useCmpfile;
    netList_Reader.ReadFootprintFilterSetOpt( true );
    netList_Reader.SetFilesnames( aNetlistFullFilename, aCmpFullFileName );

    bool success = netList_Reader.ReadNetList( netfile );
@@ -277,6 +278,9 @@ bool NETLIST_READER::InitializeModules()
        readModuleComponentLinkfile();
    }

    if( m_pcbframe == NULL )
        return true;

    for( unsigned ii = 0; ii < m_modulesInNetlist.size(); ii++ )
    {
        MODULE_INFO* currmod_info = m_modulesInNetlist[ii];
@@ -326,6 +330,9 @@ bool NETLIST_READER::InitializeModules()

void NETLIST_READER::TestFootprintsMatchingAndExchange()
{
    if( m_pcbframe == NULL )
        return;

    for( MODULE* module = m_pcbframe->GetBoard()->m_Modules; module; module = module->Next() )
    {
        // Search for the corresponding module info
Loading