circuitscript 0.0.38 → 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.
- package/dist/cjs/BaseVisitor.js +69 -46
- package/dist/cjs/SymbolValidatorVisitor.js +1 -1
- package/dist/cjs/antlr/CircuitScriptLexer.js +80 -80
- package/dist/cjs/antlr/CircuitScriptParser.js +580 -613
- package/dist/cjs/builtinMethods.js +32 -10
- package/dist/cjs/draw_symbols.js +375 -233
- package/dist/cjs/execute.js +142 -131
- package/dist/cjs/export.js +2 -4
- package/dist/cjs/geometry.js +52 -19
- package/dist/cjs/globals.js +14 -9
- package/dist/cjs/helpers.js +16 -3
- package/dist/cjs/layout.js +143 -151
- package/dist/cjs/logger.js +8 -1
- package/dist/cjs/objects/ClassComponent.js +22 -22
- package/dist/cjs/objects/ExecutionScope.js +10 -4
- package/dist/cjs/objects/Frame.js +4 -1
- package/dist/cjs/objects/ParamDefinition.js +120 -4
- package/dist/cjs/objects/PinDefinition.js +1 -4
- package/dist/cjs/objects/types.js +41 -0
- package/dist/cjs/render.js +41 -110
- package/dist/cjs/sizing.js +33 -7
- package/dist/cjs/utils.js +92 -2
- package/dist/cjs/visitor.js +279 -284
- package/dist/esm/BaseVisitor.mjs +70 -47
- package/dist/esm/SymbolValidatorVisitor.mjs +1 -1
- package/dist/esm/antlr/CircuitScriptLexer.mjs +80 -80
- package/dist/esm/antlr/CircuitScriptParser.mjs +580 -613
- package/dist/esm/builtinMethods.mjs +29 -10
- package/dist/esm/draw_symbols.mjs +381 -238
- package/dist/esm/execute.mjs +144 -133
- package/dist/esm/export.mjs +2 -4
- package/dist/esm/geometry.mjs +52 -19
- package/dist/esm/globals.mjs +13 -8
- package/dist/esm/helpers.mjs +17 -4
- package/dist/esm/layout.mjs +144 -153
- package/dist/esm/logger.mjs +8 -1
- package/dist/esm/objects/ClassComponent.mjs +21 -26
- package/dist/esm/objects/ExecutionScope.mjs +10 -4
- package/dist/esm/objects/Frame.mjs +4 -1
- package/dist/esm/objects/ParamDefinition.mjs +119 -3
- package/dist/esm/objects/PinDefinition.mjs +0 -2
- package/dist/esm/objects/types.mjs +42 -0
- package/dist/esm/render.mjs +44 -113
- package/dist/esm/sizing.mjs +34 -8
- package/dist/esm/utils.mjs +86 -1
- package/dist/esm/visitor.mjs +281 -286
- package/dist/types/BaseVisitor.d.ts +3 -2
- package/dist/types/antlr/CircuitScriptParser.d.ts +5 -3
- package/dist/types/draw_symbols.d.ts +81 -49
- package/dist/types/execute.d.ts +16 -11
- package/dist/types/geometry.d.ts +31 -19
- package/dist/types/globals.d.ts +15 -10
- package/dist/types/helpers.d.ts +2 -1
- package/dist/types/layout.d.ts +22 -21
- package/dist/types/logger.d.ts +1 -1
- package/dist/types/objects/ClassComponent.d.ts +19 -16
- package/dist/types/objects/ExecutionScope.d.ts +2 -1
- package/dist/types/objects/Frame.d.ts +5 -3
- package/dist/types/objects/ParamDefinition.d.ts +31 -2
- package/dist/types/objects/PinDefinition.d.ts +0 -2
- package/dist/types/objects/types.d.ts +7 -2
- package/dist/types/render.d.ts +2 -1
- package/dist/types/utils.d.ts +9 -1
- package/dist/types/visitor.d.ts +5 -5
- package/libs/lib.cst +102 -32
- package/package.json +7 -3
package/dist/esm/execute.mjs
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { BlockTypes, ComponentTypes, GlobalNames, NoNetText, ParamKeys, ReferenceTypes } from './globals.mjs';
|
|
2
|
-
import { ClassComponent } from './objects/ClassComponent.mjs';
|
|
1
|
+
import { BlockTypes, ComponentTypes, GlobalNames, NoNetText, ParamKeys, ReferenceTypes, SymbolPinSide } from './globals.mjs';
|
|
2
|
+
import { ClassComponent, ModuleComponent } from './objects/ClassComponent.mjs';
|
|
3
3
|
import { ActiveObject, ExecutionScope, FrameAction, SequenceAction } from './objects/ExecutionScope.mjs';
|
|
4
4
|
import { Net } from './objects/Net.mjs';
|
|
5
|
+
import { numeric } from './objects/ParamDefinition.mjs';
|
|
5
6
|
import { PortSide } from './objects/PinDefinition.mjs';
|
|
6
7
|
import { DeclaredReference, Direction } from './objects/types.mjs';
|
|
7
8
|
import { Wire } from './objects/Wire.mjs';
|
|
8
9
|
import { Frame } from './objects/Frame.mjs';
|
|
9
10
|
import { CalculatePinPositions } from './layout.mjs';
|
|
11
|
+
import { UnitDimension } from './helpers.mjs';
|
|
12
|
+
import { PlaceHolderCommands, SymbolDrawingCommands } from './draw_symbols.mjs';
|
|
10
13
|
export class ExecutionContext {
|
|
11
14
|
name;
|
|
12
15
|
namespace;
|
|
@@ -56,27 +59,14 @@ export class ExecutionContext {
|
|
|
56
59
|
}
|
|
57
60
|
setupRoot() {
|
|
58
61
|
const componentRoot = ClassComponent.simple(GlobalNames.__root, 1, '__root');
|
|
59
|
-
componentRoot.typeProp = ComponentTypes.
|
|
60
|
-
componentRoot.displayProp =
|
|
62
|
+
componentRoot.typeProp = ComponentTypes.net;
|
|
63
|
+
componentRoot.displayProp = this.getPointSymbol();
|
|
61
64
|
this.scope.instances.set(GlobalNames.__root, componentRoot);
|
|
62
|
-
this.scope.
|
|
63
|
-
this.scope.currentPin = componentRoot.getDefaultPin();
|
|
65
|
+
this.scope.setCurrent(componentRoot);
|
|
64
66
|
this.scope.componentRoot = componentRoot;
|
|
65
67
|
}
|
|
66
|
-
getUniqueInstanceName(
|
|
67
|
-
|
|
68
|
-
switch (className) {
|
|
69
|
-
case GlobalNames.DefaultResistor:
|
|
70
|
-
extraPrefix = 'R_';
|
|
71
|
-
break;
|
|
72
|
-
case GlobalNames.DefaultCapacitor:
|
|
73
|
-
extraPrefix = 'C_';
|
|
74
|
-
break;
|
|
75
|
-
case GlobalNames.DefaultInductor:
|
|
76
|
-
extraPrefix = 'L_';
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
const tmpName = extraPrefix + 'COMP_' + this.scope.unnamedCounter;
|
|
68
|
+
getUniqueInstanceName() {
|
|
69
|
+
const tmpName = 'COMP_' + this.scope.unnamedCounter;
|
|
80
70
|
this.scope.unnamedCounter += 1;
|
|
81
71
|
return tmpName;
|
|
82
72
|
}
|
|
@@ -89,14 +79,8 @@ export class ExecutionContext {
|
|
|
89
79
|
return [this.scope.currentComponent, this.scope.currentPin];
|
|
90
80
|
}
|
|
91
81
|
linkComponentPinNet(component1, component1Pin, component2, component2Pin) {
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
const net1 = net1_exists
|
|
95
|
-
? this.scope.getNet(component1, component1Pin)
|
|
96
|
-
: null;
|
|
97
|
-
const net2 = net2_exists
|
|
98
|
-
? this.scope.getNet(component2, component2Pin)
|
|
99
|
-
: null;
|
|
82
|
+
const net1 = this.scope.getNet(component1, component1Pin);
|
|
83
|
+
const net2 = this.scope.getNet(component2, component2Pin);
|
|
100
84
|
this.log('link nets', component1, component1Pin, net1, 'to', component2, component2Pin, net2);
|
|
101
85
|
let returnNet;
|
|
102
86
|
if (net1 === null && net2 === null) {
|
|
@@ -118,43 +102,43 @@ export class ExecutionContext {
|
|
|
118
102
|
returnNet = this.mergeNets(net1, net2);
|
|
119
103
|
}
|
|
120
104
|
else {
|
|
121
|
-
|
|
105
|
+
returnNet = net1;
|
|
122
106
|
}
|
|
123
107
|
}
|
|
108
|
+
this.log('final net after link: ', returnNet);
|
|
124
109
|
return returnNet;
|
|
125
110
|
}
|
|
126
111
|
mergeNets(net1, net2) {
|
|
127
112
|
if (net1 === net2) {
|
|
128
113
|
return net1;
|
|
129
114
|
}
|
|
130
|
-
let tmpNet;
|
|
131
115
|
if (net2.priority > net1.priority) {
|
|
132
|
-
tmpNet = net1;
|
|
116
|
+
const tmpNet = net1;
|
|
133
117
|
net1 = net2;
|
|
134
118
|
net2 = tmpNet;
|
|
135
119
|
}
|
|
136
|
-
|
|
137
|
-
scopeNets.forEach(([component, pin, net]) => {
|
|
120
|
+
this.scope.getNets().forEach(([component, pin, net]) => {
|
|
138
121
|
if (Net.isSame(net, net2)) {
|
|
139
122
|
this.scope.setNet(component, pin, net1);
|
|
140
123
|
}
|
|
141
124
|
});
|
|
142
125
|
return net1;
|
|
143
126
|
}
|
|
144
|
-
createComponent(instanceName, pins, params, props) {
|
|
145
|
-
const
|
|
146
|
-
const component = new
|
|
127
|
+
createComponent(instanceName, pins, params, props, isModule = false) {
|
|
128
|
+
const className = isModule ? ModuleComponent : ClassComponent;
|
|
129
|
+
const component = new className(instanceName, pins.length);
|
|
147
130
|
pins.forEach((pin) => {
|
|
148
131
|
component.pins.set(pin.id, pin);
|
|
149
132
|
});
|
|
150
133
|
component.arrangeProps = props.arrange ?? null;
|
|
151
134
|
component.displayProp = props.display ?? null;
|
|
152
135
|
component.widthProp = props.width ?? null;
|
|
136
|
+
component.heightProp = props.height ?? null;
|
|
153
137
|
component.typeProp = props.type ?? null;
|
|
154
138
|
component.copyProp = props.copy ?? false;
|
|
155
139
|
let useAngle = null;
|
|
156
140
|
if (props.angle) {
|
|
157
|
-
useAngle = props.angle % 360;
|
|
141
|
+
useAngle = props.angle.toNumber() % 360;
|
|
158
142
|
if (useAngle < 0) {
|
|
159
143
|
useAngle += 360;
|
|
160
144
|
}
|
|
@@ -166,10 +150,12 @@ export class ExecutionContext {
|
|
|
166
150
|
component.parameters.set(param.paramName, param.paramValue);
|
|
167
151
|
paramsMap.set(param.paramName, param.paramValue);
|
|
168
152
|
});
|
|
169
|
-
if (component.typeProp === ComponentTypes.net
|
|
170
|
-
|| component.typeProp === ComponentTypes.label) {
|
|
153
|
+
if (component.typeProp === ComponentTypes.net) {
|
|
171
154
|
const netName = paramsMap.get(ParamKeys.net_name);
|
|
172
|
-
|
|
155
|
+
let priority = 0;
|
|
156
|
+
if (paramsMap.has(ParamKeys.priority)) {
|
|
157
|
+
priority = paramsMap.get(ParamKeys.priority).toNumber();
|
|
158
|
+
}
|
|
173
159
|
const result = this.resolveNet(netName, this.netNamespace);
|
|
174
160
|
let tmpNet;
|
|
175
161
|
if (result.found) {
|
|
@@ -183,8 +169,9 @@ export class ExecutionContext {
|
|
|
183
169
|
this.scope.setNet(component, 1, tmpNet);
|
|
184
170
|
this.log('set net', netName, 'component', component);
|
|
185
171
|
}
|
|
186
|
-
const
|
|
187
|
-
|
|
172
|
+
const { pins: pinSides, maxPositions } = getPortSide(component.pins, component.arrangeProps);
|
|
173
|
+
component.pinsMaxPositions = maxPositions;
|
|
174
|
+
pinSides.forEach(({ pinId, side, position }) => {
|
|
188
175
|
if (component.pins.has(pinId)) {
|
|
189
176
|
const tmpPin = component.pins.get(pinId);
|
|
190
177
|
tmpPin.side = side;
|
|
@@ -215,10 +202,9 @@ export class ExecutionContext {
|
|
|
215
202
|
this.scope.currentPin + ' ' + netString);
|
|
216
203
|
}
|
|
217
204
|
addComponentExisting(component, pin) {
|
|
218
|
-
const
|
|
219
|
-
const nextPin = component.getNextPinAfter(startPin);
|
|
205
|
+
const nextPin = component.getNextPinAfter(pin);
|
|
220
206
|
this.applyComponentAngleFromWire(component, pin);
|
|
221
|
-
this.toComponent(component,
|
|
207
|
+
this.toComponent(component, pin, { addSequence: true });
|
|
222
208
|
this.log('move to next pin: ' + nextPin);
|
|
223
209
|
this.atComponent(component, nextPin, {
|
|
224
210
|
addSequence: true
|
|
@@ -254,13 +240,10 @@ export class ExecutionContext {
|
|
|
254
240
|
}
|
|
255
241
|
const linkedNet = this.linkComponentPinNet(this.scope.currentComponent, this.scope.currentPin, component, pinId);
|
|
256
242
|
this.applyComponentAngleFromWire(component, pinId);
|
|
257
|
-
this.scope.
|
|
258
|
-
this.scope.currentPin = pinId;
|
|
243
|
+
this.scope.setCurrent(component, pinId);
|
|
259
244
|
this.scope.clearActive();
|
|
260
245
|
if (addSequence) {
|
|
261
246
|
if (this.scope.sequence.length > 0) {
|
|
262
|
-
if (component.pinWires.has(pinId) && component.typeProp !== ComponentTypes.point) {
|
|
263
|
-
}
|
|
264
247
|
const [entryType, , segments] = this.scope.sequence[this.scope.sequence.length - 1];
|
|
265
248
|
if (entryType === SequenceAction.Wire && isWireSegmentsEndAuto(segments)) {
|
|
266
249
|
segments[segments.length - 1].until = [
|
|
@@ -278,7 +261,6 @@ export class ExecutionContext {
|
|
|
278
261
|
atComponent(component, pinId, options) {
|
|
279
262
|
this.log('at component');
|
|
280
263
|
const { addSequence = false } = options ?? {};
|
|
281
|
-
this.scope.currentComponent = component;
|
|
282
264
|
let usePinId;
|
|
283
265
|
if (pinId === null) {
|
|
284
266
|
usePinId = component.getDefaultPin();
|
|
@@ -291,9 +273,7 @@ export class ExecutionContext {
|
|
|
291
273
|
throw 'Invalid pin number ' + pinId + ' in ' + component;
|
|
292
274
|
}
|
|
293
275
|
}
|
|
294
|
-
|
|
295
|
-
this.scope.currentPin = usePinId;
|
|
296
|
-
}
|
|
276
|
+
this.scope.setCurrent(component, usePinId);
|
|
297
277
|
this.scope.clearActive();
|
|
298
278
|
if (addSequence) {
|
|
299
279
|
this.scope.sequence.push([SequenceAction.At,
|
|
@@ -320,12 +300,9 @@ export class ExecutionContext {
|
|
|
320
300
|
return componentCopy;
|
|
321
301
|
}
|
|
322
302
|
enterBlocks(blockType) {
|
|
323
|
-
if (blockType === BlockTypes.Point) {
|
|
324
|
-
|
|
325
|
-
this.tmpPointId
|
|
326
|
-
}
|
|
327
|
-
else if (blockType === BlockTypes.Parallel) {
|
|
328
|
-
this.addPoint(`_parallel.${this.name}.${this.tmpPointId}`, false);
|
|
303
|
+
if (blockType === BlockTypes.Point || blockType === BlockTypes.Parallel) {
|
|
304
|
+
const key = blockType === BlockTypes.Point ? 'point' : 'parallel';
|
|
305
|
+
this.addPoint(`_${key}.${this.name}.${this.tmpPointId}`, false);
|
|
329
306
|
this.tmpPointId += 1;
|
|
330
307
|
}
|
|
331
308
|
this.scope.blockStack.set(this.scope.indentLevel, {
|
|
@@ -346,8 +323,7 @@ export class ExecutionContext {
|
|
|
346
323
|
if (blockType === BlockTypes.Join || blockType === BlockTypes.Parallel) {
|
|
347
324
|
const { final_point: finalPoint } = stackRef;
|
|
348
325
|
const [component, pin, wireId] = finalPoint;
|
|
349
|
-
this.scope.
|
|
350
|
-
this.scope.currentPin = pin;
|
|
326
|
+
this.scope.setCurrent(component, pin);
|
|
351
327
|
this.scope.currentWireId = wireId;
|
|
352
328
|
if (wireId !== -1) {
|
|
353
329
|
this.scope.sequence.push([
|
|
@@ -370,8 +346,7 @@ export class ExecutionContext {
|
|
|
370
346
|
ignore_last_net: false,
|
|
371
347
|
});
|
|
372
348
|
if (blockType === BlockTypes.Join || blockType === BlockTypes.Point) {
|
|
373
|
-
this.scope.
|
|
374
|
-
this.scope.currentPin = null;
|
|
349
|
+
this.scope.setCurrent(null);
|
|
375
350
|
this.scope.currentWireId = -1;
|
|
376
351
|
}
|
|
377
352
|
else if (blockType === BlockTypes.Parallel) {
|
|
@@ -465,7 +440,7 @@ export class ExecutionContext {
|
|
|
465
440
|
getFunction(functionName) {
|
|
466
441
|
return this.scope.functions.get(functionName);
|
|
467
442
|
}
|
|
468
|
-
resolveVariable(executionStack, idName) {
|
|
443
|
+
resolveVariable(executionStack, idName, trailers = []) {
|
|
469
444
|
const reversed = [...executionStack].reverse();
|
|
470
445
|
for (let i = 0; i < reversed.length; i++) {
|
|
471
446
|
const context = reversed[i];
|
|
@@ -477,21 +452,34 @@ export class ExecutionContext {
|
|
|
477
452
|
name: idName,
|
|
478
453
|
});
|
|
479
454
|
}
|
|
480
|
-
else
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
455
|
+
else {
|
|
456
|
+
const isVariable = context.scope.variables.has(idName);
|
|
457
|
+
const isComponentInstance = context.scope.instances.has(idName);
|
|
458
|
+
if (isVariable || isComponentInstance) {
|
|
459
|
+
const scopeList = isVariable ? context.scope.variables
|
|
460
|
+
: context.scope.instances;
|
|
461
|
+
let parentValue = undefined;
|
|
462
|
+
let useValue = scopeList.get(idName);
|
|
463
|
+
if (trailers.length > 0) {
|
|
464
|
+
parentValue = useValue;
|
|
465
|
+
const trailersPath = trailers.join(".");
|
|
466
|
+
if (isVariable) {
|
|
467
|
+
useValue = parentValue[trailersPath];
|
|
468
|
+
}
|
|
469
|
+
else if (isComponentInstance) {
|
|
470
|
+
useValue = parentValue.parameters.get(trailersPath);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return new DeclaredReference({
|
|
474
|
+
type: isVariable ? ReferenceTypes.variable
|
|
475
|
+
: ReferenceTypes.instance,
|
|
476
|
+
found: (useValue !== undefined),
|
|
477
|
+
parentValue,
|
|
478
|
+
value: useValue,
|
|
479
|
+
name: idName,
|
|
480
|
+
trailers,
|
|
481
|
+
});
|
|
482
|
+
}
|
|
495
483
|
}
|
|
496
484
|
}
|
|
497
485
|
return new DeclaredReference({
|
|
@@ -575,7 +563,6 @@ export class ExecutionContext {
|
|
|
575
563
|
}
|
|
576
564
|
const wireIdOffset = this.scope.wires.length;
|
|
577
565
|
const frameIdOffset = this.scope.frames.length;
|
|
578
|
-
let incrementGndLinkId = 0;
|
|
579
566
|
childScope.sequence.forEach(sequenceAction => {
|
|
580
567
|
const [action] = sequenceAction;
|
|
581
568
|
if (action === SequenceAction.Wire) {
|
|
@@ -588,20 +575,6 @@ export class ExecutionContext {
|
|
|
588
575
|
this.scope.sequence.push([SequenceAction.WireJump, jumpWireId, 1]);
|
|
589
576
|
}
|
|
590
577
|
else if (action === SequenceAction.At || action === SequenceAction.To) {
|
|
591
|
-
const tmpComponent = sequenceAction[1];
|
|
592
|
-
if (tmpComponent.typeProp === ComponentTypes.net
|
|
593
|
-
&& tmpComponent.parameters.get(ParamKeys.net_name) === 'gnd') {
|
|
594
|
-
tmpComponent._copyID = gndCopyIdOffset + incrementGndLinkId;
|
|
595
|
-
incrementGndLinkId += 1;
|
|
596
|
-
}
|
|
597
|
-
else if (tmpComponent === tmpRoot) {
|
|
598
|
-
if (currentWireId !== -1) {
|
|
599
|
-
sequenceAction = [SequenceAction.WireJump, currentWireId];
|
|
600
|
-
}
|
|
601
|
-
else {
|
|
602
|
-
sequenceAction = [action, currentComponent, currentPin];
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
578
|
this.scope.sequence.push(sequenceAction);
|
|
606
579
|
}
|
|
607
580
|
else if (action === SequenceAction.Frame) {
|
|
@@ -615,13 +588,11 @@ export class ExecutionContext {
|
|
|
615
588
|
}
|
|
616
589
|
});
|
|
617
590
|
if (childScope.currentComponent === childScope.componentRoot) {
|
|
618
|
-
this.scope.currentComponent
|
|
619
|
-
this.scope.currentPin = currentPin;
|
|
591
|
+
this.scope.setCurrent(currentComponent, currentPin);
|
|
620
592
|
this.scope.currentWireId = currentWireId;
|
|
621
593
|
}
|
|
622
594
|
else {
|
|
623
|
-
this.scope.currentComponent
|
|
624
|
-
this.scope.currentPin = childScope.currentPin;
|
|
595
|
+
this.scope.setCurrent(childScope.currentComponent, childScope.currentPin);
|
|
625
596
|
this.scope.currentWireId = childScope.currentWireId + wireIdOffset;
|
|
626
597
|
}
|
|
627
598
|
this.printPoint('resume at');
|
|
@@ -651,7 +622,15 @@ export class ExecutionContext {
|
|
|
651
622
|
this.scope.wires.push(new Wire(tmp));
|
|
652
623
|
const output = [];
|
|
653
624
|
segments.forEach(item => {
|
|
654
|
-
|
|
625
|
+
const tmpArray = item.map(item2 => {
|
|
626
|
+
if (item2 instanceof UnitDimension) {
|
|
627
|
+
return item2.value;
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
return item2;
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
output.push(tmpArray.join(","));
|
|
655
634
|
});
|
|
656
635
|
this.log('add wire: ', output.join("|"));
|
|
657
636
|
this.scope.setActive(ActiveObject.Wire, wireId);
|
|
@@ -668,12 +647,26 @@ export class ExecutionContext {
|
|
|
668
647
|
}
|
|
669
648
|
const useName = userDefined ? 'point.' + pointId : pointId;
|
|
670
649
|
const componentPoint = ClassComponent.simple(useName, 1, "point");
|
|
671
|
-
componentPoint.displayProp =
|
|
672
|
-
componentPoint.typeProp = ComponentTypes.
|
|
650
|
+
componentPoint.displayProp = this.getPointSymbol();
|
|
651
|
+
componentPoint.typeProp = ComponentTypes.net;
|
|
673
652
|
this.scope.instances.set(pointId, componentPoint);
|
|
674
653
|
this.toComponent(componentPoint, 1, { addSequence: true });
|
|
675
654
|
return this.getCurrentPoint();
|
|
676
655
|
}
|
|
656
|
+
getPointSymbol() {
|
|
657
|
+
return new SymbolDrawingCommands(() => {
|
|
658
|
+
return [
|
|
659
|
+
[PlaceHolderCommands.pin,
|
|
660
|
+
[numeric(1), numeric(0), numeric(0),
|
|
661
|
+
numeric(0), numeric(0)],
|
|
662
|
+
new Map([
|
|
663
|
+
["display_pin_id", false]
|
|
664
|
+
]),
|
|
665
|
+
null
|
|
666
|
+
]
|
|
667
|
+
];
|
|
668
|
+
});
|
|
669
|
+
}
|
|
677
670
|
setProperty(nameWithProp, value) {
|
|
678
671
|
this.log('set property', nameWithProp, 'value', value);
|
|
679
672
|
let idName;
|
|
@@ -706,11 +699,6 @@ export class ExecutionContext {
|
|
|
706
699
|
}
|
|
707
700
|
}
|
|
708
701
|
}
|
|
709
|
-
setCurrentComponentStyle(styles) {
|
|
710
|
-
for (const key in styles) {
|
|
711
|
-
this.scope.currentComponent.styles[key] = styles[key];
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
702
|
applyComponentAngleFromWire(component, pin, opposite = false) {
|
|
715
703
|
if (this.componentAngleFollowsWire
|
|
716
704
|
&& component.followWireOrientationProp
|
|
@@ -761,23 +749,23 @@ export class ExecutionContext {
|
|
|
761
749
|
return;
|
|
762
750
|
}
|
|
763
751
|
this.log('set component angle from wire, target angle:', targetAngle, ', component angle:', component.angleProp, 'pin angle:', connectedPinPos.angle);
|
|
764
|
-
let useAngle = (targetAngle - connectedPinPos.angle) % 360;
|
|
752
|
+
let useAngle = (targetAngle - connectedPinPos.angle.toNumber()) % 360;
|
|
765
753
|
if (useAngle < 0) {
|
|
766
754
|
useAngle += 360;
|
|
767
755
|
}
|
|
768
756
|
if (useAngle === 90) {
|
|
769
|
-
component.setParam(
|
|
757
|
+
component.setParam(ParamKeys.angle, numeric(90));
|
|
770
758
|
}
|
|
771
759
|
else if (useAngle === 180) {
|
|
772
760
|
if (component.angleProp === 0 || component.angleProp === 180) {
|
|
773
|
-
component.setParam(
|
|
761
|
+
component.setParam(ParamKeys.flipX, 1);
|
|
774
762
|
}
|
|
775
763
|
else if (component.angleProp === 90 || component.angleProp === 270) {
|
|
776
|
-
component.setParam(
|
|
764
|
+
component.setParam(ParamKeys.flipY, 1);
|
|
777
765
|
}
|
|
778
766
|
}
|
|
779
767
|
else if (useAngle === 270) {
|
|
780
|
-
component.setParam(
|
|
768
|
+
component.setParam(ParamKeys.angle, numeric(270));
|
|
781
769
|
}
|
|
782
770
|
component.wireOrientationAngle = useAngle;
|
|
783
771
|
component.didSetWireOrientationAngle = true;
|
|
@@ -812,6 +800,12 @@ function isWireSegmentsEndAuto(segments) {
|
|
|
812
800
|
}
|
|
813
801
|
export function getPortSide(pins, arrangeProps) {
|
|
814
802
|
const result = [];
|
|
803
|
+
const maxPositions = {
|
|
804
|
+
[SymbolPinSide.Left]: 0,
|
|
805
|
+
[SymbolPinSide.Right]: 0,
|
|
806
|
+
[SymbolPinSide.Top]: 0,
|
|
807
|
+
[SymbolPinSide.Bottom]: 0,
|
|
808
|
+
};
|
|
815
809
|
if (arrangeProps === null) {
|
|
816
810
|
let counter = 0;
|
|
817
811
|
for (const [pinId] of pins) {
|
|
@@ -823,6 +817,14 @@ export function getPortSide(pins, arrangeProps) {
|
|
|
823
817
|
});
|
|
824
818
|
counter++;
|
|
825
819
|
}
|
|
820
|
+
const leftSideItems = result.filter(item => {
|
|
821
|
+
return item.side === PortSide.WEST;
|
|
822
|
+
});
|
|
823
|
+
const rightSideItems = result.filter(item => {
|
|
824
|
+
return item.side === PortSide.EAST;
|
|
825
|
+
});
|
|
826
|
+
maxPositions[SymbolPinSide.Left] = leftSideItems.length;
|
|
827
|
+
maxPositions[SymbolPinSide.Right] = rightSideItems.length;
|
|
826
828
|
}
|
|
827
829
|
else {
|
|
828
830
|
let counter = pins.size;
|
|
@@ -836,35 +838,44 @@ export function getPortSide(pins, arrangeProps) {
|
|
|
836
838
|
useItems = [...items];
|
|
837
839
|
}
|
|
838
840
|
let useSide = PortSide.WEST;
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
841
|
+
switch (key) {
|
|
842
|
+
case SymbolPinSide.Left:
|
|
843
|
+
useSide = PortSide.WEST;
|
|
844
|
+
break;
|
|
845
|
+
case SymbolPinSide.Right:
|
|
846
|
+
useSide = PortSide.EAST;
|
|
847
|
+
break;
|
|
848
|
+
case SymbolPinSide.Top:
|
|
849
|
+
useSide = PortSide.NORTH;
|
|
850
|
+
break;
|
|
851
|
+
case SymbolPinSide.Bottom:
|
|
852
|
+
useSide = PortSide.SOUTH;
|
|
853
|
+
break;
|
|
850
854
|
}
|
|
851
855
|
let position = 0;
|
|
852
856
|
useItems.forEach(item => {
|
|
853
857
|
if (typeof item === 'object' && Array.isArray(item)) {
|
|
854
|
-
position += item[0];
|
|
858
|
+
position += item[0].toNumber();
|
|
855
859
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
860
|
+
else {
|
|
861
|
+
const itemValue = item.toNumber();
|
|
862
|
+
if (existingPinIds.indexOf(itemValue) !== -1) {
|
|
863
|
+
result.push({
|
|
864
|
+
pinId: itemValue,
|
|
865
|
+
side: useSide,
|
|
866
|
+
position,
|
|
867
|
+
order: counter
|
|
868
|
+
});
|
|
869
|
+
counter--;
|
|
870
|
+
position += 1;
|
|
871
|
+
}
|
|
865
872
|
}
|
|
866
873
|
});
|
|
874
|
+
maxPositions[key] = position;
|
|
867
875
|
}
|
|
868
876
|
}
|
|
869
|
-
return
|
|
877
|
+
return {
|
|
878
|
+
pins: result,
|
|
879
|
+
maxPositions,
|
|
880
|
+
};
|
|
870
881
|
}
|
package/dist/esm/export.mjs
CHANGED
|
@@ -47,10 +47,8 @@ export function generateKiCADNetList(netlist) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
|
-
if (instance.typeProp !== ComponentTypes.
|
|
51
|
-
instance.typeProp !== ComponentTypes.
|
|
52
|
-
instance.typeProp !== ComponentTypes.point &&
|
|
53
|
-
instance.typeProp !== ComponentTypes.frame &&
|
|
50
|
+
if (instance.typeProp !== ComponentTypes.net &&
|
|
51
|
+
instance.typeProp !== ComponentTypes.graphic &&
|
|
54
52
|
instance.typeProp !== null) {
|
|
55
53
|
console.log('Skipping', instance.instanceName);
|
|
56
54
|
}
|