How to use the node-opcua-utils.set_flag function in node-opcua-utils

To help you get started, we’ve selected a few node-opcua-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-data-value / schemas / DataValue_schema.js View on Github external
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);
github node-opcua / node-opcua / packages / node-opcua-basic-types / src / nodeid.js View on Github external
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;
}
github node-opcua / node-opcua / packages / node-opcua-data-model / schemas / DiagnosticInfo_schema.js View on Github external
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;
}
github node-opcua / node-opcua / packages / node-opcua-basic-types / src / nodeid.js View on Github external
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);
github node-opcua / node-opcua / packages / node-opcua-basic-types / src / nodeid.js View on Github external
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;
github node-opcua / node-opcua / packages / node-opcua-basic-types / src / nodeid.js View on Github external
!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;
}
github node-opcua / node-opcua / packages / node-opcua-basic-types / src / nodeid.js View on Github external
} 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;
}
github node-opcua / node-opcua / packages / node-opcua-data-model / schemas / DiagnosticInfo_schema.js View on Github external
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;
}