How to use the node-opcua.resolveNodeId function in node-opcua

To help you get started, we’ve selected a few node-opcua 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 PacktPublishing / Industrial-Internet-Application-Development / Chapter03 / opcua / hub / index.js View on Github external
});

      subscription.on("started", function () {
        console.log("subscription id: ", subscription.subscriptionId);
      }).on("terminated", function () {
        cb();
      });

      setTimeout(function () {
        subscription.terminate();
      }, 5000);

      // install monitored item
      var monitor = subscription.monitor({
          attributeId: opcua.AttributeIds.Value,
          nodeId: opcua.resolveNodeId("ns=1;s=Variable1"),
        },
        {
          discardOldest: true,
          samplingInterval: 50,
          queueSize: 5,
        },
        opcua.read_service.TimestampsToReturn.Both
      );

      monitor.on("changed", function (dataValue) {
        console.log("Variable1 = ", dataValue.value.value);

        // send to receiver
        var data = {
          device: "sensor1",
          timestamp: Date.now(),
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client.js View on Github external
function _getAllEventTypes(baseNodeId, tree, callback) {

        //xx console.log(" exploring elements,",element.nodeId.toString());
        const browseDesc1 = {
            nodeId: baseNodeId,
            referenceTypeId: opcua.resolveNodeId("HasSubtype"),
            browseDirection: BrowseDirection.Forward,
            includeSubtypes: true,
            nodeClassMask: opcua.NodeClassMask.ObjectType, // Objects
            resultMask: 63
        };
        session.browse(browseDesc1, function (err, browseResult) {
            if (err) {
                console.log(" ERROR = ", err);
            } else {
                // to do continuation points
                browseResult.references.forEach(function (reference) {
                    const subtree = { nodeId: reference.nodeId.toString() };
                    tree[reference.browseName.toString()] = subtree;
                    q.push({ nodeId: reference.nodeId, tree: subtree });
                });
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client.js View on Github external
const q = async.queue(function worker(element, callback) {

            //xx console.log(" exploring elements,",element.nodeId.toString());
            const browseDesc1 = {
                nodeId: element.nodeId,
                referenceTypeId: opcua.resolveNodeId("HierarchicalReferences"),
                browseDirection: BrowseDirection.Forward,
                includeSubtypes: true,
                nodeClassMask: 0x1, // Objects
                resultMask: 63
            };

            const nodesToBrowse = [browseDesc1];
            session.browse(nodesToBrowse, function (err, browseResults) {
                if (err) {
                    console.log("err =", err);
                }
                if (!err) {
                    browseResults[0].references.forEach(function (ref) {
                        if (isConditionEventType(ref.typeDefinition)) {
                            //
                            const alarm = {
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client_ts.ts View on Github external
async function _getAllEventTypes(session: ClientSession, baseNodeId: NodeId, tree: any) {

    const browseDesc1 = {
        nodeId: baseNodeId,
        referenceTypeId: resolveNodeId("HasSubtype"),

        browseDirection: BrowseDirection.Forward,
        includeSubtypes: true,
        nodeClassMask: NodeClassMask.ObjectType, // Objects
        resultMask: 63
    };
    const browseResult = await session.browse(browseDesc1);

    const promises = [];
    // to do continuation points
    for (const reference of browseResult.references!) {
        const subtree = { nodeId: reference.nodeId.toString() };
        tree[reference.browseName.toString()] = subtree;
        promises.push(_getAllEventTypes(session, reference.nodeId, subtree));
    }
    await Promise.all(promises);
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client_ts.ts View on Github external
async function worker(element: any) {

            const nodeToBrowse = {
                nodeId: element.nodeId,
                referenceTypeId: resolveNodeId("HierarchicalReferences"),

                browseDirection: BrowseDirection.Forward,
                includeSubtypes: true,
                nodeClassMask: 0x1, // Objects
                resultMask: 63
            };

            const browseResult = await session1.browse(nodeToBrowse);

            for (const ref of browseResult.references!) {
                if (isConditionEventType(ref.typeDefinition)) {
                    //
                    const alarm = {
                        parent: element.nodeId,

                        alarmNodeId: ref.nodeId,
github frangoteam / FUXA / server / runtime / devices / opcua / index.js View on Github external
this.browse = function (node) {
        let nodeId = (node) ? node.id : opcua.resolveNodeId('RootFolder');
        return new Promise(function (resolve, reject) {
            // "RootFolder"
            if (the_session) {
                const b = [{
                    nodeId: nodeId,
                    referenceTypeId: 'Organizes',
                    includeSubtypes: true,
                    browseDirection: opcua.BrowseDirection.Forward,
                    resultMask: 0x3f

                },
                {
                    nodeId: nodeId,
                    referenceTypeId: 'Aggregates',
                    includeSubtypes: true,
                    browseDirection: opcua.BrowseDirection.Forward,
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client.js View on Github external
async function findAllNodeOfType(tree, typeNodeId, browseName) {

        const browseDesc1 = {
            nodeId: typeNodeId,
            referenceTypeId: opcua.resolveNodeId("HasSubtype"),
            browseDirection: BrowseDirection.Forward,
            includeSubtypes: true,
            resultMask: 63

        };
        const browseDesc2 = {
            nodeId: typeNodeId,
            referenceTypeId: opcua.resolveNodeId("HasTypeDefinition"),
            browseDirection: BrowseDirection.Inverse,
            includeSubtypes: true,
            resultMask: 63

        };
        const browseDesc3 = {
            nodeId: typeNodeId,
            referenceTypeId: opcua.resolveNodeId("HasTypeDefinition"),
            browseDirection: BrowseDirection.Forward,
            includeSubtypes: true,
            resultMask: 63

        };

        const nodesToBrowse = [
            browseDesc1,
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client_ts.ts View on Github external
browseDesc2,
            browseDesc3
        ];
        const browseResults = await session.browse(nodesToBrowse);

        tree1[browseName] = {};
        browseResults[0].references = browseResults[0].references || [];
        const promises = [];
        for (const reference of browseResults[0].references) {
            conditionEventTypes[reference.nodeId.toString()] = reference.browseName.toString();
            promises.push(findAllNodeOfType(tree1[browseName], reference.nodeId, reference.browseName.toString()));
        }
        await Promise.all(promises);
    }

    const typeNodeId = resolveNodeId("ConditionType");

    await findAllNodeOfType(tree, typeNodeId, "ConditionType");

    return tree;
}
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client.js View on Github external
function findAllNodeOfType(tree,typeNodeId,browseName,callback) {

        const browseDesc1 = {
            nodeId: typeNodeId,
            referenceTypeId: opcua.resolveNodeId("HasSubtype"),
            browseDirection: BrowseDirection.Forward,
            includeSubtypes: true,
            resultMask: 63

        };
        const browseDesc2 = {
            nodeId: typeNodeId,
            referenceTypeId: opcua.resolveNodeId("HasTypeDefinition"),
            browseDirection: BrowseDirection.Inverse,
            includeSubtypes: true,
            resultMask: 63

        };
        const browseDesc3 = {
            nodeId: typeNodeId,
            referenceTypeId: opcua.resolveNodeId("HasTypeDefinition"),
            browseDirection: BrowseDirection.Forward,
            includeSubtypes: true,
            resultMask: 63

        };

        const nodesToBrowse = [
            browseDesc1,
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client_ts.ts View on Github external
};
                    found.push(alarm);

                } else {
                    await worker(ref.nodeId);
                }
            }
        }

        await worker(nodeId);

    }

    await enumerateAllConditionTypes(session);

    await exploreForObjectOfType(session, resolveNodeId("RootFolder"));

    return Object.values(conditions);
}