Skip to content

Commit

Permalink
handling sub-atomic types in dotdot loader + few other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhchandw committed Sep 17, 2024
1 parent 70c803d commit d9df456
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 6 deletions.
52 changes: 52 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -19614,6 +19614,7 @@ This module provides the APIs for dotdot Loading
* [~prepareCommands(commands, side, types)](#module_Loader API_ Loader APIs..prepareCommands) ⇒
* [~prepareCluster(cluster, isExtension, types)](#module_Loader API_ Loader APIs..prepareCluster) ⇒
* [~prepareAtomic(type)](#module_Loader API_ Loader APIs..prepareAtomic) ⇒
* [~prepareSubAtomic(type)](#module_Loader API_ Loader APIs..prepareSubAtomic) ⇒
* [~prepareBitmap(type, isContained)](#module_Loader API_ Loader APIs..prepareBitmap) ⇒
* [~prepareEnum(type)](#module_Loader API_ Loader APIs..prepareEnum) ⇒
* [~prepareStruct(type)](#module_Loader API_ Loader APIs..prepareStruct) ⇒
Expand Down Expand Up @@ -19881,6 +19882,18 @@ Parses xml type into the atomic object for insertion into the DB
| --- | --- | --- |
| type | <code>\*</code> | an xml object which conforms to the atomic format in the dotdot xml |

<a name="module_Loader API_ Loader APIs..prepareSubAtomic"></a>

### Loader API: Loader APIs~prepareSubAtomic(type) ⇒
Parses xml type into the sub-atomic object for insertion into the DB

**Kind**: inner method of [<code>Loader API: Loader APIs</code>](#module_Loader API_ Loader APIs)
**Returns**: object ready for insertion into the DB

| Param | Type | Description |
| --- | --- | --- |
| type | <code>\*</code> | an xml object which conforms to the sub-atomic format in the dotdot xml |

<a name="module_Loader API_ Loader APIs..prepareBitmap"></a>

### Loader API: Loader APIs~prepareBitmap(type, isContained) ⇒
Expand Down Expand Up @@ -21414,6 +21427,7 @@ This module provides the APIs for new data model loading
* [~prepareCommands(commands, side, types)](#module_Loader API_ Loader APIs..prepareCommands) ⇒
* [~prepareCluster(cluster, isExtension, types)](#module_Loader API_ Loader APIs..prepareCluster) ⇒
* [~prepareAtomic(type)](#module_Loader API_ Loader APIs..prepareAtomic) ⇒
* [~prepareSubAtomic(type)](#module_Loader API_ Loader APIs..prepareSubAtomic) ⇒
* [~prepareBitmap(type, isContained)](#module_Loader API_ Loader APIs..prepareBitmap) ⇒
* [~prepareEnum(type)](#module_Loader API_ Loader APIs..prepareEnum) ⇒
* [~prepareStruct(type)](#module_Loader API_ Loader APIs..prepareStruct) ⇒
Expand Down Expand Up @@ -21681,6 +21695,18 @@ Parses xml type into the atomic object for insertion into the DB
| --- | --- | --- |
| type | <code>\*</code> | an xml object which conforms to the atomic format in the dotdot xml |

<a name="module_Loader API_ Loader APIs..prepareSubAtomic"></a>

### Loader API: Loader APIs~prepareSubAtomic(type) ⇒
Parses xml type into the sub-atomic object for insertion into the DB

**Kind**: inner method of [<code>Loader API: Loader APIs</code>](#module_Loader API_ Loader APIs)
**Returns**: object ready for insertion into the DB

| Param | Type | Description |
| --- | --- | --- |
| type | <code>\*</code> | an xml object which conforms to the sub-atomic format in the dotdot xml |

<a name="module_Loader API_ Loader APIs..prepareBitmap"></a>

### Loader API: Loader APIs~prepareBitmap(type, isContained) ⇒
Expand Down Expand Up @@ -23214,6 +23240,7 @@ This module provides the APIs for ZCL/Data-Model loading.
* [~prepareCommands(commands, side, types)](#module_Loader API_ Loader APIs..prepareCommands) ⇒
* [~prepareCluster(cluster, isExtension, types)](#module_Loader API_ Loader APIs..prepareCluster) ⇒
* [~prepareAtomic(type)](#module_Loader API_ Loader APIs..prepareAtomic) ⇒
* [~prepareSubAtomic(type)](#module_Loader API_ Loader APIs..prepareSubAtomic) ⇒
* [~prepareBitmap(type, isContained)](#module_Loader API_ Loader APIs..prepareBitmap) ⇒
* [~prepareEnum(type)](#module_Loader API_ Loader APIs..prepareEnum) ⇒
* [~prepareStruct(type)](#module_Loader API_ Loader APIs..prepareStruct) ⇒
Expand Down Expand Up @@ -23481,6 +23508,18 @@ Parses xml type into the atomic object for insertion into the DB
| --- | --- | --- |
| type | <code>\*</code> | an xml object which conforms to the atomic format in the dotdot xml |

<a name="module_Loader API_ Loader APIs..prepareSubAtomic"></a>

### Loader API: Loader APIs~prepareSubAtomic(type) ⇒
Parses xml type into the sub-atomic object for insertion into the DB

**Kind**: inner method of [<code>Loader API: Loader APIs</code>](#module_Loader API_ Loader APIs)
**Returns**: object ready for insertion into the DB

| Param | Type | Description |
| --- | --- | --- |
| type | <code>\*</code> | an xml object which conforms to the sub-atomic format in the dotdot xml |

<a name="module_Loader API_ Loader APIs..prepareBitmap"></a>

### Loader API: Loader APIs~prepareBitmap(type, isContained) ⇒
Expand Down Expand Up @@ -25014,6 +25053,7 @@ This module provides the APIs for for common functionality related to loading.
* [~prepareCommands(commands, side, types)](#module_Loader API_ Loader APIs..prepareCommands) ⇒
* [~prepareCluster(cluster, isExtension, types)](#module_Loader API_ Loader APIs..prepareCluster) ⇒
* [~prepareAtomic(type)](#module_Loader API_ Loader APIs..prepareAtomic) ⇒
* [~prepareSubAtomic(type)](#module_Loader API_ Loader APIs..prepareSubAtomic) ⇒
* [~prepareBitmap(type, isContained)](#module_Loader API_ Loader APIs..prepareBitmap) ⇒
* [~prepareEnum(type)](#module_Loader API_ Loader APIs..prepareEnum) ⇒
* [~prepareStruct(type)](#module_Loader API_ Loader APIs..prepareStruct) ⇒
Expand Down Expand Up @@ -25281,6 +25321,18 @@ Parses xml type into the atomic object for insertion into the DB
| --- | --- | --- |
| type | <code>\*</code> | an xml object which conforms to the atomic format in the dotdot xml |

<a name="module_Loader API_ Loader APIs..prepareSubAtomic"></a>

### Loader API: Loader APIs~prepareSubAtomic(type) ⇒
Parses xml type into the sub-atomic object for insertion into the DB

**Kind**: inner method of [<code>Loader API: Loader APIs</code>](#module_Loader API_ Loader APIs)
**Returns**: object ready for insertion into the DB

| Param | Type | Description |
| --- | --- | --- |
| type | <code>\*</code> | an xml object which conforms to the sub-atomic format in the dotdot xml |

<a name="module_Loader API_ Loader APIs..prepareBitmap"></a>

### Loader API: Loader APIs~prepareBitmap(type, isContained) ⇒
Expand Down
35 changes: 29 additions & 6 deletions src-electron/zcl/zcl-loader-dotdot.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,30 @@ function prepareAtomic(type) {
}
}

/**
* Parses xml type into the sub-atomic object for insertion into the DB
*
* @param {*} type an xml object which conforms to the sub-atomic format in the dotdot xml
* @returns object ready for insertion into the DB
*/
function prepareSubAtomic(type) {
let desc = type.$.inheritsFrom
return {
name: type.$.short,
id: parseInt(normalizeHexValue(type.$.id)),
size: getNumBytesFromShortName(type.$.inheritsFrom),
description: desc,
isDiscrete: false,
isSigned:
!a.name.startsWith('u') && !a.name.endsWith('u') && a.name.includes('int')
? 1
: 0,
isString: desc.includes('str'),
isLong: desc.includes('str') && desc.includes('Long'),
isChar: desc.includes('str') && desc.includes('haracter')
}
}

/**
*
* Parses xml type into the bitmap object for insertion into the DB
Expand Down Expand Up @@ -593,14 +617,11 @@ function prepareTypes(zclTypes, types) {
} else if (type.$.inheritsFrom === undefined) {
types.atomics.push(prepareAtomic(type))
} else {
// TODO: Need to handle sub-atomic types, these are types that impose restrictions
// and inherit from an atomic type but are not a struct, bitmap or enum
droppedTypes.push(type.$.name)
// Handling sub-atomic types by adding to atomic
// and inferring details such as size, signed, string etc from the inherited type
types.atomics.push(prepareSubAtomic(type))
}
})
if (droppedTypes.length > 0) {
env.logDebug(`Dropped types in DotDot loader: ${droppedTypes}`)
}
}

/**
Expand Down Expand Up @@ -721,6 +742,8 @@ function prepareDataType(a, dataType, typeMap) {
a.name.toLowerCase().includes(dbEnum.zclType.string)
) {
dataTypeRef = typeMap.get(dbEnum.zclType.string)
} else if (!dataType && a.isString !== undefined && a.isString == 1) {
dataTypeRef = typeMap.get(dbEnum.zclType.string)
} else if (
!dataType &&
a.name.toLowerCase().includes(dbEnum.zclType.struct)
Expand Down

0 comments on commit d9df456

Please sign in to comment.