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

Generation performance - test and analysis (#1348)

* Add back the sequential template generation.
* Add additional matter test case.
* Add a unit test for one of the latest poorly-performing matter templates.
上级 254425fd
No related branches found
No related tags found
无相关合并请求
显示
7538 个添加495 个删除
......@@ -76,7 +76,7 @@
"analyze": "node src-script/zap-start.js analyze ./test/resource/three-endpoint-device.zap",
"version": "node src-script/zap-start.js --version",
"metafile-check": "node src-script/zap-validate-metafiles.js",
"test:gen": "npm run gen && npm run gen2 && npm run genmatter && npm run genmatter1 && npm run genmatter2 && npm run gendotdot && npm run genmeta && npm run genmeta2 && npm run genfullth",
"test:gen": "npm run gen && npm run gen2 && npm run genmatter && npm run genmatter1 && npm run genmatter2 && npm run gendotdot && npm run genmeta && npm run genmeta2 && npm run genfullth && npm run genmatter4",
"gen": "node src-script/zap-generate.js --genResultFile --stateDirectory ~/.zap/gen -z ./zcl-builtin/silabs/zcl.json -g ./test/gen-template/zigbee/gen-templates.json -i ./test/resource/three-endpoint-device.zap -o ./tmp",
"gen2": "node src-script/zap-generate.js --genResultFile -z ./zcl-builtin/silabs/zcl.json -g ./test/gen-template/zigbee/gen-templates.json -i ./test/resource/generation-test-file-1.zap -o ./tmp",
"genfullth": "node src-script/zap-generate.js --genResultFile --stateDirectory ~/.zap/genfullth -z ./zcl-builtin/silabs/zcl.json -g ./test/gen-template/zigbee2/gen-templates.json -i ./test/resource/full-th.zap -o ./tmp/full-th",
......@@ -85,6 +85,7 @@
"genmatter1": "node src-script/zap-generate.js --genResultFile --stateDirectory ~/.zap/genmatter1 -z ./zcl-builtin/matter/zcl.json -g ./test/gen-template/matter/gen-test.json -i ./test/resource/matter-test.zap -o ./tmp/matter1",
"genmatter2": "node src-script/zap-generate.js --genResultFile --stateDirectory ~/.zap/genmatter2 -z ./zcl-builtin/matter/zcl.json -g ./test/gen-template/matter/gen-test.json -i ./test/resource/matter-switch.zap -o ./tmp/matter2",
"genmatter3": "node src-script/zap-generate.js --genResultFile --stateDirectory ~/.zap/genmatter3 -z ./zcl-builtin/matter/zcl.json -g ./test/gen-template/matter3/t.json -i ./test/resource/matter-all-clusters.zap -o ./tmp/matter3",
"genmatter4": "node src-script/zap-generate.js --genResultFile --stateDirectory ~/.zap/genmatter4 -z ./zcl-builtin/matter/zcl.json -g ./test/gen-template/matter4/m4.json -i ./test/gen-template/matter4/app.zap -o ./tmp/matter4",
"genmeta": "node src-script/zap-generate.js --genResultFile --stateDirectory ~/.zap/genmeta -z ./test/resource/meta/zcl.json -g ./test/resource/meta/gen-test.json --appendGenerationSubdirectory -o ./tmp -i ./test/resource/test-meta.zap",
"genmeta2": "node src-script/zap-generate.js --genResultFile --stateDirectory ~/.zap/genmeta --appendGenerationSubdirectory -o ./tmp -i ./test/resource/test-meta.zap --packageMatch fuzzy",
"gentest": "node src-script/zap-generate.js --genResultFile --stateDirectory ~/.zap/gentest -z ./zcl-builtin/silabs/zcl.json -g ./test/gen-template/test/gen-test.json -o ./tmp",
......
......@@ -635,6 +635,7 @@ async function generateAllTemplates(
options = {
generateOnly: null,
disableDeprecationWarnings: false,
generateSequentially: false,
}
) {
let packages = await queryPackage.getPackageByParent(
......@@ -723,13 +724,24 @@ async function generateAllTemplates(
// And finally go over the actual templates.
await Promise.all(helperPromises)
await Promise.all(partialPromises)
let templates = generationTemplates.map((pkg) =>
generateSingleTemplate(hb, metaInfo, genResult, pkg, genTemplateJsonPkg, {
overridePath: overridePath,
disableDeprecationWarnings: options.disableDeprecationWarnings,
})
)
await Promise.all(templates)
if (options.generateSequentially) {
await util.executePromisesSequentially(generationTemplates, (t) =>
generateSingleTemplate(hb, metaInfo, genResult, t, genTemplateJsonPkg, {
overridePath: overridePath,
disableDeprecationWarnings: options.disableDeprecationWarnings,
})
)
} else {
let templates = generationTemplates.map((pkg) =>
generateSingleTemplate(hb, metaInfo, genResult, pkg, genTemplateJsonPkg, {
overridePath: overridePath,
disableDeprecationWarnings: options.disableDeprecationWarnings,
})
)
await Promise.all(templates)
}
genResult.partial = false
return genResult
}
......@@ -752,7 +764,9 @@ async function generateSingleTemplate(
disableDeprecationWarnings: false,
}
) {
env.logInfo(`Start generating from template: ${genTemplateJsonPackage?.path}`)
let genStart = process.hrtime.bigint()
//console.log(`Start generating from template: ${singleTemplatePkg?.path}`)
env.logInfo(`Start generating from template: ${singleTemplatePkg?.path}`)
let genFunction
if (singleTemplatePkg.iterator != null) {
genFunction = templateEngine.produceIterativeContent
......@@ -774,8 +788,12 @@ async function generateSingleTemplate(
genResult.stats[result.key] = result.stats
}
genResult.partial = true
let nsDuration = process.hrtime.bigint() - genStart
//console.log(`Finish generating from template: ${singleTemplatePkg?.path}: ${util.duration(nsDuration)}`)
env.logInfo(
`Finish generating from template: ${genTemplateJsonPackage?.path}`
`Finish generating from template: ${
singleTemplatePkg?.path
}: ${util.duration(nsDuration)}`
)
return genResult
} catch (err) {
......
......@@ -585,7 +585,7 @@ async function sessionDump(db, sessionId) {
* @param {*} arrayOfData
* @param {*} promiseCreator
*/
function executePromisesSequentially(arrayOfData, promiseCreator) {
async function executePromisesSequentially(arrayOfData, promiseCreator) {
return arrayOfData.reduce((prev, nextData, currentIndex) => {
return prev.then(() => promiseCreator(nextData, currentIndex))
}, Promise.resolve())
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
#pragma once
#include <app/data-model/DecodableList.h>
#include <app/data-model/Decode.h>
#include <app/data-model/Encode.h>
#include <app/data-model/List.h>
#include <app/data-model/NullObject.h>
#include <app/ConcreteAttributePath.h>
#include <app/EventLoggingTypes.h>
#include <app/util/basic-types.h>
#include <lib/core/ClusterEnums.h>
#include <lib/support/BitMask.h>
#include <protocols/interaction_model/Constants.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app-common/zap-generated/ids/Commands.h>
#include <app-common/zap-generated/ids/Events.h>
namespace chip {
namespace app {
namespace Clusters {
namespace detail {
// Structs shared across multiple clusters.
namespace Structs {
{{#zcl_structs}}
{{#if has_more_than_one_cluster}}
{{> cluster_objects_struct header=true}}
{{/if}}
{{/zcl_structs}}
} // namespace Structs
} // namespace detail
namespace Globals {
namespace Attributes {
{{#zcl_attributes_server}}
{{#unless clusterRef}}
namespace {{asUpperCamelCase label}} {
{{> cluster_objects_attribute_typeinfo ns=""}}
} // namespace {{asUpperCamelCase label}}
{{/unless}}
{{/zcl_attributes_server}}
} // namespace Attributes
} // namespace Globals
{{#zcl_clusters}}
namespace {{asUpperCamelCase name}} {
{{#zcl_structs}}
{{#first}}
namespace Structs {
{{/first}}
{{#if has_more_than_one_cluster}}
namespace {{asUpperCamelCase name}} = Clusters::detail::Structs::{{asUpperCamelCase name}};
{{else}}
{{> cluster_objects_struct header=true}}
{{/if}}
{{#last}}
} // namespace Structs
{{/last}}
{{/zcl_structs}}
{{#zcl_commands}}
{{#first}}
namespace Commands {
// Forward-declarations so we can reference these later.
{{/first}}
namespace {{asUpperCamelCase name}} {
struct Type;
struct DecodableType;
} // namespace {{asUpperCamelCase name}}
{{#last}}
} // namespace Commands
{{/last}}
{{/zcl_commands}}
{{#zcl_commands}}
{{#first}}
namespace Commands {
{{/first}}
namespace {{asUpperCamelCase name}} {
enum class Fields : uint8_t {
{{#zcl_command_arguments}}
k{{asUpperCamelCase label}} = {{fieldIdentifier}},
{{/zcl_command_arguments}}
};
struct Type
{
public:
// Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand
static constexpr CommandId GetCommandId() { return Commands::{{asUpperCamelCase name}}::Id; }
static constexpr ClusterId GetClusterId() { return Clusters::{{asUpperCamelCase parent.name}}::Id; }
{{#zcl_command_arguments}}
{{zapTypeToEncodableClusterObjectType type}} {{asLowerCamelCase label}}{{> cluster_objects_field_init}};
{{/zcl_command_arguments}}
CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const;
using ResponseType =
{{~#if responseName}}
Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase responseName}}::DecodableType;
{{else}}
DataModel::NullObjectType;
{{/if}}
static constexpr bool MustUseTimedInvoke() { return {{mustUseTimedInvoke}}; }
};
struct DecodableType {
public:
static constexpr CommandId GetCommandId() { return Commands::{{asUpperCamelCase name}}::Id; }
static constexpr ClusterId GetClusterId() { return Clusters::{{asUpperCamelCase parent.name}}::Id; }
{{#zcl_command_arguments}}
{{zapTypeToDecodableClusterObjectType type}} {{asLowerCamelCase label}}{{> cluster_objects_field_init}};
{{/zcl_command_arguments}}
CHIP_ERROR Decode(TLV::TLVReader &reader);
};
}; // namespace {{asUpperCamelCase name}}
{{#last}}
} // namespace Commands
{{/last}}
{{/zcl_commands}}
namespace Attributes {
{{#zcl_attributes_server}}
namespace {{asUpperCamelCase label}} {
{{#if clusterRef}}
{{> cluster_objects_attribute_typeinfo ns=parent.name}}
{{else}}
struct TypeInfo : public Clusters::Globals::Attributes::{{asUpperCamelCase label}}::TypeInfo {
static constexpr ClusterId GetClusterId() { return Clusters::{{asUpperCamelCase parent.name}}::Id; }
};
{{/if}}
} // namespace {{asUpperCamelCase label}}
{{/zcl_attributes_server}}
struct TypeInfo
{
struct DecodableType {
static constexpr ClusterId GetClusterId() { return Clusters::{{asUpperCamelCase name}}::Id; }
CHIP_ERROR Decode(TLV::TLVReader &reader, const ConcreteAttributePath &path);
{{#zcl_attributes_server}}
{{! isOptional=false because optional attributes don't get represented
as Optional types here. }}
Attributes::{{asUpperCamelCase label}}::TypeInfo::DecodableType {{asLowerCamelCase label}}{{> cluster_objects_field_init ns=parent.name isOptional=false}};
{{/zcl_attributes_server}}
};
};
} // namespace Attributes
{{#zcl_events}}
{{#first}}
namespace Events {
{{/first}}
namespace {{asUpperCamelCase name}} {
static constexpr PriorityLevel kPriorityLevel = PriorityLevel::{{asUpperCamelCase priority}};
enum class Fields : uint8_t {
{{#zcl_event_fields}}
k{{asUpperCamelCase name}} = {{fieldIdentifier}},
{{/zcl_event_fields}}
};
struct Type
{
public:
static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; }
static constexpr EventId GetEventId() { return Events::{{asUpperCamelCase name}}::Id; }
static constexpr ClusterId GetClusterId() { return Clusters::{{asUpperCamelCase parent.name}}::Id; }
static constexpr bool kIsFabricScoped = {{isFabricSensitive}};
{{#zcl_event_fields}}
{{zapTypeToEncodableClusterObjectType type}} {{asLowerCamelCase name}}{{> cluster_objects_field_init}};
{{/zcl_event_fields}}
{{#if isFabricSensitive}}
auto GetFabricIndex() const {
return fabricIndex;
}
{{/if}}
CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const;
};
struct DecodableType {
public:
static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; }
static constexpr EventId GetEventId() { return Events::{{asUpperCamelCase name}}::Id; }
static constexpr ClusterId GetClusterId() { return Clusters::{{asUpperCamelCase parent.name}}::Id; }
{{#zcl_event_fields}}
{{zapTypeToDecodableClusterObjectType type}} {{asLowerCamelCase name}}{{> cluster_objects_field_init}};
{{/zcl_event_fields}}
CHIP_ERROR Decode(TLV::TLVReader &reader);
};
} // namespace {{asUpperCamelCase name}}
{{#last}}
} // namespace Events
{{/last}}
{{/zcl_events}}
} // namespace {{asUpperCamelCase name}}
{{/zcl_clusters}}
} // namespace Clusters
bool CommandNeedsTimedInvoke(ClusterId aCluster, CommandId aCommand);
bool CommandIsFabricScoped(ClusterId aCluster, CommandId aCommand);
} // namespace app
} // namespace chip
{
"name": "Matter 4 test templates",
"version": "matter-4",
"category": "matter",
"helpers": [
"common/ChipTypesHelper.js",
"common/ListHelper.js",
"common/StringHelper.js",
"partials/helper.js",
"templates/app/helper.js",
"templates/chip/helper.js",
"controller/java/templates/helper.js",
"controller/python/templates/helper.js",
"darwin/Framework/CHIP/templates/helper.js"
],
"partials": [
{
"name": "header",
"path": "partials/header.zapt"
},
{
"name": "clusters_header",
"path": "partials/clusters_header.zapt"
},
{
"name": "cluster_header",
"path": "partials/cluster_header.zapt"
},
{
"name": "cluster_objects_attribute_typeinfo",
"path": "partials/cluster-objects-attribute-typeinfo.zapt"
},
{
"name": "cluster_objects_struct",
"path": "partials/cluster-objects-struct.zapt"
},
{
"name": "cluster_objects_field_init",
"path": "partials/cluster-objects-field-init.zapt"
}
],
"resources": {
"pics-metafile": "../matter2/yaml/x.yaml",
"certification-metadir": "../matter2/yaml/",
"test-metadir": "../matter2/yaml/"
},
"templates": [
{
"path": "cluster-objects.zapt",
"name": "Cluster objects",
"output": "cluster-objects.out"
}
]
}
// Enum for {{label}}
enum class {{asType label}} : {{asUnderlyingZclType name}} {
{{#zcl_enum_items}}
k{{asUpperCamelCase label}} = {{asHex value 2}},
{{/zcl_enum_items}}
{{#unless (isInConfigList (concat ns "::" label) "EnumsNotUsedAsTypeInXML")}}
// All received enum values that are not listed above will be mapped
// to kUnknownEnumValue. This is a helper enum value that should only
// be used by code to process how it handles receiving and unknown
// enum value. This specific should never be transmitted.
kUnknownEnumValue = {{first_unused_enum_value mode="first_unused"}},
{{else}}
// kUnknownEnumValue intentionally not defined. This enum never goes
// through DataModel::Decode, likely because it is a part of a derived
// cluster. As a result having kUnknownEnumValue in this enum is error
// prone, and was removed. See
// src/app/common/templates/config-data.yaml.
{{/unless}}
};
\ No newline at end of file
struct TypeInfo {
{{! forceNotOptional=true because the optionality is on the attribute
itself, but we want just the type of the attribute. }}
{{#if entryType}}
using Type = {{zapTypeToEncodableClusterObjectType entryType ns=ns forceNotOptional=true}};
using DecodableType = {{zapTypeToDecodableClusterObjectType entryType ns=ns forceNotOptional=true}};
using DecodableArgType = {{zapTypeToDecodableClusterObjectType entryType ns=ns forceNotOptional=true isArgument=true}};
{{else}}
using Type = {{zapTypeToEncodableClusterObjectType type ns=ns forceNotOptional=true}};
using DecodableType = {{zapTypeToDecodableClusterObjectType type ns=ns forceNotOptional=true}};
using DecodableArgType = {{zapTypeToDecodableClusterObjectType type ns=ns forceNotOptional=true isArgument=true}};
{{/if}}
{{#if clusterRef}}
static constexpr ClusterId GetClusterId() { return Clusters::{{asUpperCamelCase parent.name}}::Id; }
{{/if}}
static constexpr AttributeId GetAttributeId() { return Attributes::{{asUpperCamelCase label}}::Id; }
static constexpr bool MustUseTimedWrite() { return {{mustUseTimedWrite}}; }
{{#unless isArray}}
{{#if (isString type)}}
{{#if maxLength}}
static constexpr size_t MaxLength() { return {{maxLength}}; }
{{/if}}
{{/if}}
{{/unless}}
};
{{! For now, just initialize fields to type defaults. Longer-term, we
may want to use spec-defined default values here. }}
{{#unless isOptional}} {{! Optionals inited by constructor }}
{{~#unless isNullable}} {{! Nullables inited by constructor }}
{{~#unless isArray}} {{! DataModel lists inited by constructor }}
{{~#unless entryType}} {{! DataModel lists (for attributes) inited by constructor }}
{{~#unless (isString type)}} {{! Strings are Spans, inited by constructor }}
{{~#if_is_struct type}}
{{! Structs have their own initializers }}
{{~else~}}
= static_cast<{{zapTypeToEncodableClusterObjectType type ns=ns}}>(0)
{{~/if_is_struct}}
{{~/unless}}
{{~/unless}}
{{~/unless}}
{{~/unless}}
{{~/unless}}
\ No newline at end of file
{{#if header}}
namespace {{asUpperCamelCase name}} {
enum class Fields : uint8_t {
{{#zcl_struct_items}}
k{{asUpperCamelCase label}} = {{fieldIdentifier}},
{{/zcl_struct_items}}
};
struct Type {
public:
{{#zcl_struct_items}}
{{zapTypeToEncodableClusterObjectType type}} {{asLowerCamelCase label}}{{> cluster_objects_field_init}};
{{/zcl_struct_items}}
{{#unless struct_contains_array}}
CHIP_ERROR Decode(TLV::TLVReader &reader);
{{/unless}}
static constexpr bool kIsFabricScoped = {{isFabricScoped}};
{{#if isFabricScoped}}
auto GetFabricIndex() const {
return fabricIndex;
}
void SetFabricIndex(chip::FabricIndex fabricIndex_) {
fabricIndex = fabricIndex_;
}
CHIP_ERROR EncodeForWrite(TLV::TLVWriter & aWriter, TLV::Tag aTag) const;
CHIP_ERROR EncodeForRead(TLV::TLVWriter & aWriter, TLV::Tag aTag, FabricIndex aAccessingFabricIndex) const;
private:
CHIP_ERROR DoEncode(TLV::TLVWriter & aWriter, TLV::Tag aTag, const Optional<FabricIndex> & aAccessingFabricIndex) const;
{{else}}
CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const;
{{/if}}
};
{{#if struct_contains_array}}
struct DecodableType {
public:
{{#zcl_struct_items}}
{{zapTypeToDecodableClusterObjectType type}} {{asLowerCamelCase label}}{{> cluster_objects_field_init}};
{{/zcl_struct_items}}
CHIP_ERROR Decode(TLV::TLVReader &reader);
static constexpr bool kIsFabricScoped = {{isFabricScoped}};
{{#if isFabricScoped}}
auto GetFabricIndex() const {
return fabricIndex;
}
void SetFabricIndex(chip::FabricIndex fabricIndex_) {
fabricIndex = fabricIndex_;
}
{{/if}}
};
{{else}}
using DecodableType = Type;
{{/if}}
} // namespace {{asUpperCamelCase name}}
{{else}}
namespace {{asUpperCamelCase name}} {
{{#if isFabricScoped}}
CHIP_ERROR Type::EncodeForWrite(TLV::TLVWriter & aWriter, TLV::Tag aTag) const
{
return DoEncode(aWriter, aTag, NullOptional);
}
CHIP_ERROR Type::EncodeForRead(TLV::TLVWriter & aWriter, TLV::Tag aTag, FabricIndex aAccessingFabricIndex) const
{
return DoEncode(aWriter, aTag, MakeOptional(aAccessingFabricIndex));
}
CHIP_ERROR Type::DoEncode(TLV::TLVWriter & aWriter, TLV::Tag aTag, const Optional<FabricIndex> & aAccessingFabricIndex) const
{
{{#if struct_has_fabric_sensitive_fields}}
bool includeSensitive = !aAccessingFabricIndex.HasValue() || (aAccessingFabricIndex.Value() == fabricIndex);
{{/if}}
DataModel::WrappedStructEncoder encoder{aWriter, aTag};
{{#zcl_struct_items}}
{{#if (is_num_equal fieldIdentifier 254)}}
if (aAccessingFabricIndex.HasValue()) {
encoder.Encode(to_underlying(Fields::k{{asUpperCamelCase label}}), {{asLowerCamelCase label}});
}
{{else if isFabricSensitive}}
if (includeSensitive) {
encoder.Encode(to_underlying(Fields::k{{asUpperCamelCase label}}), {{asLowerCamelCase label}});
}
{{else}}
encoder.Encode(to_underlying(Fields::k{{asUpperCamelCase label}}), {{asLowerCamelCase label}});
{{/if}}
{{/zcl_struct_items}}
return encoder.Finalize();
}
{{else}}
CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const
{
DataModel::WrappedStructEncoder encoder{aWriter, aTag};
{{#zcl_struct_items}}
encoder.Encode(to_underlying(Fields::k{{asUpperCamelCase label}}), {{asLowerCamelCase label}});
{{/zcl_struct_items}}
return encoder.Finalize();
}
{{/if}}
CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader) {
detail::StructDecodeIterator __iterator(reader);
while (true) {
auto __element = __iterator.Next();
if (std::holds_alternative<CHIP_ERROR>(__element)) {
return std::get<CHIP_ERROR>(__element);
}
{{#zcl_struct_items}}
{{#first}}
CHIP_ERROR err = CHIP_NO_ERROR;
const uint8_t __context_tag = std::get<uint8_t>(__element);
{{/first~}}
{{! NOTE: using if/else instead of switch because it seems to generate smaller code. ~}}
if (__context_tag == to_underlying(Fields::k{{asUpperCamelCase label}}))
{
err = DataModel::Decode(reader, {{asLowerCamelCase label}});
}
else
{{#last}}
{
}
ReturnErrorOnFailure(err);
{{/last}}
{{/zcl_struct_items}}
}
}
} // namespace {{asUpperCamelCase name}}
{{/if}}
{{pad '/*' 78 '-'}}*\
{{pad (concat "| Cluster " (asUpperCamelCase name)) 70 ' '~}}
{{~#if manufacturerCode}}
{{~pad (concat "| " (asMEI manufacturerCode code)) ' '}}
{{~else}}
{{~pad (concat "| " (asHex code 4)) ' '}}
{{~/if}} |
{{pad "|" 79 '-'}}|
{{pad "| Commands: " 70 ' '}}{{pad "| " 9 ' '}}|
{{#zcl_commands_source_client}}
{{pad (concat "| * " (asUpperCamelCase name)) 70 ' '}}{{pad (concat "| " (asHex code 2)) 9 ' '}}|
{{/zcl_commands_source_client}}
{{pad "|" 79 '-'}}|
{{pad "| Attributes: " 70 ' '}}{{pad "| " 9 ' '}}|
{{#zcl_attributes_server}}
{{pad (concat "| * " (asUpperCamelCase name)) 70 ' '}}{{pad (concat "| " (asHex code 4)) 9 ' '}}|
{{/zcl_attributes_server}}
{{pad "|" 79 '-'}}|
{{pad "| Events: " 70 ' '}}{{pad "| " 9 ' '}}|
{{#zcl_events}}
{{pad (concat "| * " (asUpperCamelCase name)) 70 ' '}}{{pad (concat "| " (asHex code 4)) 9 ' '}}|
{{/zcl_events}}
{{pad '\*' 78 '-'}}*/
{{pad '/*' 78 '-'}}*\
{{pad "| Cluster Name" 70 ' '}}{{pad "| ID" 9 ' '}}|
{{pad "|" 70 '-'}}{{pad "+" 9 '-'}}|
{{#zcl_clusters}}
{{pad (concat "| " (asUpperCamelCase name)) 70 " "}}{{pad (concat "| " (asHex code 4)) 9 ' '}}|
{{/zcl_clusters}}
{{pad '\*' 78 '-'}}*/
/*
*
* Copyright (c) 2022 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{{#unless excludeZapComment}}
// THIS FILE IS GENERATED BY ZAP
{{/unless}}
{{#if mustUseTimedWrite~}}
timedwrite {{!marker to place a space even with whitespace removal~}}
{{~/if~}}
{{~#unless isWritableAttribute~}}
readonly {{!marker to place a space even with whitespace removal~}}
{{~/unless~}}
{{~!TODO: write only attributes should also be supported~}}
{{~#unless isReportableAttribute~}}
nosubscribe {{!marker to place a space even with whitespace removal~}}
{{~/unless~}}
{{~!Removes spaces~}} attribute {{!ensure space}}
{{~#chip_access_elements entity="attribute"~}}
{{~#first~}}access({{~/first~}}
{{~#not_first~}}, {{/not_first~}}
{{operation}}: {{role}}
{{~#last}}) {{/last~}}
{{~/chip_access_elements~}}
{{#if isOptional~}}
optional {{!marker to place a space even with whitespace removal~}}
{{~/if~}}
{{~#if isNullable~}}
nullable {{!marker to place a space even with whitespace removal~}}
{{~/if~}} {{type}}
{{~#unless isArray~}}
{{~#if (isString type)~}}
{{~#if maxLength~}}
<{{maxLength}}>
{{~/if~}}
{{~/if~}}
{{/unless}} {{asLowerCamelCase name~}}
{{~#if isArray~}} [] {{~/if}} = {{!}}
{{~#if manufacturerCode}}
{{~asMEI manufacturerCode code~}}
{{else}}
{{~code~}}
{{/if~}}
;
\ No newline at end of file
/** {{description}} */
{{#if apiMaturity}}{{apiMaturity}} {{/if~}}
cluster {{asUpperCamelCase name}} = {{!}}
{{~#if manufacturerCode}}
{{~asMEI manufacturerCode code~}}
{{else}}
{{~code~}}
{{/if}} {
{{#global_attribute_default code="0xFFFD"}}
{{#if defaultValue}}
revision {{defaultValue}};
{{else}}
revision 1; // NOTE: Default/not specifically set
{{/if}}
{{/global_attribute_default}}
{{#zcl_enums}}
enum {{asUpperCamelCase name preserveAcronyms=true}} : enum{{multiply size 8}} {
{{#zcl_enum_items}}
k{{asUpperCamelCase label preserveAcronyms=true}} = {{value}};
{{/zcl_enum_items}}
}
{{/zcl_enums}}
{{#zcl_bitmaps}}
bitmap {{asUpperCamelCase name preserveAcronyms=true}} : bitmap{{multiply size 8}} {
{{#zcl_bitmap_items}}
k{{asUpperCamelCase label preserveAcronyms=true}} = {{asHex mask}};
{{/zcl_bitmap_items}}
}
{{/zcl_bitmaps}}
{{#zcl_structs}}
{{~>idl_structure_definition extraIndent=1}}
{{/zcl_structs}}
{{#zcl_events}}
{{#if isFabricSensitive}}fabric_sensitive {{/if~}} {{priority}} event {{!ensure space}}
{{~#chip_access_elements entity="event"~}}
{{~#first~}}access({{~/first~}}
{{~#not_first~}}, {{/not_first~}}
{{operation}}: {{role}}
{{~#last}}) {{/last~}}
{{~/chip_access_elements~}}
{{asUpperCamelCase name preserveAcronyms=true}} = {{!}}
{{~#if manufacturerCode}}
{{~asMEI manufacturerCode code~}}
{{else}}
{{~code~}}
{{/if}} {
{{#zcl_event_fields}}
{{>idl_structure_member label=name}}
{{/zcl_event_fields}}
}
{{/zcl_events}}
{{#zcl_attributes_server}}
{{#if clusterRef}}
{{! ensure indent }}{{>idl_attribute_definition}}
{{/if}}
{{/zcl_attributes_server}}
{{~!--Global attributes: spec 7.13 describes these as mandatory --}}
{{~!TODO(26053): global attributes are marked as optional,
hence the exclusion above and re-add here.}}
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;
{{#zcl_commands}}
{{#if (isStrEqual source "client")}}
{{~>idl_command_request_struct}}
{{else}}
{{~>idl_command_response_struct}}
{{/if}}
{{/zcl_commands}}
{{#zcl_commands_source_client}}
{{~>idl_command_request_response}}{{~new_line 1~}}
{{/zcl_commands_source_client}}
}
{{#first}}
{{/first}}
{{#if description}}
/** {{description}} */
{{/if}}
{{~indent 1~}}
{{#if isFabricScoped~}} fabric {{/if~}}
{{#if mustUseTimedInvoke~}} timed {{/if~}}
command {{!ensure space}}
{{~#chip_access_elements entity="command"~}}
{{~#first~}} access( {{~/first~}}
{{~#not_first~}}, {{/not_first~}}
{{operation}}: {{role}}
{{~#last}}) {{/last~}}
{{~/chip_access_elements~}}
{{asUpperCamelCase commandName}}(
{{~#zcl_command_arguments~}}
{{~#first~}}
{{asUpperCamelCase parent.commandName}}Request
{{~/first~}}
{{~/zcl_command_arguments~}}
): {{#if responseName~}}
{{asUpperCamelCase responseName}}
{{~else~}}
DefaultSuccess
{{~/if~}}
{{~indent 0}} = {{code}};
\ No newline at end of file
{{#zcl_command_arguments}}
{{#first}}
{{~new_line 1~}}{{~indent 1~}}request struct {{asUpperCamelCase parent.commandName}}Request {
{{/first}}
{{~indent 2~}}{{> idl_structure_member}}
{{#last}}
{{~indent 1~}}}
{{/last}}
{{/zcl_command_arguments}}
\ No newline at end of file
{{#zcl_command_arguments}}
{{#first}}
{{~new_line 1~}}{{~indent 1~}}response struct {{asUpperCamelCase parent.commandName}} = {{!}}
{{~#if parent.manufacturerCode}}
{{~asMEI parent.manufacturerCode parent.code~}}
{{else}}
{{~parent.code~}}
{{/if}} {
{{/first}}
{{~indent 2~}}{{> idl_structure_member}}
{{#last}}
{{~indent 1~}}}
{{/last}}
{{/zcl_command_arguments}}
\ No newline at end of file
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册