Skip to content

Commit baa3034

Browse files
authored
- Add additional is_power_of_two helper for matter use case to determine odd sized data types (#1472)
- update the atomic table schema, retrieval and mapping - Add unit tests with the example needed for Matter code - update feature level pointer - Updating the zap schema - Adding support to determine if a data type is baseline type or not from the xml itself - This is done by adding BASE_TYPE column to the atomic table and then mapping it appropriately to baseType for the zcl_atomics helper - Adding base types for derived types in the atomic xml file - This is done by adding baseType column to the atomic table and then mapping it appropriately to baseType for the zcl_atomics helper such that derived types can refer to base types Cleanup - Github: ZAP#1438
1 parent ecf3659 commit baa3034

File tree

15 files changed

+4943
-4751
lines changed

15 files changed

+4943
-4751
lines changed

apack.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Graphical configuration tool for application and libraries based on Zigbee Cluster Library.",
55
"path": [".", "node_modules/.bin/", "ZAP.app/Contents/MacOS"],
66
"requiredFeatureLevel": "apack.core:9",
7-
"featureLevel": 104,
7+
"featureLevel": 105,
88
"uc.triggerExtension": "zap",
99
"executable": {
1010
"zap:win32.x86_64": {

docs/api.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11266,6 +11266,7 @@ This module contains the API for templating. For more detailed instructions, rea
1126611266
* [~replace_string(mainString, replaceString, replaceWithString)](#module_Templating API_ toplevel utility helpers..replace_string) ⇒
1126711267
* [~add_prefix_to_all_strings(str, prefixStr)](#module_Templating API_ toplevel utility helpers..add_prefix_to_all_strings) ⇒
1126811268
* [~multiply()](#module_Templating API_ toplevel utility helpers..multiply) ⇒
11269+
* [~is_power_of_two(val)](#module_Templating API_ toplevel utility helpers..is_power_of_two) ⇒
1126911270
* [~is_string_underscored(val)](#module_Templating API_ toplevel utility helpers..is_string_underscored) ⇒
1127011271
* [~as_uppercase(val)](#module_Templating API_ toplevel utility helpers..as_uppercase) ⇒
1127111272

@@ -11587,6 +11588,18 @@ Returns a concatenated string with spaces between each string
1158711588
### Templating API: toplevel utility helpers~multiply() ⇒
1158811589
**Kind**: inner method of [<code>Templating API: toplevel utility helpers</code>](#module_Templating API_ toplevel utility helpers)
1158911590
**Returns**: A number which is result of multiplying all the arguments given
11591+
<a name="module_Templating API_ toplevel utility helpers..is_power_of_two"></a>
11592+
11593+
### Templating API: toplevel utility helpers~is\_power\_of\_two(val) ⇒
11594+
Returns a boolean based on whether a given value is a power or 2 or not.
11595+
11596+
**Kind**: inner method of [<code>Templating API: toplevel utility helpers</code>](#module_Templating API_ toplevel utility helpers)
11597+
**Returns**: boolean
11598+
11599+
| Param | Type |
11600+
| --- | --- |
11601+
| val | <code>\*</code> |
11602+
1159011603
<a name="module_Templating API_ toplevel utility helpers..is_string_underscored"></a>
1159111604

1159211605
### Templating API: toplevel utility helpers~is\_string\_underscored(val) ⇒

docs/helpers.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,6 +2945,7 @@ This module contains the API for templating. For more detailed instructions, rea
29452945
* [~replace_string(mainString, replaceString, replaceWithString)](#module_Templating API_ toplevel utility helpers..replace_string) ⇒
29462946
* [~add_prefix_to_all_strings(str, prefixStr)](#module_Templating API_ toplevel utility helpers..add_prefix_to_all_strings) ⇒
29472947
* [~multiply()](#module_Templating API_ toplevel utility helpers..multiply) ⇒
2948+
* [~is_power_of_two(val)](#module_Templating API_ toplevel utility helpers..is_power_of_two) ⇒
29482949
* [~is_string_underscored(val)](#module_Templating API_ toplevel utility helpers..is_string_underscored) ⇒
29492950
* [~as_uppercase(val)](#module_Templating API_ toplevel utility helpers..as_uppercase) ⇒
29502951

@@ -3266,6 +3267,18 @@ Returns a concatenated string with spaces between each string
32663267
### Templating API: toplevel utility helpers~multiply() ⇒
32673268
**Kind**: inner method of [<code>Templating API: toplevel utility helpers</code>](#module_Templating API_ toplevel utility helpers)
32683269
**Returns**: A number which is result of multiplying all the arguments given
3270+
<a name="module_Templating API_ toplevel utility helpers..is_power_of_two"></a>
3271+
3272+
### Templating API: toplevel utility helpers~is\_power\_of\_two(val) ⇒
3273+
Returns a boolean based on whether a given value is a power or 2 or not.
3274+
3275+
**Kind**: inner method of [<code>Templating API: toplevel utility helpers</code>](#module_Templating API_ toplevel utility helpers)
3276+
**Returns**: boolean
3277+
3278+
| Param | Type |
3279+
| --- | --- |
3280+
| val | <code>\*</code> |
3281+
32693282
<a name="module_Templating API_ toplevel utility helpers..is_string_underscored"></a>
32703283

32713284
### Templating API: toplevel utility helpers~is\_string\_underscored(val) ⇒

docs/zap-schema.svg

Lines changed: 2420 additions & 2365 deletions
Loading

src-electron/db/db-mapping.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,10 @@ exports.map = {
389389
isString: dbApi.fromDbBool(x.IS_STRING),
390390
isLong: dbApi.fromDbBool(x.IS_LONG),
391391
isChar: dbApi.fromDbBool(x.IS_CHAR),
392-
isSigned: dbApi.fromDbBool(x.IS_SIGNED)
392+
isSigned: dbApi.fromDbBool(x.IS_SIGNED),
393+
isComposite: dbApi.fromDbBool(x.IS_COMPOSITE),
394+
isFloat: dbApi.fromDbBool(x.IS_FLOAT),
395+
baseType: x.BASE_TYPE
393396
}
394397
},
395398

src-electron/db/query-atomic.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ SELECT
3636
IS_STRING,
3737
IS_LONG,
3838
IS_CHAR,
39-
IS_SIGNED
39+
IS_SIGNED,
40+
IS_COMPOSITE,
41+
IS_FLOAT,
42+
BASE_TYPE
4043
FROM ATOMIC
4144
`
4245

src-electron/db/query-loader.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ INSERT OR IGNORE INTO GLOBAL_ATTRIBUTE_BIT (
10901090
async function insertAtomics(db, packageId, data) {
10911091
return dbApi.dbMultiInsert(
10921092
db,
1093-
'INSERT INTO ATOMIC (PACKAGE_REF, NAME, DESCRIPTION, ATOMIC_IDENTIFIER, ATOMIC_SIZE, IS_DISCRETE, IS_SIGNED, IS_STRING, IS_LONG, IS_CHAR) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
1093+
'INSERT INTO ATOMIC (PACKAGE_REF, NAME, DESCRIPTION, ATOMIC_IDENTIFIER, ATOMIC_SIZE, IS_DISCRETE, IS_SIGNED, IS_STRING, IS_LONG, IS_CHAR, IS_COMPOSITE, IS_FLOAT, BASE_TYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
10941094
data.map((at) => [
10951095
packageId,
10961096
at.name,
@@ -1101,7 +1101,10 @@ async function insertAtomics(db, packageId, data) {
11011101
at.isSigned,
11021102
at.isString,
11031103
at.isLong,
1104-
at.isChar
1104+
at.isChar,
1105+
at.isComposite,
1106+
at.isFloat,
1107+
at.baseType
11051108
])
11061109
)
11071110
}

src-electron/db/zap-schema.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,9 @@ CREATE TABLE IF NOT EXISTS "ATOMIC" (
600600
"IS_LONG" integer default false,
601601
"IS_CHAR" integer default false,
602602
"IS_SIGNED" integer default false,
603+
"IS_COMPOSITE" integer default false,
604+
"IS_FLOAT" integer default false,
605+
"BASE_TYPE" text,
603606
foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE
604607
UNIQUE(PACKAGE_REF, NAME, ATOMIC_IDENTIFIER)
605608
);

src-electron/generator/helper-zap.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,15 @@ function multiply() {
465465
return nums.reduce((prev, next) => prev * next, 1)
466466
}
467467

468+
/**
469+
* Returns a boolean based on whether a given value is a power or 2 or not.
470+
* @param {*} val
471+
* @returns boolean
472+
*/
473+
function is_power_of_two(val) {
474+
return Number.isInteger(Math.log2(val))
475+
}
476+
468477
/**
469478
*
470479
* @param {*} val
@@ -526,3 +535,4 @@ exports.add_prefix_to_all_strings = add_prefix_to_all_strings
526535
exports.multiply = multiply
527536
exports.is_string_underscored = is_string_underscored
528537
exports.as_uppercase = as_uppercase
538+
exports.is_power_of_two = is_power_of_two

src-electron/importexport/import-json.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,12 @@ async function importSinglePackage(
310310
if (packageMatch && packageNameMatch) {
311311
p = packageNameMatch
312312
env.logError(
313-
`None of packages exist for ${pkg.path}, so using one which matches the file name: ${p.path} from ${pkgPaths}.`
313+
`None of packages exist for ${pkg.path || pkg}, so using one which matches the file name: ${p.path} from ${pkgPaths}.`
314314
)
315315
} else {
316316
// None exists, so use the first one from 'packages'.
317317
env.logError(
318-
`None of packages exist for ${pkg.path}, so using first one overall: ${p.path} from ${pkgPaths}.`
318+
`None of packages exist for ${pkg.path || pkg}, so using first one overall: ${p.path} from ${pkgPaths}.`
319319
)
320320
}
321321
return {

0 commit comments

Comments
 (0)