circuitscript 0.1.0 → 0.1.2

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.
Files changed (61) hide show
  1. package/dist/cjs/BaseVisitor.js +13 -8
  2. package/dist/cjs/antlr/CircuitScriptLexer.js +80 -80
  3. package/dist/cjs/antlr/CircuitScriptParser.js +599 -657
  4. package/dist/cjs/builtinMethods.js +27 -8
  5. package/dist/cjs/draw_symbols.js +314 -190
  6. package/dist/cjs/execute.js +113 -115
  7. package/dist/cjs/export.js +2 -4
  8. package/dist/cjs/geometry.js +52 -19
  9. package/dist/cjs/globals.js +12 -8
  10. package/dist/cjs/helpers.js +16 -3
  11. package/dist/cjs/layout.js +129 -125
  12. package/dist/cjs/logger.js +8 -1
  13. package/dist/cjs/objects/ClassComponent.js +22 -22
  14. package/dist/cjs/objects/ExecutionScope.js +10 -4
  15. package/dist/cjs/objects/Frame.js +2 -1
  16. package/dist/cjs/objects/ParamDefinition.js +120 -4
  17. package/dist/cjs/objects/PinDefinition.js +1 -4
  18. package/dist/cjs/render.js +40 -110
  19. package/dist/cjs/sizing.js +33 -7
  20. package/dist/cjs/utils.js +68 -2
  21. package/dist/cjs/visitor.js +214 -254
  22. package/dist/esm/BaseVisitor.mjs +15 -10
  23. package/dist/esm/antlr/CircuitScriptLexer.mjs +80 -80
  24. package/dist/esm/antlr/CircuitScriptParser.mjs +599 -657
  25. package/dist/esm/builtinMethods.mjs +24 -8
  26. package/dist/esm/draw_symbols.mjs +316 -193
  27. package/dist/esm/execute.mjs +115 -117
  28. package/dist/esm/export.mjs +2 -4
  29. package/dist/esm/geometry.mjs +52 -19
  30. package/dist/esm/globals.mjs +12 -8
  31. package/dist/esm/helpers.mjs +17 -4
  32. package/dist/esm/layout.mjs +131 -127
  33. package/dist/esm/logger.mjs +8 -1
  34. package/dist/esm/objects/ClassComponent.mjs +21 -26
  35. package/dist/esm/objects/ExecutionScope.mjs +10 -4
  36. package/dist/esm/objects/Frame.mjs +2 -1
  37. package/dist/esm/objects/ParamDefinition.mjs +119 -3
  38. package/dist/esm/objects/PinDefinition.mjs +0 -2
  39. package/dist/esm/render.mjs +42 -112
  40. package/dist/esm/sizing.mjs +34 -8
  41. package/dist/esm/utils.mjs +64 -1
  42. package/dist/esm/visitor.mjs +216 -256
  43. package/dist/types/BaseVisitor.d.ts +1 -1
  44. package/dist/types/antlr/CircuitScriptParser.d.ts +2 -3
  45. package/dist/types/draw_symbols.d.ts +71 -45
  46. package/dist/types/execute.d.ts +15 -10
  47. package/dist/types/geometry.d.ts +31 -19
  48. package/dist/types/globals.d.ts +14 -10
  49. package/dist/types/helpers.d.ts +2 -1
  50. package/dist/types/layout.d.ts +21 -21
  51. package/dist/types/logger.d.ts +1 -1
  52. package/dist/types/objects/ClassComponent.d.ts +19 -16
  53. package/dist/types/objects/ExecutionScope.d.ts +2 -1
  54. package/dist/types/objects/Frame.d.ts +2 -2
  55. package/dist/types/objects/ParamDefinition.d.ts +31 -2
  56. package/dist/types/objects/PinDefinition.d.ts +0 -2
  57. package/dist/types/render.d.ts +2 -1
  58. package/dist/types/utils.d.ts +6 -1
  59. package/dist/types/visitor.d.ts +4 -5
  60. package/libs/lib.cst +15 -3
  61. package/package.json +7 -3
@@ -11,6 +11,7 @@ const Frame_js_1 = require("./objects/Frame.js");
11
11
  const utils_js_1 = require("./utils.js");
12
12
  const types_js_1 = require("./objects/types.js");
13
13
  const helpers_js_1 = require("./helpers.js");
