.. _read_write_data: ======================== Reading and Writing Data ======================== Reading Attributes ################## Reading attributes is done with the Read method. Read parameters --------------- +----------------------------------+----------------------------------------------------------+ | **NodesToRead** | Array of nodes and attributes to read | +----------------+-----------------+------------------------------+---------------------------+ | | **NodeId** | :ref:`NodeId` | The identifier of a node | + +-----------------+------------------------------+---------------------------+ | | **AttributeId** | uint32 | :ref:`attribute` | +----------------+-----------------+------------------------------+---------------------------+ Read Example ------------ .. code-block:: lua local Server_ServerStatus_CurrentTime = "i=2258" -- Reading server's current time and product version. local nodes = { NodesToRead = { { NodeId = Server_ServerStatus_CurrentTime, AttributeId = ua.Types.AttributeId.Value }, { NodeId = Server_ServerStatus_BuildInfo_SoftwareVersion, AttributeId = ua.Types.AttributeId.Value }, } } local response = services:read(nodes) for i,result = response.Results do if result.StatusCode == s.Good then print(string.format("%s = %s", nodes.NodesToRead[i].NodeId, result.Value.String)) else print(string.format("Reading value '%s' failed: 0x%X", nodes.NodesToRead[i].NodeId, code)) end end Writing Attributes ################## Changing the values of attributes is done with the Write method. Write Parameters ---------------- +----------------------------------+---------------------------------------------------------------+ | **NodesToWrite** | Array of nodes and attributes to write | +----------------+-----------------+-----------------------------------+---------------------------+ | | **NodeId** | :ref:`NodeId` | The identifier of a node | | +-----------------+-----------------------------------+---------------------------+ | | **AttributeId** | uint32 | :ref:`attribute` | | +-----------------+-----------------------------------+---------------------------+ | | **Value** | :ref:`DataValue` | New value of the attribute| +----------------+-----------------+-----------------------------------+---------------------------+ Write example ------------- .. code-block:: lua local Server_ServerStatus_StartTime = "i=2257" local nodes = { NodesToWrite = { { NodeId = ua.NodeIds.Server_ServerStatus_StartTime, AttributeId = AttributeId.Value, Value = { -- DataValue Value = { -- Variant DateTime = 0.0 } } } } } local response = svc:write(nodes) if response.Results[1] ~= ua.StatusCode.Good then print(string.format("Changing attribute value failed: 0x%X", response.Results[1])) return end .. _attribute: Node Attribute ############## Every node in the address space is represented by a set of attributes. Base node attribute numbers --------------------------- +--------+--------------------------+-------------------+ | Number | Attribute name | Data type | +--------+--------------------------+-------------------+ | 1 | NodeId | nodeID | +--------+--------------------------+-------------------+ | 2 | NodeClass | uint32 | +--------+--------------------------+-------------------+ | 3 | BrowseName | qualifiedName | +--------+--------------------------+-------------------+ | 4 | DisplayName | localizedText | +--------+--------------------------+-------------------+ | 5 | Description | localizedText | +--------+--------------------------+-------------------+ | 6 | WriteMask | uint32 | +--------+--------------------------+-------------------+ | 7 | UserWriteMask | uint32 | +--------+--------------------------+-------------------+ | 24 | RolePermissions | structure (TBD) | +--------+--------------------------+-------------------+ | 25 | UserRolePermissions | structure (TBD) | +--------+--------------------------+-------------------+ | 26 | AccessRestrictions | uint16 | +--------+--------------------------+-------------------+ Object node attribute numbers ----------------------------- +--------+--------------------------+-------------------+ | Number | Attribute name | Data type | +--------+--------------------------+-------------------+ | * | Base attributes | | +--------+--------------------------+-------------------+ | 12 | EventNotifier | byte | +--------+--------------------------+-------------------+ Object Type node attribute numbers ---------------------------------- +--------+--------------------------+-------------------+ | Number | Attribute name | Data type | +--------+--------------------------+-------------------+ | * | Base attributes | | +--------+--------------------------+-------------------+ | 8 | IsAbstract | boolean | +--------+--------------------------+-------------------+ Variable node attribute numbers ------------------------------- +--------+--------------------------+-------------------+ | Number | Attribute name | Data type | +--------+--------------------------+-------------------+ | * | Base attributes | | +--------+--------------------------+-------------------+ | 13 | Value | DataValue | +--------+--------------------------+-------------------+ | 14 | DataType | NodeID | +--------+--------------------------+-------------------+ | 15 | Rank | int32 | +--------+--------------------------+-------------------+ | 16 | ArrayDimensions | int32[] | +--------+--------------------------+-------------------+ | 17 | AccessLevel | byte | +--------+--------------------------+-------------------+ | 18 | UserAccessLevel | byte | +--------+--------------------------+-------------------+ | 19 | MinimumSamplingInterval | double | +--------+--------------------------+-------------------+ | 20 | Historizing | boolean | +--------+--------------------------+-------------------+ | 27 | AccessLevelEx | uint32 | +--------+--------------------------+-------------------+ Variable Type node attribute numbers ------------------------------------ +--------+--------------------------+-------------------+ | Number | Attribute name | Data type | +--------+--------------------------+-------------------+ | * | Base attributes | | +--------+--------------------------+-------------------+ | 8 | IsAbstract | boolean | +--------+--------------------------+-------------------+ | 13 | Value | DataValue | +--------+--------------------------+-------------------+ | 14 | DataType | NodeID | +--------+--------------------------+-------------------+ | 15 | Rank | int32 | +--------+--------------------------+-------------------+ | 16 | ArrayDimensions | int32[] | +--------+--------------------------+-------------------+ Reference Type node attribute numbers ------------------------------------- +--------+--------------------------+-------------------+ | Number | Attribute name | Data type | +--------+--------------------------+-------------------+ | * | Base attributes | | +--------+--------------------------+-------------------+ | 8 | IsAbstract | boolean | +--------+--------------------------+-------------------+ | 9 | Symmetric | boolean | +--------+--------------------------+-------------------+ | 10 | InverseName | localizedText | +--------+--------------------------+-------------------+ Data Type node attribute numbers -------------------------------- +--------+--------------------------+-------------------+ | Number | Attribute name | Data type | +--------+--------------------------+-------------------+ | * | Base attributes | | +--------+--------------------------+-------------------+ | 8 | IsAbstract | boolean | +--------+--------------------------+-------------------+ | 23 | DataTypeDefinition | nodeID | +--------+--------------------------+-------------------+ Method node attribute numbers ----------------------------- +--------+--------------------------+-------------------+ | Number | Attribute name | Data type | +--------+--------------------------+-------------------+ | * | Base attributes | | +--------+--------------------------+-------------------+ | 21 | Executable | boolean | +--------+--------------------------+-------------------+ | 22 | UserExecutable | boolean | +--------+--------------------------+-------------------+ View node attribute numbers --------------------------- +--------+--------------------------+-------------------+ | Number | Attribute name | Data type | +--------+--------------------------+-------------------+ | * | Base attributes | | +--------+--------------------------+-------------------+ | 11 | ContainsNoLoops | boolean | +--------+--------------------------+-------------------+ | 12 | EventNotifier | byte | +--------+--------------------------+-------------------+ List of all attribute numbers ----------------------------- +--------+--------------------------+-------------------+ | Number | Attribute name | Data type | +--------+--------------------------+-------------------+ | 1 | NodeId | nodeID | +--------+--------------------------+-------------------+ | 2 | NodeClass | uint32 | +--------+--------------------------+-------------------+ | 3 | BrowseName | qualifiedName | +--------+--------------------------+-------------------+ | 4 | DisplayName | localizedText | +--------+--------------------------+-------------------+ | 5 | Description | localizedText | +--------+--------------------------+-------------------+ | 6 | WriteMask | uint32 | +--------+--------------------------+-------------------+ | 7 | UserWriteMask | uint32 | +--------+--------------------------+-------------------+ | 8 | IsAbstract | boolean | +--------+--------------------------+-------------------+ | 9 | Symmetric | boolean | +--------+--------------------------+-------------------+ | 10 | InverseName | localizedText | +--------+--------------------------+-------------------+ | 11 | ContainsNoLoops | boolean | +--------+--------------------------+-------------------+ | 12 | EventNotifier | byte | +--------+--------------------------+-------------------+ | 13 | Value | DataValue | +--------+--------------------------+-------------------+ | 14 | DataType | NodeID | +--------+--------------------------+-------------------+ | 15 | Rank | int32 | +--------+--------------------------+-------------------+ | 16 | ArrayDimensions | int32[] | +--------+--------------------------+-------------------+ | 17 | AccessLevel | byte | +--------+--------------------------+-------------------+ | 18 | UserAccessLevel | byte | +--------+--------------------------+-------------------+ | 19 | MinimumSamplingInterval | double | +--------+--------------------------+-------------------+ | 20 | Historizing | boolean | +--------+--------------------------+-------------------+ | 21 | Executable | boolean | +--------+--------------------------+-------------------+ | 22 | UserExecutable | boolean | +--------+--------------------------+-------------------+ | 23 | DataTypeDefinition | nodeID | +--------+--------------------------+-------------------+ | 24 | RolePermissions | structure (TBD) | +--------+--------------------------+-------------------+ | 25 | UserRolePermissions | structure (TBD) | +--------+--------------------------+-------------------+ | 26 | AccessRestrictions | uint16 | +--------+--------------------------+-------------------+ | 27 | AccessLevelEx | uint32 | +--------+--------------------------+-------------------+