The class encapsulates the OPC UA data type StatusCodes and conversions from and to Classic OPC codes.
More...
The class encapsulates the OPC UA data type StatusCodes and conversions from and to Classic OPC codes.
A StatusCode in OPC UA is a 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 Client applications with enough information to make decisions on how to process the results of an OPC UA Service.
The derived class UaStatus is used to combine the StatusCode with associated diagnostic information in one object.
The StatusCode is 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 Clients shall always check the StatusCode associated 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 Servers should return good/success StatusCodes if the operation completed normally and the result is always valid. Different StatusCode values can provide additional information to the Client.
OPC UA Servers should use uncertain/warning StatusCodes if they could not complete the operation in the manner requested by the Client, however, the operation did not fail entirely.
The codes for the top 16 bits of the StatusCode are defined by the OPC UA specification and it is not allowed to extend these codes with application specific codes. Application specific codes must be provided in the diagnostic information.
All OPC UA defined codes have a symbolic name and a numeric value. The SDK provides defines with the symbolic name for the defined codes. The general defines are OpcUa_Good and OpcUa_Bad. All defines for the other more specific good codes start with OpcUa_Good like OpcUa_GoodMoreData. All defines for the other more specific bad codes start with OpcUa_Bad like OpcUa_BadInvalidArgument.
The method UaStatusCode::toString() returns the symbolic name for a status code value.
The following table contains the StatusCode bit assignments.
Field | Bit Range | Description |
Severity | 30:31 | Indicates whether the StatusCode represents a good (00), bad (10), or uncertain (01) condition. |
Reserved | 29: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. |
StructureChanged | 15:15 | Indicates that the structure of the associated data value has changed since the last Notification. Clients should not process the data value unless they reread the metadata. See detailed description after the table. |
SemanticsChanged | 14:14 | Indicates that the semantics of the associated data value have changed. Clients should not process the data value until they reread the metadata associated with the Variable. See detailed description after the table. |
Reserved | 12:13 | Reserved for future use. Shall always be zero. |
InfoType | 10:11 | The type of information contained in the info bits. The valid options are NotUsed (00) and DataValue (01). All other options are reserved for future use. |
InfoBits | 0:9 | Additional information bits that qualify the StatusCode. The structure of these bits depends on the Info Type field. |
The StructureChanged flag indicates that the structure of the associated data value has changed since the last Notification. Clients should not process the data value unless they reread the metadata. Servers shall set this bit if the structure data type used for a Variable changes. The bit is also set if the data type Attribute of the Variable changes. A Variable with data type BaseDataType does not require the bit to be set when the data type changes. Servers shall also set this bit if the ArrayDimensions or the ValueRank Attribute or the EnumStrings Property of the DataType of the Variable changes. This bit is provided to warn Clients that parse structure data type values that their parsing routines could fail because the serialized form of the data value has changed. This bit has meaning only for StatusCodes returned as part of a data change Notification or the HistoryRead. StatusCodes used in other contexts shall always set this bit to zero.
The SemanticsChanged flag indicates that the semantics of the associated data value have changed. Clients should not process the data value until they reread the metadata associated with the Variable. Servers should set this bit if the metadata has changed in way that could cause application errors if the Client does not reread the metadata. For example, a change to the engineering units could create problems if the Client uses the value to perform calculations. Data Access variable type defines the conditions where a Server shall set this bit for a DA Variable. Other specifications may define additional conditions. A Server may define other conditions that cause this bit to be set. This bit has meaning only for StatusCodes returned as part of a data change Notification or the HistoryRead. StatusCodes used in other contexts shall always set this bit to zero.
The following table contains the DataValue InfoBits
Info Type | Bit Range | Description |
LimitBits | 8:9 | The limit bits associated with the data value. The limits bits have the meanings
- None (00)
- The value is free to change,
- Low (01)
- The value is at the lower limit for the data source,
- High (02)
- The value is at the higher limit for the data source,
- Constant (11)
- The value is constant and cannot change.
|
Overflow | 7:7 | If this bit is set, not every detected change has been returned since the Server’s queue buffer for the MonitoredItem reached 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 Client uses the data value. The historian bits have the 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),
- 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 aggregate criteria (i.e. multiple minimum values at different timestamps within the same interval)
|