How to use node-opcua-service-translate-browse-path - 10 common examples

To help you get started, we’ve selected a few node-opcua-service-translate-browse-path 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-address-space / source / helpers / check_event_clause.ts View on Github external
if (!eventTypeNode || !(eventTypeNode.nodeClass === NodeClass.ObjectType)) {
        // xx console.log("eventTypeNode = ",selectClause.typeDefinitionId.toString());
        // xx console.log("eventTypeNode = ",eventTypeNode);
        // istanbul ignore next
        if (eventTypeNode) {
            console.log(eventTypeNode.toString());
        }
    }

    // istanbul ignore next
    if (eventTypeNode.nodeClass !== NodeClass.ObjectType) {
        throw new Error("Expecting a ObjectType");
    }

    // navigate to the innerNode specified by the browsePath [ QualifiedName]
    const browsePath = constructBrowsePathFromQualifiedName(eventTypeNode, selectClause.browsePath);
    const browsePathResult = addressSpace.browsePath(browsePath);
    return browsePathResult.statusCode;

}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / event_data.ts View on Github external
public resolveSelectClause(selectClause: SimpleAttributeOperand) {
        const self = this;
        assert(selectClause instanceof SimpleAttributeOperand);
        const addressSpace = self.$eventDataSource.addressSpace;

        if (selectClause.browsePath!.length === 0 && selectClause.attributeId === AttributeIds.NodeId) {
            assert(!"Cannot use resolveSelectClause on this selectClause as it has no browsePath");
        }
        // navigate to the innerNode specified by the browsePath [ QualifiedName]
        const browsePath = constructBrowsePathFromQualifiedName(self.$eventDataSource, selectClause.browsePath);

        // xx console.log(self.$eventDataSource.browseName.toString());
        // xx console.log("xx browse Path", browsePath.toString());

        const browsePathResult = addressSpace.browsePath(browsePath);

        // xx console.log(" br",
        //    self.$eventDataSource.nodeId.toString(),
        //    selectClause.browsePath.toString(),
        //    browsePathResult.targets[0] ? browsePathResult.targets[0].targetId.toString() : "!!!NOT FOUND!!!"é)

        if (browsePathResult.statusCode !== StatusCodes.Good) {
            return null;
        }
        if (!browsePathResult.targets) {
            return null;
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space_add_event_type.js View on Github external
EventData.prototype.resolveSelectClause = function(selectClause) {
    const self = this;
    assert(selectClause instanceof SimpleAttributeOperand);
    const addressSpace = self.$eventDataSource.addressSpace;

    if (selectClause.browsePath.length === 0 && selectClause.attributeId === AttributeIds.NodeId) {
        assert(!"Cannot use resolveSelectClause on this selectClause as it has no browsePath");
    }
    // navigate to the innerNode specified by the browsePath [ QualifiedName]
    const browsePath = constructBrowsePathFromQualifiedName(self.$eventDataSource, selectClause.browsePath);

    //xx console.log(self.$eventDataSource.browseName.toString());
    //xx console.log("xxxxxxxxxxxxx browse Pathx", browsePath.toString());

    const browsePathResult = addressSpace.browsePath(browsePath);

    //xx console.log(" br",self.$eventDataSource.nodeId.toString(),selectClause.browsePath.toString(),browsePathResult.targets[0] ? browsePathResult.targets[0].targetId.toString() : "!!!NOT FOUNF!!!".cyan)

    if (browsePathResult.statusCode !== StatusCodes.Good) {
        return null;
    }
    // istanbul ignore next
    if (browsePathResult.targets.length !== 1) {
        //xx console.log("selectClause ",selectClause.toString());
        //xx console.log("browsePathResult ",browsePathResult.toString());
        //xx throw new Error("browsePathResult.targets.length !== 1"  + browsePathResult.targets.length);
github node-opcua / node-opcua / packages / node-opcua-client / src / tools / read_history_server_capabilities.js View on Github external
function readHistoryServerCapabilities(the_session,callback) {
    // display HistoryCapabilities of server
    const browsePath = makeBrowsePath(ObjectIds.ObjectsFolder,"/Server/ServerCapabilities.HistoryServerCapabilities");

    the_session.translateBrowsePath(browsePath,function(err,result) {
        if (err) { return callback(err); }
        if (result.statusCode !==  StatusCodes.Good) {
            return callback();
        }
        const historyServerCapabilitiesNodeId = result.targets[0].targetId;
        // (should be ns=0;i=11192)
        assert(historyServerCapabilitiesNodeId.toString() === "ns=0;i=11192");

        // -------------------------
        const properties = [
            "AccessHistoryDataCapability",
            "AccessHistoryEventsCapability",
            "DeleteAtTimeCapability",
            "DeleteRawCapability",
github node-opcua / node-opcua / packages / node-opcua-client / source / client_utils.ts View on Github external
function browsePathPropertyRequest(nodeId: NodeIdLike, propertyName: string): BrowsePath {

    return new BrowsePath({
        relativePath: /* RelativePath   */  {
            elements: /* RelativePathElement */ [
                {
                    includeSubtypes: false,
                    isInverse: false,
                    referenceTypeId: hasPropertyRefId,
                    targetName: {namespaceIndex: 0, name: propertyName}
                }
            ]
        },
        startingNode: /* NodeId  */ nodeId,
    });

}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space_browse.js View on Github external
function explore_element(curNodeObject, elements, index) {

            const element = elements[index];
            assert(element instanceof translate_service.RelativePathElement);

            const is_last = ( (index + 1) === elements.length);

            const nodeIds = curNodeObject.browseNodeByTargetName(element,is_last);

            const targets = nodeIds.map(function (nodeId) {
                return {
                    targetId: nodeId,
                    remainingPathIndex: elements.length - index
                };
            });

            if (!is_last) {
                // explorer
                for(let target of targets) {
                    const node = self.findNode(target.targetId);
github node-opcua / node-opcua / packages / node-opcua-client / src / client_session.js View on Github external
self.performMessageTransaction(request, function (err, response) {

        /* istanbul ignore next */
        if (err) {
            return callback(err, response);
        }
        assert(response instanceof translate_service.TranslateBrowsePathsToNodeIdsResponse);
        callback(null, isArray ? response.results : response.results[0]);

    });
github node-opcua / node-opcua / packages / node-opcua-client / src / client_session.js View on Github external
ClientSession.prototype.translateBrowsePath = function (browsePath, callback) {
    assert(_.isFunction(callback));
    const self = this;


    const isArray = _.isArray(browsePath);
    browsePath = isArray ?  browsePath :[browsePath];

    const request = new translate_service.TranslateBrowsePathsToNodeIdsRequest({
        browsePath: browsePath
    });

    self.performMessageTransaction(request, function (err, response) {

        /* istanbul ignore next */
        if (err) {
            return callback(err, response);
        }
        assert(response instanceof translate_service.TranslateBrowsePathsToNodeIdsResponse);
        callback(null, isArray ? response.results : response.results[0]);

    });

};
github node-opcua / node-opcua / packages / node-opcua-file-transfer / source / client / client_file.ts View on Github external
private async extractMethodsIds(): Promise {
        const browsePaths: BrowsePath[] = [
            makeBrowsePath(this.fileNodeId, "/Open"),
            makeBrowsePath(this.fileNodeId, "/Close"),
            makeBrowsePath(this.fileNodeId, "/SetPosition"),
            makeBrowsePath(this.fileNodeId, "/GetPosition"),
            makeBrowsePath(this.fileNodeId, "/Write"),
            makeBrowsePath(this.fileNodeId, "/Read"),
            makeBrowsePath(this.fileNodeId, "/OpenCount"),
            makeBrowsePath(this.fileNodeId, "/Size")
        ];

        const results = await this.session.translateBrowsePath(browsePaths);

        if (results[0].statusCode !== StatusCodes.Good) {
            throw new Error("fileType object does not expose mandatory Open Method");
        }
        if (results[1].statusCode !== StatusCodes.Good) {
            throw new Error("fileType object does not expose mandatory Close Method");
        }
        if (results[2].statusCode !== StatusCodes.Good) {
github node-opcua / node-opcua / packages / node-opcua-file-transfer / source / client / client_file.ts View on Github external
private async extractMethodsIds(): Promise {
        const browsePaths: BrowsePath[] = [
            makeBrowsePath(this.fileNodeId, "/Open"),
            makeBrowsePath(this.fileNodeId, "/Close"),
            makeBrowsePath(this.fileNodeId, "/SetPosition"),
            makeBrowsePath(this.fileNodeId, "/GetPosition"),
            makeBrowsePath(this.fileNodeId, "/Write"),
            makeBrowsePath(this.fileNodeId, "/Read"),
            makeBrowsePath(this.fileNodeId, "/OpenCount"),
            makeBrowsePath(this.fileNodeId, "/Size")
        ];

        const results = await this.session.translateBrowsePath(browsePaths);

        if (results[0].statusCode !== StatusCodes.Good) {
            throw new Error("fileType object does not expose mandatory Open Method");
        }
        if (results[1].statusCode !== StatusCodes.Good) {
            throw new Error("fileType object does not expose mandatory Close Method");
        }