How to use the node-opcua-nodeid.sameNodeId function in node-opcua-nodeid

To help you get started, we’ve selected a few node-opcua-nodeid 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 / base_node.js View on Github external
// ignore propagation on back reference to UAVariableType or UAObject Type reference
    // because there are too many !
    if (!referenceType || _is_massively_used_reference(referenceType)) {
        //xx &&(referenceNode.constructor.name === "UAVariableType" || referenceNode.constructor.name  === "UAObjectType")
        // console.log(referenceType.browseName.toString() ,referenceNode.browseName.toString(), "on ",self.browseName.toString());
        return;
    }
    // ------------------------------- EXPERIMENT


    //xx if (!referenceType.isSupertypeOf(hierarchicalReferencesId)) { return; }
    const related_node = _resolveReferenceNode(addressSpace, reference);
    if (related_node) {

        // verify that reference doesn't point to object itself (see mantis 3099)
        if (sameNodeId(reference.nodeId, self.nodeId)) {

            // istanbul ignore next
            if (displayWarningReferencePointingToItsef) {
                // this could happen with method
                console.warn("  Warning: a Reference is pointing to itself ", self.nodeId.toString(), self.browseName.toString());
                displayWarningReferencePointingToItsef = false;
            }

        }
        //xx ignore this assert(reference.nodeId.toString() !== self.nodeId.toString());
        //function w(s,l) { return (s+"                                                          ").substr(0,l);}
        //if (reference.isForward) {
        //    console.log("  CHILD => ",w(related_node.browseName   + " " + related_node.nodeId.toString(),30),
        //        "  PARENT   ",w(self.browseName + " " + self.nodeId.toString(),30) , reference.toString());
        //} else {
        //    console.log("  CHILD => ",w(self.browseName   + " " + self.nodeId.toString(),30),
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space.ts View on Github external
function populate_data(
            self: any,
            eventData1: any
        ) {

            if (sameNodeId(baseObjectType!.nodeId, self.nodeId)) {
                return; // nothing to do
            }

            const baseTypeNodeId = self.subtypeOf;
            /* istanbul ignore next */
            if (!baseTypeNodeId) {
                throw new Error("Object " + self.browseName.toString() +
                    " with nodeId " + self.nodeId + " has no Type");
            }

            const baseType = addressSpace.findNode(baseTypeNodeId);
            /* istanbul ignore next */
            if (!baseType) {
                throw new Error(chalk.red("Cannot find object with nodeId ") + baseTypeNodeId);
            }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / reference.ts View on Github external
function is_valid_reference(ref: Reference): boolean {

    const hasRequestedProperties = ref.hasOwnProperty("referenceType") &&
        ref.hasOwnProperty("nodeId") &&
        !utils.isNullOrUndefined(ref.isForward);

    if (!hasRequestedProperties) {
        return false;
    }
    assert(ref.referenceType instanceof NodeId);
    assert(!ref.node || sameNodeId(ref.node.nodeId, ref.nodeId));
    // xx assert(!ref.referenceTypeName || typeof ref.referenceTypeName === "string");
    // xx // referenceType shall no be a nodeId string (this could happen by mistake)
    // xx assert(!isNodeIdString(ref.referenceType));
    return true;
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / tool_isSupertypeOf.js View on Github external
if (self.nodeId === baseType.nodeId) {
        return true;
    }
    const references = self.allReferences();

    const subTypes = _.filter(references,_filterSubType);
    assert(subTypes.length <= 1 && " should have zero or one subtype no more");

    for (let i = 0; i < subTypes.length; i++) {
        const subTypeId = subTypes[i].nodeId;
        const subType = self.addressSpace.findNode(subTypeId);
        // istanbul ignore next
        if (!subType) {
            throw new Error("Cannot find object with nodeId " + subTypeId.toString());
        }
        if (sameNodeId(subType.nodeId,baseType.nodeId)) {
            return true;
        } else {
            if (_slow_isSupertypeOf(subType, Class, baseType)) {
                return true;
            }
        }
    }
    return false;
};
github node-opcua / node-opcua / packages / node-opcua-address-space / src / tool_isSupertypeOf.ts View on Github external
function _slow_isSupertypeOf(
  this: T,
  Class: typeof BaseNode,
  baseType: T
): boolean {

    assert(this instanceof Class);
    assert(baseType instanceof Class, " Object must have same type");
    assert(this.addressSpace);

    if (sameNodeId(this.nodeId, baseType.nodeId)) {
        return true;
    }
    const references = this.allReferences();

    const subTypes = references.filter(_filterSubType);
    assert(subTypes.length <= 1, "should have zero or one subtype no more");

    for (const subType1 of subTypes) {
        const subTypeId = subType1.nodeId;
        const subTypeNode = this.addressSpace.findNode(subTypeId) as any as T;
        // istanbul ignore next
        if (!subTypeNode) {
            throw new Error("Cannot find object with nodeId " + subTypeId.toString());
        }
        if (sameNodeId(subTypeNode.nodeId, baseType.nodeId)) {
            return true;
github node-opcua / node-opcua / packages / node-opcua-server-configuration / source / server / push_certificate_manager_server_impl.ts View on Github external
function findCertificateGroupName(certificateGroupNodeId: NodeId | string): string {

    if (typeof certificateGroupNodeId === "string") {
        return certificateGroupNodeId;
    }
    if (sameNodeId(certificateGroupNodeId, NodeId.nullNodeId) ||
      sameNodeId(certificateGroupNodeId, defaultApplicationGroup)) {
        return "DefaultApplicationGroup";
    }
    if (sameNodeId(certificateGroupNodeId, defaultHttpsGroup)) {
        return "DefaultHttpsGroup";
    }
    if (sameNodeId(certificateGroupNodeId, defaultUserTokenGroup)) {
        return "DefaultUserTokenGroup";
    }
    return "";
}
github node-opcua / node-opcua / packages / node-opcua-server-configuration / source / server / push_certificate_manager_server_impl.ts View on Github external
function findCertificateGroupName(certificateGroupNodeId: NodeId | string): string {

    if (typeof certificateGroupNodeId === "string") {
        return certificateGroupNodeId;
    }
    if (sameNodeId(certificateGroupNodeId, NodeId.nullNodeId) ||
      sameNodeId(certificateGroupNodeId, defaultApplicationGroup)) {
        return "DefaultApplicationGroup";
    }
    if (sameNodeId(certificateGroupNodeId, defaultHttpsGroup)) {
        return "DefaultHttpsGroup";
    }
    if (sameNodeId(certificateGroupNodeId, defaultUserTokenGroup)) {
        return "DefaultUserTokenGroup";
    }
    return "";
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.js View on Github external
const candidates = references.filter(function (ref) {
        return ref.isForward === false &&
            (sameNodeId(ref.referenceType, hasComponentRefId) || sameNodeId(ref.referenceType, hasPropertyRefId));
    });
    assert(candidates.length <= 1);
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable_type.ts View on Github external
references = _.filter(references, (reference: UAReference) => {
        return !sameNodeId(reference.referenceType, hasTypeDefinitionNodeId) &&
          !sameNodeId(reference.referenceType, hasModellingRuleNodeId);
    });
    return references;