/* PSTKDRL (LAY) -- Padstack/Drill Definition Report */ /* PSTKDRL (LAY) -- Padstack-/Bohrdefinitionsreport */ /* // Copyright (c) 1993-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 (091214) ENHANCEMENT: // Added drill radius oriented list to output. // rl (091021) RELEASED FOR BAE V7.4. // rl (081014) RELEASED FOR BAE V7.2. // rl (071029) RELEASED FOR BAE V7.0. // rl (061108) ENHANCEMENT: // Added class information to output. // 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 (000509) RELEASED FOR BAE V4.6. // rl (990625) RELEASED FOR BAE V4.4. // rl (980910) RELEASED FOR BAE V4.2. // mb (980711) ENHANCEMENT: // Dynamic multi-language support introduced. // rl (970929) RELEASED FOR BAE V4.0. // mb (970611) CHANGE: // Applied new UL system function ddbcheck wherever // appropriate. // mb (960919) RELEASED FOR BAE V3.4. // mb (951012) CHANGE: // Skipped fileout() option/function (which was obsolete // due to (Dump) option in popup menu display). // mb (95) RELEASED FOR BAE V3.2. // mb (941129) IMPROVEMENT: // Alternatively select output mode for screen popup or // file output (instead of file output only). // Re-load original element. // mb (94) RELEASED FOR BAE V3.0. // mb (93) RELEASED FOR BAE V2.6. // mb (93) ORIGINAL CODING. // // DESCRIPTION // // The pstkdrl User Language program produces the list of // the padstack and/or drill holes defined in a selectable // DDB file. The output is directed to a popup menu with // file output option. */ // Includes #include "lay.ulh" // User Language layout utilities #include "pop.ulh" // User Language popup utilities // Disable undo state request #pragma ULCALLERNOUNDO // Messages string UPRFEXIT = M_UPRFEXIT(); string UPRLIB = M("Bibliotheks-Datei ? ","Library File ? "); string REPLSTINC = M("-- Auflistung abgebrochen/unvollstaendig! --", "-- Listing aborted/incomplete! --"); string ERRLOAD = M("Fehler beim Laden von Padstack '%s'!", "Error loading padstack '%s'!"); string FMTHEAD = M("Padstacks in Bibliothek '%s' :", "Padstacks in Library '%s' :"); string FMTSTACK = M("Padstack '%s':","Padstack '%s':"); string FMTDRILL = M(" Bohrung %.2f mm, Klasse '%c'", " Drill %.2f mm, Class '%c'"); string FMTMDRILL = M(" Bohrung %.2f mm, Klasse '%c', Spiegelbohrklasse '%c'", " Drill %.2f mm, Class '%c', Mirror Class '%c'"); string FMTDHEAD = M("Bohrdurchmesser in Bibliothek '%s' :", "Drill diameters in Library '%s' :"); string FMTDRLRAD = M("Bohrung %.2f mm Klasse '%c':", "Drill %.2fmm, Class '%c':"); string FMTMDRLRAD = M("Bohrung %.2f mm Klasse '%c', Spiegelbohrklasse '%c':", "Drill %.2fmm, Class '%c', Mirror Class '%c':"); string FMTDRLSTK = M(" Padstack '%s'"," Padstack '%s'"); string FMTDRLPART = M(" Bauteil '%s'"," Part '%s'"); string FMTDRLLAY = M(" Layout '%s'"," Layout '%s'"); string ERRDDBACC = M("Zugriff auf DDB-Datei '%s' fehlgeschlagen!", "Error accessing DDB file '%s'!"); // Globals #define SMALLVAL 0.00000001 // Small compare value STRINGS headl /* Header list */; int headn = 2 /* Header count */; STRINGS entryl /* Entry list */; int entryn = 0 /* Entry count */; int rows = 100 /* Rows count */; int cols = 60 /* Columns count */; struct drillraddes { // Drill radius descriptor double rad /* Drill radius */; int class /* Drill class */; string stkl[] /* Drill padstack list */; int stkn /* Drill padstack count */; } drrl[] /* Drill radius list */; int drn = 0 /* Drill radius count */; string curstk /* Currently scanned padstack name */; int scanclass /* Currently scanned class */; string libname /* Library name */; int abort = 0 /* Abort flag */; // Main program void main() { int jobclass /* Current job DDB class */; string jobfname /* Current job file name */; string jobename /* Current job element name */; string namebuf /* (Padstack) name buffer */; index L_DRILL drl /* Drill index */; double rad /* Current drill radius */; int class /* Current drill class */; int dridx /* Current drill radius index */; int i /* Loop control variable */; // Save current element with verification on request verifysave(); // Get the current job class, file and element name if ((jobclass=bae_planddbclass())!=DDBCLUNDEF) { jobfname=bae_planfname(); jobename=bae_planename(); } // Select the library file if ((libname=askddbfile(UPRLIB,DDBCLLSTK))=="") error_abort(); // Abort on DDB file access failure if (ddbcheck(libname,DDBCLUNDEF,"")) errormsg(ERRDDBACC,libname); // Print the output header sprintf(headl[0],FMTHEAD,libname); headl[1]=" "; headn=2; // Scan all library padstacks namebuf=""; while (scanddbenames(libname,DDBCLLSTK,namebuf)==1) { // Load padstack bae_setintpar(22,1); if (bae_loadelem(libname,namebuf,DDBCLLSTK)==(-1)) { // Flush scan cache scanddbenames(libname,0,""); errormsg(ERRLOAD,namebuf); } // Print padstack name sprintf(entryl[entryn],FMTSTACK,namebuf); entryn++; // Loop for all padstack drills forall (drl) { class=drl.CLASS; rad=drl.RAD; // Print drill diameter if (class&DRLCMIRR) sprintf(entryl[entryn],FMTMDRILL, cvtlength(2.0*rad,0,2), (class&DRLCMASK1) ? 'a'-1+ (class&DRLCMASK1) : '-', ((class&DRLCMASK2)>>DRLCSHFT2) ? 'a'-1+ ((class&DRLCMASK2)>>DRLCSHFT2) : '-'); else sprintf(entryl[entryn],FMTDRILL, cvtlength(2.0*rad,0,2), (class&DRLCMASK1) ? 'a'-1+ (class&DRLCMASK1) : '-'); entryn++; // Get or create drill radius entry if ((dridx=gcdrillrad(class,rad))<0) err_intern("drillscan"); drrl[dridx].stkl[drrl[dridx].stkn]=namebuf; drrl[dridx].stkn++; } } // Build drill list entryl[entryn++]=""; entryl[entryn++]=""; sprintf(entryl[entryn],FMTDHEAD,libname); entryn++; entryl[entryn++]=""; for (dridx=0;dridx>DRLCSHFT2) ? 'a'-1+ ((class&DRLCMASK2)>>DRLCSHFT2) : '-'); else sprintf(entryl[entryn],FMTDRLRAD,cvtlength(2.0*rad,0,2), (class&DRLCMASK1) ? 'a'-1+(class&DRLCMASK1) : '-'); entryn++; for (i=0;i=0) { // Drill radius found; return the tool index return(dridx); } // Insert new drill radius at insert position for (dridx=drn;dridx>insidx;dridx--) drrl[dridx]=drrl[dridx-1]; drrl[dridx].rad=rad; drrl[dridx].class=class; drrl[dridx].stkn=0; drn++; // Return the new drill radius insert index return(insidx); } int finddrillrad(int class,double rad,int insidx=(-1)) /* // Find drill with given class and radius in sorted drill radius list // Return value : // drill radius list insertion point // Parameters : // int class : Drill class // double rad : Drill radius // int insidx=(-1) : Drill radius list insertion index */ { int slb = 0 /* Search lower boundary */; int sub = drn-1 /* Search upper boundary */; int sidx /* Search index */; int compres /* Compare result */; // Loop until search area empty while (slb<=sub) { // Get the search index sidx=(slb+sub)>>1; // Compare drill radius values if (rad==drrl[sidx].rad) { // Compare drill classes if (class==drrl[sidx].class) { // Drill radius found return(sidx); } else { // Lower class first compres=class