@ebusd/ebus-typespec 0.1.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.
Files changed (55) hide show
  1. package/README.md +62 -0
  2. package/dist/src/csv_emitter.d.ts +14 -0
  3. package/dist/src/csv_emitter.js +493 -0
  4. package/dist/src/csv_emitter.js.map +1 -0
  5. package/dist/src/decorators.d.ts +284 -0
  6. package/dist/src/decorators.js +437 -0
  7. package/dist/src/decorators.js.map +1 -0
  8. package/dist/src/index.d.ts +6 -0
  9. package/dist/src/index.js +16 -0
  10. package/dist/src/index.js.map +1 -0
  11. package/dist/src/lib.d.ts +214 -0
  12. package/dist/src/lib.js +124 -0
  13. package/dist/src/lib.js.map +1 -0
  14. package/dist/src/linter.d.ts +1 -0
  15. package/dist/src/linter.js +47 -0
  16. package/dist/src/linter.js.map +1 -0
  17. package/dist/src/rules/no-function.rule.d.ts +3 -0
  18. package/dist/src/rules/no-function.rule.js +17 -0
  19. package/dist/src/rules/no-function.rule.js.map +1 -0
  20. package/dist/src/rules/no-interface.rule.d.ts +3 -0
  21. package/dist/src/rules/no-interface.rule.js +17 -0
  22. package/dist/src/rules/no-interface.rule.js.map +1 -0
  23. package/dist/src/rules/no-intrinsic.rule.d.ts +3 -0
  24. package/dist/src/rules/no-intrinsic.rule.js +19 -0
  25. package/dist/src/rules/no-intrinsic.rule.js.map +1 -0
  26. package/dist/src/rules/no-literal.rule.d.ts +3 -0
  27. package/dist/src/rules/no-literal.rule.js +20 -0
  28. package/dist/src/rules/no-literal.rule.js.map +1 -0
  29. package/dist/src/rules/no-object.rule.d.ts +3 -0
  30. package/dist/src/rules/no-object.rule.js +17 -0
  31. package/dist/src/rules/no-object.rule.js.map +1 -0
  32. package/dist/src/rules/no-operation.rule.d.ts +3 -0
  33. package/dist/src/rules/no-operation.rule.js +19 -0
  34. package/dist/src/rules/no-operation.rule.js.map +1 -0
  35. package/dist/src/rules/no-projection.rule.d.ts +3 -0
  36. package/dist/src/rules/no-projection.rule.js +17 -0
  37. package/dist/src/rules/no-projection.rule.js.map +1 -0
  38. package/dist/src/rules/no-template.rule.d.ts +3 -0
  39. package/dist/src/rules/no-template.rule.js +20 -0
  40. package/dist/src/rules/no-template.rule.js.map +1 -0
  41. package/dist/src/rules/no-tuple.rule.d.ts +3 -0
  42. package/dist/src/rules/no-tuple.rule.js +17 -0
  43. package/dist/src/rules/no-tuple.rule.js.map +1 -0
  44. package/dist/src/rules/no-union.rule.d.ts +3 -0
  45. package/dist/src/rules/no-union.rule.js +20 -0
  46. package/dist/src/rules/no-union.rule.js.map +1 -0
  47. package/dist/src/testing/index.d.ts +2 -0
  48. package/dist/src/testing/index.js +6 -0
  49. package/dist/src/testing/index.js.map +1 -0
  50. package/docs.md +453 -0
  51. package/lib/decorators.tsp +127 -0
  52. package/lib/main.tsp +3 -0
  53. package/lib/models.tsp +61 -0
  54. package/lib/types.tsp +169 -0
  55. package/package.json +61 -0
