/* LAYERUSE (LAY) -- Layout Library Layer Usage Report */ /* LAYERUSE (LAY) -- Layoutbibliothek Lagenbelegungsreport */ /* // Copyright (c) 1994-2012 Oliver Bartels F+E, Muenchen // Author: Manfred Baumeister // Changes History: // rl (120427) RELEASED FOR BAE V7.8. // rl (101019) RELEASED FOR BAE V7.6. // rl (091021) RELEASED FOR BAE V7.4. // rl (081014) RELEASED FOR BAE V7.2. // rl (071029) RELEASED FOR BAE V7.0. // rl (060829) RELEASED FOR BAE V6.8. // rl (050906) RELEASED FOR BAE V6.6. // rl (040811) RELEASED FOR BAE V6.4. // rl (030904) RELEASED FOR BAE V6.2. // rl (021209) RELEASED FOR BAE V6.0. // rl (020618) RELEASED FOR BAE V5.4. // rl (010625) RELEASED FOR BAE V5.0. // rl (010526) ENHANCEMENT: // Added trace counts to summary output. // Suppressed output of zero element entries. // rl (010402) ENHANCEMENT: // Added optional parameter settings from bae.ini file. // rl (000509) RELEASED FOR BAE V4.6. // rl (990625) RELEASED FOR BAE V4.4. // rl (980910) RELEASED FOR BAE V4.2. // mb (980712) ENHANCEMENT: // Dynamic multi-language support introduced. // rl (970929) RELEASED FOR BAE V4.0. // mb (960919) RELEASED FOR BAE V3.4. // mb (95) RELEASED FOR BAE V3.2. // mb (94) RELEASED FOR BAE V3.0. // mb (94) ORIGINAL CODING. // // DESCRIPTION // // layeruse is a layout library management utility program for // analyzing layer assignments of selectable DDB file layout // elements. The layer assignment statistics are listed to an // ASCII report file. */ // Includes #include "pop.ulh" // User Language popup utilities #include "lay.ulh" // User Language layout utilities // Disable undo state request #pragma ULCALLERNOUNDO // Messages string ITMUNDEF = M("*** UNDEFINIERT ***","*** UNDEFINED ***"); string REPDONE = M("Lagenbelegungsreport ausgegeben auf Datei '", "Layer Usage Report written to File '"); string REPANALYZE = M("Analyse %s '%s'...","Analyzing %s '%s'..."); string UPRREPCUR = M("Lagenbelegungsreport aktuelles Element ? ", "Current Element Layer Usage Report ? "); string UPRLAYLIB = M("Layout Library Datei ? ", "Layout Library File ? "); string ERRNOLIB = M("Bibliothek enthaelt keine Layout-Elemente!", "Library contains no layout elements!"); string ERRLOAD = M("Fehler beim Laden des Elementes '%s'!", "Error loading element '%s'!"); string FMTLUSHD = M("\n\nLAGENBELEGUNG IN LAYOUT-BIBLIOTHEK '%s':\n\n", "\n\nLAYER USAGE IN LAYOUT LIBRARY '%s':\n\n"); string FMTTOTLAY = M("Anzahl analysierter Layouts.............: %5d\n", "Analyzed Layouts Count.................: %5d\n"); string FMTTOTPRT = M("Anzahl analysierter Bauteile............: %5d\n", "Analyzed Parts Count...................: %5d\n"); string FMTTOTSTK = M("Anzahl analysierter Padstacks...........: %5d\n", "Analyzed Padstacks Count...............: %5d\n"); string FMTTOTPAD = M("Anzahl analysierter Pads................: %5d\n", "Analyzed Pads Count....................: %5d\n"); string FMTLAYHD = M("\nLAGE %d (%s) :\n","\nLAYER %d (%s) :\n"); string FMTREFLAY = M(" Layouts mit Objekten auf Lage.........: %5d\n", " Number of Layouts using Layer........: %5d\n"); string FMTREFPRT = M(" Bauteile mit Objekten auf Lage........: %5d\n", " Number of Parts using Layer..........: %5d\n"); string FMTREFSTK = M(" Padstacks mit Objekten auf Lage.......: %5d\n", " Number of Padstacks using Layer......: %5d\n"); string FMTREFPAD = M(" Pads mit Objekten auf Layer...........: %5d\n", " Number of Pads using Layer...........: %5d\n"); string FMTPADCNT = M(" Anzahl Pads platziert auf Lage........: %5d\n", " Number of Pads placed on Layer.......: %5d\n"); string FMTTEXTCNT = M(" Anzahl Texte platziert auf Lage.......: %5d\n", " Number of Texts placed on Layer......: %5d\n"); string FMTPOLYCNT = M(" Anzahl Polygone platziert auf Lage....: %5d\n", " Number of Polygons placed on Layer...: %5d\n"); string FMTTRCCNT = M(" Anzahl Leiterbahnen platziert auf Lage: %5d\n", " Number of Traces placed on Layer.....: %5d\n"); string FMTSUMPAD = M("\nAnzahl Pads insgesamt platziert.........: %5d\n", "\nTotal Number of Pads placed............: %5d\n"); string FMTSUMTEXT = M("Anzahl Texte insgesamt platziert........: %5d\n", "Total Number of Texts placed...........: %5d\n"); string FMTSUMPOLY = M("Anzahl Polygone insgesamt platziert.....: %5d\n", "Total Number of Polygons placed........: %5d\n"); string FMTSUMTRC = M("Anzahl Leiterbahnen insgesamt platziert.: %5d\n", "Total Number of Traces placed..........: %5d\n"); string FMTLAYER = M("\tLAGE = %d (%s) ;\n","\tLAYER = %d (%s) ;\n"); #define FMTTOPIC " '%s'\n" #define FMTELEMHD "%s '%s':\n" #define FMTUREF " %s '%s':" #define FMTTEXT " TEXT '%s':" #define FMTPOLY " %s :" // INI file parameter name definitions #define PAR_LUSFEXT "LAYUSEFEXT_LAY"// Layer usage output file name ext. // Global definitions #define ITMLAYOUT "LAYOUT" #define ITMPART "PART" #define ITMSTACK "STACK" #define ITMPAD "PAD" #define POLYTYP1 "POLY COPPPAS" // Polygon type passive copper #define POLYTYP2 "POLY KEEPOUT" // Polygon type keep out area #define POLYTYP3 "POLY BRDOUT" // Polygon type board outline #define POLYTYP4 "POLY COPPACT" // Polygon type active copper #define POLYTYP5 "POLY DOCLINE" // Polygon type documentary line #define POLYTYP6 "POLY DOCAREA" // Polygon type documentary area #define POLYTYP7 "POLY COPPFIL" // Polygon type copper fill area #define POLYTYP8 "POLY HTCHCOP" // Polygon type hatched copper area #define POLYTYP9 "POLY SPPAREA" // Polygon type split power plane area string OUTEXT = bae_inistrval(PAR_LUSFEXT,".lus") /* Output file name extension */; // Macro list STRINGS macros /* Macro name list */; int mclasses[] /* Macro plan class list */; int macron = 0 /* Macro count */; // Layer descriptors struct { // Layer descriptor int laynum /* Layer number */; int textcnt /* Texts on this layer count */; int polycnt /* Polygons on this layer count */; int trccnt /* Traces on this layer count */; int padcnt /* Pads on this layer count */; int layrefcnt /* Part reference count */; int prtrefcnt /* Part reference count */; int stkrefcnt /* Stack reference count */; int padrefcnt /* Pad reference count */; int refflag /* Reference flag */; int topiclidx /* Layer topic list index */; } layers[] /* Layer list */; int layern = 0 /* Layer count */; struct { // Topic list descriptor int padn /* Pad count */; STRINGS padl /* Pad name list */; int txtn /* Text count */; STRINGS txtl /* Text list */; } topiclists[] /* Topic list table */; int topiclistn = 0 /* Topic list count */; // Global variables int totlaycnt = 0 /* Total layout count */; int totprtcnt = 0 /* Total part count */; int totstkcnt = 0 /* Total padstack count */; int totpadcnt = 0 /* Total pad count */; // Main program void main() { string jobfname /* Job file name */; string jobename /* Job element name */; int jobclass /* Job class */; string libfile /* Library file */; string ofname /* Output file name */; int ofh /* Output file handle */; int i /* Loop control variable */; // Save current element with verification on request verifysave(); // Get the plan class and file and element name jobclass=bae_planddbclass(); jobfname=bae_planfname(); jobename=bae_planename(); // Select the layout library file if (jobclass!=DDBCLUNDEF && verify(UPRREPCUR,0)) // Set the library file designator to current element libfile=""; else if (bae_askddbfname(libfile,1,UPRLAYLIB)) // Abort error_abort(); // Build the macro list buildmaclist(libfile); // Abort if library is empty if (macron==0) error(ERRNOLIB); // Restore the library file name if (libfile=="") libfile=jobfname; // Build the output file name ofname=convstring(libfile,0)+OUTEXT; // Open the output file ofh=bae_fopen(ofname,1); // Print the layer usage header fprintf(ofh,FMTLUSHD,libfile); // Loop thru the macro list for (i=0;i>1; // Compare entries; test if layer found if ((compres=layer-layers[sidx].laynum)==0) // Layer found return(sidx); // Update the search area if (compres<0) sub=sidx-1; else slb=sidx+1; } // Insert the new entry to the layer list layern++; for (sidx=layern-2;sidx>=slb;sidx--) layers[sidx+1]=layers[sidx]; layers[slb].laynum=layer; layers[slb].textcnt=0; layers[slb].polycnt=0; layers[slb].trccnt=0; layers[slb].padcnt=0; layers[slb].layrefcnt=0; layers[slb].prtrefcnt=0; layers[slb].stkrefcnt=0; layers[slb].padrefcnt=0; layers[slb].refflag=0; layers[slb].topiclidx=topiclistn; topiclists[topiclistn].txtn=0; topiclists[topiclistn].padn=0; topiclistn++; // Return the layer list index return(slb); } void storepadtopic(int tlidx,string padname) /* // Store a pad name to a layer topic list // Parameters : // int tlidx : Topic list index // string padname : Padname */ { int slb /* Search lower boundary */; int sub /* Search upper boundary */; int sidx /* Search index */; int compres /* Compare result */; // Init. the search area variables slb=0; sub=topiclists[tlidx].padn-1; // Loop until search area empty while (slb<=sub) { // Get the search index sidx=(slb+sub)>>1; // Compare entries compres=strcmp(padname,topiclists[tlidx].padl[sidx]); // Test if pad found if (compres==0) // Pad already stored return; // Update the search area if (compres<0) sub=sidx-1; else slb=sidx+1; } // Insert the new entry to the topic table pad list topiclists[tlidx].padn++; for (sidx=topiclists[tlidx].padn-2;sidx>=slb;sidx--) topiclists[tlidx].padl[sidx+1]= topiclists[tlidx].padl[sidx]; topiclists[tlidx].padl[slb]=padname; } void storetexttopic(int tlidx,string textstr) /* // Store a text string to a layer topic list // Parameters : // int tlidx : Topic list index // string textstr : Text string */ { int slb /* Search lower boundary */; int sub /* Search upper boundary */; int sidx /* Search index */; int compres /* Compare result */; // Init. the search area variables slb=0; sub=topiclists[tlidx].txtn-1; // Loop until search area empty while (slb<=sub) { // Get the search index sidx=(slb+sub)>>1; // Compare entries compres=strcmp(textstr,topiclists[tlidx].txtl[sidx]); // Test if text found if (compres==0) // Text already stored return; // Update the search area if (compres<0) sub=sidx-1; else slb=sidx+1; } // Insert the new entry to the topic table text list topiclists[tlidx].txtn++; for (sidx=topiclists[tlidx].txtn-2;sidx>=slb;sidx--) topiclists[tlidx].txtl[sidx+1]= topiclists[tlidx].txtl[sidx]; topiclists[tlidx].txtl[slb]=textstr; } // Data conversion routines string classname() /* // Return value : // class name of the currently loaded element */ { // Get the plan class switch (bae_planddbclass()) { case DDBCLLAY : return(ITMLAYOUT); case DDBCLLPRT : return(ITMPART); case DDBCLLSTK : return(ITMSTACK); case DDBCLLPAD : return(ITMPAD); } // Return the undefined class name return(ITMUNDEF); } string macclassname(int c) /* // Return value : // class name for the given macro class code // Parameters : // int c : Macro class code */ { // Get the plan class switch (c) { case DDBCLLAY : return(ITMLAYOUT); case DDBCLLPRT : return(ITMPART); case DDBCLLSTK : return(ITMSTACK); case DDBCLLPAD : return(ITMPAD); } // Return the undefined class name return(ITMUNDEF); } string polytype(int code) /* // Convert polygon type code to item string // Return value : // polygon type denote string // Parameters : // int code : Polygon type code */ { // Evaluate the code switch (code) { case L_POLYCOPPASS : return(POLYTYP1); case L_POLYKEEPOUT : return(POLYTYP2); case L_POLYBRDOUT : return(POLYTYP3); case L_POLYCOPACT : return(POLYTYP4); case L_POLYDOCLINE : return(POLYTYP5); case L_POLYDOCAREA : return(POLYTYP6); case L_POLYCOPFILL : return(POLYTYP7); case L_POLYHTCHCOP : return(POLYTYP8); case L_POLYSPPAREA : return(POLYTYP9); } // Undefined return(ITMUNDEF); } // User Language program end