A StatusCodein OPC UA is numerical value that is used to report the outcome of an operation performed by an OPC UA Server. This code may have associated diagnostic information that describes the status in more detail; however, the code by itself is intended to provide Clientapplications with enough information to make decisions on how to process the results of an OPC UA Service.

The StatusCodeis a 32-bit unsigned integer. The top 16 bits represent the numeric value of the code that shall be used for detecting specific errors or conditions. The bottom 16 bits are bit flags that contain additional information but do not affect the meaning of the StatusCode.

All OPC UA Clientsshall always check the StatusCodeassociated with a result before using it. Results that have an uncertain/warning status associated with them shall be used with care since these results might not be valid in all situations. Results with a bad/failed status shall never be used.

OPC UA Serversshould return good/success StatusCodesif the operation completed normally and the result is always valid. Different StatusCodevalues can provide additional information to the Client.

OPC UA Serversshould use uncertain/warning StatusCodesif they could not complete the operation in the manner requested by the Client, however, the operation did not fail entirely.

The list of StatusCodesis managed by OPC UA. The complete list of StatusCodesis defined in OPC 10000-6. Serversshall not define their own StatusCodes. OPC UA companion working groups may request additional StatusCodesfrom the OPC Foundation to be added to the list in OPC 10000-6.

The exact bit assignments are shown in Table 180.

Table 180– StatusCode bit assignments

Field

Bit Range

Description

Severity

30:31

Indicates whether the StatusCoderepresents a good, bad or uncertain condition. These bits have the following meanings:

Good Success

00

Indicates that the operation was successful and the associated results may be used.

Uncertain Warning

01

Indicates that the operation was partially successful and that associated results might not be suitable for some purposes.

Bad Failure

10

Indicates that the operation failed and any associated results cannot be used.

Reserved

11

Reserved for future use. All Clientsshould treat a StatusCodewith this severity as “Bad”.

Reserved

29:29

Reserved for use in OPC UA application specific APIs. This bit shall always be zero on the wire but may be used by OPC UA application specific APIs for API specific status codes.

Reserved

28:28

Reserved for future use. Shall always be zero.

SubCode

16:27

The code is a numeric value assigned to represent different conditions. Each code has a symbolic name and a numeric value. All descriptions in the OPC UA specification refer to the symbolic name. OPC 10000-6maps the symbolic names onto a numeric value.

StructureChanged

15:15

Indicates that the structure of the associated data value has changed since the last Notification. Clientsshould not process the data value unless they re-read the metadata.

Serversshall set this bit if the DataTypeEncodingused for a Variablechanges. 7.29describes how the DataTypeEncodingis specified for a Variable.

Serversshall also set this bit if the EnumStrings Propertyof the DataTypeof the Variablechanges.

This bit is provided to warn Clientsthat parse complex data values that their parsing routines could fail because the serialized form of the data value has changed.

This bit has meaning only for StatusCodesreturned as part of a data change Notificationor the HistoryRead. StatusCodesused in other contexts shall always set this bit to zero.

The bit is set on one data change Notification per MonitoredItem that samples values at the time the structure change happened. If the data change notification with the bit set is deleted because of a queue overflow, the bit must be set on the next data change notification in the queue.

SemanticsChanged

14:14

Indicates that the semantics of the associated data value have changed. Clientsshould not process the data value until they re-read the metadata associated with the Variable.

Serversshould set this bit if the metadata has changed in way that could cause application errors if the Clientdoes not re-read the metadata. For example, a change to the engineering units could create problems if the Clientuses the value to perform calculations.

OPC 10000-8defines the conditions where a Servershall set this bit for a DA Variable. Other specifications may define additional conditions. A Servermay define other conditions that cause this bit to be set.

This bit has meaning only for StatusCodesreturned as part of a data change Notificationor the HistoryRead. StatusCodesused in other contexts shall always set this bit to zero.

The bit is set on one data change Notification per MonitoredItem that samples values at the time the semantic change happened. If the data change notification with the bit set is deleted because of a queue overflow, the bit must be set on the next data change notification in the queue.

Reserved

12:13

Reserved for future use. Shall always be zero.

InfoType

10:11

The type of information contained in the info bits. These bits have the following meanings:

NotUsed

00

The info bits are not used and shall be set to zero.

DataValue

01

The StatusCodeand its info bits are associated with a data value returned from the Server. The info bits are defined in Table 181.

Reserved

1X

Reserved for future use. The info bits shall be ignored.

InfoBits

0:9

Additional information bits that qualify the StatusCode.

The structure of these bits depends on the Info Type field.

Table 181describes the structure of the InfoBitswhen the Info Type is set to DataValue(01).

Table 181– DataValue InfoBits

Info Type

Bit Range

Description

LimitBits

8:9

The limit bits associated with the data value. The limits bits have the following meanings:

Limit

Bits

Description

None

00

The value is free to change.

Low

01

The value is at the lower limit for the data source.

High

10

The value is at the higher limit for the data source.

Constant

11

The value is constant and cannot change.

Overflow

7

This bit shall only be set if the MonitoredItemqueue size is greater than 1.

If this bit is set, not every detected change has been returned since the Server’s queue buffer for the MonitoredItemreached its limit and had to purge out data.

Reserved

5:6

Reserved for future use. Shall always be zero.

HistorianBits

0:4

These bits are set only when reading historical data. They indicate where the data value came from and provide information that affects how the Clientuses the data value. The historian bits have the following meaning:

Raw

XXX00

A raw data value.

Calculated

XXX01

A data value which was calculated.

Interpolated

XXX10

A data value which was interpolated.

Reserved

XXX11

Undefined.

Partial

XX1XX

A data value which was calculated with an incomplete interval.

Extra Data

X1XXX

A raw data value that hides other data at the same timestamp.

Multi Value

1XXXX

Multiple values match the Aggregatecriteria (i.e. multiple minimum values at different timestamps within the same interval).

OPC 10000-11describes how these bits are used in more detail.