circuitscript 0.1.23 → 0.1.25
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 +35 -23
- package/dist/cjs/BomGeneration.js +167 -0
- package/dist/cjs/ComponentMatchConditions.js +116 -0
- package/dist/cjs/antlr/CircuitScriptLexer.js +247 -244
- package/dist/cjs/antlr/CircuitScriptParser.js +1476 -825
- package/dist/cjs/builtinMethods.js +6 -1
- package/dist/cjs/execute.js +27 -16
- package/dist/cjs/graph.js +10 -9
- package/dist/cjs/helpers.js +43 -18
- package/dist/cjs/layout.js +14 -13
- package/dist/cjs/main.js +17 -1
- package/dist/cjs/objects/ExecutionScope.js +3 -0
- package/dist/cjs/objects/PinDefinition.js +11 -1
- package/dist/cjs/objects/types.js +6 -4
- package/dist/cjs/rules-check/no-connect-on-connected-pin.js +81 -0
- package/dist/cjs/rules-check/rules.js +74 -0
- package/dist/cjs/rules-check/unconnected-pins.js +52 -0
- package/dist/cjs/visitor.js +121 -5
- package/dist/esm/BaseVisitor.js +35 -23
- package/dist/esm/BomGeneration.js +137 -0
- package/dist/esm/ComponentMatchConditions.js +109 -0
- package/dist/esm/antlr/CircuitScriptLexer.js +247 -244
- package/dist/esm/antlr/CircuitScriptParser.js +1471 -824
- package/dist/esm/antlr/CircuitScriptVisitor.js +7 -0
- package/dist/esm/builtinMethods.js +6 -1
- package/dist/esm/execute.js +27 -16
- package/dist/esm/graph.js +11 -10
- package/dist/esm/helpers.js +43 -18
- package/dist/esm/layout.js +15 -13
- package/dist/esm/main.js +17 -1
- package/dist/esm/objects/ExecutionScope.js +3 -0
- package/dist/esm/objects/PinDefinition.js +11 -1
- package/dist/esm/objects/types.js +7 -5
- package/dist/esm/rules-check/no-connect-on-connected-pin.js +77 -0
- package/dist/esm/rules-check/rules.js +70 -0
- package/dist/esm/rules-check/unconnected-pins.js +48 -0
- package/dist/esm/visitor.js +121 -5
- package/dist/libs/std.cst +7 -3
- package/dist/types/BomGeneration.d.ts +13 -0
- package/dist/types/ComponentMatchConditions.d.ts +19 -0
- package/dist/types/antlr/CircuitScriptLexer.d.ts +60 -59
- package/dist/types/antlr/CircuitScriptParser.d.ts +146 -62
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +14 -0
- package/dist/types/execute.d.ts +2 -1
- package/dist/types/graph.d.ts +6 -1
- package/dist/types/helpers.d.ts +7 -2
- package/dist/types/layout.d.ts +3 -2
- package/dist/types/objects/ExecutionScope.d.ts +8 -2
- package/dist/types/objects/ParamDefinition.d.ts +1 -1
- package/dist/types/objects/PinDefinition.d.ts +1 -0
- package/dist/types/objects/types.d.ts +4 -2
- package/dist/types/rules-check/no-connect-on-connected-pin.d.ts +3 -0
- package/dist/types/rules-check/rules.d.ts +15 -0
- package/dist/types/rules-check/unconnected-pins.d.ts +2 -0
- package/dist/types/visitor.d.ts +10 -1
- package/libs/std.cst +7 -3
- package/package.json +2 -1
package/dist/cjs/BaseVisitor.js
CHANGED
|
@@ -89,34 +89,39 @@ class BaseVisitor extends CircuitScriptVisitor_js_1.CircuitScriptVisitor {
|
|
|
89
89
|
sequenceParts.push(...[itemType, leftSideReference.name, rhsValue]);
|
|
90
90
|
}
|
|
91
91
|
else {
|
|
92
|
-
if (leftSideReference.
|
|
93
|
-
this.setInstanceParam(leftSideReference.
|
|
94
|
-
this.log2(`assigned component param ${leftSideReference.
|
|
95
|
-
sequenceParts.push(...['instance', [leftSideReference.
|
|
96
|
-
if (leftSideReference.
|
|
97
|
-
const net = this.getScope().getNet(leftSideReference.
|
|
92
|
+
if (leftSideReference.rootValue instanceof ClassComponent_js_1.ClassComponent) {
|
|
93
|
+
this.setInstanceParam(leftSideReference.rootValue, trailers, rhsValue);
|
|
94
|
+
this.log2(`assigned component param ${leftSideReference.rootValue} trailers: ${trailers} value: ${rhsValue}`);
|
|
95
|
+
sequenceParts.push(...['instance', [leftSideReference.rootValue, trailers], rhsValue]);
|
|
96
|
+
if (leftSideReference.rootValue.typeProp === globals_js_1.ComponentTypes.net) {
|
|
97
|
+
const net = this.getScope().getNet(leftSideReference.rootValue, new PinDefinition_js_1.PinId(1));
|
|
98
98
|
if (net) {
|
|
99
99
|
const trailerValue = trailers.join(".");
|
|
100
100
|
net.params.set(trailerValue, rhsValue);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
else if (leftSideReference.
|
|
104
|
+
else if (leftSideReference.rootValue instanceof Object) {
|
|
105
105
|
if (Array.isArray(trailers[0]) && trailers[0][0] === globals_js_1.TrailerArrayIndex) {
|
|
106
|
-
if (Array.isArray(leftSideReference.
|
|
106
|
+
if (Array.isArray(leftSideReference.rootValue)) {
|
|
107
107
|
const arrayIndexValue = trailers[0][1];
|
|
108
|
-
leftSideReference.
|
|
109
|
-
this.log2(`assigned array index ${leftSideReference.
|
|
108
|
+
leftSideReference.rootValue[arrayIndexValue] = rhsValue;
|
|
109
|
+
this.log2(`assigned array index ${leftSideReference.rootValue} index: ${arrayIndexValue} value: ${rhsValue}`);
|
|
110
110
|
}
|
|
111
111
|
else {
|
|
112
112
|
this.throwWithContext(lhsCtx, "Invalid array");
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
else {
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
let expandedValue = leftSideReference.rootValue;
|
|
117
|
+
trailers.slice(0, -1).forEach(trailer => {
|
|
118
|
+
expandedValue = expandedValue[trailer];
|
|
119
|
+
});
|
|
120
|
+
const lastTrailer = trailers.slice(-1)[0];
|
|
121
|
+
expandedValue[lastTrailer] = rhsValue;
|
|
122
|
+
this.log2(`assigned object ${leftSideReference.rootValue} trailers: ${trailers} value: ${rhsValue}`);
|
|
118
123
|
}
|
|
119
|
-
sequenceParts.push(...['variable', [leftSideReference.
|
|
124
|
+
sequenceParts.push(...['variable', [leftSideReference.rootValue, trailers], rhsValue]);
|
|
120
125
|
}
|
|
121
126
|
}
|
|
122
127
|
if (sequenceParts.length > 0) {
|
|
@@ -189,7 +194,12 @@ class BaseVisitor extends CircuitScriptVisitor_js_1.CircuitScriptVisitor {
|
|
|
189
194
|
let nextReference;
|
|
190
195
|
if (ctxID) {
|
|
191
196
|
reference.trailers.push(ctxID.getText());
|
|
192
|
-
|
|
197
|
+
const useRootValue = reference.rootValue ?? reference.value;
|
|
198
|
+
const useTrailerIndex = reference.trailerIndex ?? 0;
|
|
199
|
+
nextReference = this.getExecutor().resolveTrailers(reference.type, useRootValue, reference.trailers);
|
|
200
|
+
nextReference.name =
|
|
201
|
+
[reference.name,
|
|
202
|
+
...reference.trailers.slice(useTrailerIndex)].join('.');
|
|
193
203
|
}
|
|
194
204
|
else if (ctxDataExpr) {
|
|
195
205
|
const arrayIndex = this.visitResult(ctxDataExpr);
|
|
@@ -203,7 +213,7 @@ class BaseVisitor extends CircuitScriptVisitor_js_1.CircuitScriptVisitor {
|
|
|
203
213
|
type: refType,
|
|
204
214
|
value: foundValue,
|
|
205
215
|
trailers: [[globals_js_1.TrailerArrayIndex, arrayIndexValue]],
|
|
206
|
-
|
|
216
|
+
rootValue: useValue
|
|
207
217
|
});
|
|
208
218
|
}
|
|
209
219
|
}
|
|
@@ -222,15 +232,15 @@ class BaseVisitor extends CircuitScriptVisitor_js_1.CircuitScriptVisitor {
|
|
|
222
232
|
});
|
|
223
233
|
}
|
|
224
234
|
else {
|
|
235
|
+
this.log('resolve variable ctx: ' + ctx.getText(), 'atomId', atomId);
|
|
225
236
|
currentReference = executor.resolveVariable(this.executionStack, atomId);
|
|
237
|
+
this.log('reference:', currentReference.name, 'found:', currentReference.found);
|
|
226
238
|
}
|
|
227
239
|
if (currentReference !== undefined && currentReference.found) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
currentReference = this.visitResult(trailerCtx);
|
|
233
|
-
}
|
|
240
|
+
ctx.trailer_expr2().forEach(ctxTrailer => {
|
|
241
|
+
this.setResult(ctxTrailer, currentReference);
|
|
242
|
+
currentReference = this.visitResult(ctxTrailer);
|
|
243
|
+
});
|
|
234
244
|
}
|
|
235
245
|
this.setResult(ctx, currentReference);
|
|
236
246
|
this.log2('atom resolved: ' + ctx.getText() + ' -> ' + currentReference);
|
|
@@ -425,7 +435,9 @@ class BaseVisitor extends CircuitScriptVisitor_js_1.CircuitScriptVisitor {
|
|
|
425
435
|
scope.sequence.push([
|
|
426
436
|
ExecutionScope_js_1.SequenceAction.At, scope.componentRoot, scope.currentPin
|
|
427
437
|
]);
|
|
428
|
-
scope.setVariable(globals_js_1.GlobalDocumentName, {
|
|
438
|
+
scope.setVariable(globals_js_1.GlobalDocumentName, {
|
|
439
|
+
'bom': {},
|
|
440
|
+
});
|
|
429
441
|
this.setupBuiltInFunctions(this.startingContext);
|
|
430
442
|
this.executionStack = [this.startingContext];
|
|
431
443
|
this.startingContext.resolveNet =
|
|
@@ -503,7 +515,7 @@ class BaseVisitor extends CircuitScriptVisitor_js_1.CircuitScriptVisitor {
|
|
|
503
515
|
const reference = this.visitResult(ctx);
|
|
504
516
|
const { trailers = [] } = reference;
|
|
505
517
|
const undefinedParentWithTrailers = trailers.length > 0
|
|
506
|
-
&& reference.
|
|
518
|
+
&& reference.rootValue === undefined;
|
|
507
519
|
if (undefinedParentWithTrailers) {
|
|
508
520
|
this.throwWithContext(ctx, 'Undefined reference: ' + reference.name + '.' + trailers.join('.'));
|
|
509
521
|
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.saveBomOutputCsv = exports.generateBomCSV = exports.groupComponents = exports.generateBom = void 0;
|
|
27
|
+
const csv = __importStar(require("@fast-csv/format"));
|
|
28
|
+
const fs = __importStar(require("fs"));
|
|
29
|
+
const ParamDefinition_js_1 = require("./objects/ParamDefinition.js");
|
|
30
|
+
const TypeSortOrder = {
|
|
31
|
+
"res": 1,
|
|
32
|
+
"cap": 2,
|
|
33
|
+
"ind": 3,
|
|
34
|
+
"diode": 9,
|
|
35
|
+
"ic": 10,
|
|
36
|
+
"conn": 20,
|
|
37
|
+
};
|
|
38
|
+
function generateBom(bomConfig, instances) {
|
|
39
|
+
const bomComponents = extractComponentValuesForBom(bomConfig, instances);
|
|
40
|
+
const tmpGroupedComponents = groupComponents(bomConfig, bomComponents);
|
|
41
|
+
const groupedBom = [];
|
|
42
|
+
tmpGroupedComponents.forEach(value => {
|
|
43
|
+
groupedBom.push({
|
|
44
|
+
...value.items[0],
|
|
45
|
+
refdes: value.allRefdes.join(', ')
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
const sortedGroupedBom = groupedBom.toSorted((a, b) => {
|
|
49
|
+
const typeSortA = TypeSortOrder[a['.type']] ?? 100;
|
|
50
|
+
const typeSortB = TypeSortOrder[b['.type']] ?? 100;
|
|
51
|
+
return typeSortA - typeSortB;
|
|
52
|
+
});
|
|
53
|
+
return sortedGroupedBom;
|
|
54
|
+
}
|
|
55
|
+
exports.generateBom = generateBom;
|
|
56
|
+
function groupComponents(bomConfig, bomComponents) {
|
|
57
|
+
const { group_by } = bomConfig;
|
|
58
|
+
const grouped = new Map();
|
|
59
|
+
bomComponents.forEach(row => {
|
|
60
|
+
const groupKeyParts = {};
|
|
61
|
+
group_by.forEach(paramKey => {
|
|
62
|
+
groupKeyParts[paramKey] = row[paramKey];
|
|
63
|
+
});
|
|
64
|
+
const groupKey = JSON.stringify(groupKeyParts);
|
|
65
|
+
if (!grouped.has(groupKey)) {
|
|
66
|
+
grouped.set(groupKey, {
|
|
67
|
+
allRefdes: [],
|
|
68
|
+
items: [],
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const entry = grouped.get(groupKey);
|
|
72
|
+
entry.items.push(row);
|
|
73
|
+
entry.allRefdes.push(row.refdes);
|
|
74
|
+
grouped.set(groupKey, entry);
|
|
75
|
+
});
|
|
76
|
+
return grouped;
|
|
77
|
+
}
|
|
78
|
+
exports.groupComponents = groupComponents;
|
|
79
|
+
function extractComponentValuesForBom(bomConfig, instances) {
|
|
80
|
+
const { columns = [] } = bomConfig;
|
|
81
|
+
const resultRows = [];
|
|
82
|
+
instances.forEach(instance => {
|
|
83
|
+
if (instance.assignedRefDes !== null) {
|
|
84
|
+
const row = {
|
|
85
|
+
'.type': instance.typeProp,
|
|
86
|
+
};
|
|
87
|
+
columns.forEach(paramKey => {
|
|
88
|
+
let useValue = '';
|
|
89
|
+
if (paramKey === 'refdes') {
|
|
90
|
+
useValue = instance.assignedRefDes;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
if (instance.hasParam(paramKey)) {
|
|
94
|
+
useValue = instance.getParam(paramKey);
|
|
95
|
+
if (typeof useValue === 'string') {
|
|
96
|
+
useValue = resolveValuesInTemplate(instance, useValue);
|
|
97
|
+
}
|
|
98
|
+
else if (useValue instanceof ParamDefinition_js_1.NumericValue) {
|
|
99
|
+
useValue = useValue.toDisplayString();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
row[paramKey] = useValue;
|
|
104
|
+
});
|
|
105
|
+
resultRows.push(row);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return resultRows;
|
|
109
|
+
}
|
|
110
|
+
function resolveValuesInTemplate(instance, templateString) {
|
|
111
|
+
return templateString.replace(/\{(\w+)\}/g, (match, paramName) => {
|
|
112
|
+
if (instance.hasParam(paramName)) {
|
|
113
|
+
const paramValue = instance.getParam(paramName);
|
|
114
|
+
if (paramValue instanceof ParamDefinition_js_1.NumericValue) {
|
|
115
|
+
return paramValue.toDisplayString();
|
|
116
|
+
}
|
|
117
|
+
return instance.getParam(paramName);
|
|
118
|
+
}
|
|
119
|
+
return match;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function generateBomCSV(bomData) {
|
|
123
|
+
const useHeaders = [];
|
|
124
|
+
const rows = [];
|
|
125
|
+
if (bomData.length > 0) {
|
|
126
|
+
const [firstRow] = bomData;
|
|
127
|
+
for (const key in firstRow) {
|
|
128
|
+
if (key.startsWith('.')) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const useKey = key[0].toUpperCase() + key.substring(1);
|
|
132
|
+
useHeaders.push(useKey);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
rows.push(useHeaders);
|
|
136
|
+
const keys = [];
|
|
137
|
+
if (bomData.length > 0) {
|
|
138
|
+
for (const key in bomData[0]) {
|
|
139
|
+
if (key.startsWith('.')) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
keys.push(key);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
bomData.forEach(row => {
|
|
146
|
+
const result = keys.map(key => {
|
|
147
|
+
return row[key];
|
|
148
|
+
});
|
|
149
|
+
rows.push(result);
|
|
150
|
+
});
|
|
151
|
+
return rows;
|
|
152
|
+
}
|
|
153
|
+
exports.generateBomCSV = generateBomCSV;
|
|
154
|
+
async function saveBomOutputCsv(bomCsvOutput, filePath) {
|
|
155
|
+
return new Promise(resolve => {
|
|
156
|
+
const outputStream = fs.createWriteStream(filePath);
|
|
157
|
+
const csvStream = csv.format();
|
|
158
|
+
csvStream.pipe(outputStream).on("finish", () => {
|
|
159
|
+
resolve();
|
|
160
|
+
});
|
|
161
|
+
bomCsvOutput.forEach(row => {
|
|
162
|
+
csvStream.write(row);
|
|
163
|
+
});
|
|
164
|
+
csvStream.end();
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
exports.saveBomOutputCsv = saveBomOutputCsv;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyPartConditions = exports.partMatchesConditions = exports.extractPartConditions = exports.flattenConditionNodes = void 0;
|
|
4
|
+
const ParamDefinition_js_1 = require("./objects/ParamDefinition.js");
|
|
5
|
+
const types_js_1 = require("./objects/types.js");
|
|
6
|
+
function flattenConditionNodes(conditionNodes, level = 0) {
|
|
7
|
+
const conditionBranches = [];
|
|
8
|
+
conditionNodes.forEach(node => {
|
|
9
|
+
const { key, values, children = [], endValue = [] } = node;
|
|
10
|
+
const firstCondition = {
|
|
11
|
+
key, values, endValue
|
|
12
|
+
};
|
|
13
|
+
if (children.length > 0) {
|
|
14
|
+
const nestedBranches = flattenConditionNodes(children, level + 1);
|
|
15
|
+
nestedBranches.forEach(tmpCondition => {
|
|
16
|
+
if (values === undefined) {
|
|
17
|
+
const modifiedCondition = {
|
|
18
|
+
...firstCondition,
|
|
19
|
+
values: [tmpCondition[0].key.value],
|
|
20
|
+
endValue: tmpCondition[0].endValue
|
|
21
|
+
};
|
|
22
|
+
conditionBranches.push([
|
|
23
|
+
modifiedCondition,
|
|
24
|
+
...tmpCondition.slice(1)
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
conditionBranches.push([
|
|
29
|
+
firstCondition,
|
|
30
|
+
...tmpCondition
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
conditionBranches.push([firstCondition]);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return conditionBranches;
|
|
40
|
+
}
|
|
41
|
+
exports.flattenConditionNodes = flattenConditionNodes;
|
|
42
|
+
function extractPartConditions(conditionBranches) {
|
|
43
|
+
const partConditions = conditionBranches.map(branch => {
|
|
44
|
+
const lastNode = branch[branch.length - 1];
|
|
45
|
+
const { endValue } = lastNode;
|
|
46
|
+
const conditions = [];
|
|
47
|
+
branch.forEach((node, index) => {
|
|
48
|
+
conditions.push({
|
|
49
|
+
key: node.key,
|
|
50
|
+
values: node.values
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
endValue,
|
|
55
|
+
conditions
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
return partConditions;
|
|
59
|
+
}
|
|
60
|
+
exports.extractPartConditions = extractPartConditions;
|
|
61
|
+
function partMatchesConditions(instance, partConditions) {
|
|
62
|
+
for (let i = 0; i < partConditions.length; i++) {
|
|
63
|
+
const { endValue, conditions } = partConditions[i];
|
|
64
|
+
const didNotMatch = conditions.some(condition => {
|
|
65
|
+
const { key, values } = condition;
|
|
66
|
+
let useKey = '';
|
|
67
|
+
if (key.type === 'ID') {
|
|
68
|
+
useKey = key.value;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
console.log('key type not supported', key);
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
if (useKey === 'type') {
|
|
75
|
+
return (instance.typeProp !== values[0]);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
if (!instance.hasParam(useKey)) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const paramValue = instance.getParam(useKey);
|
|
83
|
+
const compareValue = values[0];
|
|
84
|
+
if (typeof compareValue === "string") {
|
|
85
|
+
return (compareValue !== paramValue);
|
|
86
|
+
}
|
|
87
|
+
else if (compareValue instanceof ParamDefinition_js_1.NumericValue) {
|
|
88
|
+
return !compareValue.eq(paramValue);
|
|
89
|
+
}
|
|
90
|
+
else if (typeof compareValue === 'number') {
|
|
91
|
+
return compareValue !== paramValue;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
if (didNotMatch === false) {
|
|
97
|
+
return endValue;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.partMatchesConditions = partMatchesConditions;
|
|
102
|
+
function applyPartConditions(instances, paramKeys, partConditions) {
|
|
103
|
+
instances.forEach(item => {
|
|
104
|
+
if (item.typeProp !== types_js_1.TypeProps.Graphic) {
|
|
105
|
+
const matchedResult = partMatchesConditions(item, partConditions);
|
|
106
|
+
if (matchedResult !== undefined) {
|
|
107
|
+
paramKeys.forEach((paramKey, index) => {
|
|
108
|
+
if (matchedResult[index] !== undefined) {
|
|
109
|
+
item.setParam(paramKey, matchedResult[index]);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
exports.applyPartConditions = applyPartConditions;
|