How to use the node-opcua-data-model.NodeClass.Object 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.ts View on Github external
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;

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

        {
            const objectsFolder = namespace0.addObject({
                browseName: "Objects",
                nodeId: resolveNodeId(ObjectIds.ObjectsFolder),
                organizedBy: rootFolder
            });

            assert(rootFolder.getFolderElementByName("Objects")!
              .browseName.toString() === "Objects");

        }
        {
            const dataTypeFolder = namespace0.addObject({
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / ua_condition_base.ts View on Github external
// ConditionSource => cf SourceNode
    //  As per spec OPCUA 1.03 part 9 page 54:
    //    The ConditionType inherits all Properties of the BaseEventType. Their semantic is defined in
    //    Part 5. SourceNode identifies the ConditionSource.
    //    The SourceNode is the Node which the condition is associated with, it may be the same as the
    //    InputNode for an alarm, but it may be a separate node. For example a motor, which is a
    //    variable with a value that is an RPM, may be the ConditionSource for Conditions that are
    //    related to the motor as well as a temperature sensor associated with the motor. In the former
    //    the InputNode for the High RPM alarm is the value of the Motor RPM, while in the later the
    //    InputNode of the High Alarm would be the value of the temperature sensor that is associated
    //    with the motor.

    if (options.conditionSource) {

        options.conditionSource = addressSpace._coerceNode(options.conditionSource);
        if (options.conditionSource.nodeClass !== NodeClass.Object &&
          options.conditionSource.nodeClass !== NodeClass.Variable) {
            // tslint:disable:no-console
            console.log(options.conditionSource);
            throw new Error("Expecting condition source to be NodeClass.Object or Variable");
        }

        const conditionSourceNode = addressSpace.findNode(options.conditionSource.nodeId) as BaseNode;
        if (conditionSourceNode) {

            conditionNode.sourceNode.setValueFromSource({
                dataType: DataType.NodeId,
                value: conditionSourceNode.nodeId
            });

            // conditionSourceNode node must be registered as a EventSource of an other node.
            // As per spec OPCUA 1.03 part 9 page 54:
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.ts View on Github external
" in namespace " + this.namespaceUri + " index = " + this.index
                + "\n" +
                " browseName = " + node.browseName.toString());
        }

        this._nodeid_index[indexName] = node;

        if (node.nodeClass === NodeClass.ObjectType) {
            this._registerObjectType(node as UAObjectType);
        } else if (node.nodeClass === NodeClass.VariableType) {
            this._registerVariableType(node as UAVariableType);
        } else if (node.nodeClass === NodeClass.ReferenceType) {
            this._registerReferenceType(node as UAReferenceType);
        } else if (node.nodeClass === NodeClass.DataType) {
            this._registerDataType(node as UADataType);
        } else if (node.nodeClass === NodeClass.Object) {
            //
        } else if (node.nodeClass === NodeClass.Variable) {
            //
        } else if (node.nodeClass === NodeClass.Method) {
            //
        } else if (node.nodeClass === NodeClass.View) {
            //
        } else {
            // tslint:disable-next-line:no-console
            console.log("Invalid class Name", node.nodeClass);
            throw new Error("Invalid class name specified");
        }
    }
github node-opcua / node-opcua / packages / node-opcua-server / src / server_session.js View on Github external
}

    const sessionDiagnosticsDataType = session.addressSpace.findDataType("SessionDiagnosticsDataType");

    const sessionDiagnosticsObjectType = session.addressSpace.findObjectType("SessionDiagnosticsObjectType");
    const sessionDiagnosticsVariableType = session.addressSpace.findVariableType("SessionDiagnosticsVariableType");

    const references = [];
    if (sessionDiagnosticsObjectType) {
        references.push({referenceType: "HasTypeDefinition", isForward: true, nodeId: sessionDiagnosticsObjectType});
    }

    const namespace = session.addressSpace.getOwnNamespace();
    session.sessionObject = namespace.createNode({
        nodeId: session.nodeId,
        nodeClass: NodeClass.Object,
        browseName: session.sessionName || "Session-" + session.nodeId.toString(),
        componentOf: serverDiagnosticsNode.sessionsDiagnosticsSummary,
        typeDefinition: sessionDiagnosticsObjectType,
        references: references
    });

    if (sessionDiagnosticsDataType && sessionDiagnosticsVariableType) {

        // the extension object
        session._sessionDiagnostics = session.addressSpace.constructExtensionObject(sessionDiagnosticsDataType, {});
        session._sessionDiagnostics.session = session;

        // install property getter on property that are unlikely to change
        if (session.parent.clientDescription) {
            session._sessionDiagnostics.clientDescription = session.parent.clientDescription;
        }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space_change_event_tools.ts View on Github external
addressSpace.modelChangeTransaction(() => {

            let typeDefinitionNodeId = null;

            if (node.nodeClass === NodeClass.Object || node.nodeClass === NodeClass.Variable) {
                typeDefinitionNodeId = node.typeDefinitionObj.nodeId;
            }

            const modelChange1 = new ModelChangeStructureDataType({
                affected: node.nodeId,
                affectedType: typeDefinitionNodeId,
                verb: makeVerb("NodeAdded")
            });
            addressSpace._collectModelChange(null, modelChange1);

            const modelChangeSrc = new ModelChangeStructureDataType({
                affected: parent.nodeId,
                affectedType: null,
                verb: makeVerb("ReferenceAdded")
            });
            addressSpace._collectModelChange(null, modelChangeSrc);
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_object.js View on Github external
/**
 * @class UAObject
 * @param options
 * @constructor
 */
function UAObject(options) {
    BaseNode.apply(this, arguments);
    this.eventNotifier = options.eventNotifier || 0;
    assert(_.isNumber(this.eventNotifier) && ec.isValidByte(this.eventNotifier));
    this.symbolicName = options.symbolicName || null;
}

util.inherits(UAObject, BaseNode);
UAObject.prototype.nodeClass = NodeClass.Object;
UAObject.typeDefinition = resolveNodeId("BaseObjectType");

const getCurrentClock = require("node-opcua-date-time").getCurrentClock;


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

    assert(context instanceof SessionContext);

    const now = getCurrentClock();
    const options = {};
    switch (attributeId) {
        case AttributeIds.EventNotifier:
            assert(ec.isValidByte(this.eventNotifier));
            options.value = {dataType: DataType.Byte, value: this.eventNotifier};
            options.serverTimestamp = now.timestamp;
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.ts View on Github external
public addFolder(parentFolder: UAObject, options: any): UAObject {

        if (typeof options === "string") {
            options = { browseName: options };
        }

        const addressSpace = this.addressSpace;

        assert(!options.typeDefinition, "addFolder does not expect typeDefinition to be defined ");
        const typeDefinition = addressSpace._coerceTypeDefinition("FolderType");
        parentFolder = addressSpace._coerceFolder(parentFolder)! as UAObject;
        options.nodeClass = NodeClass.Object;
        options.references = [
            { referenceType: "HasTypeDefinition", isForward: true, nodeId: typeDefinition },
            { referenceType: "Organizes", isForward: false, nodeId: parentFolder.nodeId }
        ];
        const node = this.createNode(options) as UAObject;
        return node;
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.ts View on Github external
public addObject(options1: AddObjectOptions): UAObject {

        const options: CreateNodeOptions = options1 as CreateNodeOptions;

        assert(!options.nodeClass || options.nodeClass === NodeClass.Object);
        options.nodeClass = NodeClass.Object;

        const typeDefinition = options.typeDefinition || "BaseObjectType";
        options.references = options.references || [];
        options.references.push({ referenceType: "HasTypeDefinition", isForward: true, nodeId: typeDefinition });
        options.eventNotifier = +options.eventNotifier;
        const obj = this.createNode(options) as UAObject;
        assert(obj instanceof UAObject);
        assert(obj.nodeClass === NodeClass.Object);
        return obj;
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space.ts View on Github external
function hasTypeDefinition(node1: BaseNode) {
            return node1.nodeClass === NodeClass.Variable ||
                node1.nodeClass === NodeClass.Object ||
                node1.nodeClass === NodeClass.Method;
        }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_object.ts View on Github external
UAMethod as UAMethodPublic,
    UAObject as UAObjectPublic,
    UAObjectType as UAObjectTypePublic
} from "../source";
import { UAConditionBase } from "./alarms_and_conditions/ua_condition_base";
import { BaseNode } from "./base_node";
import {
    _clone,
    apply_condition_refresh,
    ToStringBuilder,
    UAObject_toString
} from "./base_node_private";

export class UAObject extends BaseNode implements UAObjectPublic {

    public readonly nodeClass = NodeClass.Object;
    public readonly eventNotifier: number;
    public readonly symbolicName: string;

    get typeDefinitionObj(): UAObjectTypePublic {
        return super.typeDefinitionObj as UAObjectTypePublic;
    }

    constructor(options: any) {
        super(options);
        this.eventNotifier = options.eventNotifier || 0;
        assert(_.isNumber(this.eventNotifier) && isValidByte(this.eventNotifier));
        this.symbolicName = options.symbolicName || null;
    }

    public readAttribute(context: SessionContext, attributeId: AttributeIds): DataValue {
        const now = getCurrentClock();