How to use the node-opcua-data-model.NodeClass.ReferenceType 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 / address_space.js View on Github external
//                                  +->(hasSubtype) Aggregates/AggregatedBy
    //                                                  +-> HasProperty/PropertyOf
    //                                                  +-> HasComponent/ComponentOf
    //                                                  +-> HasHistoricalConfiguration/HistoricalConfigurationOf
    //                                 +->(hasSubtype) HasSubtype/HasSupertype
    //                  +->(hasSubtype) Organizes/OrganizedBy
    //                  +->(hasSubtype) HasEventSource/EventSourceOf
    let node;

    if (isNodeIdString(refType)) {
        refType = resolveNodeId(refType);
    }
    if (refType instanceof NodeId) {
        node = this.findNode(refType);
        // istanbul ignore next
        if (!(node && (node.nodeClass === NodeClass.ReferenceType))) {
            // throw new Error("cannot resolve referenceId "+ refType.toString());
            return null;
        }
    } else {
        assert(_.isString(refType));
        node = this._findReferenceType(refType,namespace);
    }
    return node;
};
github node-opcua / node-opcua / packages / node-opcua-address-space / src / base_node.ts View on Github external
references = references.filter((reference: Reference) => {

            const ref = resolveReferenceType(this.addressSpace, reference)!;

            if (!ref) {
                return false;
            } // unknown type ... this may happen when the address space is not fully build
            assert(ref.nodeClass === NodeClass.ReferenceType);

            const is_of_type = ref.nodeId.toString() === referenceType.nodeId.toString();
            if (is_of_type) {
                return true;
            }
            if (browseDescription.includeSubtypes) {
                return ref.isSupertypeOf(referenceType as UAReferenceTypePublic);
            } else {
                return false;
            }
        });
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / test_helpers / create_minimalist_address_space_nodeset.js View on Github external
function addReferenceType(browseName,isAbstract,superType)
    {
        browseName = browseName.split("/");
        let inverseName = browseName[1];
        browseName = browseName[0];


        const options = {
            browseName: browseName,
            inverseName: inverseName,
            nodeId: resolveNodeId(ReferenceTypeIds[browseName]),
            nodeClass: NodeClass.ReferenceType,
            superType: superType,
            isAbstract: isAbstract
        };
        options.references = [];
        const hasSubType = resolveNodeId("HasSubtype");
        if (superType) {
            options.references.push({
                referenceType: hasSubType, isForward: false, nodeId: superType.nodeId
            });
        }
        const node = namespace0._createNode(options);

        node.propagate_back_references();

        return node;
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / source / loader / load_nodeset2.ts View on Github external
init(this: any, name: string, attrs: XmlAttributes) {
            this.obj = {};
            this.obj.nodeClass = NodeClass.ReferenceType;
            this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
            this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
            this.obj.browseName = convertQualifiedName(attrs.BrowseName);
        },
        finish(this: any) {
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.js View on Github external
UANamespace.prototype.addReferenceType = function (options) {

    const namespace = this;
    const addressSpace = namespace.addressSpace;

    options.nodeClass = NodeClass.ReferenceType;
    options.references = options.references || [];


    if (options.subtypeOf) {
        assert(options.subtypeOf);
        const subtypeOfNodeId = addressSpace._coerceType(options.subtypeOf, "References", NodeClass.ReferenceType);
        assert(subtypeOfNodeId);

        console.log(subtypeOfNodeId.toString().cyan);
        options.references.push({referenceType: "HasSubtype", isForward: false, nodeId: subtypeOfNodeId});
    }
    const node = namespace._createNode(options);

    node.propagate_back_references();

    return node;
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.js View on Github external
UANamespace.prototype.findReferenceTypeFromInverseName = function (inverseName) {
    assert(typeof inverseName === "string");
    const node = this._referenceTypeMapInv[inverseName];
    assert(!node || (node.nodeClass === NodeClass.ReferenceType && node.inverseName.text === inverseName));
    return node ? node : null;
};
github node-opcua / node-opcua / packages / node-opcua-address-space / src / loader / load_nodeset2.js View on Github external
init: function (name, attrs) {
            this.obj = {};
            this.obj.nodeClass = NodeClass.ReferenceType;
            this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
            this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
            this.obj.browseName = convertQualifiedName(attrs.BrowseName);
        },
        finish: function () {
github node-opcua / node-opcua / packages / node-opcua-address-space / src / referenceType.js View on Github external
* @class ReferenceType
 * @extends  BaseNode
 * @param options
 * @constructor
 */
function ReferenceType(options) {
    BaseNode.apply(this, arguments);

    this.isAbstract = util.isNullOrUndefined(options.isAbstract) ? false : !!options.isAbstract;
    this.symmetric = util.isNullOrUndefined(options.symmetric) ? false : !!options.symmetric;
    this.inverseName = coerceLocalizedText(options.inverseName);
    ReferenceTypeCounter +=1;
}

util.inherits(ReferenceType, BaseNode);
ReferenceType.prototype.nodeClass = NodeClass.ReferenceType;

/**
 *
 * @method readAttribute
 * @param attributeId {AttributeIds}
 * @param [indexRange {NumericalRange}]
 * @param [dataEncoding {String}]
 * @return {DataValue}
 */
ReferenceType.prototype.readAttribute = function (context, attributeId, indexRange, dataEncoding) {

    assert(context instanceof SessionContext);

    const options = {};
    switch (attributeId) {
        case AttributeIds.IsAbstract:
github node-opcua / node-opcua / packages / node-opcua-address-space / src / referenceType.js View on Github external
function _findAllSubType(referenceType) {
        possibleReferenceTypes.push(referenceType);
        assert(referenceType.nodeClass === NodeClass.ReferenceType);
        const references = referenceType.findReferences(hasSubtypeReferenceType, true);
        for(let _r of references) {
            const subType = addressSpace.findNode(_r.nodeId);
            _findAllSubType(subType);
        }
    }
    _findAllSubType(referenceType);