How to use the node-opcua-data-model.NodeClass.VariableType 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 / test_helpers / create_minimalist_address_space_nodeset.js View on Github external
const baseVariableType = namespace0._createNode({
        browseName: "BaseVariableType",
        nodeId: resolveNodeId(VariableTypeIds.BaseVariableType),
        nodeClass: NodeClass.VariableType,
        isAbstract: true
    });

    const propertyType = namespace0.addVariableType({
        browseName: "PropertyType",
        subtypeOf: baseVariableType,
    });

    const baseDataVariableType = namespace0._createNode({
        browseName: "BaseDataVariableType",
        nodeId: resolveNodeId(VariableTypeIds.BaseDataVariableType),
        nodeClass: NodeClass.VariableType,
        subtypeOf: baseVariableType.nodeId,
        isAbstract: true
    });

    // add the root folder
    {
        const rootFolder = namespace0._createNode({
            browseName: "RootFolder",
            nodeId: resolveNodeId(ObjectIds.RootFolder),
            nodeClass: NodeClass.Object
        });


        {
            const objectsFolder = namespace0.addObject({
                browseName: "Objects",
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable_type.ts View on Github external
assert(referenceId);

    // we need to explore
    let references = originalObject.findReferencesEx("NonHierarchicalReferences", BrowseDirection.Inverse);

    references = ([] as UAReference[]).concat(
      references,
      originalObject.findReferencesEx("HasEventSource", BrowseDirection.Inverse)
    );

    const parent = _get_parent_as_VariableOrObjectType(originalObject);

    if (parent && parent.subtypeOfObj) {

        // parent is a ObjectType or VariableType and is not a root type
        assert(parent.nodeClass === NodeClass.VariableType || parent.nodeClass === NodeClass.ObjectType);

        // let investigate the same child base child
        const child = parent.subtypeOfObj!.getChildByName(originalObject.browseName);

        if (child) {
            const baseRef = findNonHierarchicalReferences(child);
            // xx console.log("  ... ",originalObject.browseName.toString(),
            // parent.browseName.toString(), references.length, baseRef.length);
            references = ([] as UAReference[]).concat(references, baseRef);
        }
    }
    // perform some cleanup
    references = _remove_unwanted_ref(references);

    return references;
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable_type.js View on Github external
self.valueRank = options.valueRank || 0;  // Int32

    // see OPC-UA part 5 : $3.7 Conventions for Node descriptions
    self.arrayDimensions = options.arrayDimensions || [];

    assert(_.isArray(this.arrayDimensions));

    if (options.value) {
        self.value = new Variant(options.value);
        //xx console.log("setting ",self.value.toString());
    }
}

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

UAVariableType.prototype.readAttribute = function (context, attributeId) {

    assert(context instanceof SessionContext);

    const options = {};
    switch (attributeId) {
        case AttributeIds.IsAbstract:
            options.value = {dataType: DataType.Boolean, value: this.isAbstract ? true : false};
            options.statusCode = StatusCodes.Good;
            break;
        case AttributeIds.Value:
            if (this.hasOwnProperty("value") && this.value !== undefined) {
                assert(this.value.schema.name === "Variant");
                options.value = this.value;
                options.statusCode = StatusCodes.Good;
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.ts View on Github external
options.dataType = options.dataType || "Int32";
        options.dataType = this.addressSpace._coerce_DataType(options.dataType);

        // valueRank
        options.valueRank = utils.isNullOrUndefined(options.valueRank) ? -1 : options.valueRank;
        assert(_.isFinite(options.valueRank));
        assert(typeof options.valueRank === "number");

        // arrayDimensions
        options.arrayDimensions = options.arrayDimensions || [];
        assert(_.isArray(options.arrayDimensions) || options.arrayDimensions === null);

        const variableType = this._addObjectOrVariableType(
            options,
            "BaseVariableType",
            NodeClass.VariableType) as UAVariableType;

        variableType.dataType = options.dataType;
        variableType.valueRank = options.valueRank || 0;
        variableType.arrayDimensions = options.arrayDimensions;

        return variableType as UAVariableTypePublic;
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / test_helpers / create_minimalist_address_space_nodeset.ts View on Github external
if (doDebug) {
        dumpReferencesHierarchy(addressSpace);
    }

    const baseObjectType = namespace0._createNode({
        browseName: "BaseObjectType",
        isAbstract: true,
        nodeClass: NodeClass.ObjectType,
        nodeId: resolveNodeId(ObjectTypeIds.BaseObjectType)
    });

    const baseVariableType = namespace0._createNode({
        browseName: "BaseVariableType",
        isAbstract: true,
        nodeClass: NodeClass.VariableType,
        nodeId: resolveNodeId(VariableTypeIds.BaseVariableType)
    }) as any as UAVariableType;

    const propertyType = namespace0.addVariableType({
        browseName: "PropertyType",
        subtypeOf: baseVariableType
    });

    const baseDataVariableType = namespace0._createNode({
        browseName: "BaseDataVariableType",
        isAbstract: true,
        nodeClass: NodeClass.VariableType,
        nodeId: resolveNodeId(VariableTypeIds.BaseDataVariableType),
        subtypeOf: baseVariableType.nodeId
    }) as any as UAVariableType;
github node-opcua / node-opcua / packages / node-opcua-address-space / test_helpers / create_minimalist_address_space_nodeset.js View on Github external
}
    }

    dumpReferencesHierarchy(addressSpace);

    const baseObjectType = namespace0._createNode({
        browseName: "BaseObjectType",
        nodeId: resolveNodeId(ObjectTypeIds.BaseObjectType),
        nodeClass: NodeClass.ObjectType,
        isAbstract: true
    });

    const baseVariableType = namespace0._createNode({
        browseName: "BaseVariableType",
        nodeId: resolveNodeId(VariableTypeIds.BaseVariableType),
        nodeClass: NodeClass.VariableType,
        isAbstract: true
    });

    const propertyType = namespace0.addVariableType({
        browseName: "PropertyType",
        subtypeOf: baseVariableType,
    });

    const baseDataVariableType = namespace0._createNode({
        browseName: "BaseDataVariableType",
        nodeId: resolveNodeId(VariableTypeIds.BaseDataVariableType),
        nodeClass: NodeClass.VariableType,
        subtypeOf: baseVariableType.nodeId,
        isAbstract: true
    });
github node-opcua / node-opcua / packages / node-opcua-address-space / test_helpers / create_minimalist_address_space_nodeset.ts View on Github external
const baseVariableType = namespace0._createNode({
        browseName: "BaseVariableType",
        isAbstract: true,
        nodeClass: NodeClass.VariableType,
        nodeId: resolveNodeId(VariableTypeIds.BaseVariableType)
    }) as any as UAVariableType;

    const propertyType = namespace0.addVariableType({
        browseName: "PropertyType",
        subtypeOf: baseVariableType
    });

    const baseDataVariableType = namespace0._createNode({
        browseName: "BaseDataVariableType",
        isAbstract: true,
        nodeClass: NodeClass.VariableType,
        nodeId: resolveNodeId(VariableTypeIds.BaseDataVariableType),
        subtypeOf: baseVariableType.nodeId
    }) as any as UAVariableType;

    const modellingRule_Optional = namespace0._createNode({
        browseName: "Optional",
        nodeClass: NodeClass.Object,
        nodeId: resolveNodeId(ObjectIds.ModellingRule_Optional),
    }) as any as UAObject;

    const modellingRule_Mandatory = namespace0._createNode({
        browseName: "Mandatory",
        nodeClass: NodeClass.Object,
        nodeId: resolveNodeId(ObjectIds.ModellingRule_Mandatory),
    }) as any as UAObject;
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable_type.js View on Github external
console.warn(" object ", originalObject.browseName.toString(), " has more than one parent !");
        console.warn(originalObject.toString());
        console.warn(" parents : ");
        for (let i = 0; i < parent.length; i++) {
            console.log("     ",
              parent[i].toString(),
              addressSpace.findNode(parent[i].nodeId).browseName.toString()
            );
        }
        return null;
    }

    assert(parent.length ===0 || parent.length === 1);
    if (parent.length === 0){ return null; }
    parent = addressSpace.findNode(parent[0].nodeId);
    if (parent && ( parent.nodeClass === NodeClass.VariableType || parent.nodeClass === NodeClass.ObjectType )) {
        return parent;
    }
    return null;
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.ts View on Github external
private _addObjectOrVariableType(
        options1: AddBaseNodeOptions,
        topMostBaseType: string,
        nodeClass: NodeClass.ObjectType | NodeClass.VariableType
    ) {
        const addressSpace = this.addressSpace;

        assert(typeof topMostBaseType === "string");
        assert(nodeClass === NodeClass.ObjectType || nodeClass === NodeClass.VariableType);

        const options = options1 as CreateNodeOptions;
        assert(!options.nodeClass);
        assert(options.browseName);
        assert(typeof options.browseName === "string");
        if (options.hasOwnProperty("references")) {
            throw new Error("options.references should not be provided, use options.subtypeOf instead");
        }
        const references: Reference[] = [];

        function process_subtypeOf_options(
            this: UANamespace,
            options2: any,
            references1: AddReferenceOpts[]
        ) {