Data Types
This page summarizes the Lua representations used by the OPC UA stack. Values are ordinary Lua values unless a table structure is shown.
Built-in Types
OPC UA type |
Lua representation |
Notes |
|---|---|---|
|
number |
Signed 8-bit integer. |
|
number |
Unsigned 8-bit integer. |
|
number |
Signed 16-bit integer. |
|
number |
Unsigned 16-bit integer. |
|
number |
Signed 32-bit integer. |
|
number |
Unsigned 32-bit integer. |
|
number |
Signed 64-bit integer. |
|
number |
Unsigned 64-bit integer. |
|
number |
32-bit floating-point value. |
|
number |
64-bit floating-point value. |
|
number |
Unix timestamp in seconds, usually from |
|
string |
UTF-8 string. |
|
string |
Binary byte sequence stored in a Lua string. |
|
string |
GUID string, for example |
|
number |
OPC UA status code, for example |
LocalizedText
Localized text is represented as a table.
Field |
Type |
Description |
|---|---|---|
|
string, optional |
Locale name such as |
|
string |
Localized text content. |
local text = {Locale = "en-US", Text = "This is localized text"}
local textDefaultLocale = {Text = "This is localized text"}
QualifiedName
A QualifiedName is the service identifier of a node. It combines a namespace index with a name.
Field |
Type |
Description |
|---|---|---|
|
number |
Namespace index. |
|
string |
Name within the namespace. |
local qualifiedName = {ns = 1, Name = "Node Name"}
NodeId
A NodeId is encoded as a string:
[ns=<namespace_index>;]<type>=<value>
Part |
Value |
Description |
|---|---|---|
|
unsigned 16-bit integer |
Optional. Omit when the namespace index is |
|
|
Identifier type: integer, string, GUID, or opaque byte string. |
|
type-specific string |
Decimal integer, UTF-8 string, lowercase GUID, or base64 byte string. |
Type code |
Identifier type |
Example |
|---|---|---|
|
Integer |
|
|
String |
|
|
GUID |
|
|
Opaque byte string |
|
Additional examples are available in node_id.lua. The official syntax is described in the OPC Foundation NodeId reference.
NodeId helpers
Function |
Parameters |
Return value |
|---|---|---|
|
|
Encoded NodeId string. |
|
Table form of the same parameters. |
Encoded NodeId string. |
|
Encoded NodeId string. |
Table with |
Variant
A Variant wraps a value with an OPC UA type. It can represent a scalar or an array.
Field |
Type |
Description |
|---|---|---|
|
|
Type of the stored value. |
|
any supported Lua value |
Value to encode. |
|
boolean, optional |
Set to |
|
number array, optional |
Dimensions for array values. |
local uint32 = {Type = ua.VariantType.UInt32, Value = 0}
local uint32Array = {
Type = ua.VariantType.UInt32,
Value = {1, 2, 3, 4},
IsArray = true,
ArrayDimensions = {4}
}
VariantType constants
Name |
Value |
Name |
Value |
|---|---|---|---|
|
0 |
|
1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
DataValue
A DataValue is a Variant value plus optional status and timestamp fields.
Field |
Type |
Description |
|---|---|---|
|
|
Type of |
|
any supported Lua value |
Value to encode. |
|
status code, optional |
Value status, for example |
|
DateTime, optional |
Source timestamp. |
|
DateTime, optional |
Server timestamp. |
|
UInt16, optional |
Fractional source timestamp precision. |
|
UInt16, optional |
Fractional server timestamp precision. |
local dataValue = {
Type = ua.VariantType.UInt32,
Value = 100,
StatusCode = ua.StatusCode.Good,
SourceTimestamp = os.time()
}
ExtensionObject
An ExtensionObject represents a structured value. It is also used when a field
can contain one of several structure types, such as node attributes for
AddNodes.
Field |
Type |
Description |
|---|---|---|
|
NodeId of the structure type. This is the decoded structure NodeId, not the binary, XML, or JSON encoding NodeId. |
|
|
table, ByteString, XML string, or JSON string |
Decoded body table when the structure is known. Otherwise, the body is left opaque and must be decoded by application code. |
local extensionObject = {
TypeId = "i=338", -- BuildInfo
Body = {
ProductUri = ua.Version.ProductUri,
ManufacturerName = ua.Version.ManufacturerName,
ProductName = ua.Version.ProductName,
SoftwareVersion = ua.Version.Version,
BuildNumber = ua.Version.BuildNumber,
BuildDate = compat.gettime()
}
}
Service Structures
ActivateSessionResponse
Field |
Type |
Description |
|---|---|---|
|
ByteString |
Random value that should not be reused. |
|
StatusCode array |
User identity token validation results. |
AddNodesResponse
Field |
Type |
Description |
|---|---|---|
|
array |
One result per requested node. |
|
StatusCode |
Status of the add operation. |
|
Server-assigned NodeId, or |
BrowseParameters
Field |
Type |
Description |
|---|---|---|
|
UInt32 |
Maximum number of references to return. |
|
array |
Nodes to browse. |
|
Node to browse. |
|
|
Reference type to follow. |
|
|
|
Browse direction. |
|
|
Node classes to include. |
|
|
Fields to include in the response. |
|
boolean |
Include subtypes of |
BrowseResult
Field |
Type |
Description |
|---|---|---|
|
array |
One result per requested node. |
|
StatusCode |
Browse status for the requested node. |
|
array |
References returned by the browse operation. |
|
Target node identifier. |
|
|
Reference type identifier. |
|
|
boolean |
Reference direction. |
|
Service name of the node. |
|
|
User-facing node label. |
|
|
Int32 |
Node class. |
|
Node type definition. |
CloseSecureChannelResponse
Empty table.
CloseSessionResponse
Empty table.
CreateSessionResponse
Field |
Type |
Description |
|---|---|---|
|
table |
Standard OPC UA response header. |
|
Unique NodeId assigned by the server to the session. |
|
|
Unique token assigned by the server to the session. |
|
|
Double |
Actual maximum session idle time in milliseconds. |
|
ByteString |
Random value that should not be reused in another request. |
|
ByteString |
Server application instance certificate. |
|
array |
Endpoint descriptions supported by the server. |
|
table |
Signature generated with the server certificate private key. |
|
UInt32 |
Maximum request body size in bytes. |
FindServersResponse
Field |
Type |
Description |
|---|---|---|
|
array |
Servers that match the request criteria. |
|
string |
Application URI. |
|
string |
Product URI. |
|
Human-readable application name. |
|
|
number |
OPC UA application type. |
|
string |
Gateway server URI, if used. |
|
string |
Discovery profile URI, if used. |
|
string array |
Discovery endpoint URLs. |
GetEndpointsResponse
Field |
Type |
Description |
|---|---|---|
|
array |
Endpoint descriptions. |
|
string |
Endpoint URL. |
|
table |
Server application description. |
|
ByteString |
Server certificate. |
|
number |
Message security mode. |
|
string |
Security policy URI. |
|
array |
Supported user identity token policies. |
|
string |
Transport profile URI. |
|
Byte |
Relative endpoint security level. |
OpenSecureChannelResponse
Field |
Type |
Description |
|---|---|---|
|
table |
Standard OPC UA response header. |
|
table |
Secure channel token. |
|
UInt32 |
Unique SecureChannel identifier. |
|
UInt32 |
Unique token identifier within the channel. |
|
DateTime |
Token creation time. |
|
UInt32 |
Token lifetime in milliseconds. |
ReadResponse
Field |
Type |
Description |
|---|---|---|
|
DataValue array |
Attribute values returned by the server. |
WriteResponse
Field |
Type |
Description |
|---|---|---|
|
StatusCode array |
Results for the nodes written by the request. |