============ Adding Nodes ============ Adding Folder Node ------------------ UA Folder in the OPC-UA Address space is of the type Folder object and is based on the Object NodeClass. The purpose with this object is to organize nodes into a tree structure. To create a Folder node, specify the following attributes: .. literalinclude:: examples/client/client_add_nodes.lua :language: lua :lines: 50-80 `Full source <_static/client/client_add_nodes.lua>`__ Adding Variables ---------------- A Variable in OPC-UA is a node in the address space with a set of predefined attributes: .. literalinclude:: examples/client/client_add_nodes.lua :language: lua :lines: 82-99 `Full source <_static/client/client_add_nodes.lua>`__ .. _valuerank_def: Variable Node Attributes ------------------------ To add a new variable node, you need to set the following parameters: **ParentNodeId** (type :ref:`NodeID`) Parent's node identifier. **ReferenceTypeId** (type :ref:`NodeID`) Parent's reference type identifier. **RequestedNewNodeId** (type :ref:`NodeID`) NodeID for the new node. If NodeId equals to ua.NodeId.Null, then the actual identifier will be automatically assigned by server. **BrowseName** (type QualifiedName) Internal name for the node. This name is used in the TranslateBrowsePathsToNodeIdsservice to resolve NodeId by path from some nodes. **NodeClass** (value from table ua.Types.NodeClass) Node class: Variable, Object, DataType. Only Variable node class is currently supported. **DisplayName** (type LocalizedText) Clients use this attribute if they want to display the name of the node to the user. Can be localized. **Description** (type LocalizedText) The optional description attribute explains the purpose with the node using localised text. **WriteMask** (type UInt32) Bit mask. Every bit defines ability to change corresponding attribute. **UserWriteMask** (type UInt32) Bit mask. Every bit defines ability to change corresponding attribute for current user. **Value** (:ref:`DataValue`) Initial value of a variable node. **DataType** (type :ref:`NodeID`) Identifier of a node of NodeClass DataType that describes structue of a value. For example encoding/decoding in binary, json, xml formats. This may be an ID of a node of simple type (Int32, UInt,Float, etc), and complex structures (for example certificate, ApplicationDescription, BuildInfo). **ValueRank** (type Int32) The value rank for the field. It shall be Scalar (-1) or a fixed rank Array (>=1). There are next predefined values: * ScalarOrOneDimension = -3, * Any = -2, * Scalar = -1, * OneOrMoreDimensions = 0, * OneDimension = 1, Greater values are number of dimensions: 2(matrix),3,4.. **ArrayDimensions** (array of UInt32) Array dimensions of the value. For example: {2,2} describes square matrix with size 2*2. **AccessLevel** (type Byte) The AccessLevel Attribute is used to indicate how the Value of a Variable can be accessed (read/write) and if it contains current and/or historic data. **UserAccessLevel** (type Byte) Write mask of current user Object node attributes ---------------------- To add a new Folder node, you need to set the following parameters: **ParentNodeId** (type :ref:`NodeID`) Parent's node identifier. **ReferenceTypeId** (type :ref:`NodeID`) Parent's reference type identifier. **RequestedNewNodeId** (type :ref:`NodeID`) NodeID for the new node. The identifier will be automatically assigned by server if NodeId equals ua.NodeId.Null. **BrowseName** (type QualifiedName) Internal name for the node. This name is used in the TranslateBrowsePathsToNodeIdsservice to resolve NodeId by path from some nodes. **NodeClass** (value from table ua.Types.NodeClass) Node class: Variable, Object, DataType. Only Variable node class is currently supported. **DisplayName** (type LocalizedText) Clients use this attribute if they want to show the name of the node to the user. Can be localized. **Description** (type LocalizedText) The optional description attribute explains the purpose with the node using localised text. **WriteMask** (type UInt32) Bit mask. Makes it possible for a client to write the Attributes of the Node. **EventNotifier** (type Byte) Event notifier. Results ------- The result from an OPC UA call will be an array. Every element of the array will be a table with two fields: Status code for current node and Identifier of added node. Every element of the array contains a table with the following fields: **StatusCode** Status code of adding corresponding node. **AddedNodeId** Identifier of added node. Server automatically assign an identifier for the node if not included. In other case will be returned identifier passed in parameters. Nil in case of error.