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

Add bitmaps helpers.

上级 30984493
No related branches found
No related tags found
无相关合并请求
......@@ -92,6 +92,12 @@ function selectAllBitmaps(db, packageId = null) {
.then((rows) => rows.map(dbMapping.map.bitmap))
}
function selectAllBitmapFieldsById(db, id) {
return dbApi
.dbAll(db, 'SELECT NAME, MASK FROM BITMAP_FIELD WHERE BITMAP_REF=?', [id])
.then((rows) => rows.map(dbMapping.map.bitmapField))
}
function selectAllBitmapFields(db, packageId = null) {
return dbApi
.dbAll(
......@@ -1464,3 +1470,4 @@ exports.selectEndpointType = selectEndpointType
exports.insertAtomics = insertAtomics
exports.selectAllAtomics = selectAllAtomics
exports.getAtomicSizeFromType = getAtomicSizeFromType
exports.selectAllBitmapFieldsById = selectAllBitmapFieldsById
......@@ -25,6 +25,29 @@ const templateUtil = require('./template-util.js')
* @module Templating API: static zcl helpers
*/
/**
* Block helper iterating over all bitmaps.
*
* @param {*} options
* @returns Promise of content.
*/
function zcl_bitmaps(options) {
return templateUtil
.ensurePackageId(this)
.then((packageId) => queryZcl.selectAllBitmaps(this.global.db, packageId))
.then((ens) => templateUtil.collectBlocks(ens, options.fn, this))
}
/**
* Iterates over enum items. Valid only inside zcl_enums.
* @param {*} options
*/
function zcl_bitmap_items(options) {
return queryZcl
.selectAllBitmapFieldsById(this.global.db, this.id)
.then((items) => templateUtil.collectBlocks(items, options.fn, this))
}
/**
* Block helper iterating over all enums.
*
......@@ -240,6 +263,8 @@ function zcl_atomics(options) {
// Note: these exports are public API. Templates that might have been created in the past and are
// available in the wild might depend on these names.
// If you rename the functions, you need to still maintain old exports list.
exports.zcl_bitmaps = zcl_bitmaps
exports.zcl_bitmap_items = zcl_bitmap_items
exports.zcl_enums = zcl_enums
exports.zcl_enum_items = zcl_enum_items
exports.zcl_structs = zcl_structs
......
{{zap_header}}
#ifndef __ZAP_GEN_TYPE__
// ZCL attribute types
enum {
{{#zcl_atomics}}
......@@ -28,6 +30,18 @@ typedef enum {
} EmberAf{{asType label}};
{{/zcl_enums}}
// ZCL bitmaps
{{#zcl_bitmaps}}
// Enum for {{label}}
typedef enum {
{{#zcl_bitmap_items}}
{{ident}}EMBER_ZCL_{{asDelimitedMacro parent.label}}_{{asDelimitedMacro label}} = {{mask}},
{{/zcl_bitmap_items}}
} EmberAf{{asType label}};
{{/zcl_bitmaps}}
/* COMMENT ALL THIS OUT TEMPORARILY
// ZCL Structs
......@@ -42,4 +56,6 @@ typedef struct _{{asType label}} {
} {{asType label}};
{{/zcl_structs}}
*/
\ No newline at end of file
*/
#endif
\ No newline at end of file
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册