High Performance OPC UA Server SDK  1.7.1.383
ua_statuscode

A numerical value that is used to report the outcome of an operation performed by an OPC UA Server. More...

Macros

#define UA_SCGOOD   0x00000000
 Generic good status code. More...
 
#define UA_SCUNCERTAIN   0x40000000
 Generic uncertain status code. More...
 
#define UA_SEVERITY_MASK   0xC0000000
 for marking out the severity
 
#define UA_SUBCODE_MASK   0x0FFF0000
 for marking out the sub code
 

Typedefs

typedef uint32_t ua_statuscode
 A numerical value indicating outcome of an UA server operation, possible values are listed in ua_statuscodes.
 

Functions

static void ua_statuscode_init (ua_statuscode *dt)
 Initialize statuscode with good.
 
static void ua_statuscode_clear (ua_statuscode *dt)
 Clear statuscode and write good.
 
static int ua_statuscode_compare (const ua_statuscode *a, const ua_statuscode *b)
 Compare two statuscodes. More...
 
static int ua_statuscode_copy (ua_statuscode *dst, const ua_statuscode *src)
 Copy statuscode from src to dst. More...
 
static bool ua_statuscode_is_good (ua_statuscode status)
 Test if a statuscode is good.
 
static bool ua_statuscode_is_uncertain (ua_statuscode status)
 Test if a statuscode is uncertain.
 
static bool ua_statuscode_is_bad (ua_statuscode status)
 Test if a statuscode is bad.
 
static ua_statuscode ua_statuscode_get_code (ua_statuscode status)
 Get severity and sub code portion of a status code.
 
static uint16_t ua_statuscode_get_code_to_uint16 (ua_statuscode status)
 Get severity and sub code portion of a status code as unit16 value. More...
 
static ua_statuscode ua_statuscode_from_uint16_code (uint16_t code)
 Creates a 32bit status code with severity from the 16bit sub code. More...
 
BASE_EXPORT ua_statuscode ua_statuscode_from_errorcode (int error_code)
 Map an internal errorcode to a ua_statuscode. More...
 
BASE_EXPORT const char * ua_statuscode_printable (ua_statuscode status)
 Returns a human readable string for the given statuscode. More...
 

Detailed Description

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 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 list of StatusCodes is managed by OPC UA. The complete list of StatusCodes is defined in Part 6 of the OPC UA Specification. Servers shall not define their own StatusCodes. OPC UA companion working groups may request additional StatusCodes from the OPC Foundation to be added to the list in Part 6.

Macro Definition Documentation

◆ UA_SCGOOD

#define UA_SCGOOD   0x00000000

Generic good status code.

◆ UA_SCUNCERTAIN

#define UA_SCUNCERTAIN   0x40000000

Generic uncertain status code.

Function Documentation

◆ ua_statuscode_compare()

static int ua_statuscode_compare ( const ua_statuscode a,
const ua_statuscode b 
)
inlinestatic

Compare two statuscodes.

Returns
Zero if both statuscodes are the same.

◆ ua_statuscode_copy()

static int ua_statuscode_copy ( ua_statuscode dst,
const ua_statuscode src 
)
inlinestatic

Copy statuscode from src to dst.

Returns
Zero on success.

◆ ua_statuscode_from_errorcode()

BASE_EXPORT ua_statuscode ua_statuscode_from_errorcode ( int  error_code)

Map an internal errorcode to a ua_statuscode.

This function maps an errorcode to an equivalent ua_statuscode or to a more generic ua_statuscode. Depending on the situation the same errorcode might be mapped to a different ua_statuscode, this must be done before calling this function, as it shall not map generic errorcodes to specialized statuscodes.

If no ua_statuscode matches or the input is UA_EBAD, then UA_SCBAD is returned. When the input is invalid or UA_EBADINTERNALERROR, then UA_SCBADINTERNALERROR is returned.

◆ ua_statuscode_from_uint16_code()

static ua_statuscode ua_statuscode_from_uint16_code ( uint16_t  code)
inlinestatic

Creates a 32bit status code with severity from the 16bit sub code.

This is the reverse operation of ua_statuscode_get_code_to_uint16.

◆ ua_statuscode_get_code_to_uint16()

static uint16_t ua_statuscode_get_code_to_uint16 ( ua_statuscode  status)
inlinestatic

Get severity and sub code portion of a status code as unit16 value.

This is required to store in statuscode in UA PubSub messages.

See also
ua_statuscode_from_uint16_code

◆ ua_statuscode_printable()

BASE_EXPORT const char* ua_statuscode_printable ( ua_statuscode  status)

Returns a human readable string for the given statuscode.

The returned pointer is always valid and can be used in TRACE or printf commands. If the statuscode is not known the string "<Unknown Statuscode>" is returned.