File: split-device-symbol.ulp

package info (click to toggle)
eagle 5.10.0-2
  • links: PTS
  • area: non-free
  • in suites: squeeze
  • size: 88,616 kB
  • ctags: 720
  • sloc: makefile: 33; sh: 24
file content (215 lines) | stat: -rw-r--r-- 7,126 bytes parent folder | download | duplicates (3)
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
#usage "en: <qt>This ULP generates the CONNECT list for a new Device, that consists of several Symbols (Gates),<br> "
       "which have been extracted from one big Symbol by GROUP; CUT; and PASTE.</nobr><p> "
       "Example:<br> "
       "It is possible to generate a Device with Symbol and Package from a BSDL file or text file (spreadsheet) with "
       "the help of <i>RUN make-symbol-device-package-bsdl</i>. In cases where the Symbol becomes too big, due to the "
       "number of pins, and it does not fit onto a single schematic sheet, you can divide into several smaller Symbols with "
       "the commands GROUP, CUT, EDIT xx.sym, PASTE ...., and adopt the Connect list from the 'original Device'.<p> "
       "Please note:<br> "
       "There must not be pins with same names. So it is not possible to use this ULP for Devices that consist of "
       "identical Symbols (gates like NAND or OP-AMP..). "
       "<p>"
       "<author>librarian@cadsoft.de</author></qt>"
       ,
       "de: <qt><nobr>Dieses ULP erstellt die CONNECT-Liste für ein neues Device, das aus mehreren Symbolen (Gates) besteht,<br> "
       "die wiederum durch GROUP; CUT; und PASTE aus einem großen Symbol erstellt wurden.<p></nobr>"
       "Beispiel:<br>"
       "Mit <i>RUN make-symbol-device-package-bsdl</i> kann mit einer BSDL- oder Textdatei (Tabelle) ein Device mit Symbol "
       "und Package generiert werden. In den Fällen, in denen das Symbol durch die Anzahl der Pins zu groß wird, "
       "um es im Schaltplan auf eine Seite zu platzieren, kann mit GROUP - CUT - EDIT xx.sym - PASTE .... das Symbol in "
       "mehrere kleinere Symbole aufgeteilt werden und mit Hilfe dieses ULPs die Connect-Liste vom 'Original-Device' übernommen werden.<p>"
       "ACHTUNG:<br>"
       "Es dürfen keine Pin-Namen doppelt vorkommen. So ist es z.B. nicht möglich dieses ULP für ein Device, das aus mehreren gleichen "
       "Symbolen (Gates wie NAND oder OP-AMP) besteht, zu benutzen."
       "<p>"
       "<author>librarian@cadsoft.de</author></qt>"



string Version = "1.0";  // 2006.12.01 alf@cadsoft.de


string DeviceVariant, Pin_Name[], Pad_Name[];
string DeviceSet;
string Device_Sets[];
string Variant[];
string Package[];
string Device_Variant[], Device_Package[];
int    cntD = 0;
int    cntConnect = 0;

string actualpackage = " ";

string cmd;
string DeviceDescription;

string replacenewline(string nl) {
  string a[];
  int n = strsplit(a, nl, '\n');
  if (n > 0) {
    nl = "";
    for (int x = 0; x < n - 1; x++) {
      nl += a[x] + "\\n";
    }
    nl += a[x];
  }
  return "'" + nl + "'";
}


string checkVariant(string s) {
  if (s == "''") s = "''''";
  return s;
}


void getPackage(int x) {
  actualpackage = Device_Package[x]+".PAC";
  return;
}


void getVariant(int x) {
  string p[], v[];
  int cnt;
  cnt = strsplit(p, Package[x], ' ');
  cnt = strsplit(v, Variant[x], ' ');
  for (int n = 0; n < cnt; n++) {
    Device_Variant[n] = v[n];
    Device_Package[n] = p[n];
  }
  return;
}


string getPadName(string name) {
  for (int n = 0; n < cntConnect; n++) {
    if (name == Pin_Name[n]) return Pad_Name[n];
  }
  return "";
}


