kisch 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kisch",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -4,10 +4,11 @@ export default class CompoundSymbol {
4
4
  this.pins=[];
5
5
 
6
6
  for (let symbol of symbols) {
7
- for (let pin of symbol.pins) {
8
- //console.log(pin.getNum());
7
+ let pinNums=symbol.getPinNums();
8
+ pinNums.sort();
9
9
 
10
- this.pins.push(pin);
10
+ for (let pinNum of pinNums) {
11
+ this.pins.push(symbol.pin(pinNum));
11
12
  }
12
13
  }
13
14
  }
@@ -5,15 +5,25 @@ class EntityPin {
5
5
  constructor(sexpr, entity) {
6
6
  this.sexpr=sexpr;
7
7
  this.entity=entity;
8
+
9
+ //console.log("ctor pin num: "+this.sexpr[1]);
8
10
  }
9
11
 
10
12
  getNum() {
13
+ //console.log("pin num: "+this.sexpr[1]);
14
+
11
15
  return this.sexpr[1];
12
16
  }
13
17
 
14
18
  initPoint() {
15
19
  let librarySymbol=this.entity.getLibrarySymbol();
16
- let librarySymbolPin=librarySymbol.getPin(Number(this.getNum()));
20
+ let librarySymbolPin;
21
+ if (isNaN(this.getNum()))
22
+ librarySymbolPin=librarySymbol.getPin(this.getNum());
23
+
24
+ else
25
+ librarySymbolPin=librarySymbol.getPin(Number(this.getNum()));
26
+
17
27
  let pinAt=Point.from(librarySymbolPin.at);
18
28
  let symbolAt=this.entity.getAt();
19
29
  let symbolRot=this.entity.getRotation();
@@ -283,15 +293,28 @@ export default class Entity {
283
293
  if (!num)
284
294
  throw new Error("Pin numbers start at 1");
285
295
 
286
- for (let p of this.pins)
296
+ for (let p of this.pins) {
297
+ //console.log("pin num: "+p.getNum());
298
+
287
299
  if (p.getNum()==num)
288
300
  return p;
301
+ }
302
+
303
+ throw new Error("Can't find pin: "+num);
289
304
  }
290
305
 
291
306
  getType() {
292
307
  return this.type;
293
308
  }
294
309
 
310
+ getPinNums() {
311
+ let nums=[];
312
+ for (let p of this.pins)
313
+ nums.push(p.getNum())
314
+
315
+ return nums;
316
+ }
317
+
295
318
  getConnectionPoints() {
296
319
  switch (this.getType()) {
297
320
  case "wire":
@@ -304,8 +327,11 @@ export default class Entity {
304
327
 
305
328
  case "symbol":
306
329
  let p=[];
307
- for (let i=1; i<=this.pins.length; i++)
308
- p.push(this.pin(i).getPoint());
330
+ for (let num of this.getPinNums())
331
+ p.push(this.pin(num).getPoint());
332
+
333
+ /*for (let i=1; i<=this.pins.length; i++)
334
+ p.push(this.pin(i).getPoint());*/
309
335
 
310
336
  return p;
311
337
  break;
@@ -317,7 +343,7 @@ export default class Entity {
317
343
 
318
344
  connect(...pins) {
319
345
  if (this.getType()!="symbol")
320
- throw new Error("can only connect sybols");
346
+ throw new Error("can only connect symbols");
321
347
 
322
348
  if (pins.length!=this.pins.length)
323
349
  throw new Error("pin count mismatch");
@@ -44,10 +44,17 @@ export default class Schematic {
44
44
  this.entities.push(e);
45
45
  }
46
46
 
47
- if (sexpCallName(o)=="uuid")
48
- this.uuid=o[1];
47
+ if (sexpCallName(o)=="uuid") {
48
+ let cand=o[1];
49
+ if (isSym(cand))
50
+ cand=symName(cand);
51
+
52
+ //console.log(cand);
53
+ this.uuid=cand;
54
+ }
49
55
  }
50
56
 
57
+ //console.log("loaded: "+this.uuid);
51
58
  this.sexp=this.sexp.filter(o=>!["wire","label","symbol","uuid"].includes(sexpCallName(o)));
52
59
  }
53
60
 
@@ -433,8 +440,14 @@ export default class Schematic {
433
440
  ]
434
441
  ]);
435
442
 
436
- for (let i=1; i<=librarySymbol.pins.length; i++)
443
+ for (let p of librarySymbol.pins) {
444
+ expr.push([sym("pin"),p.number,[sym("uuid"),crypto.randomUUID()]]);
445
+ }
446
+
447
+ /*for (let i=1; i<=librarySymbol.pins.length; i++) {
448
+ //console.log("create pin: "+i);
437
449
  expr.push([sym("pin"),String(i),[sym("uuid"),crypto.randomUUID()]]);
450
+ }*/
438
451
 
439
452
  expr.push([sym("instances"),
440
453
  [sym("project"),"",