@tsplc/typegen 0.5.14 → 0.5.16
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/README.md +29 -3
- package/dist/cli.js +574 -424
- package/dist/cli.js.map +21 -16
- package/dist/codegen.js +242 -192
- package/dist/codegen.js.map +8 -6
- package/dist/declarations.js +277 -138
- package/dist/declarations.js.map +8 -7
- package/dist/hardware.js +348 -105
- package/dist/hardware.js.map +13 -10
- package/dist/index.js +617 -459
- package/dist/index.js.map +21 -17
- package/dist/project-snapshot.js +17 -19
- package/dist/project-snapshot.js.map +5 -4
- package/package.json +3 -3
- package/src/cli.ts +25 -33
- package/src/codegen/constants.ts +19 -25
- package/src/codegen/declarations.ts +12 -39
- package/src/codegen/generate.ts +118 -179
- package/src/codegen/parser.ts +121 -63
- package/src/codegen/resolution.ts +68 -0
- package/src/device-tree.ts +14 -97
- package/src/files.ts +40 -0
- package/src/hardware/catalog.ts +49 -0
- package/src/hardware/channels.ts +12 -5
- package/src/hardware/eds.ts +165 -31
- package/src/hardware/mapping-types.ts +58 -21
- package/src/hardware/modbus.ts +42 -28
- package/src/hardware/process-image.ts +57 -24
- package/src/hardware/selection.ts +25 -9
- package/src/hardware.ts +56 -77
- package/src/index.ts +4 -7
- package/src/outputs.ts +50 -0
- package/src/project-snapshot.ts +13 -25
- package/src/project.ts +108 -136
package/dist/index.js
CHANGED
|
@@ -1,25 +1,54 @@
|
|
|
1
1
|
// packages/typegen/src/index.ts
|
|
2
|
-
import { ioScalarBits as
|
|
2
|
+
import { ioScalarBits as ioScalarBits3 } from "@tsplc/iec";
|
|
3
3
|
|
|
4
4
|
// packages/typegen/src/codegen/generate.ts
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import {
|
|
6
|
+
elementaryType as elementaryType3,
|
|
7
|
+
elementaryTypesByName,
|
|
8
|
+
fitsNumber as fitsNumber2,
|
|
9
|
+
isIntegerValued as isIntegerValued2,
|
|
10
|
+
isWholeValue,
|
|
11
|
+
stringTypeText
|
|
12
|
+
} from "@tsplc/iec";
|
|
8
13
|
import { identifierPattern as identifierPattern2 } from "@tsplc/iec/st";
|
|
9
14
|
|
|
15
|
+
// packages/typegen/src/files.ts
|
|
16
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
var isMissingFile = (error) => error instanceof Error && ("code" in error) && error.code === "ENOENT";
|
|
19
|
+
var readIfPresent = (path) => readFile(path, "utf8").catch((error) => {
|
|
20
|
+
if (isMissingFile(error)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
throw error;
|
|
24
|
+
});
|
|
25
|
+
async function filesUnder(directory, extension, order) {
|
|
26
|
+
const pattern = new RegExp(`\\.${extension}$`, "i");
|
|
27
|
+
const entries = await readdir(directory, { withFileTypes: true });
|
|
28
|
+
const paths = await Promise.all(entries.sort((a, b) => order(a.name, b.name)).map(async (entry) => {
|
|
29
|
+
const path = join(directory, entry.name);
|
|
30
|
+
if (entry.isDirectory()) {
|
|
31
|
+
return filesUnder(path, extension, order);
|
|
32
|
+
}
|
|
33
|
+
return entry.isFile() && pattern.test(entry.name) ? [path] : [];
|
|
34
|
+
}));
|
|
35
|
+
return paths.flat();
|
|
36
|
+
}
|
|
37
|
+
var stFiles = (directory) => filesUnder(directory, "st", (a, b) => a < b ? -1 : 1);
|
|
38
|
+
|
|
10
39
|
// packages/typegen/src/codegen/constants.ts
|
|
11
40
|
import {
|
|
12
41
|
elementaryType,
|
|
13
42
|
elementaryTypes,
|
|
43
|
+
fitsNumber,
|
|
14
44
|
integerRange,
|
|
15
45
|
isIntegerValued
|
|
16
46
|
} from "@tsplc/iec";
|
|
17
|
-
|
|
18
|
-
const type = elementaryType(name);
|
|
19
|
-
return isIntegerValued(type) && type.bits <= 32;
|
|
20
|
-
};
|
|
47
|
+
import { identifierPart, identifierStart, integerLiteral } from "@tsplc/iec/st";
|
|
21
48
|
var integerRanges = new Map(elementaryTypes.filter(isIntegerValued).map((type) => [type.name, integerRange(type)]));
|
|
22
|
-
var
|
|
49
|
+
var identifier = `${identifierStart}${identifierPart}*`;
|
|
50
|
+
var startsWithIdentifier = new RegExp(`^${identifierStart}`);
|
|
51
|
+
var integerToken = new RegExp(String.raw`(?:${[...integerRanges.keys()].join("|")})\s*#\s*[+-]?(?:(?:2|8|16)#[\da-fA-F_]+|\d[\d_]*)|(?:2|8|16)#[\da-fA-F_]+|\d[\d_]*|${identifier}(?:\s*\.\s*${identifier})?|[()+\-*/]`, "g");
|
|
23
52
|
function integerExpression(text, lookup) {
|
|
24
53
|
const compact = text.replace(/\s+/g, "");
|
|
25
54
|
const tokens = (text.match(integerToken) ?? []).map((token) => token.replace(/\s+/g, ""));
|
|
@@ -58,13 +87,13 @@ function integerExpression(text, lookup) {
|
|
|
58
87
|
return value;
|
|
59
88
|
}
|
|
60
89
|
if (token && /^\d/.test(token)) {
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
throw new Error(`invalid
|
|
90
|
+
const literal = integerLiteral(token);
|
|
91
|
+
if (literal === undefined) {
|
|
92
|
+
throw new Error(`invalid integer literal: ${token}`);
|
|
64
93
|
}
|
|
65
|
-
return safe(
|
|
94
|
+
return safe(Number(literal));
|
|
66
95
|
}
|
|
67
|
-
if (token &&
|
|
96
|
+
if (token && startsWithIdentifier.test(token)) {
|
|
68
97
|
return lookup(token);
|
|
69
98
|
}
|
|
70
99
|
throw new Error(`invalid integer expression: ${text}`);
|
|
@@ -91,11 +120,12 @@ function integerExpression(text, lookup) {
|
|
|
91
120
|
return value;
|
|
92
121
|
}
|
|
93
122
|
const value = sum();
|
|
94
|
-
if (position !== tokens.length
|
|
95
|
-
throw new Error(`invalid
|
|
123
|
+
if (position !== tokens.length) {
|
|
124
|
+
throw new Error(`invalid integer expression: ${text}`);
|
|
96
125
|
}
|
|
97
126
|
return value;
|
|
98
127
|
}
|
|
128
|
+
var isIntegerConstant = (member) => member.type.kind === "named" && fitsNumber(elementaryType(member.type.name.toUpperCase()));
|
|
99
129
|
function constantResolver(lists) {
|
|
100
130
|
const values = new Map;
|
|
101
131
|
const resolving = new Set;
|
|
@@ -119,7 +149,7 @@ function constantResolver(lists) {
|
|
|
119
149
|
throw new Error(`cyclic constant ${name}`);
|
|
120
150
|
}
|
|
121
151
|
const { member, list } = definition;
|
|
122
|
-
if (member.initial === undefined ||
|
|
152
|
+
if (member.initial === undefined || !isIntegerConstant(member)) {
|
|
123
153
|
throw new Error(`${list.source}: constant ${member.name} must have an integer type and initializer`);
|
|
124
154
|
}
|
|
125
155
|
resolving.add(definition.key);
|
|
@@ -132,72 +162,89 @@ function constantResolver(lists) {
|
|
|
132
162
|
}
|
|
133
163
|
|
|
134
164
|
// packages/typegen/src/codegen/parser.ts
|
|
165
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
166
|
+
import { basename } from "node:path";
|
|
167
|
+
import { defaultStringLength } from "@tsplc/iec";
|
|
135
168
|
import {
|
|
136
169
|
blockCommentEnd,
|
|
137
170
|
directAddressEnd,
|
|
171
|
+
identifierPart as identifierPart2,
|
|
138
172
|
identifierPattern,
|
|
173
|
+
identifierStart as identifierStart2,
|
|
139
174
|
lineCommentEnd,
|
|
140
|
-
qualifiers
|
|
175
|
+
qualifiers,
|
|
176
|
+
stringEnd
|
|
141
177
|
} from "@tsplc/iec/st";
|
|
178
|
+
var pragmaEnd = (text, offset) => {
|
|
179
|
+
const next = text.slice(offset).search(/[}'"]/);
|
|
180
|
+
if (next < 0) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
const at = offset + next;
|
|
184
|
+
if (text[at] === "}") {
|
|
185
|
+
return at + 1;
|
|
186
|
+
}
|
|
187
|
+
const end = stringEnd(text, at);
|
|
188
|
+
return end === null ? null : pragmaEnd(text, end);
|
|
189
|
+
};
|
|
190
|
+
var codeToken = new RegExp(String.raw`^(?:\d[\d_]*#[\da-fA-F_]+|\d[\d_]*(?:\.(?!\.)[\d_]+)?(?:[eE][+-]?\d+)?|${identifierStart2}${identifierPart2}*|:=|\.\.|[[\]():;,.+\-*/#])`, "i");
|
|
191
|
+
function tokenAt(source, start) {
|
|
192
|
+
const { text } = source;
|
|
193
|
+
const offset = start + text.slice(start).search(/\S|$/);
|
|
194
|
+
if (offset === text.length) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const rest = text.slice(offset);
|
|
198
|
+
if (rest.startsWith("(*")) {
|
|
199
|
+
const end = blockCommentEnd(text, offset);
|
|
200
|
+
if (end === null) {
|
|
201
|
+
throw new Error(`${source.name}: unterminated comment`);
|
|
202
|
+
}
|
|
203
|
+
const comment = text.slice(offset + 2, end - 2).trim();
|
|
204
|
+
return { text: comment, offset, end, kind: "comment" };
|
|
205
|
+
}
|
|
206
|
+
if (rest.startsWith("//")) {
|
|
207
|
+
const end = lineCommentEnd(text, offset);
|
|
208
|
+
const comment = text.slice(offset + 2, end).trim();
|
|
209
|
+
return { text: comment, offset, end, kind: "comment" };
|
|
210
|
+
}
|
|
211
|
+
const code = (kind, end) => ({
|
|
212
|
+
text: text.slice(offset, end),
|
|
213
|
+
offset,
|
|
214
|
+
end,
|
|
215
|
+
kind
|
|
216
|
+
});
|
|
217
|
+
const attributeEnd = rest.startsWith("{") ? pragmaEnd(text, offset + 1) : null;
|
|
218
|
+
if (attributeEnd !== null) {
|
|
219
|
+
return code("attribute", attributeEnd);
|
|
220
|
+
}
|
|
221
|
+
const addressEnd = directAddressEnd(text, offset);
|
|
222
|
+
if (addressEnd !== null) {
|
|
223
|
+
return code("code", addressEnd);
|
|
224
|
+
}
|
|
225
|
+
const literalEnd = rest.startsWith("'") || rest.startsWith('"') ? stringEnd(text, offset) : null;
|
|
226
|
+
if (literalEnd !== null) {
|
|
227
|
+
return code("code", literalEnd);
|
|
228
|
+
}
|
|
229
|
+
const word = codeToken.exec(rest);
|
|
230
|
+
if (!word) {
|
|
231
|
+
throw new Error(`${source.name}:${text.slice(0, offset).split(`
|
|
232
|
+
`).length}: unsupported token ${JSON.stringify(rest.slice(0, 24))}`);
|
|
233
|
+
}
|
|
234
|
+
return code("code", offset + word[0].length);
|
|
235
|
+
}
|
|
142
236
|
function tokenize(source) {
|
|
143
237
|
const tokens = [];
|
|
144
|
-
let
|
|
145
|
-
|
|
146
|
-
const rest = source.text.slice(offset);
|
|
147
|
-
const whitespace = /^\s+/.exec(rest);
|
|
148
|
-
if (whitespace) {
|
|
149
|
-
offset += whitespace[0].length;
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
if (rest.startsWith("(*")) {
|
|
153
|
-
const end = blockCommentEnd(source.text, offset);
|
|
154
|
-
if (end === null) {
|
|
155
|
-
throw new Error(`${source.name}: unterminated comment`);
|
|
156
|
-
}
|
|
157
|
-
tokens.push({
|
|
158
|
-
text: source.text.slice(offset + 2, end - 2).trim(),
|
|
159
|
-
offset,
|
|
160
|
-
kind: "comment"
|
|
161
|
-
});
|
|
162
|
-
offset = end;
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
if (rest.startsWith("//")) {
|
|
166
|
-
const end = lineCommentEnd(source.text, offset);
|
|
167
|
-
tokens.push({
|
|
168
|
-
text: source.text.slice(offset + 2, end).trim(),
|
|
169
|
-
offset,
|
|
170
|
-
kind: "comment"
|
|
171
|
-
});
|
|
172
|
-
offset = end;
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
const attribute = /^\{(?:[^}'"]|'(?:\$[\s\S]|''|[^'])*'|"(?:\$[\s\S]|""|[^"])*")*\}/.exec(rest);
|
|
176
|
-
if (attribute) {
|
|
177
|
-
tokens.push({ text: attribute[0], offset, kind: "attribute" });
|
|
178
|
-
offset += attribute[0].length;
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
const addressEnd = directAddressEnd(source.text, offset);
|
|
182
|
-
if (addressEnd !== null) {
|
|
183
|
-
tokens.push({
|
|
184
|
-
text: source.text.slice(offset, addressEnd),
|
|
185
|
-
offset,
|
|
186
|
-
kind: "code"
|
|
187
|
-
});
|
|
188
|
-
offset = addressEnd;
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
const code = /^(?:'(?:\$[\s\S]|''|[^'])*'|"(?:\$[\s\S]|""|[^"])*"|\d[\d_]*#[\da-fA-F_]+|\d[\d_]*(?:\.(?!\.)[\d_]+)?(?:[eE][+-]?\d+)?|[A-Za-z_]\w*|:=|\.\.|[[\]():;,.+\-*/#])/i.exec(rest);
|
|
192
|
-
if (!code) {
|
|
193
|
-
throw new Error(`${source.name}:${source.text.slice(0, offset).split(`
|
|
194
|
-
`).length}: unsupported token ${JSON.stringify(rest.slice(0, 24))}`);
|
|
195
|
-
}
|
|
196
|
-
tokens.push({ text: code[0], offset, kind: "code" });
|
|
197
|
-
offset += code[0].length;
|
|
238
|
+
for (let token = tokenAt(source, 0);token; token = tokenAt(source, token.end)) {
|
|
239
|
+
tokens.push(token);
|
|
198
240
|
}
|
|
199
241
|
return tokens;
|
|
200
242
|
}
|
|
243
|
+
var codeTokenAt = (source, offset) => {
|
|
244
|
+
const token = tokenAt(source, offset);
|
|
245
|
+
return token && token.kind !== "code" ? codeTokenAt(source, token.end) : token;
|
|
246
|
+
};
|
|
247
|
+
var firstCodeToken = (source) => codeTokenAt(source, 0)?.text;
|
|
201
248
|
|
|
202
249
|
class Parser {
|
|
203
250
|
source;
|
|
@@ -299,7 +346,11 @@ class Parser {
|
|
|
299
346
|
if (upper === "STRING" || upper === "WSTRING") {
|
|
300
347
|
const opening = this.peek();
|
|
301
348
|
if (opening !== "(" && opening !== "[") {
|
|
302
|
-
return {
|
|
349
|
+
return {
|
|
350
|
+
kind: "string",
|
|
351
|
+
name: upper,
|
|
352
|
+
length: String(defaultStringLength)
|
|
353
|
+
};
|
|
303
354
|
}
|
|
304
355
|
this.take();
|
|
305
356
|
const closing = opening === "(" ? ")" : "]";
|
|
@@ -438,126 +489,143 @@ function parseDeclarations(source) {
|
|
|
438
489
|
function parseGlobals(source, name) {
|
|
439
490
|
return new Parser(source).globals(name);
|
|
440
491
|
}
|
|
492
|
+
var readSource = async (name) => ({
|
|
493
|
+
name,
|
|
494
|
+
text: await readFile2(name, "utf8")
|
|
495
|
+
});
|
|
496
|
+
async function parseSources(files) {
|
|
497
|
+
return {
|
|
498
|
+
types: (await Promise.all(files.types.map(readSource))).flatMap(parseDeclarations),
|
|
499
|
+
globals: (await Promise.all(files.globals.map(readSource))).map((source) => parseGlobals(source, basename(source.name).replace(/\.st$/i, "")))
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// packages/typegen/src/codegen/resolution.ts
|
|
504
|
+
import { elementaryType as elementaryType2 } from "@tsplc/iec";
|
|
505
|
+
function resolveDeclarations({
|
|
506
|
+
types,
|
|
507
|
+
globals
|
|
508
|
+
}) {
|
|
509
|
+
const declarations = new Map(types.map((declaration) => [declaration.name.toUpperCase(), declaration]));
|
|
510
|
+
const constant = constantResolver(globals.filter((list) => list.constant));
|
|
511
|
+
const integer = (expression) => integerExpression(expression, (name) => constant(name, null));
|
|
512
|
+
const declaration = (name) => {
|
|
513
|
+
const found = declarations.get(name.toUpperCase());
|
|
514
|
+
if (!found) {
|
|
515
|
+
throw new Error(`unknown IEC type ${name}`);
|
|
516
|
+
}
|
|
517
|
+
return found;
|
|
518
|
+
};
|
|
519
|
+
const aliasTarget = (reference) => {
|
|
520
|
+
if (reference.kind !== "named" || elementaryType2(reference.name.toUpperCase())) {
|
|
521
|
+
return reference;
|
|
522
|
+
}
|
|
523
|
+
const named = declaration(reference.name);
|
|
524
|
+
return named.kind === "alias" ? aliasTarget(named.type) : reference;
|
|
525
|
+
};
|
|
526
|
+
const bounds = (array) => array.dimensions.map(({ lower, upper }) => {
|
|
527
|
+
const start = integer(lower);
|
|
528
|
+
const end = integer(upper);
|
|
529
|
+
if (end < start || !Number.isSafeInteger(end - start + 1)) {
|
|
530
|
+
throw new Error(`invalid array bounds ${lower}..${upper}`);
|
|
531
|
+
}
|
|
532
|
+
return { start, end };
|
|
533
|
+
});
|
|
534
|
+
const enumMembers = (enumeration) => {
|
|
535
|
+
const members = [];
|
|
536
|
+
for (const member of enumeration.members) {
|
|
537
|
+
const value = member.value === undefined ? (members.at(-1)?.value ?? -1) + 1 : integerExpression(member.value, (name) => members.find((item) => item.name.toUpperCase() === name.toUpperCase())?.value ?? constant(name, null));
|
|
538
|
+
members.push({ name: member.name, value });
|
|
539
|
+
}
|
|
540
|
+
return members;
|
|
541
|
+
};
|
|
542
|
+
return { constant, integer, declaration, aliasTarget, bounds, enumMembers };
|
|
543
|
+
}
|
|
441
544
|
|
|
442
545
|
// packages/typegen/src/codegen/generate.ts
|
|
443
546
|
var scalarType = (type) => {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
return "boolean";
|
|
447
|
-
case "integer":
|
|
448
|
-
case "bits":
|
|
449
|
-
return type.bits === 64 ? "bigint" : "number";
|
|
450
|
-
case "real":
|
|
451
|
-
return "number";
|
|
452
|
-
case "duration":
|
|
453
|
-
case "date":
|
|
454
|
-
case "timeOfDay":
|
|
455
|
-
case "dateTime":
|
|
456
|
-
return type.bits === 32 ? "number" : undefined;
|
|
457
|
-
case "char":
|
|
458
|
-
case "string":
|
|
459
|
-
return;
|
|
547
|
+
if (type.family === "bool") {
|
|
548
|
+
return "boolean";
|
|
460
549
|
}
|
|
550
|
+
return isIntegerValued2(type) && !fitsNumber2(type) ? "bigint" : "number";
|
|
461
551
|
};
|
|
462
|
-
var scalars = Object.fromEntries([...elementaryTypesByName].flatMap(([name, type]) =>
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
if (entry.isDirectory()) {
|
|
476
|
-
return stFiles(file);
|
|
477
|
-
}
|
|
478
|
-
return entry.isFile() && /\.st$/i.test(file) ? [file] : [];
|
|
479
|
-
}));
|
|
480
|
-
return paths.flat();
|
|
481
|
-
}
|
|
552
|
+
var scalars = Object.fromEntries([...elementaryTypesByName].flatMap(([name, type]) => isWholeValue(type) ? [[name, scalarType(type)]] : []));
|
|
553
|
+
var sourceFiles = async (setting) => typeof setting === "string" ? stFiles(setting) : setting;
|
|
554
|
+
var contractNames = {
|
|
555
|
+
field: "PlcField",
|
|
556
|
+
globals: "PlcGlobals",
|
|
557
|
+
typeFields: "typeFields",
|
|
558
|
+
globalVariableLists: "globalVariableLists",
|
|
559
|
+
symbols: "symbols",
|
|
560
|
+
publication: "publication"
|
|
561
|
+
};
|
|
562
|
+
var fieldList = (index) => `_fields${index}`;
|
|
563
|
+
var isFieldList = (name) => /^_fields\d+$/.test(name);
|
|
564
|
+
var javascriptReserved = "break case catch class const continue debugger default delete do else enum export extends false finally for function if import in instanceof new null return super switch this throw true try typeof var void while with yield let static implements interface package private protected public await arguments eval".split(" ");
|
|
482
565
|
var quote = (value) => JSON.stringify(value);
|
|
483
566
|
var documentation = (value) => value ? `/** ${value.replace(/\*\//g, "* /").replace(/\r?\n/g, `
|
|
484
567
|
* `)} */
|
|
485
568
|
` : "";
|
|
486
|
-
function
|
|
487
|
-
const
|
|
488
|
-
for (const
|
|
489
|
-
const key =
|
|
490
|
-
|
|
491
|
-
|
|
569
|
+
function assertUniqueNames(items) {
|
|
570
|
+
const seen = new Map;
|
|
571
|
+
for (const { name, source } of items) {
|
|
572
|
+
const key = name.toUpperCase();
|
|
573
|
+
const previous = seen.get(key);
|
|
574
|
+
if (previous !== undefined) {
|
|
575
|
+
throw new Error(`${source}: duplicate declaration ${name} (also in ${previous})`);
|
|
492
576
|
}
|
|
493
|
-
|
|
577
|
+
seen.set(key, source);
|
|
494
578
|
}
|
|
495
|
-
return result;
|
|
496
579
|
}
|
|
497
|
-
var readSources = (files) => Promise.all(files.map(async (name) => ({ name, text: await readFile(name, "utf8") })));
|
|
498
580
|
async function generateTypes(options) {
|
|
499
|
-
const typeFiles =
|
|
500
|
-
const
|
|
501
|
-
const globalFiles = typeof options.globals === "string" ? await stFiles(options.globals) : options.globals ?? [];
|
|
581
|
+
const typeFiles = await sourceFiles(options.types);
|
|
582
|
+
const globalFiles = await sourceFiles(options.globals);
|
|
502
583
|
if (!typeFiles.length && !globalFiles.length && (typeof options.types === "string" || typeof options.globals === "string")) {
|
|
503
584
|
throw new Error(`no .st declarations found in ${typeof options.types === "string" ? options.types : "the selected source files"}`);
|
|
504
585
|
}
|
|
505
|
-
const globals =
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
586
|
+
const { types: declarations, globals } = await parseSources({
|
|
587
|
+
types: typeFiles,
|
|
588
|
+
globals: globalFiles
|
|
589
|
+
});
|
|
590
|
+
const { publication } = options;
|
|
591
|
+
const contract = emit(declarations, publication ? published(globals, publication) : globals, {
|
|
592
|
+
publishedGlobalsOnly: publication !== null,
|
|
593
|
+
emitDeclarations: options.declarations
|
|
594
|
+
});
|
|
595
|
+
return publication ? `${contract}
|
|
596
|
+
export const ${contractNames.publication} = ${JSON.stringify(publication, null, 2)} as const;
|
|
510
597
|
` : contract;
|
|
511
598
|
}
|
|
512
599
|
function published(globals, publication) {
|
|
600
|
+
const selected = new Set([
|
|
601
|
+
...publication.production,
|
|
602
|
+
...publication.development
|
|
603
|
+
]);
|
|
513
604
|
return globals.map((list) => list.constant ? list : {
|
|
514
605
|
...list,
|
|
515
|
-
members: list.members.filter((member) =>
|
|
516
|
-
...publication.production,
|
|
517
|
-
...publication.development
|
|
518
|
-
].includes(`${list.name}.${member.name}`) : member.symbol !== undefined)
|
|
606
|
+
members: list.members.filter((member) => selected.has(`${list.name}.${member.name}`))
|
|
519
607
|
}).filter((list) => list.constant || list.members.length);
|
|
520
608
|
}
|
|
521
609
|
function emit(declarations, globals, {
|
|
522
610
|
publishedGlobalsOnly,
|
|
523
611
|
emitDeclarations
|
|
524
612
|
}) {
|
|
525
|
-
|
|
526
|
-
|
|
613
|
+
assertUniqueNames(declarations);
|
|
614
|
+
assertUniqueNames(globals);
|
|
527
615
|
const constants = globals.filter((list) => list.constant);
|
|
528
616
|
const constantLists = publishedGlobalsOnly ? constants.map((list) => ({
|
|
529
617
|
...list,
|
|
530
|
-
members: list.members.filter(
|
|
618
|
+
members: list.members.filter(isIntegerConstant)
|
|
531
619
|
})).filter((list) => list.members.length) : constants;
|
|
532
620
|
const variableLists = globals.filter((list) => !list.constant);
|
|
533
|
-
const constant =
|
|
534
|
-
function bound(expression) {
|
|
535
|
-
return integerExpression(expression, (name) => constant(name, null));
|
|
536
|
-
}
|
|
537
|
-
function dimensions(type) {
|
|
538
|
-
return type.dimensions.map(({ lower, upper }) => {
|
|
539
|
-
const start = bound(lower);
|
|
540
|
-
const end = bound(upper);
|
|
541
|
-
if (end < start || !Number.isSafeInteger(end - start + 1)) {
|
|
542
|
-
throw new Error(`invalid array bounds ${lower}..${upper}`);
|
|
543
|
-
}
|
|
544
|
-
return { start, end };
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
function declaration(name) {
|
|
548
|
-
const found = types.get(name.toUpperCase());
|
|
549
|
-
if (!found) {
|
|
550
|
-
throw new Error(`unknown IEC type ${name}`);
|
|
551
|
-
}
|
|
552
|
-
return found;
|
|
553
|
-
}
|
|
621
|
+
const { constant, integer, declaration, aliasTarget, bounds, enumMembers } = resolveDeclarations({ types: declarations, globals });
|
|
554
622
|
function tsType(type) {
|
|
555
623
|
if (type.kind === "array") {
|
|
556
|
-
|
|
624
|
+
bounds(type);
|
|
557
625
|
return type.dimensions.reduce((child) => `Array<${child}>`, tsType(type.element));
|
|
558
626
|
}
|
|
559
627
|
if (type.kind === "string") {
|
|
560
|
-
const length =
|
|
628
|
+
const length = integer(type.length);
|
|
561
629
|
if (length < 1) {
|
|
562
630
|
throw new Error(`invalid ${type.name} length ${length}`);
|
|
563
631
|
}
|
|
@@ -566,25 +634,23 @@ function emit(declarations, globals, {
|
|
|
566
634
|
return scalars[type.name.toUpperCase()] ?? declaration(type.name).name;
|
|
567
635
|
}
|
|
568
636
|
function resolved(type) {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
const definition = declaration(type.name);
|
|
573
|
-
if (definition.kind === "alias") {
|
|
574
|
-
return resolved(definition.type);
|
|
637
|
+
const target = aliasTarget(type);
|
|
638
|
+
if (target.kind !== "named" || scalars[target.name.toUpperCase()]) {
|
|
639
|
+
return target;
|
|
575
640
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
}
|
|
579
|
-
return type;
|
|
641
|
+
const definition = declaration(target.name);
|
|
642
|
+
return definition.kind === "enum" ? { kind: "named", name: definition.base } : target;
|
|
580
643
|
}
|
|
581
644
|
function iecType(type) {
|
|
582
645
|
const actual = resolved(type);
|
|
583
646
|
if (actual.kind === "string") {
|
|
584
|
-
return
|
|
647
|
+
return stringTypeText({
|
|
648
|
+
wide: actual.name === "WSTRING",
|
|
649
|
+
capacity: integer(actual.length)
|
|
650
|
+
});
|
|
585
651
|
}
|
|
586
652
|
if (actual.kind === "array") {
|
|
587
|
-
return `ARRAY[${
|
|
653
|
+
return `ARRAY[${bounds(actual).map(({ start, end }) => `${start}..${end}`).join(", ")}] OF ${iecType(actual.element)}`;
|
|
588
654
|
}
|
|
589
655
|
return scalars[actual.name.toUpperCase()] ? actual.name.toUpperCase() : declaration(actual.name).name;
|
|
590
656
|
}
|
|
@@ -621,17 +687,19 @@ function emit(declarations, globals, {
|
|
|
621
687
|
ordered.push(type);
|
|
622
688
|
}
|
|
623
689
|
declarations.forEach(visit);
|
|
624
|
-
const reserved = new Set(
|
|
690
|
+
const reserved = new Set([
|
|
691
|
+
...javascriptReserved,
|
|
692
|
+
...Object.values(contractNames)
|
|
693
|
+
]);
|
|
625
694
|
for (const name of [
|
|
626
695
|
...declarations.map((type) => type.name),
|
|
627
696
|
...constantLists.map((list) => list.name)
|
|
628
697
|
]) {
|
|
629
|
-
if (!identifierPattern2.test(name) || reserved.has(name) ||
|
|
698
|
+
if (!identifierPattern2.test(name) || reserved.has(name) || isFieldList(name)) {
|
|
630
699
|
throw new Error(`name cannot be exported to TypeScript: ${name}`);
|
|
631
700
|
}
|
|
632
701
|
reserved.add(name);
|
|
633
702
|
}
|
|
634
|
-
const indexes = new Map(ordered.map((type, index) => [type.name, index]));
|
|
635
703
|
function complex(type) {
|
|
636
704
|
const actual = resolved(type);
|
|
637
705
|
if (actual.kind === "array") {
|
|
@@ -649,14 +717,14 @@ function emit(declarations, globals, {
|
|
|
649
717
|
function fields(type, path, description, depth = 0) {
|
|
650
718
|
const actual = resolved(type);
|
|
651
719
|
if (actual.kind === "named" && complex(actual)) {
|
|
652
|
-
const children =
|
|
720
|
+
const children = fieldList(ordered.indexOf(declaration(actual.name)));
|
|
653
721
|
if (path === '""') {
|
|
654
722
|
return children;
|
|
655
723
|
}
|
|
656
724
|
return `${children}.map((member) => ({ ...member, field: ${path} + "." + member.field }))`;
|
|
657
725
|
}
|
|
658
726
|
if (actual.kind === "array" && (complex(actual.element) || keyed(type))) {
|
|
659
|
-
const ranges =
|
|
727
|
+
const ranges = bounds(actual);
|
|
660
728
|
const coordinates = ranges.map((range, index) => `String(i${depth}_${index} + (${range.start}))`);
|
|
661
729
|
const arrayPath = `${path} + "[" + ${coordinates.join(' + "," + ')} + "]"`;
|
|
662
730
|
return ranges.reduceRight((child, range, index) => `Array.from({ length: ${range.end - range.start + 1} }, (_, i${depth}_${index}) => ${child}).flat()`, fields(actual.element, `(${arrayPath})`, description, depth + 1));
|
|
@@ -667,10 +735,10 @@ function emit(declarations, globals, {
|
|
|
667
735
|
const output = [
|
|
668
736
|
`// Generated by @tsplc/typegen. Edit the PLC sources and regenerate.
|
|
669
737
|
`,
|
|
670
|
-
`export interface
|
|
738
|
+
`export interface ${contractNames.field} { field: string; type: string; description: string; }
|
|
671
739
|
`
|
|
672
740
|
];
|
|
673
|
-
for (const type of ordered) {
|
|
741
|
+
for (const [index, type] of ordered.entries()) {
|
|
674
742
|
try {
|
|
675
743
|
const doc = documentation(type.description);
|
|
676
744
|
if (type.kind === "struct") {
|
|
@@ -679,7 +747,7 @@ ${type.members.map((member) => `${documentation(member.description)}${quote(memb
|
|
|
679
747
|
`)}
|
|
680
748
|
}
|
|
681
749
|
`));
|
|
682
|
-
output.push(`const
|
|
750
|
+
output.push(`const ${fieldList(index)}: ${contractNames.field}[] = [
|
|
683
751
|
${type.members.map((member) => `...${fields(member.type, quote(member.name), member.description)},`).join(`
|
|
684
752
|
`)}
|
|
685
753
|
];
|
|
@@ -687,22 +755,17 @@ ${type.members.map((member) => `...${fields(member.type, quote(member.name), mem
|
|
|
687
755
|
} else if (type.kind === "alias") {
|
|
688
756
|
output.push(...declare(`${doc}export type ${type.name} = ${tsType(type.type)};
|
|
689
757
|
`));
|
|
690
|
-
output.push(`const
|
|
758
|
+
output.push(`const ${fieldList(index)}: ${contractNames.field}[] = ${fields({ kind: "named", name: type.name }, '""', type.description)};
|
|
691
759
|
`);
|
|
692
760
|
} else {
|
|
693
|
-
if (!
|
|
761
|
+
if (!fitsNumber2(elementaryType3(type.base))) {
|
|
694
762
|
throw new Error(`unsupported enum base ${type.base}`);
|
|
695
763
|
}
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
const previous = [...entries.values()].at(-1) ?? -1;
|
|
699
|
-
const value = member.value === undefined ? previous + 1 : integerExpression(member.value, (name) => entries.get(name.toUpperCase()) ?? constant(name, null));
|
|
700
|
-
entries.set(member.name.toUpperCase(), value);
|
|
701
|
-
}
|
|
702
|
-
output.push(...declare(`${doc}export const ${type.name} = { ${type.members.map((member) => `${quote(member.name)}: ${entries.get(member.name.toUpperCase())}`).join(", ")} } as const;
|
|
764
|
+
const members = enumMembers(type);
|
|
765
|
+
output.push(...declare(`${doc}export const ${type.name} = { ${members.map(({ name, value }) => `${quote(name)}: ${value}`).join(", ")} } as const;
|
|
703
766
|
export type ${type.name} = (typeof ${type.name})[keyof typeof ${type.name}];
|
|
704
767
|
`));
|
|
705
|
-
output.push(`const
|
|
768
|
+
output.push(`const ${fieldList(index)}: ${contractNames.field}[] = ${fields({ kind: "named", name: type.base }, '""', type.description)};
|
|
706
769
|
`);
|
|
707
770
|
}
|
|
708
771
|
} catch (error) {
|
|
@@ -713,9 +776,9 @@ export type ${type.name} = (typeof ${type.name})[keyof typeof ${type.name}];
|
|
|
713
776
|
iecType(member.type),
|
|
714
777
|
fields(member.type, '""', member.description)
|
|
715
778
|
]));
|
|
716
|
-
output.push(`export const typeFields = {
|
|
779
|
+
output.push(`export const ${contractNames.typeFields} = {
|
|
717
780
|
${[
|
|
718
|
-
...ordered.map((type) => `${quote(type.name)}:
|
|
781
|
+
...ordered.map((type, index) => `${quote(type.name)}: ${fieldList(index)},`),
|
|
719
782
|
...[...inlineArrays].map(([type, members]) => `${quote(type)}: ${members},`)
|
|
720
783
|
].join(`
|
|
721
784
|
`)}
|
|
@@ -728,7 +791,7 @@ ${list.members.map((member) => `${documentation(member.description)}${quote(memb
|
|
|
728
791
|
} as const;
|
|
729
792
|
`);
|
|
730
793
|
}
|
|
731
|
-
output.push(...declare(`export interface
|
|
794
|
+
output.push(...declare(`export interface ${contractNames.globals} {
|
|
732
795
|
${variableLists.map((list) => `${documentation(list.description)}${quote(list.name)}: {
|
|
733
796
|
${list.members.map((member) => `${documentation(member.description)}${quote(member.name)}: ${tsType(member.type)};`).join(`
|
|
734
797
|
`)}
|
|
@@ -736,9 +799,9 @@ ${list.members.map((member) => `${documentation(member.description)}${quote(memb
|
|
|
736
799
|
`)}
|
|
737
800
|
}
|
|
738
801
|
`));
|
|
739
|
-
output.push(`export const globalVariableLists = ${JSON.stringify(Object.fromEntries(variableLists.map((list) => [list.name, list.description])), null, "\t")} as const;
|
|
802
|
+
output.push(`export const ${contractNames.globalVariableLists} = ${JSON.stringify(Object.fromEntries(variableLists.map((list) => [list.name, list.description])), null, "\t")} as const;
|
|
740
803
|
`);
|
|
741
|
-
output.push(`export const symbols = ${JSON.stringify(variableLists.flatMap((list) => list.members.map((member) => ({
|
|
804
|
+
output.push(`export const ${contractNames.symbols} = ${JSON.stringify(variableLists.flatMap((list) => list.members.map((member) => ({
|
|
742
805
|
name: member.name,
|
|
743
806
|
gvl: list.name,
|
|
744
807
|
type: member.type.kind === "named" && !scalars[member.type.name.toUpperCase()] ? declaration(member.type.name).name : iecType(member.type),
|
|
@@ -749,9 +812,19 @@ ${list.members.map((member) => `${documentation(member.description)}${quote(memb
|
|
|
749
812
|
`);
|
|
750
813
|
}
|
|
751
814
|
// packages/typegen/src/device-tree.ts
|
|
752
|
-
import { readFile as
|
|
815
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
753
816
|
import { iecName } from "@tsplc/config/build";
|
|
754
817
|
|
|
818
|
+
// packages/typegen/src/hardware/catalog.ts
|
|
819
|
+
var deviceChannel = (catalog, binding) => catalog.devices.find((device) => device.id === binding.device)?.channels.find((channel) => channel.id === binding.channel);
|
|
820
|
+
function boundChannel(catalog, symbol, binding) {
|
|
821
|
+
const channel = deviceChannel(catalog, binding);
|
|
822
|
+
if (!channel?.address) {
|
|
823
|
+
throw new Error(`${symbol}: unknown or unaddressable channel ${binding.device}.${binding.channel}.`);
|
|
824
|
+
}
|
|
825
|
+
return { ...channel, address: channel.address };
|
|
826
|
+
}
|
|
827
|
+
|
|
755
828
|
// packages/typegen/src/hardware/eds.ts
|
|
756
829
|
var cipTypes = {
|
|
757
830
|
193: "BOOL",
|
|
@@ -770,6 +843,23 @@ var cipTypes = {
|
|
|
770
843
|
211: "DWORD",
|
|
771
844
|
212: "LWORD"
|
|
772
845
|
};
|
|
846
|
+
var connectionFields = {
|
|
847
|
+
transport: 0,
|
|
848
|
+
outputSize: 3,
|
|
849
|
+
outputFormat: 4,
|
|
850
|
+
inputSize: 6,
|
|
851
|
+
inputFormat: 7,
|
|
852
|
+
name: 12,
|
|
853
|
+
path: 14
|
|
854
|
+
};
|
|
855
|
+
var assemblyFields = {
|
|
856
|
+
name: 0,
|
|
857
|
+
path: 1,
|
|
858
|
+
size: 2,
|
|
859
|
+
descriptor: 3,
|
|
860
|
+
firstMember: 6
|
|
861
|
+
};
|
|
862
|
+
var isConnection = (key) => /^Connection\d+$/.test(key);
|
|
773
863
|
function stripComments(text) {
|
|
774
864
|
let clean = "";
|
|
775
865
|
const offsets = [];
|
|
@@ -849,14 +939,15 @@ function edsSections(text) {
|
|
|
849
939
|
if (!section) {
|
|
850
940
|
throw new Error("EDS record outside a section.");
|
|
851
941
|
}
|
|
942
|
+
const start = offsets[match.index];
|
|
943
|
+
const last = offsets[end - 1];
|
|
944
|
+
if (key === undefined || body === undefined || start === undefined || last === undefined) {
|
|
945
|
+
throw new Error("Malformed EDS record or section.");
|
|
946
|
+
}
|
|
852
947
|
if (section.has(key)) {
|
|
853
948
|
throw new Error(`Duplicate EDS record ${key}.`);
|
|
854
949
|
}
|
|
855
|
-
section.set(key, {
|
|
856
|
-
fields: recordFields(body),
|
|
857
|
-
start: offsets[match.index],
|
|
858
|
-
end: offsets[end - 1] + 1
|
|
859
|
-
});
|
|
950
|
+
section.set(key, { fields: recordFields(body), start, end: last + 1 });
|
|
860
951
|
}
|
|
861
952
|
if (clean.slice(end).trim()) {
|
|
862
953
|
throw new Error("Unterminated EDS record.");
|
|
@@ -924,7 +1015,7 @@ function logicalPath(path, params) {
|
|
|
924
1015
|
};
|
|
925
1016
|
}
|
|
926
1017
|
var optionalNumber = (value) => value?.trim() && Number.isFinite(Number(value)) ? Number(value) : undefined;
|
|
927
|
-
function parseEds(text, file
|
|
1018
|
+
function parseEds(text, file) {
|
|
928
1019
|
const records = readEdsRecords(text);
|
|
929
1020
|
const device = records.Device;
|
|
930
1021
|
if (!device?.ProdName?.[0]) {
|
|
@@ -962,11 +1053,11 @@ function parseEds(text, file = "device.eds") {
|
|
|
962
1053
|
maximum: parameter.maximum
|
|
963
1054
|
};
|
|
964
1055
|
};
|
|
965
|
-
const connections = Object.entries(records["Connection Manager"] ?? {}).filter(([id]) =>
|
|
966
|
-
const path = fields[
|
|
1056
|
+
const connections = Object.entries(records["Connection Manager"] ?? {}).filter(([id]) => isConnection(id)).map(([id, fields]) => {
|
|
1057
|
+
const path = fields[connectionFields.path] ?? "";
|
|
967
1058
|
const points = logicalPath(path, params).points;
|
|
968
|
-
const outputSize = size(fields[
|
|
969
|
-
const inputSize = size(fields[
|
|
1059
|
+
const outputSize = size(fields[connectionFields.outputSize]);
|
|
1060
|
+
const inputSize = size(fields[connectionFields.inputSize]);
|
|
970
1061
|
const assembly = (reference, point, payload) => {
|
|
971
1062
|
if (!reference) {
|
|
972
1063
|
if (!payload || payload.value <= 0 || point === undefined) {
|
|
@@ -979,7 +1070,7 @@ function parseEds(text, file = "device.eds") {
|
|
|
979
1070
|
if (!/^Assem\d+$/.test(reference) || !record) {
|
|
980
1071
|
throw new Error(`${file}: unknown connection assembly ${reference}.`);
|
|
981
1072
|
}
|
|
982
|
-
const instance = point ?? logicalPath(record[
|
|
1073
|
+
const instance = point ?? logicalPath(record[assemblyFields.path] ?? "", params).instance;
|
|
983
1074
|
if (instance === undefined) {
|
|
984
1075
|
throw new Error(`${file}: no runtime instance for ${reference}.`);
|
|
985
1076
|
}
|
|
@@ -992,11 +1083,11 @@ function parseEds(text, file = "device.eds") {
|
|
|
992
1083
|
};
|
|
993
1084
|
return {
|
|
994
1085
|
id,
|
|
995
|
-
name: fields[
|
|
996
|
-
owner: /^0x[\da-f]{8}$/i.test(fields[
|
|
1086
|
+
name: fields[connectionFields.name] || id,
|
|
1087
|
+
owner: /^0x[\da-f]{8}$/i.test(fields[connectionFields.transport] ?? "") && (Number(fields[connectionFields.transport]) >>> 24 & 15) === 4,
|
|
997
1088
|
path,
|
|
998
|
-
outputAssembly: assembly(fields[
|
|
999
|
-
inputAssembly: assembly(fields[
|
|
1089
|
+
outputAssembly: assembly(fields[connectionFields.outputFormat], points.at(-2), outputSize),
|
|
1090
|
+
inputAssembly: assembly(fields[connectionFields.inputFormat], points.at(-1), inputSize),
|
|
1000
1091
|
outputSize,
|
|
1001
1092
|
inputSize
|
|
1002
1093
|
};
|
|
@@ -1004,7 +1095,7 @@ function parseEds(text, file = "device.eds") {
|
|
|
1004
1095
|
const assemblies = Object.entries(records.Assembly ?? {}).filter(([id]) => /^Assem\d+$/.test(id)).map(([id, fields]) => {
|
|
1005
1096
|
const members = [];
|
|
1006
1097
|
let offsetBits = 0;
|
|
1007
|
-
for (let index =
|
|
1098
|
+
for (let index = assemblyFields.firstMember;index < fields.length; index += 2) {
|
|
1008
1099
|
if (!fields[index] && !fields[index + 1]) {
|
|
1009
1100
|
continue;
|
|
1010
1101
|
}
|
|
@@ -1027,12 +1118,19 @@ function parseEds(text, file = "device.eds") {
|
|
|
1027
1118
|
});
|
|
1028
1119
|
offsetBits += bits;
|
|
1029
1120
|
}
|
|
1030
|
-
const
|
|
1121
|
+
const declared = fields[assemblyFields.size];
|
|
1122
|
+
const size = declared ? integer(declared, `${id} size`, { minimum: 0 }) : Math.ceil(offsetBits / 8);
|
|
1031
1123
|
if (offsetBits > size * 8) {
|
|
1032
1124
|
throw new Error(`${file}: ${id} members exceed its ${size} byte payload.`);
|
|
1033
1125
|
}
|
|
1034
|
-
const instance = logicalPath(fields[
|
|
1035
|
-
return {
|
|
1126
|
+
const instance = logicalPath(fields[assemblyFields.path] ?? "", params).instance ?? instances.get(id);
|
|
1127
|
+
return {
|
|
1128
|
+
id,
|
|
1129
|
+
instance,
|
|
1130
|
+
name: fields[assemblyFields.name] || id,
|
|
1131
|
+
size,
|
|
1132
|
+
members
|
|
1133
|
+
};
|
|
1036
1134
|
});
|
|
1037
1135
|
for (const [instance, payloadSize] of recordless) {
|
|
1038
1136
|
if (!assemblies.some((assembly) => assembly.instance === instance)) {
|
|
@@ -1055,70 +1153,10 @@ function parseEds(text, file = "device.eds") {
|
|
|
1055
1153
|
connections
|
|
1056
1154
|
};
|
|
1057
1155
|
}
|
|
1058
|
-
|
|
1059
|
-
// packages/typegen/src/hardware/process-image.ts
|
|
1060
|
-
import { ioArray, ioScalar, sizePrefix } from "@tsplc/iec";
|
|
1061
|
-
function ioLayout(type) {
|
|
1062
|
-
const array = ioArray(type.trim());
|
|
1063
|
-
if (array) {
|
|
1064
|
-
const element = ioLayout(array.element);
|
|
1065
|
-
return element && element !== "BOOL" ? `${array.length}x${element}` : undefined;
|
|
1066
|
-
}
|
|
1067
|
-
const scalar = ioScalar(type);
|
|
1068
|
-
if (scalar?.family === "integer" || scalar?.family === "bits") {
|
|
1069
|
-
return `INT${scalar.bits}`;
|
|
1070
|
-
}
|
|
1071
|
-
return scalar?.name;
|
|
1072
|
-
}
|
|
1073
|
-
var addressSize = (bits) => bits === 64 ? undefined : sizePrefix(bits);
|
|
1074
|
-
function directAddress(region, base, offsetBits, bits) {
|
|
1075
|
-
const size = addressSize(bits);
|
|
1076
|
-
if (!size) {
|
|
1077
|
-
return;
|
|
1078
|
-
}
|
|
1079
|
-
const byte = base + Math.floor(offsetBits / 8);
|
|
1080
|
-
if (bits === 1) {
|
|
1081
|
-
return `%${region}X${byte}.${offsetBits % 8}`;
|
|
1082
|
-
}
|
|
1083
|
-
if ((base * 8 + offsetBits) % bits) {
|
|
1084
|
-
return;
|
|
1085
|
-
}
|
|
1086
|
-
return `%${region}${size}${byte / (bits / 8)}`;
|
|
1087
|
-
}
|
|
1088
|
-
var byteOffset = (address) => Number(address.slice(3));
|
|
1089
|
-
function regionPlacer(regions, { generatedTree }) {
|
|
1090
|
-
const taken = regions.flatMap(({ region, size, address }) => address ? [
|
|
1091
|
-
{
|
|
1092
|
-
region,
|
|
1093
|
-
start: byteOffset(address),
|
|
1094
|
-
end: byteOffset(address) + size
|
|
1095
|
-
}
|
|
1096
|
-
] : []);
|
|
1097
|
-
const cursors = { I: 0, Q: 0 };
|
|
1098
|
-
const aligned = (offset) => Math.ceil(offset / 4) * 4;
|
|
1099
|
-
return ({ id, region, size, address }) => {
|
|
1100
|
-
if (address) {
|
|
1101
|
-
return address;
|
|
1102
|
-
}
|
|
1103
|
-
if (!generatedTree) {
|
|
1104
|
-
throw new Error(`${id}: set the %${region}B address the template assigns to this assembly, or let codesys.deviceTree place it.`);
|
|
1105
|
-
}
|
|
1106
|
-
const clear = (start) => {
|
|
1107
|
-
const overlap = taken.find((item) => item.region === region && item.start < start + size && start < item.end);
|
|
1108
|
-
return overlap ? clear(aligned(overlap.end)) : start;
|
|
1109
|
-
};
|
|
1110
|
-
const start = clear(aligned(cursors[region]));
|
|
1111
|
-
taken.push({ region, start, end: start + size });
|
|
1112
|
-
cursors[region] = start + size;
|
|
1113
|
-
return `%${region}B${start}`;
|
|
1114
|
-
};
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
// packages/typegen/src/device-tree.ts
|
|
1118
1156
|
var quoted = (value) => `"${value.replaceAll('"', '""')}"`;
|
|
1119
1157
|
function normalizeEds(text, selection) {
|
|
1120
1158
|
const sections = edsSections(text);
|
|
1121
|
-
const connections = [...sections.get("Connection Manager") ?? []].filter(([key]) =>
|
|
1159
|
+
const connections = [...sections.get("Connection Manager") ?? []].filter(([key]) => isConnection(key));
|
|
1122
1160
|
const selected = connections.find(([key]) => key === selection.connection)?.[1];
|
|
1123
1161
|
if (!selected) {
|
|
1124
1162
|
throw new Error(`EDS has no ${selection.connection}.`);
|
|
@@ -1126,8 +1164,16 @@ function normalizeEds(text, selection) {
|
|
|
1126
1164
|
const fields = [...selected.fields];
|
|
1127
1165
|
const resized = new Map;
|
|
1128
1166
|
for (const [sizeField, formatField, size] of [
|
|
1129
|
-
[
|
|
1130
|
-
|
|
1167
|
+
[
|
|
1168
|
+
connectionFields.outputSize,
|
|
1169
|
+
connectionFields.outputFormat,
|
|
1170
|
+
selection.outputSize
|
|
1171
|
+
],
|
|
1172
|
+
[
|
|
1173
|
+
connectionFields.inputSize,
|
|
1174
|
+
connectionFields.inputFormat,
|
|
1175
|
+
selection.inputSize
|
|
1176
|
+
]
|
|
1131
1177
|
]) {
|
|
1132
1178
|
const assembly = fields[formatField];
|
|
1133
1179
|
if (!assembly) {
|
|
@@ -1142,19 +1188,19 @@ function normalizeEds(text, selection) {
|
|
|
1142
1188
|
const edits = connections.map(([, record]) => ({
|
|
1143
1189
|
start: record.start,
|
|
1144
1190
|
end: record.end,
|
|
1145
|
-
text: record === selected ? `Connection1 = ${fields.map((value, index) => index >=
|
|
1191
|
+
text: record === selected ? `Connection1 = ${fields.map((value, index) => index >= connectionFields.name ? quoted(value) : value).join(",")};` : ""
|
|
1146
1192
|
}));
|
|
1147
1193
|
for (const [key, record] of sections.get("Assembly") ?? []) {
|
|
1148
1194
|
const size = resized.get(key);
|
|
1149
1195
|
if (size === undefined) {
|
|
1150
1196
|
continue;
|
|
1151
1197
|
}
|
|
1152
|
-
const
|
|
1198
|
+
const path = record.fields[assemblyFields.path] ?? "";
|
|
1153
1199
|
const rawBytes = [
|
|
1154
|
-
quoted(name),
|
|
1200
|
+
quoted(record.fields[assemblyFields.name] ?? ""),
|
|
1155
1201
|
path && quoted(path),
|
|
1156
1202
|
size,
|
|
1157
|
-
descriptor,
|
|
1203
|
+
record.fields[assemblyFields.descriptor] ?? "",
|
|
1158
1204
|
"",
|
|
1159
1205
|
"",
|
|
1160
1206
|
size * 8,
|
|
@@ -1172,6 +1218,77 @@ function normalizeEds(text, selection) {
|
|
|
1172
1218
|
}
|
|
1173
1219
|
return edits.sort((a, b) => b.start - a.start).reduce((result, edit) => result.slice(0, edit.start) + edit.text + result.slice(edit.end), text);
|
|
1174
1220
|
}
|
|
1221
|
+
|
|
1222
|
+
// packages/typegen/src/hardware/process-image.ts
|
|
1223
|
+
import {
|
|
1224
|
+
elementaryTypes as elementaryTypes2,
|
|
1225
|
+
ioArray,
|
|
1226
|
+
ioScalar,
|
|
1227
|
+
isIntegerValued as isIntegerValued3,
|
|
1228
|
+
isWholeValue as isWholeValue2,
|
|
1229
|
+
sizePrefix,
|
|
1230
|
+
sizePrefixes
|
|
1231
|
+
} from "@tsplc/iec";
|
|
1232
|
+
var scalarLayout = (scalar) => isIntegerValued3(scalar) ? `INT${scalar.bits}` : scalar.name;
|
|
1233
|
+
var scalarLayoutBits = new Map(elementaryTypes2.filter(isWholeValue2).map((scalar) => [scalarLayout(scalar), scalar.bits]));
|
|
1234
|
+
function ioLayout(type) {
|
|
1235
|
+
const array = ioArray(type.trim());
|
|
1236
|
+
if (array) {
|
|
1237
|
+
const element = ioLayout(array.element);
|
|
1238
|
+
return element && element !== "BOOL" ? `${array.length}x${element}` : undefined;
|
|
1239
|
+
}
|
|
1240
|
+
const scalar = ioScalar(type);
|
|
1241
|
+
return scalar && scalarLayout(scalar);
|
|
1242
|
+
}
|
|
1243
|
+
var layoutBits = (layout) => scalarLayoutBits.get(layout.replace(/^\d+x/, ""));
|
|
1244
|
+
var addressSize = (bits) => bits === 64 ? undefined : sizePrefix(bits);
|
|
1245
|
+
function directAddress(region, base, offsetBits, bits) {
|
|
1246
|
+
const size = addressSize(bits);
|
|
1247
|
+
if (!size) {
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
const byte = base + Math.floor(offsetBits / 8);
|
|
1251
|
+
if (bits === 1) {
|
|
1252
|
+
return `%${region}X${byte}.${offsetBits % 8}`;
|
|
1253
|
+
}
|
|
1254
|
+
if ((base * 8 + offsetBits) % bits) {
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
return `%${region}${size}${byte / (bits / 8)}`;
|
|
1258
|
+
}
|
|
1259
|
+
function addressBits(address) {
|
|
1260
|
+
const [, region, size, index, bit] = /^%([IQ])([A-Z])(\d+)(?:\.([0-7]))?$/.exec(address) ?? [];
|
|
1261
|
+
const bits = size === undefined ? undefined : sizePrefixes.get(size)?.bits;
|
|
1262
|
+
if (region !== "I" && region !== "Q" || bits === undefined || addressSize(bits) !== size || bits === 1 !== (bit !== undefined)) {
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
const offsetBits = bits === 1 ? Number(index) * 8 + Number(bit) : Number(index) * bits;
|
|
1266
|
+
return { region, offsetBits, bits };
|
|
1267
|
+
}
|
|
1268
|
+
var regionOf = (direction) => direction === "input" ? "I" : "Q";
|
|
1269
|
+
function regionPlacer(regions, { generatedTree }) {
|
|
1270
|
+
const taken = regions.flatMap(({ region, size, offset }) => offset === undefined ? [] : [{ region, start: offset, end: offset + size }]);
|
|
1271
|
+
const cursors = { I: 0, Q: 0 };
|
|
1272
|
+
const aligned = (offset) => Math.ceil(offset / 4) * 4;
|
|
1273
|
+
return ({ id, region, size, offset }) => {
|
|
1274
|
+
if (offset !== undefined) {
|
|
1275
|
+
return offset;
|
|
1276
|
+
}
|
|
1277
|
+
if (!generatedTree) {
|
|
1278
|
+
throw new Error(`${id}: set the %${region}B address the template assigns to this assembly, or let codesys.deviceTree place it.`);
|
|
1279
|
+
}
|
|
1280
|
+
const clear = (start) => {
|
|
1281
|
+
const overlap = taken.find((item) => item.region === region && item.start < start + size && start < item.end);
|
|
1282
|
+
return overlap ? clear(aligned(overlap.end)) : start;
|
|
1283
|
+
};
|
|
1284
|
+
const start = clear(aligned(cursors[region]));
|
|
1285
|
+
taken.push({ region, start, end: start + size });
|
|
1286
|
+
cursors[region] = start + size;
|
|
1287
|
+
return start;
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
// packages/typegen/src/device-tree.ts
|
|
1175
1292
|
async function deviceTree(config, catalog) {
|
|
1176
1293
|
const settings = config.codesys?.deviceTree;
|
|
1177
1294
|
if (!settings) {
|
|
@@ -1195,21 +1312,20 @@ async function deviceTree(config, catalog) {
|
|
|
1195
1312
|
if (!("device" in binding) || binding.device !== device.id) {
|
|
1196
1313
|
return [];
|
|
1197
1314
|
}
|
|
1198
|
-
const channel =
|
|
1315
|
+
const channel = boundChannel(catalog, key, binding);
|
|
1199
1316
|
if (channel.assembly === undefined) {
|
|
1200
1317
|
return [];
|
|
1201
1318
|
}
|
|
1202
1319
|
if (channel.bits === 1) {
|
|
1203
1320
|
return [{ address: channel.address, text: key }];
|
|
1204
1321
|
}
|
|
1205
|
-
const
|
|
1322
|
+
const location = addressBits(channel.address);
|
|
1323
|
+
const address = location && directAddress(location.region, 0, location.offsetBits, 8);
|
|
1324
|
+
if (!address) {
|
|
1325
|
+
throw new Error(`${key}: channel ${binding.device}.${binding.channel} does not start on a byte.`);
|
|
1326
|
+
}
|
|
1206
1327
|
const bytes = channel.bits / 8;
|
|
1207
|
-
return [
|
|
1208
|
-
{
|
|
1209
|
-
address: `${area.address.slice(0, 3)}${byteOffset(area.address) + channel.offsetBits / 8}`,
|
|
1210
|
-
text: bytes > 1 ? `${key} (${bytes} bytes)` : key
|
|
1211
|
-
}
|
|
1212
|
-
];
|
|
1328
|
+
return [{ address, text: bytes > 1 ? `${key} (${bytes} bytes)` : key }];
|
|
1213
1329
|
});
|
|
1214
1330
|
const network = config.devices[device.id]?.network;
|
|
1215
1331
|
if (device.modbus && !network?.address) {
|
|
@@ -1217,7 +1333,7 @@ async function deviceTree(config, catalog) {
|
|
|
1217
1333
|
}
|
|
1218
1334
|
return {
|
|
1219
1335
|
name: device.id,
|
|
1220
|
-
eds: normalizeEds(await
|
|
1336
|
+
eds: normalizeEds(await readFile3(device.descriptor, "utf8"), {
|
|
1221
1337
|
connection: connection.id,
|
|
1222
1338
|
inputSize: inputs?.size,
|
|
1223
1339
|
outputSize: outputs?.size
|
|
@@ -1239,11 +1355,12 @@ async function deviceTree(config, catalog) {
|
|
|
1239
1355
|
return { ethernet: settings.ethernet ?? {}, devices: [first, ...rest] };
|
|
1240
1356
|
}
|
|
1241
1357
|
// packages/typegen/src/hardware.ts
|
|
1242
|
-
import {
|
|
1358
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
1243
1359
|
import { resolve } from "node:path";
|
|
1360
|
+
import { tsplcConfigSchema } from "@tsplc/config/schema";
|
|
1244
1361
|
|
|
1245
1362
|
// packages/typegen/src/hardware/channels.ts
|
|
1246
|
-
import { ioScalarBits } from "@tsplc/iec";
|
|
1363
|
+
import { arrayTypeText, ioScalarBits } from "@tsplc/iec";
|
|
1247
1364
|
function assemblyChannels({
|
|
1248
1365
|
device,
|
|
1249
1366
|
direction,
|
|
@@ -1253,7 +1370,7 @@ function assemblyChannels({
|
|
|
1253
1370
|
payloadSize
|
|
1254
1371
|
}) {
|
|
1255
1372
|
const prefix = `${direction}s`;
|
|
1256
|
-
const region = direction
|
|
1373
|
+
const region = regionOf(direction);
|
|
1257
1374
|
const payloadBits = payloadSize * 8;
|
|
1258
1375
|
const address = (offsetBits, bits) => directAddress(region, base, offsetBits, bits);
|
|
1259
1376
|
const channels = [];
|
|
@@ -1331,7 +1448,11 @@ function assemblyChannels({
|
|
|
1331
1448
|
const span = {
|
|
1332
1449
|
...channel,
|
|
1333
1450
|
bits: length * scalarBits,
|
|
1334
|
-
type:
|
|
1451
|
+
type: arrayTypeText({
|
|
1452
|
+
lower: 0,
|
|
1453
|
+
upper: length - 1,
|
|
1454
|
+
element: member.type
|
|
1455
|
+
}),
|
|
1335
1456
|
address: address(member.offsetBits, scalarBits)
|
|
1336
1457
|
};
|
|
1337
1458
|
channels.push(span);
|
|
@@ -1359,21 +1480,35 @@ function placeModbusRegisters(device, registers, place) {
|
|
|
1359
1480
|
if (!entries.length) {
|
|
1360
1481
|
return [];
|
|
1361
1482
|
}
|
|
1362
|
-
const outputBase =
|
|
1363
|
-
|
|
1483
|
+
const outputBase = place({
|
|
1484
|
+
id: device,
|
|
1485
|
+
region: "Q",
|
|
1486
|
+
size: entries.length * registerBytes.Q
|
|
1487
|
+
});
|
|
1488
|
+
const inputBase = place({
|
|
1489
|
+
id: device,
|
|
1490
|
+
region: "I",
|
|
1491
|
+
size: entries.length * registerBytes.I
|
|
1492
|
+
});
|
|
1364
1493
|
return entries.map(([name, offset], index) => {
|
|
1365
|
-
const channel = (field, direction, offsetBits, bits, type, description) =>
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1494
|
+
const channel = (field, direction, offsetBits, bits, type, description) => {
|
|
1495
|
+
const address = directAddress(regionOf(direction), direction === "input" ? inputBase + index * registerBytes.I : outputBase + index * registerBytes.Q, offsetBits, bits);
|
|
1496
|
+
if (!address) {
|
|
1497
|
+
throw new Error(`${device}: Modbus register ${name} ${field} has no direct address.`);
|
|
1498
|
+
}
|
|
1499
|
+
return {
|
|
1500
|
+
device,
|
|
1501
|
+
id: `modbus.${name}.${field}`,
|
|
1502
|
+
name: `${name} ${field}`,
|
|
1503
|
+
direction,
|
|
1504
|
+
offsetBits,
|
|
1505
|
+
bits,
|
|
1506
|
+
type,
|
|
1507
|
+
address,
|
|
1508
|
+
unit: "",
|
|
1509
|
+
description
|
|
1510
|
+
};
|
|
1511
|
+
};
|
|
1377
1512
|
const value = channel("value", "output", 0, 16, "WORD", "Value to write");
|
|
1378
1513
|
const write = channel("write", "output", 16, 1, "BOOL", "Writes the value when it rises");
|
|
1379
1514
|
const status = channel("status", "input", 0, 8, "BYTE", "The last answer: 0 accepted, otherwise the exception code");
|
|
@@ -1412,6 +1547,14 @@ function selectConnection(id, settings, descriptor) {
|
|
|
1412
1547
|
const choices = compatible.map((item) => `${item.id} "${item.name}" (in ${item.inputAssembly ?? "-"}, out ${item.outputAssembly ?? "-"})`).join(", ");
|
|
1413
1548
|
throw new Error(`${id}: select connection; ${settings.file} offers ${choices}.`);
|
|
1414
1549
|
}
|
|
1550
|
+
function configuredByte(id, direction, address) {
|
|
1551
|
+
const region = regionOf(direction);
|
|
1552
|
+
const location = addressBits(address);
|
|
1553
|
+
if (location?.region !== region || location.bits !== 8) {
|
|
1554
|
+
throw new Error(`${id}: ${direction} assembly needs a %${region}B address.`);
|
|
1555
|
+
}
|
|
1556
|
+
return location.offsetBits / 8;
|
|
1557
|
+
}
|
|
1415
1558
|
function selectAssemblies(id, settings, descriptor, connection) {
|
|
1416
1559
|
return ["input", "output"].flatMap((direction) => {
|
|
1417
1560
|
const selection = direction === "input" ? settings.inputs : settings.outputs;
|
|
@@ -1426,10 +1569,8 @@ function selectAssemblies(id, settings, descriptor, connection) {
|
|
|
1426
1569
|
if (!assembly) {
|
|
1427
1570
|
throw new Error(`${id}: assembly ${instance} is not present in ${settings.file}.`);
|
|
1428
1571
|
}
|
|
1429
|
-
const region = direction
|
|
1430
|
-
|
|
1431
|
-
throw new Error(`${id}: ${direction} assembly needs a %${region}B address.`);
|
|
1432
|
-
}
|
|
1572
|
+
const region = regionOf(direction);
|
|
1573
|
+
const offset = selection?.address === undefined ? undefined : configuredByte(id, direction, selection.address);
|
|
1433
1574
|
const declaredSize = direction === "input" ? connection?.inputSize : connection?.outputSize;
|
|
1434
1575
|
const payloadSize = selection?.size ?? declaredSize?.value ?? assembly.size;
|
|
1435
1576
|
if (!Number.isSafeInteger(payloadSize) || payloadSize <= 0 || payloadSize > assembly.size || declaredSize?.minimum !== undefined && payloadSize < declaredSize.minimum || declaredSize?.maximum !== undefined && payloadSize > declaredSize.maximum || selection?.size !== undefined && declaredSize && !declaredSize.parameter && payloadSize !== declaredSize.value) {
|
|
@@ -1443,29 +1584,49 @@ function selectAssemblies(id, settings, descriptor, connection) {
|
|
|
1443
1584
|
instance,
|
|
1444
1585
|
assembly,
|
|
1445
1586
|
size: payloadSize,
|
|
1446
|
-
|
|
1587
|
+
offset
|
|
1447
1588
|
}
|
|
1448
1589
|
];
|
|
1449
1590
|
});
|
|
1450
1591
|
}
|
|
1451
1592
|
|
|
1452
1593
|
// packages/typegen/src/hardware.ts
|
|
1453
|
-
import { ioScalarBits as
|
|
1594
|
+
import { ioScalarBits as ioScalarBits2 } from "@tsplc/iec";
|
|
1454
1595
|
|
|
1455
1596
|
// packages/typegen/src/hardware/mapping-types.ts
|
|
1456
|
-
import {
|
|
1597
|
+
import { relative, sep } from "node:path";
|
|
1598
|
+
import { sizePrefixes as sizePrefixes2 } from "@tsplc/iec";
|
|
1599
|
+
var region = '${"I" | "Q"}';
|
|
1600
|
+
var bitAddress = `\`%${region}X\${number}.\${0 | 1 | 2 | 3 | 4 | 5 | 6 | 7}\``;
|
|
1601
|
+
var byteSizes = [...sizePrefixes2].filter(([prefix, type]) => type.bits > 1 && addressSize(type.bits) === prefix).map(([prefix]) => JSON.stringify(prefix)).join(" | ");
|
|
1602
|
+
var addressBinding = (address) => `{ address: ${address}; type?: string }`;
|
|
1457
1603
|
var directBinding = (layout) => {
|
|
1458
|
-
const
|
|
1459
|
-
const integer = /^INT(\d+)$/.exec(scalar);
|
|
1460
|
-
const bits = integer ? Number(integer[1]) : ioScalarBits2(scalar);
|
|
1604
|
+
const bits = layoutBits(layout);
|
|
1461
1605
|
const size = bits === undefined ? undefined : addressSize(bits);
|
|
1462
1606
|
if (!size) {
|
|
1463
1607
|
return;
|
|
1464
1608
|
}
|
|
1465
|
-
return size === "X" ?
|
|
1609
|
+
return addressBinding(size === "X" ? bitAddress : `\`%${region}${size}\${number}\``);
|
|
1610
|
+
};
|
|
1611
|
+
var portableCatalog = (catalog, root) => {
|
|
1612
|
+
const portable = (file) => relative(root, file).split(sep).join("/");
|
|
1613
|
+
return {
|
|
1614
|
+
descriptors: catalog.descriptors.map((descriptor) => ({
|
|
1615
|
+
...descriptor,
|
|
1616
|
+
file: portable(descriptor.file)
|
|
1617
|
+
})),
|
|
1618
|
+
devices: catalog.devices.map((device) => ({
|
|
1619
|
+
...device,
|
|
1620
|
+
descriptor: portable(device.descriptor)
|
|
1621
|
+
}))
|
|
1622
|
+
};
|
|
1466
1623
|
};
|
|
1467
|
-
function generateHardwareTypes(catalog,
|
|
1468
|
-
|
|
1624
|
+
function generateHardwareTypes(catalog, {
|
|
1625
|
+
root,
|
|
1626
|
+
targets,
|
|
1627
|
+
ioTypes
|
|
1628
|
+
}) {
|
|
1629
|
+
const selectors = targets?.publication.map((selector) => JSON.stringify(selector)).join(" | ") ?? "string";
|
|
1469
1630
|
const publicationTypes = `// Generated by tsPLC. Run tsplc typegen after changing EDS files, device selections or PLC storage.
|
|
1470
1631
|
export type PublicationSelector = ${selectors || "never"};
|
|
1471
1632
|
export type PlcPublication = { readonly production: readonly PublicationSelector[]; readonly development: readonly PublicationSelector[] };
|
|
@@ -1478,11 +1639,11 @@ export type PlcPublication = { readonly production: readonly PublicationSelector
|
|
|
1478
1639
|
binding: channel(device.id, item.id, item.direction === "input" && item.type === "BOOL" ? "; inverted?: boolean; shared?: boolean" : ""),
|
|
1479
1640
|
layout: ioLayout(item.type)
|
|
1480
1641
|
})));
|
|
1481
|
-
const direct =
|
|
1642
|
+
const direct = addressBinding(`\`%${region}\${${byteSizes}}\${number}\` | ${bitAddress}`);
|
|
1482
1643
|
const anyBinding = [...channels.map((item) => item.binding), direct].join(`
|
|
1483
1644
|
| `);
|
|
1484
|
-
const mapping = targets ? [...new Set(targets.map((target) => target.layout))].sort().map((layout) => {
|
|
1485
|
-
const keys = targets.filter((target) => target.layout === layout).map((target) => `\`${target.key}\``);
|
|
1645
|
+
const mapping = targets ? [...new Set(targets.io.map((target) => target.layout))].sort().map((layout) => {
|
|
1646
|
+
const keys = targets.io.filter((target) => target.layout === layout).map((target) => `\`${target.key}\``);
|
|
1486
1647
|
const bindings = [
|
|
1487
1648
|
...channels.filter((item) => item.layout === layout).map((item) => item.binding),
|
|
1488
1649
|
directBinding(layout)
|
|
@@ -1493,45 +1654,37 @@ export type PlcPublication = { readonly production: readonly PublicationSelector
|
|
|
1493
1654
|
}).join(" & ") || "Readonly<Record<string, never>>" : "Readonly<Record<string, HardwareIoBinding>>";
|
|
1494
1655
|
return `${publicationTypes}export type HardwareIoBinding = ${anyBinding};
|
|
1495
1656
|
export type HardwareIoMapping = ${mapping};
|
|
1496
|
-
export const hardware = ${JSON.stringify(catalog, null, 2)} as const;
|
|
1657
|
+
export const hardware = ${JSON.stringify(portableCatalog(catalog, root), null, 2)} as const;
|
|
1497
1658
|
`;
|
|
1498
1659
|
}
|
|
1499
1660
|
|
|
1500
1661
|
// packages/typegen/src/hardware.ts
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
}
|
|
1506
|
-
throw cause;
|
|
1507
|
-
});
|
|
1508
|
-
const files = [];
|
|
1509
|
-
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
1510
|
-
const path = resolve(directory, entry.name);
|
|
1511
|
-
if (entry.isDirectory()) {
|
|
1512
|
-
files.push(...await edsFiles(path));
|
|
1513
|
-
} else if (entry.isFile() && /\.eds$/i.test(entry.name)) {
|
|
1514
|
-
files.push(path);
|
|
1515
|
-
}
|
|
1662
|
+
var defaultEds = tsplcConfigSchema.shape.eds.parse(undefined);
|
|
1663
|
+
var edsFiles = (config, directory) => filesUnder(directory, "eds", (a, b) => a.localeCompare(b)).catch((error) => {
|
|
1664
|
+
if (config.eds === defaultEds && isMissingFile(error)) {
|
|
1665
|
+
return [];
|
|
1516
1666
|
}
|
|
1517
|
-
|
|
1518
|
-
}
|
|
1667
|
+
throw error;
|
|
1668
|
+
});
|
|
1519
1669
|
async function readDescriptors(config, root) {
|
|
1520
1670
|
const files = new Set;
|
|
1521
1671
|
for (const directory of [config.eds].flat()) {
|
|
1522
|
-
for (const file of await edsFiles(resolve(root, directory))) {
|
|
1672
|
+
for (const file of await edsFiles(config, resolve(root, directory))) {
|
|
1523
1673
|
files.add(file);
|
|
1524
1674
|
}
|
|
1525
1675
|
}
|
|
1526
1676
|
for (const device of Object.values(config.devices)) {
|
|
1527
1677
|
files.add(resolve(root, device.file));
|
|
1528
1678
|
}
|
|
1529
|
-
return Promise.all([...files].map(async (file) => parseEds(await
|
|
1679
|
+
return new Map(await Promise.all([...files].map(async (file) => [file, parseEds(await readFile4(file, "utf8"), file)])));
|
|
1530
1680
|
}
|
|
1531
1681
|
async function loadHardware(config, root) {
|
|
1532
1682
|
const descriptors = await readDescriptors(config, root);
|
|
1533
1683
|
const selected = Object.entries(config.devices).map(([id, settings]) => {
|
|
1534
|
-
const descriptor = descriptors.
|
|
1684
|
+
const descriptor = descriptors.get(resolve(root, settings.file));
|
|
1685
|
+
if (!descriptor) {
|
|
1686
|
+
throw new Error(`${id}: ${settings.file} was not read.`);
|
|
1687
|
+
}
|
|
1535
1688
|
const connection = selectConnection(id, settings, descriptor);
|
|
1536
1689
|
const selections = selectAssemblies(id, settings, descriptor, connection);
|
|
1537
1690
|
return { id, settings, descriptor, connection, selections };
|
|
@@ -1539,10 +1692,14 @@ async function loadHardware(config, root) {
|
|
|
1539
1692
|
const place = regionPlacer(selected.flatMap((device) => device.selections), { generatedTree: config.codesys?.deviceTree !== undefined });
|
|
1540
1693
|
const placed = selected.map((device) => ({
|
|
1541
1694
|
...device,
|
|
1542
|
-
assemblies: device.selections.map((selection) =>
|
|
1543
|
-
|
|
1544
|
-
address
|
|
1545
|
-
|
|
1695
|
+
assemblies: device.selections.map((selection) => {
|
|
1696
|
+
const offset = place(selection);
|
|
1697
|
+
const address = directAddress(selection.region, offset, 0, 8);
|
|
1698
|
+
if (!address) {
|
|
1699
|
+
throw new Error(`${device.id}: byte ${offset} has no direct address.`);
|
|
1700
|
+
}
|
|
1701
|
+
return { ...selection, offset, address };
|
|
1702
|
+
})
|
|
1546
1703
|
}));
|
|
1547
1704
|
const devices = placed.map(({ id, settings, descriptor, connection, assemblies }) => {
|
|
1548
1705
|
const registers = placeModbusRegisters(id, settings.modbus?.registers ?? {}, place);
|
|
@@ -1564,12 +1721,12 @@ async function loadHardware(config, root) {
|
|
|
1564
1721
|
})),
|
|
1565
1722
|
channels: [
|
|
1566
1723
|
...registers.flatMap((register) => register.channels),
|
|
1567
|
-
...assemblies.flatMap(({ direction, instance, assembly, size,
|
|
1724
|
+
...assemblies.flatMap(({ direction, instance, assembly, size, offset }) => assemblyChannels({
|
|
1568
1725
|
device: id,
|
|
1569
1726
|
direction,
|
|
1570
1727
|
instance,
|
|
1571
1728
|
members: assembly.members,
|
|
1572
|
-
base:
|
|
1729
|
+
base: offset,
|
|
1573
1730
|
payloadSize: size
|
|
1574
1731
|
}))
|
|
1575
1732
|
],
|
|
@@ -1582,18 +1739,14 @@ async function loadHardware(config, root) {
|
|
|
1582
1739
|
}
|
|
1583
1740
|
};
|
|
1584
1741
|
});
|
|
1585
|
-
return { descriptors, devices };
|
|
1742
|
+
return { descriptors: [...descriptors.values()], devices };
|
|
1586
1743
|
}
|
|
1587
1744
|
function resolveIo(config, catalog) {
|
|
1588
1745
|
return Object.fromEntries(Object.entries(config.io).map(([symbol, binding]) => {
|
|
1589
1746
|
if ("address" in binding) {
|
|
1590
1747
|
return [symbol, binding];
|
|
1591
1748
|
}
|
|
1592
|
-
const
|
|
1593
|
-
const channel = device?.channels.find((c) => c.id === binding.channel);
|
|
1594
|
-
if (!channel?.address) {
|
|
1595
|
-
throw new Error(`${symbol}: unknown or unaddressable channel ${binding.device}.${binding.channel}.`);
|
|
1596
|
-
}
|
|
1749
|
+
const channel = boundChannel(catalog, symbol, binding);
|
|
1597
1750
|
return [
|
|
1598
1751
|
symbol,
|
|
1599
1752
|
{
|
|
@@ -1606,73 +1759,92 @@ function resolveIo(config, catalog) {
|
|
|
1606
1759
|
}));
|
|
1607
1760
|
}
|
|
1608
1761
|
// packages/typegen/src/project.ts
|
|
1609
|
-
import {
|
|
1610
|
-
import { dirname, resolve as resolve2 } from "node:path";
|
|
1762
|
+
import { resolve as resolve2 } from "node:path";
|
|
1611
1763
|
import {
|
|
1612
1764
|
ioSymbolsSchema,
|
|
1613
|
-
loadTsplcConfig,
|
|
1614
1765
|
publicationSchema,
|
|
1615
|
-
|
|
1766
|
+
typegenSettings
|
|
1616
1767
|
} from "@tsplc/config";
|
|
1617
1768
|
import {
|
|
1618
1769
|
emittedFiles,
|
|
1619
1770
|
emittedStDirectory,
|
|
1620
|
-
projectSnapshotFile
|
|
1771
|
+
projectSnapshotFile,
|
|
1772
|
+
stRoot
|
|
1621
1773
|
} from "@tsplc/config/project-files";
|
|
1622
|
-
import {
|
|
1774
|
+
import { isWithin } from "@tsplc/iec/st";
|
|
1623
1775
|
|
|
1624
1776
|
// packages/typegen/src/codegen/declarations.ts
|
|
1625
|
-
import { readFile as
|
|
1626
|
-
import { blockCommentEnd as blockCommentEnd2, lineCommentEnd as lineCommentEnd2 } from "@tsplc/iec/st";
|
|
1627
|
-
var codeStart = (text, offset) => {
|
|
1628
|
-
const start = offset + text.slice(offset).search(/\S|$/);
|
|
1629
|
-
if (text.startsWith("(*", start)) {
|
|
1630
|
-
const end = blockCommentEnd2(text, start);
|
|
1631
|
-
return end === null ? start : codeStart(text, end);
|
|
1632
|
-
}
|
|
1633
|
-
if (text.startsWith("//", start)) {
|
|
1634
|
-
return codeStart(text, lineCommentEnd2(text, start));
|
|
1635
|
-
}
|
|
1636
|
-
if (text.startsWith("{", start)) {
|
|
1637
|
-
const end = text.indexOf("}", start);
|
|
1638
|
-
return end < 0 ? start : codeStart(text, end + 1);
|
|
1639
|
-
}
|
|
1640
|
-
return start;
|
|
1641
|
-
};
|
|
1777
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
1642
1778
|
var declarationFiles = async (files) => {
|
|
1643
1779
|
const sorted = {
|
|
1644
1780
|
types: [],
|
|
1645
1781
|
globals: []
|
|
1646
1782
|
};
|
|
1647
1783
|
for (const file of files) {
|
|
1648
|
-
const
|
|
1649
|
-
|
|
1650
|
-
|
|
1784
|
+
const keyword = firstCodeToken({
|
|
1785
|
+
name: file,
|
|
1786
|
+
text: await readFile5(file, "utf8")
|
|
1787
|
+
})?.toUpperCase();
|
|
1788
|
+
if (keyword === "TYPE") {
|
|
1651
1789
|
sorted.types.push(file);
|
|
1652
|
-
} else if (
|
|
1790
|
+
} else if (keyword === "VAR_GLOBAL") {
|
|
1653
1791
|
sorted.globals.push(file);
|
|
1654
1792
|
}
|
|
1655
1793
|
}
|
|
1656
1794
|
return sorted;
|
|
1657
1795
|
};
|
|
1658
1796
|
|
|
1659
|
-
// packages/typegen/src/
|
|
1797
|
+
// packages/typegen/src/outputs.ts
|
|
1798
|
+
import { randomUUID } from "node:crypto";
|
|
1799
|
+
import { mkdir, rename, rm, writeFile } from "node:fs/promises";
|
|
1800
|
+
import { dirname } from "node:path";
|
|
1801
|
+
import { format } from "prettier";
|
|
1660
1802
|
var formatTypeScript = (source) => format(source, { parser: "typescript" });
|
|
1661
|
-
|
|
1803
|
+
async function writeOutputs(outputs) {
|
|
1804
|
+
for (const { path, content } of outputs) {
|
|
1805
|
+
if (content === null) {
|
|
1806
|
+
await rm(path, { force: true });
|
|
1807
|
+
continue;
|
|
1808
|
+
}
|
|
1809
|
+
await mkdir(dirname(path), { recursive: true });
|
|
1810
|
+
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
1811
|
+
try {
|
|
1812
|
+
await writeFile(temporary, content);
|
|
1813
|
+
await rename(temporary, path);
|
|
1814
|
+
} finally {
|
|
1815
|
+
await rm(temporary, { force: true });
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
async function checkOutputs(outputs) {
|
|
1820
|
+
for (const { path, content } of outputs) {
|
|
1821
|
+
const actual = await readIfPresent(path);
|
|
1822
|
+
const normalized = actual !== null && /\.ts$/i.test(path) ? await formatTypeScript(actual).catch(() => actual) : actual;
|
|
1823
|
+
if (normalized !== content) {
|
|
1824
|
+
throw new Error(`Generated file is missing or stale: ${path}`);
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
// packages/typegen/src/project.ts
|
|
1830
|
+
var emittedPath = (root, file) => resolve2(root, emittedStDirectory, file);
|
|
1831
|
+
var missingEmission = (root) => new Error(`No emitted Structured Text in ${resolve2(root, emittedStDirectory)}: emit the program with tsplc build --emit-only, or check with tsplc typegen --check, which emits it first.`);
|
|
1832
|
+
var readPublication = async (root) => {
|
|
1833
|
+
const text = await readIfPresent(emittedPath(root, emittedFiles.publication));
|
|
1834
|
+
if (text === null) {
|
|
1835
|
+
throw missingEmission(root);
|
|
1836
|
+
}
|
|
1837
|
+
return publicationSchema.parse(JSON.parse(text));
|
|
1838
|
+
};
|
|
1662
1839
|
var generatedFiles = {
|
|
1663
1840
|
hardware: "hardware.ts",
|
|
1664
1841
|
contract: "plc.ts",
|
|
1665
1842
|
machines: "machines.ts"
|
|
1666
1843
|
};
|
|
1667
1844
|
async function readIoSymbols(root) {
|
|
1668
|
-
const file =
|
|
1669
|
-
const text = await
|
|
1670
|
-
|
|
1671
|
-
return "{}";
|
|
1672
|
-
}
|
|
1673
|
-
throw error;
|
|
1674
|
-
});
|
|
1675
|
-
const symbols = ioSymbolsSchema.safeParse(JSON.parse(text));
|
|
1845
|
+
const file = emittedPath(root, emittedFiles.ioSymbols);
|
|
1846
|
+
const text = await readIfPresent(file);
|
|
1847
|
+
const symbols = ioSymbolsSchema.safeParse(JSON.parse(text ?? "{}"));
|
|
1676
1848
|
if (!symbols.success) {
|
|
1677
1849
|
throw new Error(`Invalid IO symbols in ${file}`, { cause: symbols.error });
|
|
1678
1850
|
}
|
|
@@ -1683,6 +1855,7 @@ async function contractSources(config, root, settings) {
|
|
|
1683
1855
|
const types = directories(settings.types);
|
|
1684
1856
|
const globals = directories(settings.globals);
|
|
1685
1857
|
if (types.length || globals.length) {
|
|
1858
|
+
const filesIn = async (directories) => (await Promise.all(directories.map(stFiles))).flat();
|
|
1686
1859
|
const sources = {
|
|
1687
1860
|
types: await filesIn(types),
|
|
1688
1861
|
globals: await filesIn(globals),
|
|
@@ -1693,56 +1866,32 @@ async function contractSources(config, root, settings) {
|
|
|
1693
1866
|
}
|
|
1694
1867
|
return sources;
|
|
1695
1868
|
}
|
|
1696
|
-
const source = config
|
|
1869
|
+
const source = stRoot(config);
|
|
1697
1870
|
if (!source) {
|
|
1698
|
-
|
|
1699
|
-
throw new Error("Configure build.sourceDir or typegen.types/globals to generate PLC types.");
|
|
1700
|
-
}
|
|
1701
|
-
return;
|
|
1871
|
+
throw new Error("Configure build.sourceDir or typegen.types/globals to generate PLC types.");
|
|
1702
1872
|
}
|
|
1703
1873
|
const sourceRoot = resolve2(root, source);
|
|
1704
|
-
const files = await stFiles(sourceRoot)
|
|
1874
|
+
const files = await stFiles(sourceRoot).catch((cause) => {
|
|
1875
|
+
if (!isMissingFile(cause)) {
|
|
1876
|
+
throw cause;
|
|
1877
|
+
}
|
|
1878
|
+
throw config.compiler ? missingEmission(root) : new Error(`build.sourceDir ${sourceRoot} doesn't exist.`);
|
|
1879
|
+
});
|
|
1705
1880
|
if (!files.length) {
|
|
1706
1881
|
throw new Error(`no .st declarations found in ${sourceRoot}`);
|
|
1707
1882
|
}
|
|
1708
1883
|
return { ...await declarationFiles(files), explicit: false };
|
|
1709
1884
|
}
|
|
1710
|
-
async function filesIn(directories) {
|
|
1711
|
-
const files = [];
|
|
1712
|
-
for (const directory of directories) {
|
|
1713
|
-
files.push(...await stFiles(directory));
|
|
1714
|
-
}
|
|
1715
|
-
return files;
|
|
1716
|
-
}
|
|
1717
1885
|
function checkHmiTargets(controls, published) {
|
|
1718
1886
|
for (const { target } of controls) {
|
|
1719
|
-
if (!published.some((symbol) =>
|
|
1887
|
+
if (!published.some((symbol) => isWithin(symbol, target))) {
|
|
1720
1888
|
throw new Error(`HMI control ${target} is not in the production publication.`);
|
|
1721
1889
|
}
|
|
1722
1890
|
}
|
|
1723
1891
|
}
|
|
1724
|
-
async function
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
const temp = `${output.path}.${process.pid}.tmp`;
|
|
1728
|
-
await writeFile(temp, output.content);
|
|
1729
|
-
await rename(temp, output.path);
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
|
-
async function checkOutputs(outputs) {
|
|
1733
|
-
for (const output of outputs) {
|
|
1734
|
-
const actual = await readFile5(output.path, "utf8").catch(() => {
|
|
1735
|
-
return;
|
|
1736
|
-
});
|
|
1737
|
-
const normalized = actual !== undefined && /\.ts$/i.test(output.path) ? await formatTypeScript(actual) : actual;
|
|
1738
|
-
if (normalized !== output.content) {
|
|
1739
|
-
throw new Error(`Generated file is missing or stale: ${output.path}`);
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1742
|
-
}
|
|
1743
|
-
async function generateProject(file = "tsplc.config.ts", options = {}) {
|
|
1744
|
-
const { config, root, configFile } = options.loaded ?? await loadTsplcConfig(file);
|
|
1745
|
-
const settings = typegenSchema.parse(config.typegen ?? {});
|
|
1892
|
+
async function generateProject({ config, root, configFile }, options = {}) {
|
|
1893
|
+
const hardwareOnly = options.hardwareOnly || !config.compiler && !config.typegen;
|
|
1894
|
+
const settings = typegenSettings(config);
|
|
1746
1895
|
const catalog = await loadHardware(config, root);
|
|
1747
1896
|
const io = resolveIo(config, catalog);
|
|
1748
1897
|
const project = {
|
|
@@ -1754,44 +1903,53 @@ async function generateProject(file = "tsplc.config.ts", options = {}) {
|
|
|
1754
1903
|
const outputs = [
|
|
1755
1904
|
{
|
|
1756
1905
|
path: resolve2(root, settings.dir, generatedFiles.hardware),
|
|
1757
|
-
content: await formatTypeScript(generateHardwareTypes(catalog,
|
|
1906
|
+
content: await formatTypeScript(generateHardwareTypes(catalog, {
|
|
1907
|
+
root,
|
|
1908
|
+
targets: options.targets ?? null,
|
|
1909
|
+
ioTypes: settings.ioTypes
|
|
1910
|
+
}))
|
|
1758
1911
|
},
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1912
|
+
...options.check ? [] : [
|
|
1913
|
+
{
|
|
1914
|
+
path: resolve2(root, projectSnapshotFile),
|
|
1915
|
+
content: `${JSON.stringify(project, null, 2)}
|
|
1762
1916
|
`
|
|
1763
|
-
|
|
1917
|
+
}
|
|
1918
|
+
]
|
|
1764
1919
|
];
|
|
1765
|
-
const sources =
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1920
|
+
const sources = hardwareOnly ? null : await contractSources(config, root, settings);
|
|
1921
|
+
const inferred = sources !== null && !!config.compiler && !sources.explicit;
|
|
1922
|
+
const hmi = config.compiler && config.publish && !hardwareOnly ? config.hmi : undefined;
|
|
1923
|
+
const publication = inferred || hmi ? await readPublication(root) : null;
|
|
1924
|
+
const contract = sources && {
|
|
1925
|
+
path: resolve2(root, settings.dir, generatedFiles.contract),
|
|
1926
|
+
content: await formatTypeScript(await generateTypes({
|
|
1927
|
+
types: sources.types,
|
|
1928
|
+
globals: sources.globals,
|
|
1929
|
+
publication: inferred ? publication : null,
|
|
1930
|
+
declarations: settings.declarations
|
|
1931
|
+
}))
|
|
1932
|
+
};
|
|
1933
|
+
if (contract) {
|
|
1934
|
+
outputs.push(contract);
|
|
1778
1935
|
}
|
|
1779
|
-
if (
|
|
1780
|
-
checkHmiTargets(
|
|
1936
|
+
if (hmi && publication) {
|
|
1937
|
+
checkHmiTargets(hmi.controls, publication.production);
|
|
1781
1938
|
}
|
|
1782
|
-
if (config.compiler && !
|
|
1783
|
-
const
|
|
1784
|
-
|
|
1939
|
+
if (config.compiler && !hardwareOnly) {
|
|
1940
|
+
const machines = await readIfPresent(emittedPath(root, emittedFiles.machines));
|
|
1941
|
+
outputs.push({
|
|
1942
|
+
path: resolve2(root, settings.dir, generatedFiles.machines),
|
|
1943
|
+
content: machines === null ? null : await formatTypeScript(machines)
|
|
1785
1944
|
});
|
|
1786
|
-
if (machine) {
|
|
1787
|
-
outputs.push({
|
|
1788
|
-
path: resolve2(root, settings.dir, generatedFiles.machines),
|
|
1789
|
-
content: await formatTypeScript(machine)
|
|
1790
|
-
});
|
|
1791
|
-
}
|
|
1792
1945
|
}
|
|
1793
1946
|
await (options.check ? checkOutputs(outputs) : writeOutputs(outputs));
|
|
1794
|
-
return {
|
|
1947
|
+
return {
|
|
1948
|
+
catalog,
|
|
1949
|
+
io,
|
|
1950
|
+
files: outputs.flatMap((output) => output.content === null ? [] : [output.path]),
|
|
1951
|
+
contract: contract?.path ?? null
|
|
1952
|
+
};
|
|
1795
1953
|
}
|
|
1796
1954
|
export {
|
|
1797
1955
|
deviceTree,
|
|
@@ -1800,7 +1958,7 @@ export {
|
|
|
1800
1958
|
generateTypes,
|
|
1801
1959
|
generatedFiles,
|
|
1802
1960
|
ioLayout,
|
|
1803
|
-
|
|
1961
|
+
ioScalarBits3 as ioScalarBits,
|
|
1804
1962
|
loadHardware,
|
|
1805
1963
|
normalizeEds,
|
|
1806
1964
|
parseEds,
|
|
@@ -1808,5 +1966,5 @@ export {
|
|
|
1808
1966
|
resolveIo
|
|
1809
1967
|
};
|
|
1810
1968
|
|
|
1811
|
-
//# debugId=
|
|
1969
|
+
//# debugId=A913FE8EC54CA54864756E2164756E21
|
|
1812
1970
|
//# sourceMappingURL=index.js.map
|