@@ -0,0 +1,17 @@
1
+ import { createRule } from "@typespec/compiler";
2
+ export const noTupleRule = createRule({
3
+ name: "no-tuple",
4
+ severity: "warning",
5
+ description: "Make sure tuple is not used.",
6
+ messages: {
7
+ default: "Tuple shouldn't be used with this library.",
8
+ },
9
+ create: (context) => {
10
+ return {
11
+ tuple: (target) => {
12
+ context.reportDiagnostic({ target });
13
+ },
14
+ };
15
+ },
16
+ });
17
+ //# sourceMappingURL=no-tuple.rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-tuple.rule.js","sourceRoot":"","sources":["../../../src/rules/no-tuple.rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAE9C,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;IACpC,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,8BAA8B;IAC3C,QAAQ,EAAE;QACR,OAAO,EAAE,4CAA4C;KACtD;IACD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,OAAO;YACL,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE;gBAChB,OAAO,CAAC,gBAAgB,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC;YACrC,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const noUnionRule: import("@typespec/compiler").LinterRuleDefinition<"no-union", {
2
+ readonly default: "Union shouldn't be used with this library.";
3
+ }>;
@@ -0,0 +1,20 @@
1
+ import { createRule } from "@typespec/compiler";
2
+ export const noUnionRule = createRule({
3
+ name: "no-union",
4
+ severity: "warning",
5
+ description: "Make sure union is not used.",
6
+ messages: {
7
+ default: "Union shouldn't be used with this library.",
8
+ },
9
+ create: (context) => {
10
+ return {
11
+ union: (target) => {
12
+ context.reportDiagnostic({ target });
13
+ },
14
+ unionVariant: (target) => {
15
+ context.reportDiagnostic({ target });
16
+ },
17
+ };
18
+ },
19
+ });
20
+ //# sourceMappingURL=no-union.rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-union.rule.js","sourceRoot":"","sources":["../../../src/rules/no-union.rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAE9C,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;IACpC,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,8BAA8B;IAC3C,QAAQ,EAAE;QACR,OAAO,EAAE,4CAA4C;KACtD;IACD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,OAAO;YACL,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE;gBAChB,OAAO,CAAC,gBAAgB,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC;YACrC,CAAC;YACD,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE;gBACvB,OAAO,CAAC,gBAAgB,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC;YACrC,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { type TypeSpecTestLibrary } from "@typespec/compiler/testing";
2
+ export declare const EbusTestLibrary: TypeSpecTestLibrary;
@@ -0,0 +1,6 @@
1
+ import { createTestLibrary, findTestPackageRoot } from "@typespec/compiler/testing";
2
+ export const EbusTestLibrary = createTestLibrary({
3
+ name: "ebus",
4
+ packageRoot: await findTestPackageRoot(import.meta.url),
5
+ });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,mBAAmB,EAA2B,MAAM,4BAA4B,CAAC;AAE5G,MAAM,CAAC,MAAM,eAAe,GAAwB,iBAAiB,CAAC;IACpE,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,MAAM,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;CACxD,CAAC,CAAC"}
package/docs.md ADDED
@@ -0,0 +1,453 @@
1
+ # ebus
2
+
3
+ TypeSpec library for defining eBUS messages and emitting to ebusd CSV.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install https://github.com/john30/ebus-typespec
9
+ ```
10
+
11
+ ## Emitter
12
+
13
+ ### Usage
14
+
15
+ 1. Via the command line
16
+
17
+ ```bash
18
+ tsp compile . --emit=ebus
19
+ ```
20
+
21
+ 2. Via the config
22
+
23
+ ```yaml
24
+ emit:
25
+ - "ebus"
26
+ ```
27
+
28
+ ### Emitter options
29
+
30
+ #### `file-type`
31
+
32
+ **Type:** `"csv"`
33
+
34
+ Serialize the schema as csv
35
+
36
+ #### `includes`
37
+
38
+ **Type:** `boolean`
39
+
40
+ Emit includes files as includes instead of inline (incomplete!)
41
+
42
+ ## Linter
43
+
44
+ ### Usage
45
+
46
+ Add the following in `tspconfig.yaml`:
47
+
48
+ ```yaml
49
+ linter:
50
+ extends:
51
+ - ebus/recommended
52
+ ```
53
+
54
+ ### RuleSets
55
+
56
+ Available ruleSets:
57
+
58
+ - [`ebus/recommended`](#ebus/recommended)
59
+ - [`ebus/all`](#ebus/all)
60
+
61
+ ### Rules
62
+
63
+ | Name | Description |
64
+ | -------------------- | --------------------------------- |
65
+ | `ebus/no-function` | Make sure function is not used. |
66
+ | `ebus/no-interface` | Make sure interface is not used. |
67
+ | `ebus/no-intrinsic` | Make sure intrinsic is not used. |
68
+ | `ebus/no-literal` | Make sure literal is not used. |
69
+ | `ebus/no-object` | Make sure object is not used. |
70
+ | `ebus/no-operation` | Make sure operation is not used. |
71
+ | `ebus/no-projection` | Make sure projection is not used. |
72
+ | `ebus/no-template` | Make sure template is not used. |
73
+ | `ebus/no-tuple` | Make sure tuple is not used. |
74
+ | `ebus/no-union` | Make sure union is not used. |
75
+
76
+ ## Decorators
77
+
78
+ ### Ebus
79
+
80
+ - [`@auth`](#@auth)
81
+ - [`@base`](#@base)
82
+ - [`@condition`](#@condition)
83
+ - [`@divisor`](#@divisor)
84
+ - [`@ext`](#@ext)
85
+ - [`@factor`](#@factor)
86
+ - [`@id`](#@id)
87
+ - [`@in`](#@in)
88
+ - [`@inherit`](#@inherit)
89
+ - [`@out`](#@out)
90
+ - [`@passive`](#@passive)
91
+ - [`@qq`](#@qq)
92
+ - [`@unit`](#@unit)
93
+ - [`@values`](#@values)
94
+ - [`@write`](#@write)
95
+ - [`@zz`](#@zz)
96
+
97
+ #### `@auth`
98
+
99
+ Define authentication level.
100
+
101
+ ```typespec
102
+ @Ebus.auth(auth: valueof string)
103
+ ```
104
+
105
+ ##### Target
106
+
107
+ `Model`
108
+
109
+ ##### Parameters
110
+
111
+ | Name | Type | Description |
112
+ | ---- | ----------------------- | ----------- |
113
+ | auth | `valueof scalar string` | |
114
+
115
+ #### `@base`
116
+
117
+ Define the base message ID to be combined with an extension ID.
118
+
119
+ ```typespec
120
+ @Ebus.base(pb: valueof Ebus.Pb, sb: valueof Ebus.Sb, ...id: valueof Ebus.Symbol[])
121
+ ```
122
+
123
+ ##### Target
124
+
125
+ `Model`
126
+
127
+ ##### Parameters
128
+
129
+ | Name | Type | Description |
130
+ | ---- | ----------------------------- | ------------------------- |
131
+ | pb | `valueof scalar Ebus.Pb` | the primary message ID. |
132
+ | sb | `valueof scalar Ebus.Sb` | the secondary message ID. |
133
+ | id | `valueof model Ebus.Symbol[]` | further message ID parts. |
134
+
135
+ #### `@condition`
136
+
137
+ Define the condition(s) for the whole message (if given multiple times, all conditions must be met).
138
+
139
+ ```typespec
140
+ @Ebus.condition(property: ModelProperty | Model, ...values: valueof string[])
141
+ ```
142
+
143
+ ##### Target
144
+
145
+ `union Namespace | Model | UnionVariant`
146
+
147
+ ##### Parameters
148
+
149
+ | Name | Type | Description |
150
+ | -------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------- |
151
+ | property | `union ModelProperty \| Model` | the referenced model property, or a model in case of existance check or single property only. |
152
+ | values | `valueof model string[]` | the optional alternative values the property needs to match (one of the values must match for the condition to be met). |
153
+
154
+ #### `@divisor`
155
+
156
+ Define the divisor.
157
+
158
+ ```typespec
159
+ @Ebus.divisor(value: valueof numeric)
160
+ ```
161
+
162
+ ##### Target
163
+
164
+ `union numeric | plainTime | ModelProperty`
165
+
166
+ ##### Parameters
167
+
168
+ | Name | Type | Description |
169
+ | ----- | ------------------------ | ------------ |
170
+ | value | `valueof scalar numeric` | the divisor. |
171
+
172
+ #### `@ext`
173
+
174
+ Define the extension message ID to be combined with a base ID.
175
+
176
+ ```typespec
177
+ @Ebus.ext(...id: valueof Ebus.Symbol[])
178
+ ```
179
+
180
+ ##### Target
181
+
182
+ `Model`
183
+
184
+ ##### Parameters
185
+
186
+ | Name | Type | Description |
187
+ | ---- | ----------------------------- | ---------------------------- |
188
+ | id | `valueof model Ebus.Symbol[]` | message ID extensions parts. |
189
+
190
+ #### `@factor`
191
+
192
+ Define the factor.
193
+
194
+ ```typespec
195
+ @Ebus.factor(value: valueof numeric)
196
+ ```
197
+
198
+ ##### Target
199
+
200
+ `union numeric | plainTime | ModelProperty`
201
+
202
+ ##### Parameters
203
+
204
+ | Name | Type | Description |
205
+ | ----- | ------------------------ | ----------- |
206
+ | value | `valueof scalar numeric` | the factor. |
207
+
208
+ #### `@id`
209
+
210
+ Define the whole message ID.
211
+
212
+ ```typespec
213
+ @Ebus.id(pb: valueof Ebus.Pb, sb: valueof Ebus.Sb, ...id: valueof Ebus.Symbol[])
214
+ ```
215
+
216
+ ##### Target
217
+
218
+ `Model`
219
+
220
+ ##### Parameters
221
+
222
+ | Name | Type | Description |
223
+ | ---- | ----------------------------- | ------------------------- |
224
+ | pb | `valueof scalar Ebus.Pb` | the primary message ID. |
225
+ | sb | `valueof scalar Ebus.Sb` | the secondary message ID. |
226
+ | id | `valueof model Ebus.Symbol[]` | further message ID parts. |
227
+
228
+ #### `@in`
229
+
230
+ Define message part inbound from target.
231
+
232
+ ```typespec
233
+ @Ebus.in
234
+ ```
235
+
236
+ ##### Target
237
+
238
+ `ModelProperty`
239
+
240
+ ##### Parameters
241
+
242
+ None
243
+
244
+ #### `@inherit`
245
+
246
+ Define the inherited model(s).
247
+
248
+ ```typespec
249
+ @Ebus.inherit(...models: valueof Model[])
250
+ ```
251
+
252
+ ##### Target
253
+
254
+ `Model`
255
+
256
+ ##### Parameters
257
+
258
+ | Name | Type | Description |
259
+ | ------ | ----------------------- | ----------------- |
260
+ | models | `valueof model Model[]` | inherited models. |
261
+
262
+ #### `@out`
263
+
264
+ Define message part outbound to target.
265
+
266
+ ```typespec
267
+ @Ebus.out
268
+ ```
269
+
270
+ ##### Target
271
+
272
+ `ModelProperty`
273
+
274
+ ##### Parameters
275
+
276
+ None
277
+
278
+ #### `@passive`
279
+
280
+ Define passive only.
281
+
282
+ ```typespec
283
+ @Ebus.passive
284
+ ```
285
+
286
+ ##### Target
287
+
288
+ `Model`
289
+
290
+ ##### Parameters
291
+
292
+ None
293
+
294
+ #### `@qq`
295
+
296
+ Define the source address.
297
+
298
+ ```typespec
299
+ @Ebus.qq(value?: valueof Ebus.Source)
300
+ ```
301
+
302
+ ##### Target
303
+
304
+ `Model`
305
+
306
+ ##### Parameters
307
+
308
+ | Name | Type | Description |
309
+ | ----- | ---------------------------- | ---------------------- |
310
+ | value | `valueof scalar Ebus.Source` | the source address QQ. |
311
+
312
+ #### `@unit`
313
+
314
+ Define the unit.
315
+
316
+ ```typespec
317
+ @Ebus.unit(value: valueof string)
318
+ ```
319
+
320
+ ##### Target
321
+
322
+ `union numeric | ModelProperty`
323
+
324
+ ##### Parameters
325
+
326
+ | Name | Type | Description |
327
+ | ----- | ----------------------- | ----------- |
328
+ | value | `valueof scalar string` | the unit. |
329
+
330
+ #### `@values`
331
+
332
+ Define the known values.
333
+
334
+ ```typespec
335
+ @Ebus.values(values: Enum)
336
+ ```
337
+
338
+ ##### Target
339
+
340
+ `union numeric | boolean | ModelProperty`
341
+
342
+ ##### Parameters
343
+
344
+ | Name | Type | Description |
345
+ | ------ | ------ | ----------- |
346
+ | values | `Enum` | |
347
+
348
+ #### `@write`
349
+
350
+ Define write direction.
351
+
352
+ ```typespec
353
+ @Ebus.write
354
+ ```
355
+
356
+ ##### Target
357
+
358
+ `Model`
359
+
360
+ ##### Parameters
361
+
362
+ None
363
+
364
+ #### `@zz`
365
+
366
+ Define the target address.
367
+
368
+ ```typespec
369
+ @Ebus.zz(value?: valueof Ebus.Target)
370
+ ```
371
+
372
+ ##### Target
373
+
374
+ `union Model | Namespace`
375
+
376
+ ##### Parameters
377
+
378
+ | Name | Type | Description |
379
+ | ----- | ---------------------------- | ---------------------- |
380
+ | value | `valueof scalar Ebus.Target` | the target address ZZ. |
381
+
382
+ ### Ebus.internal
383
+
384
+ - [`@bcd`](#@bcd)
385
+ - [`@hex`](#@hex)
386
+ - [`@maxBits`](#@maxbits)
387
+ - [`@reverse`](#@reverse)
388
+
389
+ #### `@bcd`
390
+
391
+ Define BCD encoding.
392
+
393
+ ```typespec
394
+ @Ebus.internal.bcd
395
+ ```
396
+
397
+ ##### Target
398
+
399
+ `Scalar`
400
+
401
+ ##### Parameters
402
+
403
+ None
404
+
405
+ #### `@hex`
406
+
407
+ Define HEX encoding.
408
+
409
+ ```typespec
410
+ @Ebus.internal.hex
411
+ ```
412
+
413
+ ##### Target
414
+
415
+ `Scalar`
416
+
417
+ ##### Parameters
418
+
419
+ None
420
+
421
+ #### `@maxBits`
422
+
423
+ Define the max bits.
424
+
425
+ ```typespec
426
+ @Ebus.internal.maxBits(value: valueof numeric)
427
+ ```
428
+
429
+ ##### Target
430
+
431
+ `scalar numeric`
432
+
433
+ ##### Parameters
434
+
435
+ | Name | Type | Description |
436
+ | ----- | ------------------------ | ------------- |
437
+ | value | `valueof scalar numeric` | the max bits. |
438
+
439
+ #### `@reverse`
440
+
441
+ Define reverse representation.
442
+
443
+ ```typespec
444
+ @Ebus.internal.reverse
445
+ ```
446
+
447
+ ##### Target
448
+
449
+ `Scalar`
450
+
451
+ ##### Parameters
452
+
453
+ None
@@ -0,0 +1,127 @@
1
+ import "../dist/src/decorators.js";
2
+ import "./types.tsp";
3
+
4
+ using TypeSpec.Reflection;
5
+
6
+ namespace Ebus;
7
+
8
+
9
+ /**
10
+ * Define the condition(s) for the whole message (if given multiple times, all conditions must be met).
11
+ * @param property the referenced model property, or a model in case of existance check or single property only.
12
+ * @param values the optional alternative values the property needs to match (one of the values must match for the condition to be met).
13
+ */
14
+ extern dec condition(target: Namespace|Model|UnionVariant, property: ModelProperty|Model, ...values: valueof string[]);
15
+
16
+ /**
17
+ * Define write direction.
18
+ */
19
+ extern dec write(target: Model);
20
+
21
+ /**
22
+ * Define passive only.
23
+ */
24
+ extern dec passive(target: Model);
25
+
26
+ /**
27
+ * Define authentication level.
28
+ */
29
+ extern dec auth(target: Model, auth: valueof string);
30
+
31
+ /**
32
+ * Define the source address.
33
+ * @param value the source address QQ.
34
+ */
35
+ extern dec qq(source: Model, value?: valueof Source);
36
+
37
+ /**
38
+ * Define the target address.
39
+ * @param value the target address ZZ.
40
+ */
41
+ extern dec zz(target: Model|Namespace, value?: valueof Target);
42
+
43
+ /**
44
+ * Define the whole message ID.
45
+ * @param pb the primary message ID.
46
+ * @param sb the secondary message ID.
47
+ * @param id further message ID parts.
48
+ */
49
+ extern dec id(target: Model, pb: valueof Pb, sb: valueof Sb, ...id: valueof Symbol[]);
50
+
51
+ /**
52
+ * Define the base message ID to be combined with an extension ID.
53
+ * @param pb the primary message ID.
54
+ * @param sb the secondary message ID.
55
+ * @param id further message ID parts.
56
+ */
57
+ extern dec base(target: Model, pb: valueof Pb, sb: valueof Sb, ...id: valueof Symbol[]);
58
+
59
+ /**
60
+ * Define the extension message ID to be combined with a base ID.
61
+ * @param id message ID extensions parts.
62
+ */
63
+ extern dec ext(target: Model, ...id: valueof Symbol[]);
64
+
65
+ /**
66
+ * Define the inherited model(s).
67
+ * @param models inherited models.
68
+ */
69
+ extern dec inherit(target: Model, ...models: valueof Model[]);
70
+
71
+ /**
72
+ * Define message part outbound to target.
73
+ */
74
+ extern dec out(target: ModelProperty);
75
+
76
+ /**
77
+ * Define message part inbound from target.
78
+ */
79
+ extern dec in(target: ModelProperty);
80
+
81
+ /**
82
+ * Define the unit.
83
+ * @param value the unit.
84
+ */
85
+ extern dec unit(target: numeric|ModelProperty, value: valueof string);
86
+
87
+ /**
88
+ * Define the divisor.
89
+ * @param value the divisor.
90
+ */
91
+ extern dec divisor(target: numeric|plainTime|ModelProperty, value: valueof numeric);
92
+
93
+ /**
94
+ * Define the factor.
95
+ * @param value the factor.
96
+ */
97
+ extern dec factor(target: numeric|plainTime|ModelProperty, value: valueof numeric);
98
+
99
+ /**
100
+ * Define the known values.
101
+ * @param value the divisor.
102
+ */
103
+ extern dec values(target: numeric|boolean|ModelProperty, values: Enum);
104
+
105
+
106
+ namespace internal {
107
+ /**
108
+ * Define reverse representation.
109
+ */
110
+ extern dec reverse(target: Scalar);
111
+
112
+ /**
113
+ * Define BCD encoding.
114
+ */
115
+ extern dec bcd(target: Scalar);
116
+
117
+ /**
118
+ * Define HEX encoding.
119
+ */
120
+ extern dec hex(target: Scalar);
121
+
122
+ /**
123
+ * Define the max bits.
124
+ * @param value the max bits.
125
+ */
126
+ extern dec maxBits(target: numeric, value: valueof numeric);
127
+ }
package/lib/main.tsp ADDED
@@ -0,0 +1,3 @@
1
+ import "./decorators.tsp";
2
+ import "./types.tsp";
3
+ import "./models.tsp";
package/lib/models.tsp ADDED
@@ -0,0 +1,61 @@
1
+ import "./types.tsp";
2
+
3
+ namespace Ebus;
4
+ using Ebus.num;
5
+
6
+ namespace id {
7
+
8
+ enum manufacturers {
9
+ Dungs: 0x06,
10
+ "FH Ostfalia": 0x0f,
11
+ TEM: 0x10,
12
+ Lamberti: 0x11,
13
+ CEB: 0x14,
14
+ "Landis-Staefa": 0x15,
15
+ FERRO: 0x16,
16
+ MONDIAL: 0x17,
17
+ Wikon: 0x18,
18
+ Wolf: 0x19,
19
+ RAWE: 0x20,
20
+ Satronic: 0x30,
21
+ ENCON: 0x40,
22
+ Kromschröder: 0x50,
23
+ Eberle: 0x60,
24
+ EBV: 0x65,
25
+ Grässlin: 0x75,
26
+ "ebm-papst": 0x85,
27
+ SIG: 0x95,
28
+ Theben: 0xa5,
29
+ Thermowatt: 0xa7,
30
+ Vaillant: 0xb5,
31
+ Toby: 0xc0,
32
+ Weishaupt: 0xc5,
33
+ "ebusd.eu": 0xfd,
34
+ ebusd: 0xfd,
35
+ // Pb, // <= this is how to declare the base type as it seems for unions, see https://github.com/microsoft/typespec/issues/2737
36
+ }
37
+
38
+ @values(manufacturers)
39
+ scalar manufacturer extends UCH
40
+
41
+ model id_read {}
42
+ @zz(BROADCAST)
43
+ @passive
44
+ model id_bcast {}
45
+ @zz(BROADCAST)
46
+ model id_write {}
47
+
48
+ /** identification */
49
+ @inherit(id_read, id_bcast, id_write) @id(0x07, 0x04)
50
+ model id {
51
+ /** device manufacturer */
52
+ mf?: manufacturer,
53
+ /** device id */
54
+ @maxLength(5)
55
+ id?: str.STR,
56
+ /** software version */
57
+ sw?: num.PIN,
58
+ /** hardware version */
59
+ hw?: num.PIN,
60
+ }
61
+ }