OPC UA Binary Data Encoding
The OPC UA Binary Data Encoding
is a data format which has been developed to meet the performance demands of OPC UA applications. This format is primarily designed for fast encoding and decoding, whereby the size of the encoded data on the line has also been taken into account.
OPC UA binary data encoding is based on several primitive data types with clearly defined encoding rules that can be sequentially written to or read from a binary stream.
A structure is encoded by sequentially writing the encoded form of each field. If a particular field is also a structure, then the values of its fields are written sequentially before the next field is written to the containing structure.
All fields must be written to the data stream, even if they contain zero values. The encodings for each primitive type indicate how to encode either a zero value or a default value for the type.
The OPC UA binary data encoding does not contain any type or field name information because all OPC UA applications are expected to know in advance which services and structures they support.
[P6] 5.2.1:
"The terms OPC UA Binary Data Encoding
and Raw Data Field Encoding
have the same meaning and are used accordingly depending on the cited source."
IEC 61131-3 | [P6] 5.2.1 | OPC UA | References | |
---|---|---|---|---|
| Boolean value | 1 |
| [P6] 5.2.2.1 |
| Byte | 3 |
| |
| Single-byte character | 3 |
| |
| Date (only) | 13 |
| |
| Double integer | 6 |
| |
| Date and time of day [s] | 13 |
| [P6] 5.2.2.5 |
| Bit string of length 32 | 7 |
| |
| Integer | 4 |
| [P6] 5.2.2.1 |
| Long date [ns] | 8 |
| |
| Date and time of day [ns] | 8 |
| |
| Long integer | 8 |
| |
| Long floating-point number | 11 |
| |
| Duration [ns] | 8 |
| |
| Time of day [ns] | 8 |
| |
| Bit string of length 64 | 9 |
| |
| Floating-point number | 10 |
| [P6] 5.2.2.3 |
| Short integer | 2 |
| |
| Coding: Windows-1252 | 12 |
| [P6] 5.2.2.4 |
| Duration [ms] | 8 |
| |
| Time of day [ms] | 7 |
| |
| 19 |
| [P6] 5.2.2.11 | |
|
| [P4] 7.38 | ||
| Unsigned double integer | 7 |
| |
| Unsigned integer | 5 |
| |
| Unsigned Iong integer | 9 |
| |
| Unsigned short integer | 3 |
| |
| Double-byte character | 5 |
| |
| Bit string of length 16 | 5 |
| |
| Coding: UCS-2 | 12 |
|
String
The length of an OPC UA string cannot be determined in advance due to its UTF 8 encoding. It depends on the characters used. Therefore, a maximum length must be specified when defining a DataSetField
of this data type. The remaining space is filled with 0 value bytes. The maximum length of a string (maxStringLength
) is described in [P14] 6.2.2.1.3 FieldMetaData
.
StatusCode
The variable StatusCode
is encoded as UInt32
.
VersionTime
The variable VersionTime
is encoded as UInt32
. It shows the time in seconds since the year 2000. The epoch date is midnight UTC (00:00) on January 1, 2000. It is used as a version number based on the last modification time. If the version is updated, then the new value must be greater than the previous value. The value 0 is used to indicate that no version information is available.