Avoid extra declare cycle when refreshing vparams
This commit is contained in:
1 parent
8b400a45b5
commit
945323a7da
1 file changed
+24
-14
+24
-14
@@ -679,20 +679,30 @@ rpcRequest = (sessionContext, _declarations, callback) ->
|
|||||||
allVirtualParameters = virtualParametersCache.get(sessionContext)
|
allVirtualParameters = virtualParametersCache.get(sessionContext)
|
||||||
|
|
||||||
vpd = vpd.filter((declaration) ->
|
vpd = vpd.filter((declaration) ->
|
||||||
if declaration[0].length == 1
|
if Object.keys(allVirtualParameters).length
|
||||||
if Object.keys(allVirtualParameters).length
|
if declaration[0].length == 1
|
||||||
toClear = device.set(sessionContext.deviceData, declaration[0], timestamp, {object: [timestamp, 1], writable: [timestamp, 0]}, toClear)
|
# Avoid setting on every inform as "exist" timestamp is not saved in DB
|
||||||
else
|
if not sessionContext.deviceData.attributes.has(declaration[0])
|
||||||
toClear = device.set(sessionContext.deviceData, declaration[0], timestamp, null, toClear)
|
toClear = device.set(sessionContext.deviceData, declaration[0], timestamp, {object: [timestamp, 1], writable: [timestamp, 0]}, toClear)
|
||||||
else if declaration[0].length == 2
|
return false
|
||||||
if declaration[0][1] == '*'
|
else if declaration[0].length == 2
|
||||||
for k, v of allVirtualParameters
|
if declaration[0][1] == '*'
|
||||||
toClear = device.set(sessionContext.deviceData, ['VirtualParameters', k], timestamp, {object: [timestamp, 0]}, toClear)
|
for k, v of allVirtualParameters
|
||||||
toClear = device.set(sessionContext.deviceData, declaration[0], timestamp, null, toClear)
|
toClear = device.set(sessionContext.deviceData, ['VirtualParameters', k], timestamp, {object: [timestamp, 0]}, toClear)
|
||||||
else if not (declaration[0][1] of allVirtualParameters)
|
toClear = device.set(sessionContext.deviceData, declaration[0], timestamp, null, toClear)
|
||||||
toClear = device.set(sessionContext.deviceData, declaration[0], timestamp, null, toClear)
|
return false
|
||||||
else
|
else if declaration[0][1] of allVirtualParameters
|
||||||
return true
|
# Avoid setting on every inform as "exist" timestamp is not saved in DB
|
||||||
|
if not sessionContext.deviceData.attributes.has(declaration[0])
|
||||||
|
toClear = device.set(sessionContext.deviceData, declaration[0], timestamp, {object: [timestamp, 0]}, toClear)
|
||||||
|
return true
|
||||||
|
|
||||||
|
for p in sessionContext.deviceData.paths.find(declaration[0], false, true)
|
||||||
|
if sessionContext.deviceData.attributes.has(p)
|
||||||
|
toClear ?= []
|
||||||
|
toClear.push([declaration[0], timestamp])
|
||||||
|
break
|
||||||
|
|
||||||
return false
|
return false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user