Skip to content

Commit

Permalink
finish generating write attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLiuZhuoCheng committed Nov 16, 2021
1 parent 1903401 commit 4970a32
Show file tree
Hide file tree
Showing 2 changed files with 1,746 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/controller/java/templates/ClusterInfo-java.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ public class ClusterInfoMapping {
combineCommand(clusterMap, commandMap);
Map<String, Map<String, InteractionInfo>> readAttributeMap = getReadAttributeMap();
combineCommand(clusterMap, readAttributeMap);
Map<String, Map<String, InteractionInfo>> writeAttributeMap = getWriteAttributeMap();
combineCommand(clusterMap, writeAttributeMap);
return clusterMap;
}

Expand Down Expand Up @@ -325,7 +327,7 @@ public class ClusterInfoMapping {
}

public Map<String, Map<String, InteractionInfo>> getReadAttributeMap() {
Map<String, Map<String, InteractionInfo>> readAttributeMap = new HashMap<>();
Map<String, Map<String, InteractionInfo>> readAttributeMap = new HashMap<>();
{{#chip_client_clusters}}
Map<String, InteractionInfo> read{{asUpperCamelCase name}}InteractionInfo = new LinkedHashMap<>();
// read attribute
Expand Down Expand Up @@ -354,6 +356,35 @@ public class ClusterInfoMapping {
{{/chip_client_clusters}}
return readAttributeMap;
}

public Map<String, Map<String, InteractionInfo>> getWriteAttributeMap() {
Map<String, Map<String, InteractionInfo>> writeAttributeMap = new HashMap<>();
{{#chip_client_clusters}}
Map<String, InteractionInfo> write{{asUpperCamelCase name}}InteractionInfo = new LinkedHashMap<>();
// write attribute
{{#chip_server_cluster_attributes}}
{{#if isWritableAttribute}}
Map<String, CommandParameterInfo> write{{asUpperCamelCase ../name}}{{asUpperCamelCase name}}CommandParams = new LinkedHashMap<String, CommandParameterInfo>();
CommandParameterInfo {{asLowerCamelCase ../name}}{{asLowerCamelCase name}}CommandParameterInfo = new CommandParameterInfo("value", {{asJavaBasicType type}}.class);
write{{asUpperCamelCase ../name}}{{asUpperCamelCase name}}CommandParams.put("value",{{asLowerCamelCase ../name}}{{asLowerCamelCase name}}CommandParameterInfo);
InteractionInfo write{{asUpperCamelCase ../name}}{{asUpperCamelCase name}}AttributeInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
((ChipClusters.{{asUpperCamelCase ../name}}Cluster) cluster).write{{asUpperCamelCase name}}Attribute(
(DefaultClusterCallback) callback,
({{asJavaBoxedType type}})
commandArguments.get("value")
);
},
() -> new DelegatedDefaultClusterCallback(),
write{{asUpperCamelCase ../name}}{{asUpperCamelCase name}}CommandParams
);
write{{asUpperCamelCase ../name}}InteractionInfo.put("write{{asUpperCamelCase name}}Attribute", write{{asUpperCamelCase ../name}}{{asUpperCamelCase name}}AttributeInteractionInfo);
{{/if}}
{{/chip_server_cluster_attributes}}
writeAttributeMap.put("{{asLowerCamelCase name}}", write{{asUpperCamelCase name}}InteractionInfo);
{{/chip_client_clusters}}
return writeAttributeMap;
}
}

{{/if}}
Loading

0 comments on commit 4970a32

Please sign in to comment.