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 NodeId The identifier of a node
attributeId uint32 Node Attribute

Read Example

-- Reading server's current time and product version.
local nodes = {
  nodesToRead = {
    {
      nodeId = ua.NodeIds.Server_ServerStatus_CurrentTime,
      attributeId = ua.Types.AttributeId.Value
    },
    {
      nodeId = ua.NodeIds.Server_ServerStatus_BuildInfo_SoftwareVersion,
      attributeId = ua.Types.AttributeId.Value
    },
  }
}

local results = services:read(nodes)
for i,result = 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 NodeId The identifier of a node
attributeId uint32 Node Attribute
value DataValue New value of the attribute

Write example

local nodes = {
    nodesToWrite = {
      {
        nodeId = ua.NodeIds.Server_ServerStatus_StartTime,
        attributeId = AttributeId.Value,
        value = {   -- DataValue
          value = { -- Variant
            dateTime = 0.0
          }
        }
      }
    }
  }

local results = svc:write(nodes)
if results[1] ~= ua.StatusCode.Good then
  print(string.format("Changing attribute value failed: 0x%X", resp.results[1]))
  return
end

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