Skip to content
代码片段 群组 项目
提交 cb320535 编辑于 作者: Irusha Vidanamadura's avatar Irusha Vidanamadura
浏览文件

ZCL helper to get struct items by struct name

Changes Made:
- Add helper to retrieve struct items/fields given its name/type
上级 2ab498a5
No related branches found
No related tags found
无相关合并请求
......@@ -108,6 +108,20 @@ function zcl_struct_items(options) {
return templateUtil.templatePromise(this.global, promise)
}
/**
* Block helper iterating over all struct items given the struct name.
*
* @param name
* @param options
* @returns Promise of content.
*/
function zcl_struct_items_by_struct_name(name, options) {
let promise = queryZcl
.selectAllStructItemsByStructName(this.global.db, name)
.then((st) => templateUtil.collectBlocks(st, options, this))
return templateUtil.templatePromise(this.global, promise)
}
/**
* Block helper iterating over all deviceTypes.
*
......@@ -2360,6 +2374,7 @@ exports.zcl_enums = zcl_enums
exports.zcl_enum_items = zcl_enum_items
exports.zcl_structs = zcl_structs
exports.zcl_struct_items = zcl_struct_items
exports.zcl_struct_items_by_struct_name = zcl_struct_items_by_struct_name
exports.zcl_clusters = zcl_clusters
exports.zcl_device_types = zcl_device_types
exports.zcl_commands = zcl_commands
......
......@@ -66,6 +66,9 @@ Last item
{{#zcl_command_arguments}}
{{#if_is_struct type}}
{{name}} is struct
{{#zcl_struct_items_by_struct_name type}}
{{parent.name}}::{{label}} struct item
{{/zcl_struct_items_by_struct_name}}
{{else}}
{{name}} is not struct
{{/if_is_struct}}
......
......@@ -267,6 +267,11 @@ test(
// Testing {{#if_is_struct}} helper
expect(zclId.includes(`attributeIds is not struct`)).toBeTruthy()
// Testing {{#zcl_struct_items_by_struct_name}} helper
expect(
zclId.includes(`configureReportingRecords::direction struct item`)
).toBeTruthy()
expect(
zclId.includes(`readAttributeStatusRecords is struct`)
).toBeTruthy()
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册