TypeSpec library for defining eBUS messages and emitting to ebusd CSV.
npm install @ebusd/ebus-typespec- Via the command line
tsp compile . --emit=@ebusd/ebus-typespec- Via the config
emit:
- "@ebusd/ebus-typespec"The config can be extended with options as follows:
emit:
- "@ebusd/ebus-typespec"
options:
"@ebusd/ebus-typespec":
option: valueType: absolutePath
Defines the emitter output directory. Defaults to {output-dir}/@ebusd/ebus-typespec
See Configuring output directory for more info
Type: boolean
Emit includes files as includes instead of inline (incomplete!)
Type: string
File name with translations to use.
Type: boolean
Emit min+max values
Type: string
Name(s) of additional attributes to emit separated by comma, e.g. 'category' for unit category
Add the following in tspconfig.yaml:
linter:
extends:
- ebus/recommendedAvailable ruleSets:
ebus/recommendedebus/all
| Name | Description |
|---|---|
ebus/no-interface |
Make sure interface is not used. |
ebus/no-intrinsic |
Make sure intrinsic is not used. |
ebus/no-literal |
Make sure literal is not used. |
ebus/no-operation |
Make sure operation is not used. |
ebus/no-template |
Make sure template is not used. |
ebus/no-tuple |
Make sure tuple is not used. |
ebus/no-union |
Make sure union is not used. |
@attr@auth@base@chain@condition@conditionExt@constValue@divisor@example@ext@factor@id@in@inherit@out@passive@poll@prefixName@qq@readonly@step@unit@values@write@zz
Define an additional attribute.
@Ebus.attr(name: valueof string, value?: valueof string)Scalar | ModelProperty
| Name | Type | Description |
|---|---|---|
| name | valueof string |
the name of the attribute. |
| value | valueof string |
the optional attribute value (can be omitted for boolean). |
Define authentication level.
@Ebus.auth(value: valueof string)Model
| Name | Type | Description |
|---|---|---|
| value | valueof string |
the authentication level (e.g. 'install'). |
Define the base message ID to be combined with an extension ID.
@Ebus.base(pb: valueof Ebus.pb, sb: valueof Ebus.sb, ...dd: valueof Ebus.symbol[])Model
| Name | Type | Description |
|---|---|---|
| pb | valueof pb |
the primary message ID. |
| sb | valueof sb |
the secondary message ID. |
| dd | valueof symbol[] |
further message ID parts. |
Define chained message IDs.
@Ebus.chain(length: valueof uint8, dd: valueof Ebus.symbol[], ...dds: valueof Ebus.symbol[][])Model
| Name | Type | Description |
|---|---|---|
| length | valueof uint8 |
the (maximum) length of a single message part of this chain, or 0 for default (=24). |
| dd | valueof symbol[] |
second message ID part the chain is built from (first one taken from id or ext decorator). |
| dds | valueof symbol[][] |
list of further message ID parts the chain is built from. |
Define a condition for the whole message by checking an own model or property.
This decorator and @conditionExt can be used multiple times to check that all conditions are met.
@Ebus.condition(property: ModelProperty | Model, ...values: valueof string[])Namespace | Model | UnionVariant
| Name | Type | Description |
|---|---|---|
| property | ModelProperty | Model |
the referenced model property, or a model in case of existance check or single property only. |
| values | valueof string[] |
the optional alternative values the property needs to match (one of the values must match for the condition to be met). For numeric values, a single value (e.g. "18"), a value range separated by dash (e.g. "19-22"), or a value range with comparison (e.g. "<=5", ">10") can be used. For string values, the value needs to be put in single quotes (e.g. 'abc'). |
Define a condition for the whole message by checking another target address model or property.
This decorator and @condition can be used multiple times to check that all conditions are met.
@Ebus.conditionExt(property: ModelProperty | Model, zz: valueof Ebus.target, ...values: valueof string[])Namespace | Model | UnionVariant
| Name | Type | Description |
|---|---|---|
| property | ModelProperty | Model |
the referenced model property, or a model in case of existance check or single property only. |
| zz | valueof target |
the target address ZZ. |
| values | valueof string[] |
the optional alternative values the property needs to match (one of the values must match for the condition to be met). For numeric values, a single value (e.g. "18"), a value range separated by dash (e.g. "19-22"), or a value range with comparison (e.g. "<=5", ">10") can be used. For string values, the value needs to be put in single quotes (e.g. 'abc'). |
Define the const value.
@Ebus.constValue(value: valueof numeric | string)numeric | boolean | ModelProperty
| Name | Type | Description |
|---|---|---|
| value | valueof numeric | string |
the const value. |
Define the divisor.
@Ebus.divisor(value: valueof numeric)numeric | plainTime | ModelProperty
| Name | Type | Description |
|---|---|---|
| value | valueof numeric |
the divisor. |
Define a data example.
@Ebus.example(desc: valueof string, q: valueof string | Ebus.symbol[], a?: valueof string | Ebus.symbol[])Model
| Name | Type | Description |
|---|---|---|
| desc | valueof string |
a text describing the example. |
| q | valueof string | symbol[] |
the query part of the message, i.e. pb, sb, and dd bytes sent to the target. |
| a | valueof string | symbol[] |
the answer part of the message, i.e. dd bytes received from the target. |
Define the extension message ID to be combined with a base ID.
@Ebus.ext(...dd: valueof Ebus.symbol[])Model
| Name | Type | Description |
|---|---|---|
| dd | valueof symbol[] |
message ID extensions parts. |
Define the factor.
@Ebus.factor(value: valueof numeric)numeric | plainTime | ModelProperty
| Name | Type | Description |
|---|---|---|
| value | valueof numeric |
the factor. |
Define the whole message ID.
@Ebus.id(pb: valueof Ebus.pb, sb: valueof Ebus.sb, ...dd: valueof Ebus.symbol[])Model
| Name | Type | Description |
|---|---|---|
| pb | valueof pb |
the primary message ID. |
| sb | valueof sb |
the secondary message ID. |
| dd | valueof symbol[] |
further message ID parts. |
Define message part inbound from target.
@Ebus.in(writeOnly?: valueof boolean)ModelProperty
| Name | Type | Description |
|---|---|---|
| writeOnly | valueof boolean |
optional true to put in only if write direction, false to put in only if read direction (alyways if absent). |
Define the inherited model(s).
@Ebus.inherit(...models: Model[])Model | Namespace | Union | UnionVariant
| Name | Type | Description |
|---|---|---|
| models | Model[] |
inherited models. |
Define message part outbound to target.
@Ebus.out(writeOnly?: valueof boolean)ModelProperty
| Name | Type | Description |
|---|---|---|
| writeOnly | valueof boolean |
optional true to put in only if write direction, false to put in only if read direction (alyways if absent). |
Define passive only.
@Ebus.passiveModel
None
Define the poll priority (only for active read).
@Ebus.poll(value?: valueof uint8)Model
| Name | Type | Description |
|---|---|---|
| value | valueof uint8 |
the poll priority (between 1 and 9). |
Define a name prefix for contained/referenced model(s).
@Ebus.prefixName(prefix?: valueof string)Namespace | Union | UnionVariant
| Name | Type | Description |
|---|---|---|
| prefix | valueof string |
the explicit prefix to use or omitted for using the namespace/union variant name. |
Define the source address.
@Ebus.qq(value?: valueof Ebus.source)Model
| Name | Type | Description |
|---|---|---|
| value | valueof source |
the source address QQ. |
Define a model as read only.
@Ebus.readonlyModel
None
Define the increment/decrement step value (useful in combination with @minValue and/or @maxValue).
@Ebus.step(value: valueof numeric)numeric | ModelProperty
| Name | Type | Description |
|---|---|---|
| value | valueof numeric |
the increment/decrement step value. |
Define the unit and optional category.
@Ebus.unit(value: valueof string, category?: valueof string)numeric | ModelProperty
| Name | Type | Description |
|---|---|---|
| value | valueof string |
the unit. |
| category | valueof string |
the optional category. |
Define the known values.
@Ebus.values(values: Enum)numeric | boolean | ModelProperty
| Name | Type | Description |
|---|---|---|
| values | Enum |
the known values. |
Define write direction.
@Ebus.write(toSource?: valueof boolean)Model
| Name | Type | Description |
|---|---|---|
| toSource | valueof boolean |
true to use the source address pendant of the target address instead of the target address. |
Define the target address.
@Ebus.zz(value?: valueof Ebus.target)Model | Namespace
| Name | Type | Description |
|---|---|---|
| value | valueof target |
the target address ZZ. |
Define BCD encoding.
@Ebus.Internal.bcdScalar
None
Define HEX encoding.
@Ebus.Internal.hexScalar
None
Define the max bits.
@Ebus.Internal.maxBits(value: valueof uint8)numeric
| Name | Type | Description |
|---|---|---|
| value | valueof uint8 |
the max bits. |
Define reverse representation. For numeric types this means most significant byte first (big-endian) instead of least significant byte first (little-endian). For date/time types coded as sequence of individual parts this means reverse sequence (i.e. year,month,day instead of day,month,year for dates and seconds,minutes,hours instead of hours,minutes,seconds for times).
@Ebus.Internal.reverseScalar
None