From 96ff4d24d79e2cee88134867fe137049128209a4 Mon Sep 17 00:00:00 2001 From: Darrel O'Pry Date: Thu, 8 Mar 2018 17:24:59 -0500 Subject: [PATCH] refactor: use enum.Meta --- lib/asn1.js | 6 +++--- lib/services.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/asn1.js b/lib/asn1.js index 8872a7c2..3177b5c4 100644 --- a/lib/asn1.js +++ b/lib/asn1.js @@ -1086,7 +1086,7 @@ const bacappDecodeData = (buffer, offset, maxLength, tagDataType, lenValueType) }; const bacappContextTagType = (property, tagNumber) => { - let tag = baEnum.ApplicationTags.MAX_BACNET_APPLICATION_TAG; + let tag = baEnum.Meta.ApplicationTags.max; switch (property) { case baEnum.PropertyIds.PROP_ACTUAL_SHED_LEVEL: case baEnum.PropertyIds.PROP_REQUESTED_SHED_LEVEL: @@ -1520,13 +1520,13 @@ const bacappDecodeContextApplicationData = (buffer, offset, maxOffset, objectTyp if (!subResult) return; if (subResult.value === 0) { len += subResult.len; - result = bacappDecodeApplicationData(buffer, offset + len, maxOffset, baEnum.ObjectTypes.MAX_BACNET_OBJECT_TYPE, baEnum.PropertyIds.MAX_BACNET_PROPERTY_ID); + result = bacappDecodeApplicationData(buffer, offset + len, maxOffset, baEnum.Meta.ObjectType.max, baEnum.Meta.PropertyIdentifier.max); if (!result) return; list.push(result); len += result.len; } else { const overrideTagNumber = bacappContextTagType(propertyId, subResult.tagNumber); - if (overrideTagNumber !== baEnum.ApplicationTags.MAX_BACNET_APPLICATION_TAG) { + if (overrideTagNumber !== baEnum.Meta.ApplicationTags.max) { subResult.tagNumber = overrideTagNumber; } let bacappResult = bacappDecodeData(buffer, offset + len + subResult.len, maxOffset, subResult.tagNumber, subResult.value); diff --git a/lib/services.js b/lib/services.js index cc2084cc..455465df 100644 --- a/lib/services.js +++ b/lib/services.js @@ -585,7 +585,7 @@ module.exports.encodeReadProperty = (buffer, objectType, objectInstance, propert if (objectType <= baAsn1.BACNET_MAX_OBJECT) { baAsn1.encodeContextObjectId(buffer, 0, objectType, objectInstance); } - if (propertyId <= baEnum.PropertyIds.MAX_BACNET_PROPERTY_ID) { + if (propertyId <= baEnum.Meta.PropertyIdentifier.max) { baAsn1.encodeContextEnumerated(buffer, 1, propertyId); } if (arrayIndex !== baAsn1.BACNET_ARRAY_ALL) {