if (library) {
  string file;
  if (deviceset) {
    deviceset(DEV) {
      DeviceSet = DEV.name;
      DEV.devices(D) {
        cntConnect = 0;
        D.gates(G) {
          G.symbol.pins(P) {
            cntConnect++;                  // count all pins
          }
        }
      }
    }
    if (!cntConnect) {
      dlgMessageBox("!This Deviceset use no Symbol(s)", "OK");
      exit(0);
    }

    int selD = -1;
    int selV = -1;
    library(L) {
      L.devicesets(DEV) {    // collect only devicesets with the same counts of connects as the actual deviceset
        int cntC;
        if (DEV.name != DeviceSet) {
          DEV.devices(D) {
            cntC = 0;
            D.gates(G) {
              G.symbol.pins(P) cntC++;
            }
            if (cntC == cntConnect) {
              Device_Sets[cntD] = DEV.name;
              Variant[cntD] += D.name + " ";   // Package Variant
              Package[cntD] += D.package.name + " ";
            }
          }
          if (cntC == cntConnect) cntD++;
        }
      }
      string use_Device;
      int listsel = 0;
      do {
        int RESULT = dlgDialog(filename(argv[0])) {
          dlgHBoxLayout {
            dlgLabel(DeviceSet+".DEV");
            //dlgLabel(" Variant:"+DeviceVariant);
          }
          dlgSpacing(8);

          dlgHBoxLayout {
            dlgGridLayout {
              dlgCell(0,  1) dlgLabel("Select a &Device\nto get Connect list");
              dlgCell(1,  1) dlgListView("DeviceSet", Device_Sets, selD, listsel) { getVariant(selD); actualpackage = " "; }
              dlgCell(0,  2) dlgLabel("Select a Package &Variant") ;
              dlgCell(1,  2) dlgListView("Variant", Device_Variant, selV) getPackage(selV);
              dlgCell(2,  2) dlgLabel(actualpackage, 1);
            }
            dlgStretch(1);
          }
          dlgHBoxLayout {
            dlgPushButton("+OK") dlgAccept();
            dlgPushButton("-Cancel") dlgReject();
            dlgPushButton("&Help") dlgMessageBox(usage);
          }
        };
        if (!RESULT) exit(0);

        if (selD < 0) dlgMessageBox("no device selected!", "OK");
      } while (selD < 0);
    }
    library(L) {
      file = filesetext(L.name, "~connect.scr");
      L.devicesets(DEV) {
        if (DEV.name == Device_Sets[selD]) {
          DEV.devices(D) {
            if (D.name == Device_Variant[selV]) {
              int n = 0;
              D.gates(G) {
                G.symbol.pins(P) {
                  Pin_Name[n] = P.name;
                  Pad_Name[n] = P.contact.name;
                  n++;
                }
              }
            }
          }
          DeviceDescription = DEV.description;
        }
      }
    }
    deviceset(DEV) {
      int variant_not_used = 1;
      DEV.devices(D) {
        if (D.name == Device_Variant[selV]) {
          variant_not_used = 0;
          dlgMessageBox("This Package-Variant are used, select a unused variant!", "OK");
          exit(0);
        }
      }
      if (variant_not_used) {
        output(file, "wtD") {
          DEV.devices(D) {
            printf("PACKAGE %s %s;\n", Device_Package[selV], Device_Variant[selV]);
            D.gates(G) {
              G.symbol.pins(P) {
                string pad = getPadName(P.name);
                if (!pad) dlgMessageBox("No PAD found for "+ P.name +"\nCheck Pinname of Symbols", "OK");
                printf("CONNECT %s.%s %s;\n", G.name, P.name, pad);
              }
            }
            string t[];
            printf("DESCRIPTION %s;\n", replacenewline(DeviceDescription+"<br><i>Connect-List generated from </i><b>"+ Device_Sets[selD] +".DEV</b> Variant <b>"+ checkVariant(Device_Variant[selV]) +"</b> with <i><b>"+ filename(argv[0])+"</b></i>"));
          }
          printf("WIN FIT;\n");
        }
        exit("SCRIPT '"+ file + "';\n");
      }
    }
  }
  else dlgMessageBox("Open a Device", "OK");
}

else dlgMessageBox("Start this ULP in a LBR (Device)", "OK");