How to use the node-opcua-data-model.BrowseDirection.Inverse function in node-opcua-data-model

To help you get started, we’ve selected a few node-opcua-data-model 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 / src / ua_variable_type.js View on Github external
_.forEach(extraInfo.mapOrgToClone,function(value,key){

        const originalObject = value.original;
        const instantiatedObject = value.cloned;
        const organizedByArray = originalObject.findReferencesEx("Organizes",BrowseDirection.Inverse);


        //function dumpRef(r) {
        //    var referenceTd = addressSpace.findNode(r.referenceTypeId);
        //    var obj = addressSpace.findNode(r.nodeId);
        //    return "<-- " + referenceTd.browseName.toString() + " -- " + obj.browseName.toString();
        //}
        //
        //console.log("xxxxx ========================================================".bgRed,originalObject.browseName.toString(),
        //    organizedByArray.map(dumpRef).join("\n"));
        organizedByArray.forEach(function(ref) {

            if (extraInfo.mapOrgToClone.hasOwnProperty(ref.nodeId.toString())) {

                const info = extraInfo.mapOrgToClone[ref.nodeId.toString()];
                const folder = info.original;
github node-opcua / node-opcua / packages / node-opcua-client / source / alarms_and_conditions / client_alarm_tools_extractConditionFields.ts View on Github external
async function _investigateLevel(conditionNodeId: NodeIdLike) {

        const nodeToBrowse1: BrowseDescriptionOptions = {
            browseDirection: BrowseDirection.Inverse,
            includeSubtypes: true,
            nodeClassMask: NodeClassMask.ObjectType,
            nodeId: conditionNodeId,
            referenceTypeId: resolveNodeId("HasSubtype"),
            resultMask: 63
        };
        const nodeToBrowse2: BrowseDescriptionOptions = {
            browseDirection: BrowseDirection.Forward,
            includeSubtypes: true,
            // tslint:disable-next-line: no-bitwise
            nodeClassMask: NodeClassMask.Object | NodeClassMask.Variable,
            nodeId: conditionNodeId,
            referenceTypeId: resolveNodeId("HasChild"),
            resultMask: 63
        };
        const nodesToBrowse = [nodeToBrowse1, nodeToBrowse2];
github node-opcua / node-opcua / packages / node-opcua-client-proxy / src / proxy.js View on Github external
const dataTypeName = dataValue.value.value;

        if (dataTypeId.namespace === 0 && DataType[dataTypeId.value]) {
            dataType = DataType[dataTypeId.value];
            return setImmediate(function(){callback(null, dataType);});
        }

        /// example => Duration (i=290) => Double (i=11)
        // read subTypeOf
        const nodeToBrowse = {
            // BrowseDescription
            referenceTypeId: makeRefId("HasSubtype"),
            //xx nodeClassMask: makeNodeClassMask("ObjectType"),
            includeSubtypes: false,
            browseDirection: BrowseDirection.Inverse,
            nodeId: dataTypeId,
            resultMask: resultMask
        };
        session.browse(nodeToBrowse, function (err, browseResult) {
            // istanbul ignore next
            if (err) {
                return callback(err);
            }

            const references = browseResult.references;

            if (!references || references.length !== 1) {
                return callback(new Error("cannot find SuperType of " + dataTypeName.toString()));
            }
            const nodeId = references[0].nodeId;
            return convertNodeIdToDataTypeAsync(session, nodeId, callback);
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space_change_event_tools.ts View on Github external
export function _handle_delete_node_model_change_event(node: BaseNode) {

    const addressSpace = node.addressSpace;

    // get backward references
    const references = node.findReferencesEx("HierarchicalReferences", BrowseDirection.Inverse)!;

    const parentNodes = references.map((r: UAReference) => {
        return addressSpace.findNode(r.nodeId)! as BaseNode;
    });

    const versionableNodes = parentNodes.filter((n: BaseNode) => !!n.nodeVersion);

    if (versionableNodes.length >= 1 || !!node.nodeVersion) {

        addressSpace.modelChangeTransaction(() => {
            // ...
            for (const r of references) {

                const target = addressSpace.findNode(r.nodeId)!;

                const modelChangeSrc_l = new ModelChangeStructureDataType({
github node-opcua / node-opcua / packages / node-opcua-client-proxy / source / object_explorer.ts View on Github external
}

        const dataTypeName = dataValue.value.value;

        if (dataTypeId.namespace === 0 && DataType[dataTypeId.value as number]) {
            dataType = (DataType as any)[dataTypeId.value as number] as DataType;
            setImmediate(() => {
                callback(null, dataType);
            });
            return;
        }

        /// example => Duration (i=290) => Double (i=11)
        // read subTypeOf
        const nodeToBrowse = {
            browseDirection: BrowseDirection.Inverse,
            includeSubtypes: false,
            nodeId: dataTypeId,
            // BrowseDescription
            referenceTypeId: makeRefId("HasSubtype"),
            // xx nodeClassMask: makeNodeClassMask("ObjectType"),
            resultMask
        };
        // tslint:disable:no-shadowed-variable
        session.browse(nodeToBrowse, (err: Error | null, browseResult?: BrowseResult) => {
            // istanbul ignore next
            if (err) {
                return callback(err);
            }

            const references = browseResult!.references;
github node-opcua / node-opcua / packages / node-opcua-address-space / src / nodeset_to_xml.ts View on Github external
assert(r.length === 1);
                const typeDefinitionObj = Reference.resolveReferenceNode(addressSpace, r[0])! as BaseNode;
                assert(typeDefinitionObj instanceof BaseNode);

                if (typeDefinitionObj.nodeId.namespace === node.nodeId.namespace) {
                    // only output node if it is on the same namespace
                    if (!xw.visitedNode[_hash(typeDefinitionObj)]) {
                        typeDefinitionObj.dumpXML(xw);
                    }
                }
            }
        }

        //
        {
            const r = node.findReferencesEx("HasSubtype", BrowseDirection.Inverse);
            if (r && r.length) {
                const subTypeOf = Reference.resolveReferenceNode(addressSpace, r[0])! as BaseNode;
                assert(r.length === 1);
                if (subTypeOf.nodeId.namespace === node.nodeId.namespace) {
                    // only output node if it is on the same namespace
                    if (!xw.visitedNode[_hash(subTypeOf)]) {
                        subTypeOf.dumpXML(xw);
                    }
                }
            }
        }
    } else {

        const r = node.findReferencesEx("Aggregates", BrowseDirection.Forward);
        for (const reference of r) {
            const nodeChild = Reference.resolveReferenceNode(addressSpace, reference) as BaseNode;
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space.ts View on Github external
assert(node.nodeClass === NodeClass.Object || node.nodeClass === NodeClass.Variable);

        const visitedMap: any = {};

        const q = new Dequeue();
        q.push(node);

        const objectsFolder = addressSpace.rootFolder.objects;
        assert(objectsFolder instanceof UAObject);

        const results: UAView[] = [];

        while (q.length) {
            node = q.shift();

            const references = node.findReferencesEx("HierarchicalReferences", BrowseDirection.Inverse);

            const parentNodes = references.map(
                (r: UAReference) => Reference.resolveReferenceNode(addressSpace, r) as BaseNode);

            for (const parent of parentNodes) {

                if (sameNodeId(parent.nodeId, objectsFolder.nodeId)) {
                    continue; // nothing to do
                }
                if (parent.nodeClass === NodeClass.View) {
                    results.push(parent as UAView);
                } else {
                    const key = parent.nodeId.toString();
                    if (visitedMap.hasOwnProperty(key)) {
                        continue;
                    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / condition.js View on Github external
UAConditionBase.prototype.conditionOfNode = function() {
    const refs = this.findReferencesExAsObject("HasCondition", BrowseDirection.Inverse);
    if (refs.length === 0) {
        return null;
    }
    assert(refs.length !== 0, "UAConditionBase must be the condition of some node");
    assert(refs.length === 1, "expecting only one ConditionOf");
    const node = refs[0];
    assert(
        node instanceof UAObject || node instanceof UAVariable,
        "node for which we are the condition shall be an UAObject or UAVariable"
    );
    return node;
};
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / ua_condition_base.ts View on Github external
public conditionOfNode(): UAObject | UAVariable | null {
        const refs = this.findReferencesExAsObject("HasCondition", BrowseDirection.Inverse);
        if (refs.length === 0) {
            return null;
        }
        assert(refs.length !== 0, "UAConditionBase must be the condition of some node");
        assert(refs.length === 1, "expecting only one ConditionOf");
        const node = refs[0];
        assert(
          node.nodeClass === NodeClass.Object || node.nodeClass === NodeClass.Variable,
          "node for which we are the condition shall be an UAObject or UAVariable"
        );
        return node as UAObject | UAVariable;
    }