C++ UA Server SDK  1.5.0.318
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages

The class encapsulates the OPC UA data type StatusCodes and conversions from and to Classic OPC codes. More...

#include <statuscode.h>

Inherited by UaStatus.

Public Member Functions

 UaStatusCode ()
 Construction of the status code class with initial value Good. More...
 
 UaStatusCode (const OpcUa_StatusCode &other)
 Construction of the status code class with passed code as initial value. More...
 
 ~UaStatusCode ()
 Destruction of status code class.
 
UaStatusCodeoperator= (const OpcUa_StatusCode &other)
 Implements the operator = for UaStatusCode. More...
 
UaStatusCodeoperator= (const UaStatusCode &other)
 Implements the operator = for UaStatusCode. More...
 
bool operator== (const OpcUa_StatusCode &other)
 Implements the operator == for UaStatusCode. More...
 
bool operator== (const UaStatusCode &other)
 Implements the operator == for UaStatusCode. More...
 
bool operator!= (const OpcUa_StatusCode &other)
 Implements the operator == for UaStatusCode. More...
 
bool operator!= (const UaStatusCode &other)
 Implements the operator == for UaStatusCode. More...
 
OpcUa_Boolean isGood () const
 Checks if the status code is GOOD.
 
OpcUa_Boolean isNotGood () const
 Checks if the status code is not GOOD.
 
OpcUa_Boolean isUncertain () const
 Checks if the status code is UNCERTAIN.
 
OpcUa_Boolean isNotUncertain () const
 Checks if the status code is not UNCERTAIN.
 
OpcUa_Boolean isBad () const
 Checks if the status code is BAD.
 
OpcUa_Boolean isNotBad () const
 Checks if the status code is not BAD.
 
OpcUa_StatusCode statusCode () const
 Gets the full status code value.
 
OpcUa_StatusCode code () const
 Gets the code part (Severity + SubCode) of the status code value.
 
OpcUa_StatusCode infoType () const
 Gets the InfoType part of the status code value.
 
OpcUa_StatusCode infoBits () const
 Gets the InfoBits part of the status code value.
 
void setOverflowBits ()
 Sets the DataValue bit in the InfoType and the Overflow bit in the InfoBits. More...
 
void setStructureChangedBit ()
 Sets the StructureChanged bit in the status code value. More...
 
bool isStructureChanged () const
 Checks if the StructureChanged bit is set in the status code value. More...
 
void setSemanticsChangedBit ()
 Sets the SemanticsChanged bit in the status code value. More...
 
bool isSemanticsChanged () const
 Checks if the SemanticsChanged bit is set in the status code value. More...
 
void getResponseHeader (OpcUa_RequestHeader *requestHeader, OpcUa_ResponseHeader *responseHeader)
 Creates a response header for OPC UA service calls. More...
 
UaString toString () const
 Returns the string representation of the current OPC UA status code. More...
 

Static Public Member Functions

static UaString toString (OpcUa_StatusCode statusCode)
 Return string representation of a known OpcUa_StatusCode. More...
 
static OpcUa_StatusCode setComDaError (long comDaError)
 Set the status code with a COM DA error code. More...
 
static OpcUa_StatusCode setComDaQuality (unsigned short comDaQuality)
 Set the status code with a COM DA quality. More...
 
static OpcUa_StatusCode setComDaStatus (long comDaError, unsigned short comDaQuality)
 Set the status code with COM DA error and quality. More...
 
static void getComDaStatus (const OpcUa_StatusCode statusCode, long &comDaError, unsigned short &comDaQuality, bool isValueRelated=false)
 Get COM DA error and quality from the status code. More...
 

Detailed Description

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)

Constructor & Destructor Documentation

UaStatusCode::UaStatusCode ( )

Construction of the status code class with initial value Good.

UaStatusCode::UaStatusCode ( const OpcUa_StatusCode other)

Construction of the status code class with passed code as initial value.

Parameters
otherInitial status code value

Member Function Documentation

void UaStatusCode::getComDaStatus ( const OpcUa_StatusCode  statusCode,
long &  comDaError,
unsigned short &  comDaQuality,
bool  isValueRelated = false 
)
static

Get COM DA error and quality from the status code.

Parameters
statusCodethe OPC UA Status code.
comDaErrora COM DA error.
comDaQualitya COM DA quality.
isValueRelatedflag indicating if the status code is related to service level or to value/operation.
void UaStatusCode::getResponseHeader ( OpcUa_RequestHeader requestHeader,
OpcUa_ResponseHeader responseHeader 
)

Creates a response header for OPC UA service calls.

Parameters
requestHeaderthe request header.
responseHeaderthe response header.
bool UaStatusCode::isSemanticsChanged ( ) const
inline

Checks if the SemanticsChanged bit is set in the status code value.

bool UaStatusCode::isStructureChanged ( ) const
inline

Checks if the StructureChanged bit is set in the status code value.

bool UaStatusCode::operator!= ( const OpcUa_StatusCode other)

Implements the operator == for UaStatusCode.

Parameters
otherThe OpcUa_StatusCode to assign.
Returns
Assignment operator.
bool UaStatusCode::operator!= ( const UaStatusCode other)

Implements the operator == for UaStatusCode.

Parameters
otherthe UaStatusCode to assign.
Returns
Assignment operator.
UaStatusCode & UaStatusCode::operator= ( const OpcUa_StatusCode other)

Implements the operator = for UaStatusCode.

Parameters
otherThe OpcUa_StatusCode to assign.
Returns
Assignment operator.
UaStatusCode & UaStatusCode::operator= ( const UaStatusCode other)

Implements the operator = for UaStatusCode.

Parameters
otherthe UaStatusCode to assign.
Returns
Assignment operator.
bool UaStatusCode::operator== ( const OpcUa_StatusCode other)

Implements the operator == for UaStatusCode.

Parameters
otherThe OpcUa_StatusCode to assign.
Returns
Assignment operator.
bool UaStatusCode::operator== ( const UaStatusCode other)

Implements the operator == for UaStatusCode.

Parameters
otherthe UaStatusCode to assign.
Returns
Assignment operator.
OpcUa_StatusCode UaStatusCode::setComDaError ( long  comDaError)
static

Set the status code with a COM DA error code.

Parameters
comDaErrora COM DA error code.
Returns
the OPC UA Status Code
OpcUa_StatusCode UaStatusCode::setComDaQuality ( unsigned short  comDaQuality)
static

Set the status code with a COM DA quality.

Parameters
comDaQualitya COM DA quality.
Returns
the OPC UA Status Code
OpcUa_StatusCode UaStatusCode::setComDaStatus ( long  comDaError,
unsigned short  comDaQuality 
)
static

Set the status code with COM DA error and quality.

Parameters
comDaErrora COM DA error.
comDaQualitya COM DA quality.
Returns
the OPC UA Status Code
void UaStatusCode::setOverflowBits ( )
inline

Sets the DataValue bit in the InfoType and the Overflow bit in the InfoBits.

void UaStatusCode::setSemanticsChangedBit ( )
inline

Sets the SemanticsChanged bit in the status code value.

void UaStatusCode::setStructureChangedBit ( )
inline

Sets the StructureChanged bit in the status code value.

UaString UaStatusCode::toString ( ) const

Returns the string representation of the current OPC UA status code.

Returns
The symbolic name for the passed status code
UaString UaStatusCode::toString ( OpcUa_StatusCode  statusCode)
static

Return string representation of a known OpcUa_StatusCode.

Returns
The symbolic name for the passed status code

The documentation for this class was generated from the following files: