-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLP-Daten.ulp
873 lines (801 loc) · 32.6 KB
/
LP-Daten.ulp
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
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
/**
* \file LP-Daten.ulp
* \author cadsoft.de , weiter bearbeitet von Jan Scholz
* \brief Dies ist eine Abwandelung einer ulp von Cadsoft, Leiterplatten-
* Spezifikationen werden in eine PDF-Vorlage eingetragen.
*
*/
#usage "en: <b>LP-Daten</b\n>"
"<p>"
"This is a modification of the ulp of Cadsoft ,<br>"
"PCB specifications are entered in a PDF template .",
"de: <b>LP-Daten</b>\n"
"<p>"
"Dies ist eine Abwandelung einer ulp von Cadsoft, Leiterplatten-"
"Spezifikationen werden in eine PDF-Vorlage eingetragen..<p>"
"<author>Autor: [email protected]</author><p>"
// THIS PROGRAM IS PROVIDED AS IS AND WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED
#require 6.000
string Version_Nr = " DESY -ZE- Ver 1.2";
enum { false = 0, true = 1 };
// debug stuff
int Dbg = 0;
string DbgFile;
string DbgMsg;
string debugkram;
string Datum;
sprintf(Datum,"%d.%d.%d",t2day(time()),t2month(time())+1,t2year(time()));
// Messages
string Warnings;
int Useless; // When a quote doesn't make sense (e.g empty board or such)
// Design rules
int Export = 1;
string DruFile;
// Units / scaling: Handling change of internal units V5 -> V6:
int UFactor = (EAGLE_VERSION < 6 && EAGLE_RELEASE < 12) ? 1 : 32;
int PrefUnit; // Preferred unit (representation in dialog)
// Fabrication parameters
string BoardName;
int NrLayers;
int CopperThicknessOutside = INT_MAX;
int CopperThicknessInside = INT_MAX;
int MaterialThickness;
int MinTraceWidth = INT_MAX;
int MinHoleSize = INT_MAX;
string SMDSides;
string SolderSides;
string SilkScreenSides;
int NrBlindBuriedTypes;
int NrburiedVia;
int NrblindVia;
int MinPitch = INT_MAX;
int MinWireWire;
int NrSmdPadsTop;
int NrSmdPadsBottom;
int Bohrungen;
int Bohrdurchmesser;
real drillDiameters[];
string loetstop;
string stringplace;
// Assembly parameters
int NrPackages;
int NrThruHoles;
int NrBGAs;
int NrQFNs;
int NrFinePitchs;
int NrOtherSMDs;
int HasSMDBothSides;
// DESY spezifische Daten
string engineer;
string geprueft;
string freigegeben;
string Anforderer;
string Gruppe;
string WA_Nummer;
string Description1;
string fileName;
string PROJEKT_PFAD;
string LageLageBuried;
string LageLageBlind;
int config_nicht_vorhanden;
// For computing width and height
real XMin = REAL_MAX, XMax = -REAL_MAX, YMin = REAL_MAX, YMax = -REAL_MAX;
// Language support for dialogs: German/English
// Please keep to alphabetic sorting for better maintainability !
string Dictionary[] = {
"en\v"
"de\v",
"Assembly Parameters:\v"
"Bestückungs-Parameter:\v",
"Board length (dimension Y):\v"
"Boardlänge (Y-Richtung):\v",
"Board name:\v"
"Boardname:\v",
"Board thickness:\v"
"Boarddicke:\v",
"Board width (dimension X):\v"
"Boardbreite (X-Richtung):\v",
"Board width and length could not be determined from dimension layer. \v"
"Boardbreite und -länge konnten nicht bestimmt werden anhand des Dimension-Layers. \v",
"Both Sides\v"
"beidseitig\v",
"Bottom Side\v"
"unten\v",
"Please use the dimension layer to design the board outline.\v"
"Bitte benutzen Sie den Dimension-Layer, um die Boardumrisse festzulegen.\v",
"Calculating quote parameters...\v"
"Berechne Angebots-Parameter...\v",
"Change Country:\v"
"Land wechseln:\v",
"Close\v"
"Schliessen\v",
"+Continue...\v"
"+Weiter...\v",
"Copper thickness outer layers:\v"
"Kupferstärke aussen:\v",
"Copper thickness inner layers:\v"
"Kupferstärke innen:\v",
"Estimate based on outer layers failed. \v"
"Schätzung basierend auf Aussen-Layer fehlgeschlagen. \v",
"Estimation based on outer layers. \v"
"Schätzung basierend auf Aussen-Layer. \v",
"Fabrication Parameters:\v"
"Fertigungs-Parameter:\v",
"Get PCB Quote\v"
"Zum PCB-Angebot\v",
"A quote for this board doesn't make sense yet !\v"
"Ein Angebot für dieses Board macht noch keinen Sinn !\v",
"If you want to get a quote anyway, please follow the link.\v"
"Wenn Sie dennoch ein Angebot erhalten wollen, folgen Sie bitte dem Link.\v",
"Information:\v"
"Hinweise:\v",
"Minimum hole size:\v"
"Kleinster Bohrdurchmesser:\v",
"Minimum SMD pitch:\v"
"Kleinster SMD-Abstand:\v",
"Minimum trace width (track width):\v"
"Kleinste Bahnbreite:\v",
"Minimum trace width could not be determined.\v"
"Minimale Bahnbreite konnte nicht bestimmt werden.\v",
"No copper found in the signal layers. \v"
"Kein Kupfer in den Signal-Layern vorhanden. \v",
"No\v"
"Nein\v",
"None\v"
"keine\v",
"Number of\v"
"Anzahl von\v",
"Number of blind or buried hole types:\v"
"Anzahl von Blind- oder Buried-Bohrungsarten:\v",
"Number of different packages:\v"
"Anzahl verschiedener Packages:\v",
"Number of fine pitch packages:\v"
"Anzahl von Fine-Pitch-Packages:\v",
"Number of other SMDs:\v"
"Anzahl sonstiger SMDs:\v",
"Number of SMD pads on bottom:\v"
"Anzahl von SMD-Pads unten:\v",
"Number of SMD pads on top:\v"
"Anzahl von SMD-Pads oben:\v",
"Number of thru hole packages: \v"
"Anzahl von durchkontaktierten Packages: \v",
"Number of layers:\v"
"Anzahl Layer:\v",
"Wire(s) and/or polygon(s) with zero width found on signal layer(s). \v"
"Bahnen und/oder Polygone mit Breite 0 in Signal-Layer(n) gefunden. \v",
"None of the signal layers are used.\v"
"Keines der Signal-Layer wird verwendet.\v",
"Parameters:\v"
"Parameter:\v",
"PCB Quote Service\v"
"PCB-Angebots-Service\v",
"Please start from Layout editor !\v"
"Bitte starten Sie vom Layout-Editor aus !\v",
"Silkscreen sides:\v"
"Bestückungsdruck-Seiten:\v",
"SMDs on both sides:\v"
"SMDs beidseitig:\v",
"Solder sides:\v"
"Lötseiten:\v",
"There are still airwires left.\v"
"Es sind noch Luftlinien vorhanden.\v",
"Top Side\v"
"oben\v",
"undefined\v"
"unbestimmt\v",
"Warnings:\v"
"Warnungen:\v",
"Yes\v"
"Ja\v",
"Your board layout is incomplete:\v"
"Ihr Board-Layout ist unvollständig:\v"
};
string DlgLang = language();
if (DlgLang != "de") DlgLang = "en";
int LangIdx = strstr(Dictionary[0], DlgLang) / 3;
// Translate, based on dictionary
string tr(string s) {
string t = lookup(Dictionary, s, LangIdx, '\v');
return t ? t : s;
}
string Unknown = tr("undefined");
//- Auxiliary functions -------------------------------------------------------
// String handling
string I2Str(int i) { string str; sprintf(str, "%d", i); return str; }
string B2Str(int b) { return b ? "true" : "false"; }
// HTML stuff
string LItem(string txt) { return "<li>" + txt + "</li>"; }
string Bold(string txt) { return "<b>" + txt + "</b>"; }
// Unit handling
string U2MmStr(int i) { string str; sprintf(str, "%g", u2mm(i)); return str; }
string U2InStr(int i) { string str; sprintf(str, "%f", u2inch(i)); return str; }
string U2OzStr(int i) { string str; sprintf(str, "%f", i/(350.0 * UFactor)); return str; }// Todo: Check this !
// Unit to preferred unit as String with extension !
string U2PrefUStrExt(int i) { return (PrefUnit == GRID_UNIT_MM) ? U2MmStr(i) + " mm" : U2InStr(i) + " in"; }
int Str2U(string s) {
if (strstr(s, "mm") > 0) return int(strtod(s) * 10000 * UFactor);
if (strstr(s, "mil") > 0) return int(strtod(s) * 10 * UFactor * 25.4);
if (strstr(s, "in") > 0) return int(strtod(s) * 10000 * UFactor * 25.4);
if (strstr(s, "mic") > 0) return int(strtod(s) * 10 * UFactor);
dlgMessageBox("Unknown unit in design rules !"); exit(EXIT_FAILURE);
return 0;
}
//-------------------------------------------------------
// Get PCB parameters
//-------------------------------------------------------
// Means really within, not at the borders
int Within(int val, int l, int u) { return (val > l) && (val < u); }
int ValidBBox() {
return (XMin < REAL_MAX) && (XMax > -REAL_MAX) &&
(YMin < REAL_MAX) && (YMax > -REAL_MAX) &&
(XMax - XMin > 1000) && (YMax - YMin > 1000); // Could make this much bigger, but that's not crucial (currently 0.1 mm)
}
// Update bounding box with another box
void UpdateBBoxBox(int xmin, int ymin, int xmax, int ymax) {
XMin = min(XMin, xmin);
XMax = max(XMax, xmax);
YMin = min(YMin, ymin);
YMax = max(YMax, ymax);
}
void UpdateBBoxWire(UL_WIRE W, int layer) {
if (W.layer == layer) {
real w2 = 0;
real xmin = min(W.x1 - w2, W.x2 - w2), ymin = min(W.y1 - w2, W.y2 - w2);
real xmax = max(W.x1 + w2, W.x2 + w2), ymax = max(W.y1 + w2, W.y2 + w2);
if (W.arc)
if (W.arc.angle2 > 360)
xmax = W.arc.xc + W.arc.radius + w2;
else if (((W.arc.angle1 < 90) && (W.arc.angle2 > 90)) || (W.arc.angle2 > 450))
ymax = W.arc.yc + W.arc.radius + w2;
else if (((W.arc.angle1 < 180) && (W.arc.angle2 > 180)) || (W.arc.angle2 > 540))
xmin = W.arc.xc - W.arc.radius - w2;
else if (((W.arc.angle1 < 270) && (W.arc.angle2 > 270)) || (W.arc.angle2 > 630))
ymin = W.arc.yc - W.arc.radius - w2;
UpdateBBoxBox(xmin, ymin, xmax, ymax);
}
}
void UpdateBBoxCircle(UL_CIRCLE C, int layer) {
if (C.layer == layer) {
real w2 = C.width / 2;
UpdateBBoxBox(C.x - C.radius - w2, C.y - C.radius - w2, C.x + C.radius + w2, C.y + C.radius + w2);
}
}
void UpdateBBox(int layer, int el_origin) {
board(B) {
B.wires(W) UpdateBBoxWire(W, layer);
B.circles(C) UpdateBBoxCircle(C, layer);
B.elements(E) {
if (el_origin) UpdateBBoxBox(E.x, E.y, E.x, E.y); // Elements are always on signal layers.
E.package.wires(W) UpdateBBoxWire(W, layer);
E.package.circles(C) UpdateBBoxCircle(C, layer);
}
}
}
string prozent="%";
void outputFile() {
// --- "//win.desy.de/group/sze/public/Eagle_6+/ulp"
// -- "/F (N:\\\\public\\\\Eagle_6+\\\\ulp\\\\kurzbeschreibung.pdf) \n"
output( PROJEKT_PFAD+"LP-Daten_"+filesetext(BoardName,"")+".fdf" , "wt") {
string file = "%FDF-1.4 \n"
"%âãÏÓ \n"
"1 0 obj \n"
"<<\n"
"/FDF << \n"
"/F (\\\\\\\\win.desy.de\\\\group\\\\sze\\\\public\\\\Eagle_6+\\\\ulp\\\\kurzbeschreibung.pdf) \n"
"/Type /Catalog \n"
"/Fields [<< \n"
"/T (LP-Nr) \n"
"/V ("+filesetext(BoardName,"")+")\n"
">> << \n"
"/T (Datum)\n"
"/V ("+Datum+")\n"
">> << \n"
"/T (Layouter) \n"
"/V ("+engineer+")\n"
">> <<\n"
"/T (Layoutname) \n"
"/V ("+Description1+")\n"
">> <<\n"
"/T (Lagenanzahl)\n"
"/V ("+I2Str(NrLayers)+")\n"
">> <<\n"
"/T (Leiterplatten-Dicke)\n"
"/V ("+U2MmStr(MaterialThickness)+")\n"
">> <<\n"
"/T (Leiterplatten-FormatX)\n"
"/V ("+(ValidBBox() ? U2MmStr(XMax - XMin) : "unbekannt")+") \n"
">> <<\n"
"/T (Leiterplatten-FormatY)\n"
"/V ("+(ValidBBox() ? U2MmStr(YMax - YMin) : "unbekannt")+") \n"
">> <<\n"
"/T (KupferAußen)\n"
"/V ("+U2MmStr(CopperThicknessOutside*1000)+")\n"
">> <<\n"
"/T (KupferInnen)\n"
"/V ("+(Within(CopperThicknessInside, 0, INT_MAX) ? U2MmStr(CopperThicknessInside*1000) : "unbekannt")+")\n"
">> <<\n"
"/T (klLeiterbahnbreite) \n"
"/V ("+(Within(MinTraceWidth, 0, INT_MAX) ? U2MmStr(MinTraceWidth*1000) : "unbekannt")+")\n"
">> <<\n"
"/T (Loetstoppmaske) \n"
"/V ("+SolderSides+")\n"
">> <<\n"
"/T (Positionsdruck) \n"
"/V ("+SilkScreenSides+")\n"
">> <<\n"
"/T (SMD)\n"
"/V ("+SMDSides+")\n"
">> <<\n"
"/T (AnzahlSMD)\n"
"/V ("+I2Str(NrSmdPadsTop+NrSmdPadsBottom)+")\n"
">> <<\n"
"/T (klAbstand)\n"
"/V ("+U2MmStr(MinWireWire*1000)+")\n"
">> <<\n"
"/T (BuriedVias)\n"
"/V ("+I2Str(NrburiedVia)+")\n"
">> <<\n"
"/T (BlindVias)\n"
"/V ("+I2Str(NrblindVia)+")\n"
">> <<\n"
"/T (BlindLayers)\n"
"/V ("+LageLageBlind+")\n"
">> <<\n"
"/T (BuriedLayers)\n"
"/V ("+LageLageBuried+")\n"
">> <<\n"
"/T (EPruefung)\n"
"/V ("+ (NrLayers > 2 ? "Ja" : "Nein") +")\n"
">> <<\n"
"/T (Bohrungen)\n"
"/V ("+I2Str(Bohrungen)+")\n"
">> <<\n"
"/T (klBohrdurchmesser)\n"
"/V ("+(MinHoleSize < INT_MAX ? U2MmStr(MinHoleSize) : "unbekannt")+")\n"
">> <<\n"
"/T (Bohrdurchmesser)\n"
"/V ("+I2Str(Bohrdurchmesser)+")\n"
">> <<\n"
"/T (Gruppe)\n"
"/V ("+Gruppe+")\n"
">>]\n"
">>\n"
">>\n"
"endobj\n"
"trailer\n"
"<<\n"
"/Root 1 0 R\n"
">>\n"
"%%EOF";
printf("%s",file);
// printf("Kleinster SMD-Abstand;%s\n",MinPitch < INT_MAX ? U2PrefUStrExt(MinPitch) : Unknown);
// printf("Anzahl von Blind- und Buried-Bohrungsarten;%s\n",I2Str(NrBlindBuriedTypes));
// printf("Kleinster Bohrdurchmesser;%s\n",MinHoleSize < INT_MAX ? U2PrefUStrExt(MinHoleSize) : Unknown);
}
if (fileerror()) {
dlgMessageBox("Die Datei konnte nich gespeichert werden");
exit(1);
}
}
void GetDruParams() {
string lines[];
int nrlines = fileread(lines, DruFile);
if (nrlines == 0) dlgMessageBox("Error reading design rules !");
int layer_used[], nrlayers, bottom_idx;
for (int i = 0; i < nrlines; ++i) {
string words[];
int nrwords = strsplit(words, lines[i], ' ');
if (nrwords < 3) continue; // Empty line or some other stuff
string keyword = words[0];
if (keyword == "layerSetup")
for (int k = 1; k <= 16; ++k) {
string nr_pattern;
sprintf(nr_pattern, "[\\D]%d[\\D]", k); // Number, surrounded by 'no number character'
if (strxstr(words[2], nr_pattern) != -1) {
layer_used[k - 1] = true;
++NrLayers;
bottom_idx = k - 1;
}
}
else if (keyword == "mtCopper") {
if (nrwords != 18) dlgMessageBox("Unexpected design rules !");
int top_thickness = -1, bot_thickness;
for (int k = 2; k < nrwords; ++k) {
if (layer_used[k - 2]) {
int thickness = Str2U(words[k]);
if (top_thickness == -1)
top_thickness = thickness;
else if (k - 2 == bottom_idx)
bot_thickness = thickness;
else
CopperThicknessInside = min(thickness, CopperThicknessInside);
MaterialThickness += thickness;
}
}
CopperThicknessOutside = min(top_thickness, bot_thickness);
}
else if (keyword == "mtIsolate") {
if (nrwords != 17) dlgMessageBox("Unexpected design rules !");
// n used layers => n-1 isolate layers. If only 1 layer, also 1 isolate layer.
for (int k = 2; k < nrwords; ++k)
if (layer_used[k - 2])
MaterialThickness += Str2U(words[k]);
}
else if (keyword == "mdSmdSmd")
MinPitch = Str2U(words[2]);
else if (keyword == "mdWireWire")
MinWireWire = Str2U(words[2]);
}
}
void iniFilelesen() {
string a[];
int nLines;
string lines[];
board(B) {
fileName = filesetext(B.name, "_config.ini");
int i=0;
PROJEKT_PFAD = filedir(B.name);
}
if (fileglob(a, fileName)) {
//--- get options from INI-File
nLines = fileread(lines, fileName);
engineer = lines[3];
geprueft = lines[4];
freigegeben = lines[5];
Anforderer = lines[6];
Gruppe = lines[7];
WA_Nummer = lines[8];
Description1 = lines[9];
} else {
config_nicht_vorhanden = 1;
//dlgMessageBox(fileName+" nicht vorhanden");
}
}
void CalcMinTraceWidth() {
board(B) {
B.wires(W) if (W.layer <= 16) MinTraceWidth = min(W.width, MinTraceWidth);
B.signals(S) {
S.polygons(P) if (P.layer <= 16) MinTraceWidth = min(P.width, MinTraceWidth);
S.wires(W) if (W.layer <= 16) MinTraceWidth = min(W.width, MinTraceWidth);
}
}
}
void debug(string msg) {
status("debug()");
dlgDialog("debug") {
dlgHBoxLayout { dlgLabel(msg); }
dlgPushButton("+&ok") { dlgAccept();}
dlgPushButton("-&cancel") { dlgReject(); exit (0);}
};
}
void AnzahlBohrduchmesser(real durchmesser) {
int found = 0;
int i;
for (i = 0; i < Bohrdurchmesser; i++) {
if(durchmesser==drillDiameters[i]) {
found = 1;
}
}
if(!found) {
drillDiameters[i] = durchmesser;
Bohrdurchmesser++;
debugkram += U2MmStr(durchmesser) + "\n";
//debug(U2MmStr(durchmesser));
}
Bohrungen++;
}
void CheckHoles() {
int idx[], start[], end[], k;
board(B) {
B.holes(H) {
MinHoleSize = min(MinHoleSize, H.drill);
AnzahlBohrduchmesser(H.drill);
}
B.signals(S) S.vias(V) {
MinHoleSize = min(MinHoleSize, V.drill);
AnzahlBohrduchmesser(V.drill);
// Collect blind/buried holes !
if ((V.start > 1) && (V.end < 16)) {
start[k] = V.start;
end[k] = V.end;
++k;
++NrburiedVia;
} else if ( (V.start == 1 && V.end != 16) || (V.start != 1 && V.end == 16)) {
start[k] = V.start;
end[k] = V.end;
++k;
++NrblindVia;
}
}
B.elements(E) {
E.package.contacts(C) if (C.pad) {
//debug(U2MmStr(C.pad.drill));
MinHoleSize = min(MinHoleSize, C.pad.drill);
AnzahlBohrduchmesser(C.pad.drill);
}
E.package.holes(H) {
//debug(U2MmStr(H.drill));
MinHoleSize = min(MinHoleSize, H.drill);
AnzahlBohrduchmesser(H.drill);
}
}
}
// NrBlindBuriedTypes: Find out how many different ones exist !
sort(k, idx, start, end);
for (int l = 0, cur_s = 0, cur_e = 0; l < k; ++l)
if ((start[idx[l]] != cur_s) || (end[idx[l]] != cur_e)) {
++NrBlindBuriedTypes;
cur_s = start[idx[l]];
cur_e = end[idx[l]];
if((start[idx[l]] > 1) && (end[idx[l]] < 16)) // Buried ...
LageLageBuried += (LageLageBuried == "" ? "" : ",") + I2Str(start[idx[l]]) +"/"+I2Str(end[idx[l]]);
else //Blind
LageLageBlind += (LageLageBlind == "" ? "" : ",") + I2Str(start[idx[l]]) +"/"+I2Str(end[idx[l]]);
}
//debug("Verschiedene Bohrdurchmesser\n" + debugkram);
}
void GetPCBParams() {
// Check out layers:
int smask_top, smask_bottom, silk_top, silk_bottom, smd_top ,smd_bottom;
int nr_used_layers;
board(B) {
BoardName = filename(B.name);
B.layers(L) if (L.used)
if (L.number <= 16) ++nr_used_layers;
else if (L.number == LAYER_TSTOP) smask_top = 1;
else if (L.number == LAYER_BSTOP) smask_bottom = 1;
else if (L.number == LAYER_TCREAM) smd_top = 1;
else if (L.number == LAYER_BCREAM) smd_bottom = 1;
else if (L.number == LAYER_TPLACE) silk_top = 1; // Could also take TNAMES/TVALUES. Leave the criterium less strict
else if (L.number == LAYER_BPLACE) silk_bottom = 1; // Could also take BNAMES/BVALUES. Leave the criterium less strict
}
SMDSides = smd_top ? (smd_bottom ? "Beidseitig" : "Einseitig Top") :
(smd_bottom ? "Einseitig Bottom" : "Nein");
SolderSides = smask_top ? (smask_bottom ? "Beidseitig" : "Einseitig Top") :
(smask_bottom ? "Einseitig Bottom" : "Nein");
SilkScreenSides = (silk_top) ? (silk_bottom ? "Beidseitig" : "Einseitig") :
(silk_bottom ? "Einseitig" : "Nein");
if (nr_used_layers == 0) {
Warnings += LItem(tr("None of the signal layers are used."));
Useless = 1;
}
// Board outlines:
UpdateBBox(LAYER_DIMENSION, 0);
if (!ValidBBox()) {
Warnings += "<li>" + tr("Board width and length could not be determined from dimension layer. ");
UpdateBBox(LAYER_TOP, 1);
UpdateBBox(LAYER_BOTTOM, 1);
if (!ValidBBox())
Warnings += tr("Estimate based on outer layers failed. ") +
tr("Please use the dimension layer to design the board outline.") + "</li>";
else
Warnings += tr("Estimation based on outer layers. ") + "</li>";
}
CalcMinTraceWidth();
if (MinTraceWidth == INT_MAX)
Warnings += LItem(tr("No copper found in the signal layers. ") +
tr("Minimum trace width could not be determined."));
if (MinTraceWidth == 0)
Warnings += LItem(tr("Wire(s) and/or polygon(s) with zero width found on signal layer(s). ") +
tr("Minimum trace width could not be determined."));
GetDruParams();
CheckHoles();
iniFilelesen();
int air_wires = 0;
{ // Check if there are still airwires:
board(B) {
B.wires(W) if (W.layer == LAYER_UNROUTED) air_wires = 1;
B.signals(S) {
S.polygons(P) if (P.layer == LAYER_UNROUTED) air_wires = 1;
S.wires(W) if (W.layer == LAYER_UNROUTED) air_wires = 1;
}
}
}
if (air_wires)
Warnings += LItem(tr("There are still airwires left."));
// Analysis of elements
// Alternative idea for performance optimization:
// Run SMD analysis over all library packages to avoid multiple runs
// Keep results in Arrays
string keyBGA = "BGA", keyQFN = "QFN";
real sqLimitFinePitch = 0.5 * 0.5; // Square of the threshold for Fine Pitch (in mm)
board(B) B.elements(E) {
int isThruHole, isSMD;
E.package.contacts(C)
if (C.smd) {
isSMD = true;
if (C.smd.layer == LAYER_TOP) ++NrSmdPadsTop;
else ++NrSmdPadsBottom;
}
else
isThruHole = true; // Assuming there are no mixed versions
if (isThruHole) ++NrThruHoles;
else if (isSMD) { // There might also be the case of NO contacts !
// Collect contacts in untransformed state to make geometrical checks !
real conXs[], conYs[];
int nrCons;
B.libraries(L)
if (L.name == E.package.library) L.packages(P)
if (P.name == E.package.name) P.contacts(C) {
conXs[nrCons] = u2mm(C.x);
conYs[nrCons++] = u2mm(C.y);
}
if (strstr(E.name, keyBGA) >= 0 ||
strstr(E.package.name, keyBGA) >= 0 ||
strstr(E.package.description, keyBGA) >= 0) {
// Plausibility check
++NrBGAs;
}
else if (strstr(E.name, keyQFN) >= 0 ||
strstr(E.package.name, keyQFN) >= 0 ||
strstr(E.package.description, keyQFN) >= 0) {
// Plausibility check
++NrQFNs;
}
else {
// if there's a contact pair with distance <= fine pitch limit it's a FINE Pitch, else it's an other SMD
for (int isFP = false, i = 0; i < nrCons && !isFP; ++i)
for (int j = i + 1; j < nrCons && !isFP; ++j)
if ((conXs[j] - conXs[i]) * (conXs[j] - conXs[i]) +
(conYs[j] - conYs[i]) * (conYs[j] - conYs[i]) <= sqLimitFinePitch)
isFP = true;
if (isFP)
++NrFinePitchs;
else
++NrOtherSMDs;
}
}
}
HasSMDBothSides = NrSmdPadsTop * NrSmdPadsBottom > 0;
// Packages (number of unique elements)
// Only those with contacts !
board(B) B.libraries(L) L.packages(P) P.contacts(C) {
++NrPackages;
break;
}
}
string MakeParamSendString() {
// Fab parameters:
// - Parameters that always can be determined:
string send = "?source=SBPCAD" +
"&boardName=" + BoardName +
"&numLayers=" + I2Str(NrLayers) +
"&materialThicknessMm=" + U2MmStr(MaterialThickness) +
"&materialThicknessIn=" + U2InStr(MaterialThickness) +
"&copperThicknessOutsideMm=" + U2MmStr(CopperThicknessOutside) +
"&copperThicknessOutsideOz=" + U2OzStr(CopperThicknessOutside) +
"&solderSides=" + SolderSides +
"&silkScreenSides=" + SilkScreenSides +
"&blindBuriedHoles=" + I2Str(NrBlindBuriedTypes) +
"&numPadsTop=" + I2Str(NrSmdPadsTop) +
"&numPadsBottom=" + I2Str(NrSmdPadsBottom);
// - Parameters that might miss:
if (ValidBBox())
send += "&boardWidthMm=" + U2MmStr(XMax - XMin) +
"&boardWidthIn=" + U2InStr(XMax - XMin) +
"&boardLengthMm=" + U2MmStr(YMax - YMin) +
"&boardLengthIn=" + U2InStr(YMax - YMin);
if (Within(CopperThicknessInside, 0, INT_MAX))
send += "&copperThicknessInsideMm=" + U2MmStr(CopperThicknessInside) +
"&copperThicknessInsideOz=" + U2OzStr(CopperThicknessInside);
if (Within(MinTraceWidth, 0, INT_MAX))
send += "&minTraceWidthMm=" + U2MmStr(MinTraceWidth) +
"&minTraceWidthIn=" + U2InStr(MinTraceWidth);
if (MinPitch < INT_MAX)
send += "&minPitchMm=" + U2MmStr(MinPitch) +
"&minPitchIn=" + U2InStr(MinPitch);
if (MinHoleSize < INT_MAX)
send += "&minHoleSizeMm=" + U2MmStr(MinHoleSize) +
"&minHoleSizeIn=" + U2InStr(MinHoleSize);
// Assy parameters:
send += "&numPackages=" + I2Str(NrPackages) +
"&numBGAs=" + I2Str(NrBGAs) +
"&numQFNs=" + I2Str(NrQFNs) +
"&numFinePitch=" + I2Str(NrFinePitchs) +
"&numOtherSMDs=" + I2Str(NrOtherSMDs) +
"&numThruHoles=" + I2Str(NrThruHoles) +
"&hasSMDBothSides=" + B2Str(HasSMDBothSides);
// if (Dbg) output(DbgFile, "wba") printf("%s\n%s\n", send);
return send;
}
void Hinweis() {
dlgDialog("Achtung!") {
dlgLabel("<font size =\"40\" color=\"#123456\">Es ist unbedingt ein erfolgreicher Designrule Check vor Übermittlung der Daten zu tätigen.");
dlgPushButton("Ok") dlgAccept();
dlgPushButton("DRC jetzt starten") exit("DRC");
};
}
int Dialog() {
Hinweis();
return dlgDialog(tr("DESY LP-Daten (Version " + Version_Nr + ")")) {
dlgHBoxLayout dlgSpacing(470);
if(config_nicht_vorhanden)
dlgLabel("<h2><font color=\"#FF0000\">Es existiert noch keine Config-Datei für das Board!");
dlgLabel("WA-Nr: "+WA_Nummer+"\nErsteller: "+engineer+"\n");
if (Warnings)
dlgHBoxLayout
dlgGroup(tr("Warnings:"))
dlgLabel(Warnings);
if (!Useless) {
dlgGroup(tr("Fabrication Parameters:"))
dlgGridLayout {
int Row;
dlgCell(Row, 0) dlgLabel(tr("Board name:")); dlgCell(Row++, 1) dlgLabel(Bold(BoardName));
dlgCell(Row, 0) dlgLabel(tr("Number of layers:")); dlgCell(Row++, 1) dlgLabel(Bold(I2Str(NrLayers)));
dlgCell(Row, 0) dlgLabel(tr("Board thickness:")); dlgCell(Row++, 1) dlgLabel(Bold(U2PrefUStrExt(MaterialThickness)));
dlgCell(Row, 0) dlgLabel(tr("Board width (dimension X):")); dlgCell(Row++, 1) dlgLabel(Bold(ValidBBox() ? U2PrefUStrExt(XMax - XMin) : Unknown));
dlgCell(Row, 0) dlgLabel(tr("Board length (dimension Y):")); dlgCell(Row++, 1) dlgLabel(Bold(ValidBBox() ? U2PrefUStrExt(YMax - YMin) : Unknown));
dlgCell(Row, 0) dlgLabel(tr("Copper thickness outer layers:")); dlgCell(Row++, 1) dlgLabel(Bold(U2PrefUStrExt(CopperThicknessOutside)));
dlgCell(Row, 0) dlgLabel(tr("Copper thickness inner layers:")); dlgCell(Row++, 1) dlgLabel(Bold(Within(CopperThicknessInside, 0, INT_MAX) ? U2PrefUStrExt(CopperThicknessInside) : Unknown));
dlgCell(Row, 0) dlgLabel(tr("Minimum trace width (track width):")); dlgCell(Row++, 1) dlgLabel(Bold(Within(MinTraceWidth, 0, INT_MAX) ? U2PrefUStrExt(MinTraceWidth) : Unknown));
dlgCell(Row, 0) dlgLabel(tr("Solder sides:")); dlgCell(Row++, 1) dlgLabel(Bold(tr(SolderSides)));
dlgCell(Row, 0) dlgLabel(tr("Silkscreen sides:")); dlgCell(Row++, 1) dlgLabel(Bold(tr(SilkScreenSides)));
dlgCell(Row, 0) dlgLabel(tr("Anzahl SMD-Pads:")); dlgCell(Row++, 1) dlgLabel(Bold(I2Str(NrSmdPadsTop+NrSmdPadsBottom)));
dlgCell(Row, 0) dlgLabel(tr("Minimum SMD pitch:")); dlgCell(Row++, 1) dlgLabel(Bold(MinPitch < INT_MAX ? U2PrefUStrExt(MinPitch) : Unknown));
dlgCell(Row, 0) dlgLabel(tr("Anzahl buried Vias:")); dlgCell(Row++, 1) dlgLabel(Bold(I2Str(NrburiedVia)));
dlgCell(Row, 0) dlgLabel(tr("Anzahl blind Vias:")); dlgCell(Row++, 1) dlgLabel(Bold(I2Str(NrblindVia)));
dlgCell(Row, 0) dlgLabel(tr("Anzahl Bohrungen:")); dlgCell(Row++, 1) dlgLabel(Bold(I2Str(Bohrungen)));
dlgCell(Row, 0) dlgLabel(tr("Anzahl Bohrdurchmesser:")); dlgCell(Row++, 1) dlgLabel(Bold(I2Str(Bohrdurchmesser)));
dlgCell(Row, 0) dlgLabel(tr("Number of blind or buried hole types:")); dlgCell(Row++, 1) dlgLabel(Bold(I2Str(NrBlindBuriedTypes)));
dlgCell(Row, 0) dlgLabel(tr("Minimum hole size:")); dlgCell(Row++, 1) dlgLabel(Bold(MinHoleSize < INT_MAX ? U2PrefUStrExt(MinHoleSize) : Unknown));
}
/*dlgGroup(tr("Assembly Parameters:"))
dlgGridLayout {
int Row;
dlgCell(Row, 0) dlgLabel(tr("Number of different packages:")); dlgCell(Row++, 1) dlgLabel(Bold(I2Str(NrPackages)));
dlgCell(Row, 0) dlgLabel(tr("Number of") + " BGAs:"); dlgCell(Row++, 1) dlgLabel(Bold(I2Str(NrBGAs)));
dlgCell(Row, 0) dlgLabel(tr("Number of") + " QFNs:"); dlgCell(Row++, 1) dlgLabel(Bold(I2Str(NrQFNs)));
dlgCell(Row, 0) dlgLabel(tr("Number of fine pitch packages:")); dlgCell(Row++, 1) dlgLabel(Bold(I2Str(NrFinePitchs)));
dlgCell(Row, 0) dlgLabel(tr("Number of other SMDs:")); dlgCell(Row++, 1) dlgLabel(Bold(I2Str(NrOtherSMDs)));
dlgCell(Row, 0) dlgLabel(tr("Number of thru hole packages: ")); dlgCell(Row++, 1) dlgLabel(Bold(I2Str(NrThruHoles)));
dlgCell(Row, 0) dlgLabel(tr("SMDs on both sides:")); dlgCell(Row++, 1) dlgLabel(Bold(HasSMDBothSides ? tr("Yes") : tr("No")));
}*/
}
dlgHBoxLayout {
dlgStretch(1);
if (!Useless)
dlgPushButton("Daten exportieren") {
outputFile();
system("cmd /c \""+PROJEKT_PFAD+"LP-Daten_"+filesetext(BoardName,"")+".fdf\"");
}
dlgStretch(1);
dlgPushButton(tr("Close")) dlgReject();
}
};
}
//-----------------------------------------------------------------------------
// main section
//-----------------------------------------------------------------------------
// Parse arguments
for (int i = 1; i <= argc; ++i) {
if (argv[i] == "-noexp") Export = 0;
}
if (board) {
board(B) {
string dir = filedir(B.name);
DruFile = dir + "dl-" + filename(filesetext(B.name, ".dru"));
}
if (Export)
exit("DRC SAVE '" + DruFile + "';\nRUN '" + argv[0] + "' -noexp;");
if (Dbg) board(B) {
DbgFile = filedir(B.name) + "/dbg-pcb-service.txt";
output(DbgFile, "wbaD") printf("\nBoard: %s\n", filename(B.name));
}
status(tr("Calculating quote parameters..."));
GetPCBParams();
if (Warnings) {
string tmp = tr("Your board layout is incomplete:") + "<ul>" + Warnings + "</ul>";
if (Useless) tmp += tr("A quote for this board doesn't make sense yet !");
Warnings = tmp;
}
if (Dbg && Warnings) output(DbgFile, "wba") printf("Warnings: \n%s\n", Warnings);
board(B) {
int grU = B.grid.unit;
PrefUnit = (grU == GRID_UNIT_MM || grU == GRID_UNIT_MIC) ? GRID_UNIT_MM : GRID_UNIT_INCH;
}
while (Dialog() == 1);
output(DruFile, "wD");
exit(EXIT_SUCCESS);
}
else
dlgMessageBox(tr("Please start from board editor !"));