@ebusd/ebus-typespec 0.3.1 → 0.4.0
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 +2 -0
- package/dist/src/csv_emitter.js +36 -5
- package/dist/src/csv_emitter.js.map +1 -1
- package/dist/src/decorators.d.ts +32 -0
- package/dist/src/decorators.js +158 -15
- package/dist/src/decorators.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +54 -9
- package/dist/src/lib.js +20 -1
- package/dist/src/lib.js.map +1 -1
- package/dist/src/linter.js +0 -1
- package/dist/src/linter.js.map +1 -1
- package/dist/src/validate.d.ts +2 -0
- package/dist/src/validate.js +83 -0
- package/dist/src/validate.js.map +1 -0
- package/docs.md +28 -2
- package/lib/decorators.tsp +15 -2
- package/lib/models.tsp +8 -8
- package/lib/types.tsp +235 -13
- package/package.json +3 -3
package/dist/src/lib.d.ts
CHANGED
|
@@ -45,16 +45,25 @@ export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
|
45
45
|
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
46
46
|
};
|
|
47
47
|
"banned-inheritance": {
|
|
48
|
-
default: import("@typespec/compiler").CallableMessage<[]>;
|
|
48
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
49
49
|
};
|
|
50
50
|
"duplicate-name": {
|
|
51
51
|
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
52
52
|
};
|
|
53
|
-
|
|
53
|
+
"multiple-decorator": {
|
|
54
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
55
|
+
};
|
|
56
|
+
"invalid-length": {
|
|
57
|
+
default: import("@typespec/compiler").CallableMessage<[string, string]>;
|
|
58
|
+
};
|
|
59
|
+
"missing-decorator": {
|
|
60
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
61
|
+
};
|
|
62
|
+
}, EbusdEmitterOptions, "values" | "reverse" | "unit" | "id" | "condition" | "write" | "passive" | "auth" | "qq" | "zz" | "chain" | "inherit" | "bcd" | "hex" | "maxBits" | "out" | "divisor">;
|
|
54
63
|
export declare const $flags: {
|
|
55
64
|
decoratorArgMarshalling: string;
|
|
56
65
|
};
|
|
57
|
-
export declare const reportDiagnostic: <C extends "banned-source-address" | "banned-target-address" | "banned-auth" | "banned-divisor" | "banned-factor" | "banned-values" | "banned-type" | "banned-length" | "banned-in" | "duplicate-id" | "short-id" | "banned-inheritance" | "duplicate-name", M extends keyof {
|
|
66
|
+
export declare const reportDiagnostic: <C extends "banned-source-address" | "banned-target-address" | "banned-auth" | "banned-divisor" | "banned-factor" | "banned-values" | "banned-type" | "banned-length" | "banned-in" | "duplicate-id" | "short-id" | "banned-inheritance" | "duplicate-name" | "multiple-decorator" | "invalid-length" | "missing-decorator", M extends keyof {
|
|
58
67
|
"banned-source-address": {
|
|
59
68
|
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
60
69
|
};
|
|
@@ -89,11 +98,20 @@ export declare const reportDiagnostic: <C extends "banned-source-address" | "ban
|
|
|
89
98
|
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
90
99
|
};
|
|
91
100
|
"banned-inheritance": {
|
|
92
|
-
default: import("@typespec/compiler").CallableMessage<[]>;
|
|
101
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
93
102
|
};
|
|
94
103
|
"duplicate-name": {
|
|
95
104
|
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
96
105
|
};
|
|
106
|
+
"multiple-decorator": {
|
|
107
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
108
|
+
};
|
|
109
|
+
"invalid-length": {
|
|
110
|
+
default: import("@typespec/compiler").CallableMessage<[string, string]>;
|
|
111
|
+
};
|
|
112
|
+
"missing-decorator": {
|
|
113
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
114
|
+
};
|
|
97
115
|
}[C]>(program: import("@typespec/compiler").Program, diag: import("@typespec/compiler").DiagnosticReport<{
|
|
98
116
|
"banned-source-address": {
|
|
99
117
|
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
@@ -129,12 +147,21 @@ export declare const reportDiagnostic: <C extends "banned-source-address" | "ban
|
|
|
129
147
|
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
130
148
|
};
|
|
131
149
|
"banned-inheritance": {
|
|
132
|
-
default: import("@typespec/compiler").CallableMessage<[]>;
|
|
150
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
133
151
|
};
|
|
134
152
|
"duplicate-name": {
|
|
135
153
|
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
136
154
|
};
|
|
137
|
-
|
|
155
|
+
"multiple-decorator": {
|
|
156
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
157
|
+
};
|
|
158
|
+
"invalid-length": {
|
|
159
|
+
default: import("@typespec/compiler").CallableMessage<[string, string]>;
|
|
160
|
+
};
|
|
161
|
+
"missing-decorator": {
|
|
162
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
163
|
+
};
|
|
164
|
+
}, C, M>) => void, createDiagnostic: <C extends "banned-source-address" | "banned-target-address" | "banned-auth" | "banned-divisor" | "banned-factor" | "banned-values" | "banned-type" | "banned-length" | "banned-in" | "duplicate-id" | "short-id" | "banned-inheritance" | "duplicate-name" | "multiple-decorator" | "invalid-length" | "missing-decorator", M extends keyof {
|
|
138
165
|
"banned-source-address": {
|
|
139
166
|
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
140
167
|
};
|
|
@@ -169,11 +196,20 @@ export declare const reportDiagnostic: <C extends "banned-source-address" | "ban
|
|
|
169
196
|
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
170
197
|
};
|
|
171
198
|
"banned-inheritance": {
|
|
172
|
-
default: import("@typespec/compiler").CallableMessage<[]>;
|
|
199
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
173
200
|
};
|
|
174
201
|
"duplicate-name": {
|
|
175
202
|
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
176
203
|
};
|
|
204
|
+
"multiple-decorator": {
|
|
205
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
206
|
+
};
|
|
207
|
+
"invalid-length": {
|
|
208
|
+
default: import("@typespec/compiler").CallableMessage<[string, string]>;
|
|
209
|
+
};
|
|
210
|
+
"missing-decorator": {
|
|
211
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
212
|
+
};
|
|
177
213
|
}[C]>(diag: import("@typespec/compiler").DiagnosticReport<{
|
|
178
214
|
"banned-source-address": {
|
|
179
215
|
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
@@ -209,9 +245,18 @@ export declare const reportDiagnostic: <C extends "banned-source-address" | "ban
|
|
|
209
245
|
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
210
246
|
};
|
|
211
247
|
"banned-inheritance": {
|
|
212
|
-
default: import("@typespec/compiler").CallableMessage<[]>;
|
|
248
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
213
249
|
};
|
|
214
250
|
"duplicate-name": {
|
|
215
251
|
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
216
252
|
};
|
|
217
|
-
|
|
253
|
+
"multiple-decorator": {
|
|
254
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
255
|
+
};
|
|
256
|
+
"invalid-length": {
|
|
257
|
+
default: import("@typespec/compiler").CallableMessage<[string, string]>;
|
|
258
|
+
};
|
|
259
|
+
"missing-decorator": {
|
|
260
|
+
default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
261
|
+
};
|
|
262
|
+
}, C, M>) => import("@typespec/compiler").Diagnostic, StateKeys: Record<"values" | "reverse" | "unit" | "id" | "condition" | "write" | "passive" | "auth" | "qq" | "zz" | "chain" | "inherit" | "bcd" | "hex" | "maxBits" | "out" | "divisor", symbol>;
|
package/dist/src/lib.js
CHANGED
|
@@ -88,7 +88,7 @@ export const $lib = createTypeSpecLibrary({
|
|
|
88
88
|
"banned-inheritance": {
|
|
89
89
|
severity: "error",
|
|
90
90
|
messages: {
|
|
91
|
-
default: paramMessage `The inheritance is too deep.`,
|
|
91
|
+
default: paramMessage `The inheritance is too deep in ${"ref"}.`,
|
|
92
92
|
},
|
|
93
93
|
},
|
|
94
94
|
"duplicate-name": {
|
|
@@ -97,6 +97,24 @@ export const $lib = createTypeSpecLibrary({
|
|
|
97
97
|
default: paramMessage `There are multiple models types with the same id "${"id"}".`,
|
|
98
98
|
},
|
|
99
99
|
},
|
|
100
|
+
"multiple-decorator": {
|
|
101
|
+
severity: "error",
|
|
102
|
+
messages: {
|
|
103
|
+
default: paramMessage `Only single decorator "@${"which"}" allowed.`,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
"invalid-length": {
|
|
107
|
+
severity: "error",
|
|
108
|
+
messages: {
|
|
109
|
+
default: paramMessage `Invalid @${"which"} length ${"value"}.`,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
"missing-decorator": {
|
|
113
|
+
severity: "error",
|
|
114
|
+
messages: {
|
|
115
|
+
default: paramMessage `Missing decorator "@${"which"}".`,
|
|
116
|
+
},
|
|
117
|
+
}
|
|
100
118
|
},
|
|
101
119
|
emitter: {
|
|
102
120
|
options: EmitterOptionsSchema,
|
|
@@ -109,6 +127,7 @@ export const $lib = createTypeSpecLibrary({
|
|
|
109
127
|
qq: { description: "source address QQ" },
|
|
110
128
|
zz: { description: "target address ZZ" },
|
|
111
129
|
id: { description: "message ID" },
|
|
130
|
+
chain: { description: "message chain" },
|
|
112
131
|
inherit: { description: "inherited model(s)" },
|
|
113
132
|
bcd: { description: 'BCD encoding' },
|
|
114
133
|
hex: { description: 'HEX encoding' },
|
package/dist/src/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AA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AAmB,EAAE;QACxC,EAAE,EAAE,EAAE,WAAW,EAAE,mBAAmB,EAAE;QACxC,EAAE,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE;QACjC,KAAK,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE;QACvC,OAAO,EAAE,EAAE,WAAW,EAAE,oBAAoB,EAAE;QAC9C,GAAG,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE;QACpC,GAAG,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE;QACpC,OAAO,EAAE,EAAE,WAAW,EAAE,oBAAoB,EAAE;QAC9C,GAAG,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE;QACrD,OAAO,EAAE,EAAE,WAAW,EAAE,wBAAwB,EAAE;QAClD,IAAI,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE;QAC7B,OAAO,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE;QACnC,MAAM,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE;KACxC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,MAAM,GAAG,EAAC,uBAAuB,EAAE,KAAK,EAAC,CAAC;AAEvD,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC"}
|
package/dist/src/linter.js
CHANGED
|
@@ -9,7 +9,6 @@ import { noProjectionRule } from "./rules/no-projection.rule.js";
|
|
|
9
9
|
import { noTemplateRule } from "./rules/no-template.rule.js";
|
|
10
10
|
import { noTupleRule } from "./rules/no-tuple.rule.js";
|
|
11
11
|
import { noUnionRule } from "./rules/no-union.rule.js";
|
|
12
|
-
//todo recursion as model x {x:x}
|
|
13
12
|
export const $linter = defineLinter({
|
|
14
13
|
rules: [noFunctionRule, noInterfaceRule, noIntrinsicRule, noLiteralRule,
|
|
15
14
|
noObjectRule, noOperationRule, noProjectionRule, noTemplateRule,
|
package/dist/src/linter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linter.js","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"linter.js","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AACrD,O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,YAAY,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;gBACnC,CAAC,QAAQ,eAAe,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;gBACtC,CAAC,QAAQ,gBAAgB,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;gBACvC,CAAC,QAAQ,cAAc,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;gBACrC,CAAC,QAAQ,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;gBAClC,CAAC,QAAQ,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;aACnC;SACF;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { createDiagnosticCollector } from "@typespec/compiler";
|
|
2
|
+
import { getChain, getIdType, getValues } from "./decorators.js";
|
|
3
|
+
import { reportDiagnostic, StateKeys } from "./lib.js";
|
|
4
|
+
// perform higher level validation that can't be done by decorators directly
|
|
5
|
+
export const $onValidate = (program) => {
|
|
6
|
+
const diagnostics = createDiagnosticCollector();
|
|
7
|
+
// walk through all models having an @id/@ext assigned
|
|
8
|
+
for (const target of program.stateSet(StateKeys.id).values()) {
|
|
9
|
+
const { isExt, id } = getIdType(program, target);
|
|
10
|
+
// check combination with @chain
|
|
11
|
+
const chain = getChain(program, target);
|
|
12
|
+
if (chain) {
|
|
13
|
+
const length = id.length - (isExt ? 0 : 2);
|
|
14
|
+
if (length <= 0) {
|
|
15
|
+
reportDiagnostic(program, {
|
|
16
|
+
code: "invalid-length",
|
|
17
|
+
target,
|
|
18
|
+
format: { which: isExt ? 'ext' : 'id', value: '0' },
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const badLength = chain.dds.find(dd => dd.length !== length);
|
|
23
|
+
if (badLength !== undefined) {
|
|
24
|
+
reportDiagnostic(program, {
|
|
25
|
+
code: "invalid-length",
|
|
26
|
+
target,
|
|
27
|
+
format: { which: 'chain', value: badLength.length.toString() },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// check for model recursion
|
|
33
|
+
const seen = new Set();
|
|
34
|
+
const checkRecursion = (model) => {
|
|
35
|
+
if (seen.has(model)) {
|
|
36
|
+
return model;
|
|
37
|
+
}
|
|
38
|
+
seen.add(model);
|
|
39
|
+
for (const prop of model.properties.values()) {
|
|
40
|
+
if (prop.type.kind === 'Model') {
|
|
41
|
+
const ret = checkRecursion(prop.type);
|
|
42
|
+
if (ret) {
|
|
43
|
+
return ret;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const model = checkRecursion(target);
|
|
49
|
+
if (model) {
|
|
50
|
+
reportDiagnostic(program, {
|
|
51
|
+
code: "banned-inheritance",
|
|
52
|
+
target,
|
|
53
|
+
format: { ref: model.name },
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// walk through all models having a @chain assigned
|
|
58
|
+
for (const target of program.stateMap(StateKeys.chain).keys()) {
|
|
59
|
+
const id = getIdType(program, target);
|
|
60
|
+
// only valid in combination with @id/@ext
|
|
61
|
+
if (!id || id.isExt === undefined) {
|
|
62
|
+
reportDiagnostic(program, {
|
|
63
|
+
code: "missing-decorator",
|
|
64
|
+
target,
|
|
65
|
+
format: { which: 'id/@ext' },
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// walk through all scalars+modelproperties having a @divisor or @factor assigned
|
|
70
|
+
for (const target of program.stateSet(StateKeys.divisor).values()) {
|
|
71
|
+
if (getValues(program, target)) {
|
|
72
|
+
reportDiagnostic(program, {
|
|
73
|
+
code: "banned-values",
|
|
74
|
+
target,
|
|
75
|
+
format: { detail: 'combined with divisor/factor' },
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (diagnostics.diagnostics.length > 0) {
|
|
80
|
+
program.reportDiagnostics(diagnostics.diagnostics);
|
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K,MAAM,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAA6B,EAAE,CAAC;QACzF,MAAM,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACtC,0CAA0C;QAC1C,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,KAAG,SAAS,EAAE,CAAC;YAChC,gBAAgB,CAAC,OAAO,EAAE;gBACxB,IAAI,EAAE,mBAAmB;gBACzB,MAAM;gBACN,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,EAAC;aAC5B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,kFAAkF;IAClF,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,EAA4C,EAAE,CAAC;QAC5G,IAAI,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;YAC/B,gBAAgB,CAAC,OAAO,EAAE;gBACxB,IAAI,EAAE,eAAe;gBACrB,MAAM;gBACN,MAAM,EAAE,EAAE,MAAM,EAAE,8BAA8B,EAAE;aACnD,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,IAAI,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,OAAO,CAAC,iBAAiB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IACrD,CAAC;AACH,CAAC,CAAA"}
|
package/docs.md
CHANGED
|
@@ -79,6 +79,7 @@ Available ruleSets:
|
|
|
79
79
|
|
|
80
80
|
- [`@auth`](#@auth)
|
|
81
81
|
- [`@base`](#@base)
|
|
82
|
+
- [`@chain`](#@chain)
|
|
82
83
|
- [`@condition`](#@condition)
|
|
83
84
|
- [`@divisor`](#@divisor)
|
|
84
85
|
- [`@ext`](#@ext)
|
|
@@ -132,6 +133,26 @@ Define the base message ID to be combined with an extension ID.
|
|
|
132
133
|
| sb | `valueof scalar Ebus.Sb` | the secondary message ID. |
|
|
133
134
|
| dd | `valueof model Ebus.Symbol[]` | further message ID parts. |
|
|
134
135
|
|
|
136
|
+
#### `@chain`
|
|
137
|
+
|
|
138
|
+
Define chained message IDs.
|
|
139
|
+
|
|
140
|
+
```typespec
|
|
141
|
+
@Ebus.chain(length: valueof uint8, dd: valueof Ebus.Symbol[], ...dds: valueof Ebus.Symbol[][])
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
##### Target
|
|
145
|
+
|
|
146
|
+
`Model`
|
|
147
|
+
|
|
148
|
+
##### Parameters
|
|
149
|
+
|
|
150
|
+
| Name | Type | Description |
|
|
151
|
+
| ------ | ------------------------------- | ------------------------------------------------------------------------------------------ |
|
|
152
|
+
| length | `valueof scalar uint8` | the (maximum) length of a single message part of this chain, or 0 for default (=24). |
|
|
153
|
+
| dd | `valueof model Ebus.Symbol[]` | second message ID part the chain is built from (first one taken from id or ext decorator). |
|
|
154
|
+
| dds | `valueof model Ebus.Symbol[][]` | list of further message ID parts the chain is built from. |
|
|
155
|
+
|
|
135
156
|
#### `@condition`
|
|
136
157
|
|
|
137
158
|
Define the condition(s) for the whole message (if given multiple times, all conditions must be met).
|
|
@@ -174,7 +195,7 @@ Define the divisor.
|
|
|
174
195
|
Define the extension message ID to be combined with a base ID.
|
|
175
196
|
|
|
176
197
|
```typespec
|
|
177
|
-
@Ebus.ext(...
|
|
198
|
+
@Ebus.ext(...dd: valueof Ebus.Symbol[])
|
|
178
199
|
```
|
|
179
200
|
|
|
180
201
|
##### Target
|
|
@@ -185,7 +206,7 @@ Define the extension message ID to be combined with a base ID.
|
|
|
185
206
|
|
|
186
207
|
| Name | Type | Description |
|
|
187
208
|
| ---- | ----------------------------- | ---------------------------- |
|
|
188
|
-
|
|
|
209
|
+
| dd | `valueof model Ebus.Symbol[]` | message ID extensions parts. |
|
|
189
210
|
|
|
190
211
|
#### `@factor`
|
|
191
212
|
|
|
@@ -439,6 +460,11 @@ Define the max bits.
|
|
|
439
460
|
#### `@reverse`
|
|
440
461
|
|
|
441
462
|
Define reverse representation.
|
|
463
|
+
For numeric types this means most significant byte first (big-endian)
|
|
464
|
+
instead of least significant byte first (little-endian).
|
|
465
|
+
For date/time types coded as sequence of individual parts this means reverse sequence
|
|
466
|
+
(i.e. year,month,day instead of day,month,year for dates
|
|
467
|
+
and seconds,minutes,hours instead of hours,minutes,seconds for times).
|
|
442
468
|
|
|
443
469
|
```typespec
|
|
444
470
|
@Ebus.internal.reverse
|
package/lib/decorators.tsp
CHANGED
|
@@ -59,9 +59,17 @@ extern dec base(target: Model, pb: valueof Pb, sb: valueof Sb, ...dd: valueof Sy
|
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* Define the extension message ID to be combined with a base ID.
|
|
62
|
-
* @param
|
|
62
|
+
* @param dd message ID extensions parts.
|
|
63
63
|
*/
|
|
64
|
-
extern dec ext(target: Model, ...
|
|
64
|
+
extern dec ext(target: Model, ...dd: valueof Symbol[]);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Define chained message IDs.
|
|
68
|
+
* @param length the (maximum) length of a single message part of this chain, or 0 for default (=24).
|
|
69
|
+
* @param dd second message ID part the chain is built from (first one taken from id or ext decorator).
|
|
70
|
+
* @param dds list of further message ID parts the chain is built from.
|
|
71
|
+
*/
|
|
72
|
+
extern dec chain(target: Model, length: valueof uint8, dd: valueof Symbol[], ...dds: valueof Symbol[][]);
|
|
65
73
|
|
|
66
74
|
/**
|
|
67
75
|
* Define the inherited model(s).
|
|
@@ -107,6 +115,11 @@ extern dec values(target: numeric|boolean|ModelProperty, values: Enum);
|
|
|
107
115
|
namespace internal {
|
|
108
116
|
/**
|
|
109
117
|
* Define reverse representation.
|
|
118
|
+
* For numeric types this means most significant byte first (big-endian)
|
|
119
|
+
* instead of least significant byte first (little-endian).
|
|
120
|
+
* For date/time types coded as sequence of individual parts this means reverse sequence
|
|
121
|
+
* (i.e. year,month,day instead of day,month,year for dates
|
|
122
|
+
* and seconds,minutes,hours instead of hours,minutes,seconds for times).
|
|
110
123
|
*/
|
|
111
124
|
extern dec reverse(target: Scalar);
|
|
112
125
|
|
package/lib/models.tsp
CHANGED
|
@@ -38,15 +38,8 @@ namespace id {
|
|
|
38
38
|
@values(manufacturers)
|
|
39
39
|
scalar manufacturer extends UCH;
|
|
40
40
|
|
|
41
|
-
model id_read {}
|
|
42
|
-
@zz(BROADCAST)
|
|
43
|
-
@passive
|
|
44
|
-
model id_bcast {}
|
|
45
|
-
@zz(BROADCAST)
|
|
46
|
-
model id_write {}
|
|
47
|
-
|
|
48
41
|
/** identification */
|
|
49
|
-
@
|
|
42
|
+
@id(0x07, 0x04)
|
|
50
43
|
model id {
|
|
51
44
|
/** device manufacturer */
|
|
52
45
|
mf?: manufacturer,
|
|
@@ -58,4 +51,11 @@ namespace id {
|
|
|
58
51
|
/** hardware version */
|
|
59
52
|
hw?: num.PIN,
|
|
60
53
|
}
|
|
54
|
+
|
|
55
|
+
@zz(BROADCAST)
|
|
56
|
+
@passive
|
|
57
|
+
model id_bcast is id;
|
|
58
|
+
|
|
59
|
+
@zz(BROADCAST)
|
|
60
|
+
model id_write is id;
|
|
61
61
|
}
|