Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getDataValue_EncodingByte(dataValue) {
let encoding_mask = 0;
if (dataValue.value) {
encoding_mask = set_flag(encoding_mask,DataValueEncodingByte.Value);
}
// if (dataValue.statusCode !== null ) {
if ( _.isObject(dataValue.statusCode)&& dataValue.statusCode.value !==0 ) {
encoding_mask = set_flag(encoding_mask,DataValueEncodingByte.StatusCode);
}
if (dataValue.sourceTimestamp && dataValue.sourceTimestamp !== "null") {
encoding_mask = set_flag(encoding_mask,DataValueEncodingByte.SourceTimestamp);
}
// the number of picoseconds that can be encoded are
// 100 nano * 10000;
// above this the value contains the excess in picosecond to make the sourceTimestamp more accurate
if (dataValue.sourcePicoseconds ? dataValue.sourcePicoseconds % 100000 : false) {
encoding_mask = set_flag(encoding_mask,DataValueEncodingByte.SourcePicoseconds);
}
if (dataValue.serverTimestamp && dataValue.serverTimestamp !== "null") {
encoding_mask = set_flag(encoding_mask,DataValueEncodingByte.ServerTimestamp);
}
if (dataValue.serverPicoseconds ? dataValue.serverPicoseconds % 100000 : false) {
encoding_mask = set_flag(encoding_mask,DataValueEncodingByte.ServerPicoseconds);
if (nodeId.identifierType.is(NodeIdType.NUMERIC)) {
if (is_uint8(nodeId.value) && !nodeId.namespace && !nodeId.namespaceUri && !nodeId.serverIndex) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.TwoBytes);
} else if (
is_uint16(nodeId.value) &&
is_uint8(nodeId.namespace) &&
!nodeId.namespaceUri &&
!nodeId.serverIndex
) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.FourBytes);
} else {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.Numeric);
}
} else if (nodeId.identifierType.is(NodeIdType.STRING)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.String);
} else if (nodeId.identifierType.is(NodeIdType.BYTESTRING)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.ByteString);
} else if (nodeId.identifierType.is(NodeIdType.GUID)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.Guid);
}
if (nodeId.hasOwnProperty("namespaceUri") && nodeId.namespaceUri) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.NamespaceUriFlag);
}
if (nodeId.hasOwnProperty("serverIndex") && nodeId.serverIndex) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.ServerIndexFlag);
}
return encodingByte;
}
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.NamespaceUri);
}
if (diagnosticInfo.localizedText >=0) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.LocalizedText);
}
if (diagnosticInfo.locale >= 0) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.Locale);
}
if (diagnosticInfo.additionalInfo) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.AdditionalInfo);
}
if (diagnosticInfo.innerStatusCode && diagnosticInfo.innerStatusCode !== StatusCodes.Good) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.InnerStatusCode);
}
if (diagnosticInfo.innerDiagnosticInfo) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.InnerDiagnosticInfo);
}
return encoding_mask;
}
function nodeID_encodingByte(nodeId) {
if (!nodeId) {
return 0;
}
assert(nodeId.hasOwnProperty("identifierType"));
let encodingByte = 0;
if (nodeId.identifierType.is(NodeIdType.NUMERIC)) {
if (is_uint8(nodeId.value) && !nodeId.namespace && !nodeId.namespaceUri && !nodeId.serverIndex) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.TwoBytes);
} else if (
is_uint16(nodeId.value) &&
is_uint8(nodeId.namespace) &&
!nodeId.namespaceUri &&
!nodeId.serverIndex
) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.FourBytes);
} else {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.Numeric);
}
} else if (nodeId.identifierType.is(NodeIdType.STRING)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.String);
} else if (nodeId.identifierType.is(NodeIdType.BYTESTRING)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.ByteString);
} else if (nodeId.identifierType.is(NodeIdType.GUID)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.Guid);
assert(nodeId.hasOwnProperty("identifierType"));
let encodingByte = 0;
if (nodeId.identifierType.is(NodeIdType.NUMERIC)) {
if (is_uint8(nodeId.value) && !nodeId.namespace && !nodeId.namespaceUri && !nodeId.serverIndex) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.TwoBytes);
} else if (
is_uint16(nodeId.value) &&
is_uint8(nodeId.namespace) &&
!nodeId.namespaceUri &&
!nodeId.serverIndex
) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.FourBytes);
} else {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.Numeric);
}
} else if (nodeId.identifierType.is(NodeIdType.STRING)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.String);
} else if (nodeId.identifierType.is(NodeIdType.BYTESTRING)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.ByteString);
} else if (nodeId.identifierType.is(NodeIdType.GUID)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.Guid);
}
if (nodeId.hasOwnProperty("namespaceUri") && nodeId.namespaceUri) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.NamespaceUriFlag);
}
if (nodeId.hasOwnProperty("serverIndex") && nodeId.serverIndex) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.ServerIndexFlag);
}
return encodingByte;
!nodeId.serverIndex
) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.FourBytes);
} else {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.Numeric);
}
} else if (nodeId.identifierType.is(NodeIdType.STRING)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.String);
} else if (nodeId.identifierType.is(NodeIdType.BYTESTRING)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.ByteString);
} else if (nodeId.identifierType.is(NodeIdType.GUID)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.Guid);
}
if (nodeId.hasOwnProperty("namespaceUri") && nodeId.namespaceUri) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.NamespaceUriFlag);
}
if (nodeId.hasOwnProperty("serverIndex") && nodeId.serverIndex) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.ServerIndexFlag);
}
return encodingByte;
}
} else {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.Numeric);
}
} else if (nodeId.identifierType.is(NodeIdType.STRING)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.String);
} else if (nodeId.identifierType.is(NodeIdType.BYTESTRING)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.ByteString);
} else if (nodeId.identifierType.is(NodeIdType.GUID)) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.Guid);
}
if (nodeId.hasOwnProperty("namespaceUri") && nodeId.namespaceUri) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.NamespaceUriFlag);
}
if (nodeId.hasOwnProperty("serverIndex") && nodeId.serverIndex) {
encodingByte = set_flag(encodingByte, EnumNodeIdEncoding.ServerIndexFlag);
}
return encodingByte;
}
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.SymbolicId);
}
if (diagnosticInfo.namespaceUri >=0) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.NamespaceUri);
}
if (diagnosticInfo.localizedText >=0) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.LocalizedText);
}
if (diagnosticInfo.locale >= 0) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.Locale);
}
if (diagnosticInfo.additionalInfo) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.AdditionalInfo);
}
if (diagnosticInfo.innerStatusCode && diagnosticInfo.innerStatusCode !== StatusCodes.Good) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.InnerStatusCode);
}
if (diagnosticInfo.innerDiagnosticInfo) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.InnerDiagnosticInfo);
}
return encoding_mask;
}