14
+ const ParamDefinition_js_1 = require("./objects/ParamDefinition.js");
14
15
  class LayoutEngine {
15
16
  constructor(options = { showBaseFrame: false }) {
16
17
  this.placeSubgraphVersion = 2;
@@ -115,8 +116,8 @@ class LayoutEngine {
115
116
  const allLines = wires.map(wire => {
116
117
  return wire.points.map(pt => {
117
118
  return {
118
- x: wire.x + pt.x,
119
- y: wire.y + pt.y,
119
+ x: wire.x.add(pt.x),
120
+ y: wire.y.add(pt.y),
120
121
  };
121
122
  });
122
123
  });
@@ -127,7 +128,7 @@ class LayoutEngine {
127
128
  intersectPoints,
128
129
  });
129
130
  intersectPoints.forEach(([x, y]) => {
130
- junctions.push(new RenderJunction(x, y));
131
+ junctions.push(new RenderJunction((0, ParamDefinition_js_1.numeric)(x), (0, ParamDefinition_js_1.numeric)(y)));
131
132
  });
132
133
  }
133
134
  return {
@@ -137,15 +138,15 @@ class LayoutEngine {
137
138
  }
138
139
  placeFrames(graph, subgraphInfo, frameObjects) {
139
140
  const baseFrame = frameObjects[0];
140
- baseFrame.padding = 0;
141
- baseFrame.borderWidth = 0;
141
+ baseFrame.padding = (0, ParamDefinition_js_1.numeric)(0);
142
+ baseFrame.borderWidth = (0, ParamDefinition_js_1.numeric)(0);
142
143
  if (this.showBaseFrame) {
143
- baseFrame.borderWidth = 5;
144
+ baseFrame.borderWidth = (0, ParamDefinition_js_1.numeric)(5);
144
145
  baseFrame.width = 11692 - 400 * 2;
145
146
  baseFrame.height = 8267 - 400 * 2;
146
147
  }
147
- baseFrame.x = 0;
148
- baseFrame.y = 0;
148
+ baseFrame.x = (0, ParamDefinition_js_1.numeric)(0);
149
+ baseFrame.y = (0, ParamDefinition_js_1.numeric)(0);
149
150
  let textObjects = [];
150
151
  let elementFrames = [];
151
152
  baseFrame.bounds = {
@@ -191,18 +192,18 @@ class LayoutEngine {
191
192
  const innerItems = frame.innerItems;
192
193
  innerItems.forEach(innerFrame => {
193
194
  if (innerFrame.frame.frameType === globals_js_1.FrameType.Sheet) {
194
- innerFrame.x = 0;
195
- innerFrame.y = 0;
195
+ innerFrame.x = (0, ParamDefinition_js_1.numeric)(0);
196
+ innerFrame.y = (0, ParamDefinition_js_1.numeric)(0);
196
197
  }
197
198
  else {
198
- innerFrame.x += frame.x;
199
- innerFrame.y += frame.y;
199
+ innerFrame.x = innerFrame.x.add(frame.x);
200
+ innerFrame.y = innerFrame.y.add(frame.y);
200
201
  }
201
202
  if (innerFrame.type === RenderFrameType.Elements) {
202
203
  this.print(level, "".padStart(level * 4), 'element frame', innerFrame.x, innerFrame.y);
203
204
  innerFrame.innerItems.forEach(item2 => {
204
- item2.x += innerFrame.x - innerFrame.translateX;
205
- item2.y += innerFrame.y - innerFrame.translateY;
205
+ item2.x = item2.x.add(innerFrame.x).sub(innerFrame.translateX);
206
+ item2.y = item2.y.add(innerFrame.y).sub(innerFrame.translateY);
206
207
  });
207
208
  }
208
209
  else {
@@ -214,8 +215,8 @@ class LayoutEngine {
214
215
  placeAndSizeFrame(frame, level = 0) {
215
216
  const innerFrames = frame.innerItems;
216
217
  const gridSize = globals_js_1.defaultGridSizeUnits;
217
- let accumX = 0;
218
- let accumY = 0;
218
+ let accumX = (0, ParamDefinition_js_1.numeric)(0);
219
+ let accumY = (0, ParamDefinition_js_1.numeric)(0);
219
220
  const boundPoints = [];
220
221
  const frameSizes = innerFrames.map(innerFrame => {
221
222
  if (innerFrame.type === RenderFrameType.Elements) {
@@ -243,7 +244,7 @@ class LayoutEngine {
243
244
  return accum;
244
245
  }
245
246
  return accum + width +
246
- ((index + 1 < frameSizes.length) ? frame.gap : 0);
247
+ ((index + 1 < frameSizes.length) ? frame.gap.toNumber() : 0);
247
248
  }, 0);
248
249
  }
249
250
  else {
@@ -267,49 +268,55 @@ class LayoutEngine {
267
268
  innerFrames.forEach(innerFrame => {
268
269
  const { width: frameWidth, height: frameHeight } = (0, utils_js_1.getBoundsSize)(innerFrame.bounds);
269
270
  if (innerFrame.containsTitle) {
270
- innerFrame.x = offsetX + accumX + (0, utils_js_1.toNearestGrid)(widthForTitle / 2 - frameWidth / 2, gridSize);
271
- innerFrame.y = offsetY + accumY;
272
- accumY += (frameHeight + frame.gap);
271
+ innerFrame.x = offsetX.add(accumX).add((0, utils_js_1.toNearestGrid)(widthForTitle / 2 - frameWidth / 2, gridSize));
272
+ innerFrame.y = offsetY.add(accumY);
273
+ accumY = accumY.add(frameHeight).add(frame.gap);
273
274
  }
274
275
  else {
275
276
  if (frame.direction === Frame_js_1.FramePlotDirection.Column) {
276
- innerFrame.x = offsetX + accumX + (0, utils_js_1.toNearestGrid)(maxWidth / 2 - frameWidth / 2, gridSize);
277
- innerFrame.y = offsetY + accumY;
278
- accumY += (frameHeight + frame.gap);
277
+ innerFrame.x = offsetX.add(accumX).add((0, utils_js_1.toNearestGrid)(maxWidth / 2 - frameWidth / 2, gridSize));
278
+ innerFrame.y = offsetY.add(accumY);
279
+ accumY = accumY.add(frameHeight).add(frame.gap);
279
280
  }
280
281
  else if (frame.direction === Frame_js_1.FramePlotDirection.Row) {
281
- innerFrame.x = offsetX + centeredOffsetX + accumX;
282
- innerFrame.y = offsetY + accumY;
283
- accumX += (frameWidth + frame.gap);
282
+ innerFrame.x = offsetX.add(centeredOffsetX).add(accumX);
283
+ innerFrame.y = offsetY.add(accumY);
284
+ accumX = accumX.add(frameWidth).add(frame.gap);
284
285
  }
285
286
  }
286
- boundPoints.push([innerFrame.x, innerFrame.y], [innerFrame.x + frameWidth, innerFrame.y + frameHeight]);
287
+ boundPoints.push([innerFrame.x, innerFrame.y], [innerFrame.x.add(frameWidth), innerFrame.y.add(frameHeight)]);
287
288
  });
288
- const contentsBounds = (0, utils_js_1.resizeBounds)(getBoundsFromPoints(boundPoints), frame.padding);
289
+ const tmpBoundPoints = boundPoints.map(item => {
290
+ return [
291
+ item[0].toNumber(),
292
+ item[1].toNumber(),
293
+ ];
294
+ });
295
+ const contentsBounds = (0, utils_js_1.resizeBounds)(getBoundsFromPoints(tmpBoundPoints), frame.padding.toNumber());
289
296
  if (frame.frame.parameters.has(Frame_js_1.FrameParamKeys.SheetType)) {
290
297
  const frameComponent = frame.frame.parameters.get(Frame_js_1.FrameParamKeys.SheetType);
291
298
  const frameDrawing = frameComponent.displayProp;
292
299
  frameDrawing.variables = (0, utils_js_1.combineMaps)(frameComponent.parameters, frame.frame.parameters);
293
300
  const rects = ExtractDrawingRects(frameDrawing);
294
- let frameWidth = 0;
295
- let frameHeight = 0;
301
+ let frameWidth = (0, ParamDefinition_js_1.numeric)(0);
302
+ let frameHeight = (0, ParamDefinition_js_1.numeric)(0);
296
303
  if (rects[1]) {
297
304
  frameWidth = (0, helpers_js_1.milsToMM)(rects[1].width);
298
305
  frameHeight = (0, helpers_js_1.milsToMM)(rects[1].height);
299
306
  }
300
307
  const contentsWidth = contentsBounds.xmax - contentsBounds.xmin;
301
308
  const contentsHeight = contentsBounds.ymax - contentsBounds.ymin;
302
- const frameOffsetX = (0, utils_js_1.toNearestGrid)((frameWidth - contentsWidth) / 2, gridSize);
303
- const frameOffsetY = (0, utils_js_1.toNearestGrid)((frameHeight - contentsHeight) / 2, gridSize);
309
+ const frameOffsetX = (0, utils_js_1.toNearestGrid)((frameWidth.toNumber() - contentsWidth) / 2, gridSize);
310
+ const frameOffsetY = (0, utils_js_1.toNearestGrid)((frameHeight.toNumber() - contentsHeight) / 2, gridSize);
304
311
  innerFrames.forEach(innerFrame => {
305
- innerFrame.x += frameOffsetX;
306
- innerFrame.y += frameOffsetY;
312
+ innerFrame.x = innerFrame.x.add(frameOffsetX);
313
+ innerFrame.y = innerFrame.y.add(frameOffsetY);
307
314
  });
308
315
  frame.bounds = {
309
316
  xmin: 0,
310
317
  ymin: 0,
311
- xmax: frameWidth,
312
- ymax: frameHeight
318
+ xmax: frameWidth.toNumber(),
319
+ ymax: frameHeight.toNumber(),
313
320
  };
314
321
  }
315
322
  else {
@@ -383,7 +390,7 @@ class LayoutEngine {
383
390
  tmpFrame.containsTitle = true;
384
391
  tmpFrame.subgraphId = title.replace(/\s/g, "_");
385
392
  const textObject = new RenderText(title);
386
- textObject.fontSize = globals_js_1.defaultFrameTitleTextSize;
393
+ textObject.fontSize = (0, ParamDefinition_js_1.numeric)(globals_js_1.defaultFrameTitleTextSize);
387
394
  textObject.fontWeight = 'bold';
388
395
  textObject.symbol.refreshDrawing();
389
396
  tmpFrame.innerItems.push(textObject);
@@ -394,8 +401,8 @@ class LayoutEngine {
394
401
  xmax: tmpBox.start[0] + tmpBox.width,
395
402
  ymax: tmpBox.start[1] + tmpBox.height
396
403
  };
397
- textObject.x = 0;
398
- textObject.y = 0;
404
+ textObject.x = (0, ParamDefinition_js_1.numeric)(0);
405
+ textObject.y = (0, ParamDefinition_js_1.numeric)(0);
399
406
  frame.innerItems.splice(0, 0, tmpFrame);
400
407
  this.printLevel(level, frame, 'added text', tmpFrame);
401
408
  textObjects.push(textObject);
@@ -428,46 +435,43 @@ class LayoutEngine {
428
435
  const tmpInstanceName = component.instanceName;
429
436
  if (!graph.hasNode(tmpInstanceName)) {
430
437
  this.print('create instance', tmpInstanceName);
431
- let { displayProp = null, widthProp = null, typeProp = null } = component;
438
+ const { displayProp = null, widthProp = null, heightProp = null } = component;
432
439
  let tmpSymbol;
433
- if (displayProp === null &&
434
- component.parameters.get(globals_js_1.ParamKeys.net_name) === globals_js_1.GlobalNames.gnd) {
435
- displayProp = 'gnd';
436
- }
437
- if (displayProp !== null) {
438
- if (displayProp instanceof draw_symbols_js_1.SymbolDrawing) {
439
- tmpSymbol = new draw_symbols_js_1.SymbolPlaceholder(displayProp);
440
- tmpSymbol.drawing.logger = this.logger;
441
- }
442
- else if (typeof displayProp === "string") {
443
- tmpSymbol = (0, draw_symbols_js_1.SymbolFactory)(displayProp);
444
- }
440
+ if (displayProp instanceof draw_symbols_js_1.SymbolDrawing) {
441
+ tmpSymbol = new draw_symbols_js_1.SymbolPlaceholder(displayProp);
442
+ tmpSymbol.drawing.logger = this.logger;
445
443
  }
446
444
  else {
447
445
  const symbolPinDefinitions = generateLayoutPinDefinition(component);
448
- if (component.typeProp === 'module') {
449
- tmpSymbol = new draw_symbols_js_1.SymbolCustomModule(symbolPinDefinitions);
446
+ if (component.typeProp === globals_js_1.ComponentTypes.module) {
447
+ tmpSymbol = new draw_symbols_js_1.SymbolCustomModule(symbolPinDefinitions, component.pinsMaxPositions);
450
448
  }
451
449
  else {
452
- tmpSymbol = new draw_symbols_js_1.SymbolCustom(symbolPinDefinitions);
450
+ tmpSymbol = new draw_symbols_js_1.SymbolCustom(symbolPinDefinitions, component.pinsMaxPositions);
453
451
  }
454
452
  }
455
453
  applyComponentParamsToSymbol(component, tmpSymbol);
456
454
  let didSetAngle = false;
457
- if (component.parameters.has('angle')) {
455
+ if (component.parameters.has(globals_js_1.ParamKeys.angle)) {
458
456
  didSetAngle = true;
459
- tmpSymbol.angle = component.parameters.get('angle');
457
+ const value = component.parameters.get(globals_js_1.ParamKeys.angle).toNumber();
458
+ tmpSymbol.angle = value;
460
459
  }
461
- if (component.parameters.has('flipX')) {
460
+ if (component.parameters.has(globals_js_1.ParamKeys.flipX)) {
462
461
  tmpSymbol.flipX =
463
- component.parameters.get('flipX');
462
+ component.parameters.get(globals_js_1.ParamKeys.flipX);
464
463
  }
465
- if (component.parameters.has('flipY')) {
464
+ if (component.parameters.has(globals_js_1.ParamKeys.flipY)) {
466
465
  tmpSymbol.flipY =
467
- component.parameters.get('flipY');
466
+ component.parameters.get(globals_js_1.ParamKeys.flipY);
468
467
  }
469
- if (tmpSymbol instanceof draw_symbols_js_1.SymbolCustom && widthProp) {
470
- tmpSymbol.bodyWidth = (0, helpers_js_1.milsToMM)(widthProp);
468
+ if (tmpSymbol instanceof draw_symbols_js_1.SymbolCustom) {
469
+ if (widthProp) {
470
+ tmpSymbol.bodyWidth = (0, helpers_js_1.milsToMM)(widthProp);
471
+ }
472
+ if (heightProp) {
473
+ tmpSymbol.bodyHeight = (0, helpers_js_1.milsToMM)(heightProp);
474
+ }
471
475
  }
472
476
  if (!didSetAngle && component.parameters.has('_addDirection')) {
473
477
  tmpSymbol.refreshDrawing(false);
@@ -489,7 +493,7 @@ class LayoutEngine {
489
493
  }
490
494
  else if (action === ExecutionScope_js_1.SequenceAction.Wire) {
491
495
  const [, wireId, wireSegments] = sequence[i];
492
- const wire = new RenderWire(0, 0, wireSegments);
496
+ const wire = new RenderWire((0, ParamDefinition_js_1.numeric)(0), (0, ParamDefinition_js_1.numeric)(0), wireSegments);
493
497
  wire.id = wireId;
494
498
  let useNetName = null;
495
499
  if (previousNode !== null) {
@@ -653,7 +657,7 @@ class LayoutEngine {
653
657
  }
654
658
  if (subgraphEdges.length === 0) {
655
659
  const [, node1] = graph.node(firstNodeId);
656
- this.placeNodeAtPosition(0, 0, node1, 1);
660
+ this.placeNodeAtPosition((0, ParamDefinition_js_1.numeric)(0), (0, ParamDefinition_js_1.numeric)(0), node1, 1);
657
661
  return;
658
662
  }
659
663
  let fixedNode;
@@ -666,7 +670,7 @@ class LayoutEngine {
666
670
  const [, node2] = graph.node(nodeId2);
667
671
  if (nodeId1 === firstNodeId && !firstNodePlaced) {
668
672
  this.print('first node placed at origin');
669
- this.placeNodeAtPosition(0, 0, node1, pin1);
673
+ this.placeNodeAtPosition((0, ParamDefinition_js_1.numeric)(0), (0, ParamDefinition_js_1.numeric)(0), node1, pin1);
670
674
  firstNodePlaced = true;
671
675
  node1.isFloating = false;
672
676
  originNodes.push(node1);
@@ -689,7 +693,7 @@ class LayoutEngine {
689
693
  originNodes.push(node1);
690
694
  originNodeGroups.set(node1.toString(), [node1]);
691
695
  this.print('creating new origin node at', node1);
692
- this.placeNodeAtPosition(0, 0, node1, pin1);
696
+ this.placeNodeAtPosition((0, ParamDefinition_js_1.numeric)(0), (0, ParamDefinition_js_1.numeric)(0), node1, pin1);
693
697
  node1.isFloating = false;
694
698
  fixedNode = node1;
695
699
  fixedNodePin = pin1;
@@ -706,7 +710,7 @@ class LayoutEngine {
706
710
  else {
707
711
  const [x1, y1] = getNodePositionAtPin(node1, pin1);
708
712
  const [x2, y2] = getNodePositionAtPin(node2, pin2);
709
- if (x1 !== x2 && y1 !== y2) {
713
+ if (!x1.eq(x2) && !y1.eq(y2)) {
710
714
  if (node1 instanceof RenderWire &&
711
715
  node2 instanceof RenderComponent) {
712
716
  const refdes = node2.component.assignedRefDes;
@@ -783,8 +787,8 @@ class LayoutEngine {
783
787
  this.print('merging origin node groups, fixed:', keepOriginNode, ', other:', otherOriginNode);
784
788
  const [x, y] = getNodePositionAtPin(fixedNode, fixedNodePin);
785
789
  const [otherNodeOriginX, otherNodeOriginY] = getNodePositionAtPin(mergedNode, mergedNodePin);
786
- const offsetX = x - otherNodeOriginX;
787
- const offsetY = y - otherNodeOriginY;
790
+ const offsetX = x.sub(otherNodeOriginX);
791
+ const offsetY = y.sub(otherNodeOriginY);
788
792
  this.print('offset of other origin:', offsetX, offsetY);
789
793
  const otherItemsLinkedToOriginNode = originNodeGroups.get(otherOriginNode);
790
794
  this.print('nodes in other origin:', otherItemsLinkedToOriginNode);
@@ -806,7 +810,7 @@ class LayoutEngine {
806
810
  const [, node2] = graph.node(nodeId2);
807
811
  if (nodeId1 === firstNodeId && !firstNodePlaced) {
808
812
  this.print('first node placed at origin');
809
- this.placeNodeAtPosition(0, 0, node1, pin1);
813
+ this.placeNodeAtPosition((0, ParamDefinition_js_1.numeric)(0), (0, ParamDefinition_js_1.numeric)(0), node1, pin1);
810
814
  firstNodePlaced = true;
811
815
  node1.isFloating = false;
812
816
  }
@@ -852,14 +856,14 @@ class LayoutEngine {
852
856
  });
853
857
  }
854
858
  translateNodeBy(offsetX, offsetY, item) {
855
- item.x += offsetX;
856
- item.y += offsetY;
859
+ item.x = item.x.add(offsetX);
860
+ item.y = item.y.add(offsetY);
857
861
  }
858
862
  placeNodeAtPosition(fromX, fromY, item, pin, depth = 0) {
859
863
  if (item instanceof RenderComponent) {
860
864
  const pinPosition = item.symbol.pinPosition(pin);
861
- item.x = fromX - pinPosition.x;
862
- item.y = fromY - pinPosition.y;
865
+ item.x = fromX.sub(pinPosition.x);
866
+ item.y = fromY.sub(pinPosition.y);
863
867
  }
864
868
  else if (item instanceof RenderWire) {
865
869
  if (pin === 0) {
@@ -868,8 +872,8 @@ class LayoutEngine {
868
872
  }
869
873
  else {
870
874
  const wireEnd = item.getWireEnd();
871
- item.x = fromX - wireEnd.x;
872
- item.y = fromY - wireEnd.y;
875
+ item.x = fromX.sub(wireEnd.x);
876
+ item.y = fromY.sub(wireEnd.y);
873
877
  }
874
878
  }
875
879
  this.print(this.padLevel(depth), 'place', item, 'pin', pin, 'at', item.x, item.y);
@@ -909,12 +913,12 @@ class LayoutEngine {
909
913
  }
910
914
  exports.LayoutEngine = LayoutEngine;
911
915
  function getNodePositionAtPin(item, pin) {
912
- let x = 0;
913
- let y = 0;
916
+ let x = (0, ParamDefinition_js_1.numeric)(0);
917
+ let y = (0, ParamDefinition_js_1.numeric)(0);
914
918
  if (item instanceof RenderComponent) {
915
919
  const pinPosition = item.symbol.pinPosition(pin);
916
- x = item.x + pinPosition.x;
917
- y = item.y + pinPosition.y;
920
+ x = item.x.add(pinPosition.x);
921
+ y = item.y.add(pinPosition.y);
918
922
  }
919
923
  else if (item instanceof RenderWire) {
920
924
  if (pin === 0) {
@@ -923,8 +927,8 @@ function getNodePositionAtPin(item, pin) {
923
927
  }
924
928
  else {
925
929
  const wireEnd = item.getWireEnd();
926
- x = item.x + wireEnd.x;
927
- y = item.y + wireEnd.y;
930
+ x = item.x.add(wireEnd.x);
931
+ y = item.y.add(wireEnd.y);
928
932
  }
929
933
  }
930
934
  return [
@@ -957,7 +961,7 @@ function generateLayoutPinDefinition(component) {
957
961
  const pinPosition = Math.floor(i / 2);
958
962
  const pin = pins.get(existingPinIds[i]);
959
963
  symbolPinDefinitions.push({
960
- side: (i % 2 === 0) ? "left" : "right",
964
+ side: (i % 2 === 0) ? globals_js_1.SymbolPinSide.Left : globals_js_1.SymbolPinSide.Right,
961
965
  pinId: existingPinIds[i],
962
966
  text: pin.name,
963
967
  position: pinPosition,
@@ -976,24 +980,24 @@ function generateLayoutPinDefinition(component) {
976
980
  useItems = [...items];
977
981
  }
978
982
  useItems.forEach(pinId => {
979
- if (existingPinIds.indexOf(pinId) !== -1) {
980
- const pin = pins.get(pinId);
981
- symbolPinDefinitions.push({
982
- side: key,
983
- pinId: pinId,
984
- text: pin.name,
985
- position: pin.position,
986
- pinType: pin.pinType,
987
- });
988
- addedPins.push(pinId);
983
+ if (pinId instanceof ParamDefinition_js_1.NumericValue) {
984
+ const pinIdValue = pinId.toNumber();
985
+ if (existingPinIds.indexOf(pinIdValue) !== -1) {
986
+ const pin = pins.get(pinIdValue);
987
+ symbolPinDefinitions.push({
988
+ side: key,
989
+ pinId: pinIdValue,
990
+ text: pin.name,
991
+ position: pin.position,
992
+ pinType: pin.pinType,
993
+ });
994
+ addedPins.push(pinIdValue);
995
+ }
989
996
  }
990
997
  });
991
998
  }
992
- const unplacedPins = [];
993
- existingPinIds.forEach(item => {
994
- if (addedPins.indexOf(item) === -1) {
995
- unplacedPins.push(item);
996
- }
999
+ const unplacedPins = existingPinIds.filter(pinId => {
1000
+ return addedPins.indexOf(pinId) === -1;
997
1001
  });
998
1002
  if (unplacedPins.length > 0) {
999
1003
  throw "'arrange' property is defined, but not all pins are specified: " + unplacedPins.join(",");
@@ -1035,21 +1039,21 @@ function getBounds(components, wires, junctions, frames) {
1035
1039
  const bbox = item.symbol.drawing.getBoundingBox();
1036
1040
  const [x1, y1] = bbox.start;
1037
1041
  const [x2, y2] = bbox.end;
1038
- points.push([x1 + item.x, y1 + item.y]);
1039
- points.push([x2 + item.x, y2 + item.y]);
1042
+ points.push([x1 + item.x.toNumber(), y1 + item.y.toNumber()]);
1043
+ points.push([x2 + item.x.toNumber(), y2 + item.y.toNumber()]);
1040
1044
  });
1041
1045
  wires.forEach(wire => {
1042
1046
  wire.points.forEach(point => {
1043
- points.push([wire.x + point.x, wire.y + point.y]);
1047
+ points.push([wire.x.add(point.x).toNumber(), wire.y.add(point.y).toNumber()]);
1044
1048
  });
1045
1049
  });
1046
1050
  junctions.forEach(item => {
1047
- points.push([item.x, item.y]);
1051
+ points.push([item.x.toNumber(), item.y.toNumber()]);
1048
1052
  });
1049
1053
  frames.forEach(item => {
1050
1054
  const { width, height } = (0, utils_js_1.getBoundsSize)(item.bounds);
1051
- points.push([item.x, item.y]);
1052
- points.push([item.x + width, item.y + height]);
1055
+ points.push([item.x.toNumber(), item.y.toNumber()]);
1056
+ points.push([item.x.toNumber() + width, item.y.toNumber() + height]);
1053
1057
  });
1054
1058
  return getBoundsFromPoints(points);
1055
1059
  }
@@ -1067,8 +1071,8 @@ function getBoundsFromPoints(points) {
1067
1071
  }
1068
1072
  class RenderObject {
1069
1073
  constructor() {
1070
- this.x = -1;
1071
- this.y = -1;
1074
+ this.x = (0, ParamDefinition_js_1.numeric)(-1);
1075
+ this.y = (0, ParamDefinition_js_1.numeric)(-1);
1072
1076
  this.isFloating = true;
1073
1077
  this.floatingRelativeTo = [];
1074
1078
  }
@@ -1111,7 +1115,7 @@ class RenderWire extends RenderObject {
1111
1115
  tmpX += useValue;
1112
1116
  }
1113
1117
  else if (direction === globals_js_1.WireAutoDirection.Auto || direction === globals_js_1.WireAutoDirection.Auto_) {
1114
- const { valueXY = [0, 0] } = segment;
1118
+ const { valueXY = [(0, ParamDefinition_js_1.numeric)(0), (0, ParamDefinition_js_1.numeric)(0)] } = segment;
1115
1119
  const tmpPoints = this.getAutoPoints(valueXY, direction);
1116
1120
  tmpPoints.forEach(point => {
1117
1121
  if (point[0] !== 0 || point[1] !== 0) {
@@ -1129,8 +1133,8 @@ class RenderWire extends RenderObject {
1129
1133
  this.points = points;
1130
1134
  }
1131
1135
  getAutoPoints(value, direction) {
1132
- const valueX = (0, utils_js_1.roundValue)(value[0]);
1133
- const valueY = (0, utils_js_1.roundValue)(value[1]);
1136
+ const valueX = (0, utils_js_1.roundValue)(value[0]).toNumber();
1137
+ const valueY = (0, utils_js_1.roundValue)(value[1]).toNumber();
1134
1138
  const inQuadrant = geometry_js_1.Geometry.getQuadrant(valueX, valueY);
1135
1139
  const [dx, dy] = [valueX, valueY];
1136
1140
  if (direction === globals_js_1.WireAutoDirection.Auto) {
@@ -1186,16 +1190,16 @@ class RenderWire extends RenderObject {
1186
1190
  useValue = value;
1187
1191
  }
1188
1192
  if (direction === types_js_1.Direction.Down) {
1189
- tmpY += useValue;
1193
+ tmpY = tmpY.add(useValue);
1190
1194
  }
1191
1195
  else if (direction === types_js_1.Direction.Up) {
1192
- tmpY -= useValue;
1196
+ tmpY = tmpY.sub(useValue);
1193
1197
  }
1194
1198
  else if (direction === types_js_1.Direction.Left) {
1195
- tmpX -= useValue;
1199
+ tmpX = tmpX.sub(useValue);
1196
1200
  }
1197
1201
  else if (direction === types_js_1.Direction.Right) {
1198
- tmpX += useValue;
1202
+ tmpX = tmpX.add(useValue);
1199
1203
  }
1200
1204
  });
1201
1205
  let useValue = null;
@@ -1203,22 +1207,22 @@ class RenderWire extends RenderObject {
1203
1207
  const lastSegment = this.segments[this.segments.length - 1];
1204
1208
  switch (lastSegment.direction) {
1205
1209
  case types_js_1.Direction.Left:
1206
- useValue = tmpX - untilX;
1210
+ useValue = tmpX.sub(untilX);
1207
1211
  break;
1208
1212
  case types_js_1.Direction.Right:
1209
- useValue = untilX - tmpX;
1213
+ useValue = untilX.sub(tmpX);
1210
1214
  break;
1211
1215
  case types_js_1.Direction.Up:
1212
- useValue = untilY - tmpY;
1216
+ useValue = untilY.sub(tmpY);
1213
1217
  break;
1214
1218
  case types_js_1.Direction.Down:
1215
- useValue = tmpY - untilY;
1219
+ useValue = tmpY.sub(untilY);
1216
1220
  break;
1217
1221
  case globals_js_1.WireAutoDirection.Auto:
1218
1222
  case globals_js_1.WireAutoDirection.Auto_:
1219
1223
  valueXY = [
1220
- untilX - tmpX,
1221
- untilY - tmpY,
1224
+ untilX.sub(tmpX),
1225
+ untilY.sub(tmpY),
1222
1226
  ];
1223
1227
  useValue = 0;
1224
1228
  break;
@@ -1269,7 +1273,7 @@ class RenderText extends RenderObject {
1269
1273
  }
1270
1274
  constructor(text) {
1271
1275
  super();
1272
- this._fontSize = 12;
1276
+ this._fontSize = (0, ParamDefinition_js_1.numeric)(12);
1273
1277
  this._fontWeight = 'regular';
1274
1278
  this.symbol = new draw_symbols_js_1.SymbolText(text);
1275
1279
  }
@@ -1284,11 +1288,10 @@ class RenderFrame extends RenderObject {
1284
1288
  this.translateY = 0;
1285
1289
  this.padding = (0, helpers_js_1.milsToMM)(100);
1286
1290
  this.gap = (0, helpers_js_1.milsToMM)(100);
1291
+ this.borderWidth = (0, ParamDefinition_js_1.numeric)(5);
1287
1292
  this.direction = Frame_js_1.FramePlotDirection.Column;
1288
- this.borderWidth = 5;
1289
1293
  this.width = null;
1290
1294
  this.height = null;
1291
- this.size = null;
1292
1295
  this.subgraphId = "";
1293
1296
  this.containsTitle = false;
1294
1297
  this.frame = frame;
@@ -1302,7 +1305,8 @@ class RenderFrame extends RenderObject {
1302
1305
  else if (this.type === RenderFrameType.Elements) {
1303
1306
  name = 'elements_' + this.subgraphId;
1304
1307
  }
1305
- return name + ": " + this.x + "," + this.y + " bounds:" + (0, utils_js_1.printBounds)(this.bounds);
1308
+ return name + ": " + this.x + "," + this.y
1309
+ + " bounds:" + (this.bounds && (0, utils_js_1.printBounds)(this.bounds));
1306
1310
  }
1307
1311
  }
1308
1312
  exports.RenderFrame = RenderFrame;
@@ -1327,7 +1331,7 @@ function CalculatePinPositions(component) {
1327
1331
  }
1328
1332
  else {
1329
1333
  const symbolPinDefinitions = generateLayoutPinDefinition(component);
1330
- tmpSymbol = new draw_symbols_js_1.SymbolCustom(symbolPinDefinitions);
1334
+ tmpSymbol = new draw_symbols_js_1.SymbolCustom(symbolPinDefinitions, component.pinsMaxPositions);
1331
1335
  }
1332
1336
  applyComponentParamsToSymbol(component, tmpSymbol);
1333
1337
  tmpSymbol.refreshDrawing();
@@ -7,7 +7,14 @@ class Logger {
7
7
  this.add((new Date()).toISOString());
8
8
  this.add('starting logger...');
9
9
  }
10
- add(message) {
10
+ add(...args) {
11
+ let message = "";
12
+ if (args.length === 1) {
13
+ message = args[0].toString();
14
+ }
15
+ else {
16
+ message = args.join(" ");
17
+ }
11
18
  this.logs.push((new Date()).toISOString() + " | " + message);
12
19
  }
13
20
  dump() {