1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
|
#usage "<b>RUN Library statistics</b>\n"
"<p>"
"<author>Author: support@cadsoft.de</author>"
string Revision = "1.01"; // 2005.11.15 alf@cadsoft.de
string src_dev[];
string src_pac[];
string src_sym[];
string src_tec[];
string src_var[];
int cnt_variant[];
string srt_dev[];
string srt_pac[];
string srt_sym[];
string srt_tec[];
string srt_var[];
string srt_drills[];
int index_dev[];
int index_pac[];
int index_sym[];
int index_tec[];
int index_var[];
int index_dril[];
int drills[];
int cntdril[];
int cntdev = 0;
int cntpac = 0;
int cntsym = 0;
int cnttec = 0;
int cntvar = 0;
int cntdrills = 0;
int used_pac[];
int used_sym[];
string unUsed_pac[];
string unUsed_sym[];
string usedlabel = " ";
string used[] = { "used in Devices\tcnt" };
int cntclearused = 0; // Error in dlgListView,
// clear all strings in array befor use dlgListView
// if used a second time less string entry
int cntUnUsed_pac = 0;
int cntUnUsed_sym = 0;
int us, up;
string PackInfo = " \n \n \n ";
string SymbolInfo = " \n \n";
string used_layers[] = {"" };
int cnt_used_layers = 0;
string user_layers[] = {"" };
int cnt_user_layers = 0;
// *** --- Functions --- ***
void checkVariant(string var) {
int f = 0;
for (int n = 0; n <= cntvar; n++) {
if (src_var[n] == var) {
f = 1;
break;
}
}
if (f) return;
src_var[cntvar] = var;
cntvar++;
return;
}
void checkTechno(string tech) {
string techno[];
int t = strsplit(techno, tech, ' ');
for (int xt = 0; xt < t; xt++) {
int notf = 1;
for (int n = 0; n <= cnttec; n++) {
if (src_tec[n] == techno[xt]) {
notf = 0;
break;
}
}
if (notf) {
src_tec[cnttec] = techno[xt];
cnttec++;
}
}
return;
}
void checkUsedPac(string pac) {
int f = 0;
for (int n = 0; n <= cntpac; n++) {
if (src_pac[n] == pac) {
used_pac[n]++;
return;
}
}
dlgMessageBox("Pac not found!", "OK");
}
void checkUsedSym(string sym) {
int f = 0;
for (int n = 0; n <= cntsym; n++) {
if (src_sym[n] == sym) {
used_sym[n]++;
return;
}
}
dlgMessageBox("Sym not found!", "OK");
}
// ** ------------------------ **
void checkDrill(int drill) {
int nof = 1;
for (int n = 0; n < cntdrills; n++) {
if (drills[n] == drill) {
nof = 0;
cntdril[n]++;
break;
}
}
if (nof) {
drills[cntdrills] = drill;
cntdril[cntdrills]++;
cntdrills++;
}
return;
}
int countPAD(UL_PACKAGE P) {
int Pads;
P.contacts(C) {
if (C.pad) {
Pads++;
}
}
return Pads;
}
int countSMD(UL_PACKAGE P) {
int Smds;
P.contacts(C) {
if (C.smd) {
Smds++;
}
}
return Smds;
}
int countHOLE(UL_PACKAGE P) {
int Holes;
P.holes(H) {
Holes++;
}
return Holes;
}
int countPIN(UL_SYMBOL S) {
int Pins;
S.pins(P) {
Pins++;
}
return Pins;
}
int newUsed(string use_name) {
int new = 1;
int n = 0;
do {
if (used[n] == use_name) {
new = 0;
break;
}
n++;
} while(used[n]);
return new;
}
void syminfo(string Name_and_count) {
string symbolname[];
int n = strsplit(symbolname, Name_and_count, '\t');
usedlabel = "<b>" + symbolname[0]+".SYM</b>";
used[0] = "used in Devices\tcnt";
int usedcount = 1;
used[usedcount] = "";
for (int u = 1; u < cntclearused; u++) used[u] = ""; // while error in dlgListView()
// clear all strings in array 03.05.2005 alf
library(L) {
L.symbols(S) {
if (S.name == symbolname[0]) {
sprintf(SymbolInfo, "<b>%s</b><br>%3d Pin in symbol", S.name, countPIN(S) );
}
}
L.devicesets(DS) {
int cntinuse;
int new = 0;
DS.gates(G) {
if (G.symbol.name == symbolname[0]) {
if (newUsed(DS.name)) {
used[usedcount] = DS.name;
usedcount++;
used[usedcount] = "";
new++;
}
cntinuse++;
}
}
if (new) {
string h;
sprintf(h, "\t%d", cntinuse);
used[usedcount-1] += h;
}
}
}
used[usedcount] = "";
if (cntclearused < usedcount) cntclearused = usedcount;
return;
}
void pacinfo(string Name_and_count) {
string packname[];
int n = strsplit(packname, Name_and_count, '\t');
usedlabel = "<b>" + packname[0]+".PAC</b>";
used[0] = "used in Devices\tcnt";
int usedcount = 1;
used[usedcount] = "";
for (int u = 1; u < cntclearused; u++) used[u] = ""; // while error in dlgListView()
// clear all strings in array 03.05.2005 alf
library(L) {
L.packages(P) {
if (P.name == packname[0]) {
sprintf(PackInfo, "<b>%s</b><br>%3d Pad<br>%3d Smd<br>%3d Hole", P.name, countPAD(P), countSMD(P), countHOLE(P) );
}
}
L.devicesets(DS) {
int cntinuse;
int new = 0;
DS.devices(D) {
if (D.package) {
if (D.package.name == packname[0]) {
if (newUsed(DS.name)) {
used[usedcount] = DS.name;
usedcount++;
used[usedcount] = "";
new++;
}
cntinuse++;
}
}
}
if (new) {
string h;
sprintf(h, "\t%d", cntinuse);
used[usedcount-1] += h;
}
}
}
used[usedcount] = "";
if (cntclearused < usedcount) cntclearused = usedcount;
return;
}
void drillinfo(int Drill) {
sprintf(usedlabel, "<b>Drill %.4f mm</b>", u2mm(Drill));
used[0] = "used in Package\tcnt";
int usedcount = 1;
used[usedcount] = "";
for (int u = 1; u < cntclearused; u++) used[u] = ""; // while error in dlgListView()
// clear all strings in array 03.05.2005 alf
library(L) {
L.packages(P) {
int cntinuse;
int new = 0;
P.contacts(C) {
if (C.pad) {
if (C.pad.drill == Drill) {
if (newUsed(P.name)) {
used[usedcount] = P.name;
usedcount++;
used[usedcount] = "";
new++;
}
cntinuse++;
}
}
}
if (new) {
string h;
sprintf(h, "\t%d", cntinuse);
used[usedcount-1] += h;
}
}
}
used[usedcount] = "";
if (cntclearused < usedcount) cntclearused = usedcount;
return;
}
void collectLbr(UL_LIBRARY L) {
L.packages(P) {
src_pac[cntpac] = P.name ;
cntpac++;
src_pac[cntpac] = "";
P.contacts(C) {
if (C.pad) {
checkDrill(C.pad.drill);
}
}
}
L.symbols(S) {
src_sym[cntsym] = S.name ;
cntsym++;
src_sym[cntsym] = "";
}
L.devicesets(DS) {
src_dev[cntdev] = DS.name ;
DS.devices(D) {
checkVariant(D.name);
checkTechno(D.technologies);
if (D.package) {
checkUsedPac(D.package.name);
}
cnt_variant[cntdev]++;
}
cntdev++;
src_dev[cntdev] = "";
DS.gates(G) {
checkUsedSym(G.symbol.name);
}
}
return;
}
void sort_data(void) {
int n;
string s;
sort (cntdev, index_dev, src_dev, cnt_variant); // 2005.11.15 alf
sort (cntvar, index_var, src_var);
sort (cnttec, index_tec, src_tec);
sort (cntpac, index_pac, src_pac, used_pac);
sort (cntsym, index_sym, src_sym, used_sym);
sort (cntdrills, index_dril, drills, cntdril);
for (n = 0; n < cntdev; n++) {
srt_dev[n] = src_dev[index_dev[n]];
}
for (n = 0; n < cntvar; n++) {
srt_var[n] = src_var[index_var[n]];
}
for (n = 0; n < cnttec; n++) {
srt_tec[n] = src_tec[index_tec[n]];
}
for (n = 0; n < cntpac; n++) {
if (used_pac[index_pac[n]]) sprintf(s, "\t%d", used_pac[index_pac[n]]);
else {
s = "\t -";
unUsed_pac[cntUnUsed_pac] = src_pac[index_pac[n]];
cntUnUsed_pac++;
}
srt_pac[n] = src_pac[index_pac[n]] + s;
}
for (n = 0; n < cntsym; n++) {
if (used_sym[index_sym[n]]) sprintf(s, "\t%d", used_sym[index_sym[n]]);
else {
s = "\t -";
unUsed_sym[cntUnUsed_sym] = src_sym[index_sym[n]];
cntUnUsed_sym++;
}
srt_sym[n] = src_sym[index_sym[n]] + s;
}
for (n = 0; n < cntdrills; n++) {
sprintf(srt_drills[n], "%.4f\t%d", u2mm(drills[index_dril[n]]), cntdril[index_dril[n]]);
}
return;
}
//
void menue_1(void) {
int seldev = 0;
int seltec = 0;
int selvar = 0;
int selsym = -1;
int selpac = -1;
int seldril = -1;
int selused = 0;
string ndev, nvar, ntec, npac, nsym, ndril, cupac, cusym;
string usedVariants = " select Device";
sprintf(ndev, "%3d", cntdev);
sprintf(nvar, "%3d", cntvar);
sprintf(ntec, "%3d", cnttec);
sprintf(npac, "%3d", cntpac);
sprintf(nsym, "%3d", cntsym);
sprintf(ndril, "%3d", cntdrills);
sprintf(cupac, "%3d", cntUnUsed_pac);
sprintf(cusym, "%3d", cntUnUsed_sym);
int listsort = 0;
int sellay;
int Result = dlgDialog("Library statistic") {
dlgHBoxLayout {
dlgVBoxLayout dlgSpacing(400);
dlgGridLayout {
dlgCell(0,0) { dlgLabel(ndev); dlgLabel("&Devices"); }
dlgCell(0,1) dlgComboBox(srt_dev, seldev) { sprintf(usedVariants, "%d Variant ", cnt_variant[seldev]); }
dlgCell(0,2) dlgLabel(usedVariants, 1);
dlgCell(1,0) { dlgLabel(nvar); dlgLabel("&Variants"); }
dlgCell(1,1) dlgComboBox(srt_var, selvar);
dlgCell(0,2) dlgSpacing(100);
dlgCell(2,0) { dlgLabel(ntec); dlgLabel("&Technoligies"); }
dlgCell(2,1) dlgComboBox(srt_tec, seltec);
dlgCell(2,2) dlgSpacing(10);
dlgCell(3,0) dlgLabel("&Used Layers");
dlgCell(3,1) dlgComboBox(used_layers, sellay);
if (cnt_user_layers) {
dlgCell(4,1) dlgLabel("<font color = red>Layer user defined</font>");
dlgCell(5,1) dlgComboBox(user_layers, sellay);
}
dlgCell(6,1) dlgVBoxLayout {
dlgLabel(usedlabel, 1);
dlgListView("", used, selused, listsort);
}
dlgCell(7,0) dlgLabel("Unused &Package");
dlgCell(7,1) dlgComboBox(unUsed_pac, up);
dlgCell(7,2) dlgLabel(cupac);
dlgCell(8,0) dlgLabel("Unused &Symbol");
dlgCell(8,1) dlgComboBox(unUsed_sym, us);
dlgCell(8,2) dlgLabel(cusym);
}
dlgVBoxLayout {
dlgLabel("Symbols " + nsym);
dlgListView("Symbol\tUsed", srt_sym, selsym) {
syminfo(srt_sym[selsym]);
selpac = -1;
seldril = -1;
}
dlgLabel(SymbolInfo, 1);
}
dlgVBoxLayout {
dlgLabel("Packages " + npac);
dlgListView("Package\tUsed", srt_pac, selpac) {
pacinfo(srt_pac[selpac]);
selsym = -1;
seldril = -1;
}
dlgLabel(PackInfo, 1);
}
dlgVBoxLayout {
dlgLabel("Drills " + ndril);
dlgListView("Drill mm\tUsed", srt_drills, seldril) {
drillinfo(drills[index_dril[seldril]]);
selsym = -1;
selpac = -1;
}
}
dlgVBoxLayout dlgSpacing(300);
}
dlgSpacing(12);
dlgHBoxLayout {
dlgPushButton("+&OK") dlgAccept();
dlgStretch(1);
}
};
return ;
}
// main
if (library) library(L) {
L.layers(LAY) {
if (LAY.used) {
sprintf(used_layers[cnt_used_layers], "%d %s", LAY.number, LAY.name);
cnt_used_layers++;
}
if (LAY.number >= 100) {
sprintf(user_layers[cnt_user_layers], "%d %s", LAY.number, LAY.name);
cnt_user_layers++;
}
}
collectLbr(L);
sort_data();
menue_1();
}
|