Skip to content

Commit

Permalink
reorg and confirm functions get deleted when generating
Browse files Browse the repository at this point in the history
  • Loading branch information
paulr34 committed Oct 10, 2023
1 parent 82b81f9 commit 9d6ea90
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 106 deletions.
102 changes: 0 additions & 102 deletions src-electron/db/query-zcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* @module DB API: zcl database access
*/
const dbApi = require('./db-api')
const upgrade = require('../upgrade/upgrade.js')
const dbMapping = require('./db-mapping')
const queryAtomic = require('./query-atomic')
const queryEnum = require('./query-enum')
Expand Down Expand Up @@ -676,53 +675,6 @@ ORDER BY CODE`,
.then((rows) => rows.map(dbMapping.map.attribute))
}

async function selectAttributesByClusterIdIncludingGlobalGen(
db,
clusterId,
packageIds
) {
return dbApi
.dbAll(
db,
`
SELECT
ATTRIBUTE_ID,
CLUSTER_REF,
CODE,
MANUFACTURER_CODE,
NAME,
TYPE,
SIDE,
DEFINE,
MIN,
MAX,
MIN_LENGTH,
MAX_LENGTH,
REPORT_MIN_INTERVAL,
REPORT_MAX_INTERVAL,
REPORTABLE_CHANGE,
REPORTABLE_CHANGE_LENGTH,
IS_WRITABLE,
DEFAULT_VALUE,
IS_OPTIONAL,
REPORTING_POLICY,
STORAGE_POLICY,
IS_NULLABLE,
IS_SCENE_REQUIRED,
ARRAY_TYPE,
MUST_USE_TIMED_WRITE
FROM ATTRIBUTE
WHERE (CLUSTER_REF = ? OR CLUSTER_REF IS NULL)
AND PACKAGE_REF IN (${dbApi.toInClause(packageIds)})
ORDER BY CODE`,
[clusterId]
)
.then(async (rows) => {
rows = rows.map(dbMapping.map.attribute)
return await upgrade.computeStorageTemplate(db, clusterId, rows)
})
}

async function selectAttributesByClusterIdAndSideIncludingGlobal(
db,
clusterId,
Expand Down Expand Up @@ -770,56 +722,6 @@ ORDER BY CODE`,
.then((rows) => rows.map(dbMapping.map.attribute))
}

async function selectAttributesByClusterIdAndSideIncludingGlobalGen(
db,
clusterId,
packageIds,
side
) {
return dbApi
.dbAll(
db,
`
SELECT
ATTRIBUTE_ID,
CLUSTER_REF,
CODE,
MANUFACTURER_CODE,
NAME,
TYPE,
SIDE,
DEFINE,
MIN,
MAX,
MIN_LENGTH,
MAX_LENGTH,
REPORT_MIN_INTERVAL,
REPORT_MAX_INTERVAL,
REPORTABLE_CHANGE,
REPORTABLE_CHANGE_LENGTH,
IS_WRITABLE,
DEFAULT_VALUE,
IS_OPTIONAL,
REPORTING_POLICY,
STORAGE_POLICY,
IS_NULLABLE,
IS_SCENE_REQUIRED,
ARRAY_TYPE,
MUST_USE_TIMED_WRITE
FROM ATTRIBUTE
WHERE
SIDE = ?
AND (CLUSTER_REF = ? OR CLUSTER_REF IS NULL)
AND PACKAGE_REF IN (${dbApi.toInClause(packageIds)})
ORDER BY CODE`,
[side, clusterId]
)
.then(async (rows) => {
rows = rows.map(dbMapping.map.attribute)
return await upgrade.computeStorageTemplate(db, clusterId, rows)
})
}

/**
* Queries for attributes inside a cluster.
*
Expand Down Expand Up @@ -1248,12 +1150,8 @@ exports.selectClusterByCode = selectClusterByCode

exports.selectAttributesByClusterIdAndSideIncludingGlobal =
selectAttributesByClusterIdAndSideIncludingGlobal
exports.selectAttributesByClusterIdAndSideIncludingGlobalGen =
selectAttributesByClusterIdAndSideIncludingGlobalGen
exports.selectAttributesByClusterIdIncludingGlobal =
selectAttributesByClusterIdIncludingGlobal
exports.selectAttributesByClusterIdIncludingGlobalGen =
selectAttributesByClusterIdIncludingGlobalGen
exports.selectAttributesByClusterCodeAndManufacturerCode =
selectAttributesByClusterCodeAndManufacturerCode
exports.selectAttributeById = selectAttributeById
Expand Down
22 changes: 19 additions & 3 deletions src-electron/generator/helper-zcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

const queryZcl = require('../db/query-zcl')
const upgrade = require('../upgrade/upgrade.js')
const queryDeviceType = require('../db/query-device-type')
const queryCommand = require('../db/query-command')
const queryEvent = require('../db/query-event')
Expand Down Expand Up @@ -737,11 +738,16 @@ async function zcl_attributes(options) {
let attributes = ''
if ('id' in this) {
// We're functioning inside a nested context with an id, so we will only query for this cluster.
attributes = await queryZcl.selectAttributesByClusterIdIncludingGlobalGen(
attributes = await queryZcl.selectAttributesByClusterIdIncludingGlobal(
this.global.db,
this.id,
packageIds
)
attributes = await upgrade.computeStorageTemplate(
this.global.db,
this.id,
attributes
)
} else {
attributes = await queryZcl.selectAllAttributes(this.global.db, packageIds)
}
Expand Down Expand Up @@ -769,12 +775,17 @@ async function zcl_attributes_client(options) {
if ('id' in this) {
// We're functioning inside a nested context with an id, so we will only query for this cluster.
clientAttributes =
await queryZcl.selectAttributesByClusterIdAndSideIncludingGlobalGen(
await queryZcl.selectAttributesByClusterIdAndSideIncludingGlobal(
this.global.db,
this.id,
packageIds,
dbEnum.side.server
)
clientAttributes = await upgrade.computeStorageTemplate(
this.global.db,
this.id,
clientAttributes
)
} else {
clientAttributes = await queryZcl.selectAllAttributesBySide(
this.global.db,
Expand Down Expand Up @@ -809,12 +820,17 @@ async function zcl_attributes_server(options) {
if ('id' in this) {
// We're functioning inside a nested context with an id, so we will only query for this cluster.
serverAttributes =
await queryZcl.selectAttributesByClusterIdAndSideIncludingGlobalGen(
await queryZcl.selectAttributesByClusterIdAndSideIncludingGlobal(
this.global.db,
this.id,
packageIds,
dbEnum.side.server
)
serverAttributes = await upgrade.computeStorageTemplate(
this.global.db,
this.id,
serverAttributes
)
} else {
serverAttributes = await queryZcl.selectAllAttributesBySide(
this.global.db,
Expand Down
1 change: 0 additions & 1 deletion src-electron/upgrade/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ async function computeStorageTemplate(db, clusterRef, attributes) {
await attributes.map(async (attribute) => {
forcedExternal = await getForcedExternalStorage(db, attribute.id)
if (
!attribute.clusterRef &&
forcedExternal.byName &&
forcedExternal.byName[clusterName] &&
forcedExternal.byName[clusterName].includes(attribute.name)
Expand Down

0 comments on commit 9d6ea90

Please sign in to comment.