From 68ea4887b1ee23118e0a29b7db1f8e2760775d35 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Tue, 4 Jul 2017 02:30:16 -0700 Subject: [PATCH] Fix repeating vparam execution This issue only happens when a device doesn't maintain a single connection for the entire session. --- lib/session.coffee | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/session.coffee b/lib/session.coffee index 44215a9..0ba1edb 100644 --- a/lib/session.coffee +++ b/lib/session.coffee @@ -1049,15 +1049,20 @@ generateGetVirtualParameterProvisions = (sessionContext, virtualParameterDeclara provisions = null for declaration in virtualParameterDeclarations if declaration[1] - provisions ?= [] currentTimestamps = {} currentValues = {} + dec = {} attrs = sessionContext.deviceData.attributes.get(declaration[0]) + for k, v of declaration[1] + continue if k != 'value' and k != 'writable' + if not (v < attrs[k][0]) + dec[k] = v for k, v of attrs currentTimestamps[k] = v[0] currentValues[k] = v[1] - provisions.push([declaration[0][1], declaration[1], {}, currentTimestamps, currentValues]) - delete declaration[1] + if (Object.keys(dec).length) + provisions ?= [] + provisions.push([declaration[0][1], dec, {}, currentTimestamps, currentValues]) return provisions