|
@@ -1,6 +1,6 @@
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
-* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
-* file, You can obtain one at http://mozilla.org/MPL/2.0/.*/
|
|
|
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.*/
|
|
|
|
|
|
#ifndef UA_TYPES_H_
|
|
#ifndef UA_TYPES_H_
|
|
#define UA_TYPES_H_
|
|
#define UA_TYPES_H_
|
|
@@ -24,34 +24,16 @@ extern "C" {
|
|
* generated from standard XML definitions. Their exact definitions can be
|
|
* generated from standard XML definitions. Their exact definitions can be
|
|
* looked up at https://opcfoundation.org/UA/schemas/Opc.Ua.Types.bsd.xml.
|
|
* looked up at https://opcfoundation.org/UA/schemas/Opc.Ua.Types.bsd.xml.
|
|
*
|
|
*
|
|
- * Note that arrays can only be part of a scalar data type and never constitute
|
|
|
|
- * a data type on their own. Also, open62541 does not implement unions so far.
|
|
|
|
- * They are a recent addition to the protocol (since OPC UA v1.03). And so far,
|
|
|
|
- * no service definition makes of unions in the request / response message
|
|
|
|
- * definition. Instead, :ref:`Variants <variant>` are used when values of
|
|
|
|
- * different types are possible.
|
|
|
|
|
|
+ * For users that are new to open62541, take a look at the :ref:`tutorial for
|
|
|
|
+ * working with data types<types-tutorial>` before diving into the
|
|
|
|
+ * implementation details.
|
|
*
|
|
*
|
|
- * All data types ``T`` (builtin and generated) share the same basic API for
|
|
|
|
- * creation, copying and deletion:
|
|
|
|
- *
|
|
|
|
- * - ``void T_init(T *ptr)``: Initialize the data type. This is synonymous with
|
|
|
|
- * zeroing out the memory, i.e. ``memset(ptr, 0, sizeof(T))``.
|
|
|
|
- * - ``T* T_new()``: Allocate and return the memory for the data type. The
|
|
|
|
- * value is already initialized.
|
|
|
|
- * - ``UA_StatusCode T_copy(const T *src, T *dst)``: Copy the content of the
|
|
|
|
- * data type. Returns ``UA_STATUSCODE_GOOD`` or
|
|
|
|
- * ``UA_STATUSCODE_BADOUTOFMEMORY``.
|
|
|
|
- * - ``void T_deleteMembers(T *ptr)``: Delete the dynamically allocated content
|
|
|
|
- * of the data type and perform a ``T_init`` to reset the type.
|
|
|
|
- * - ``void T_delete(T *ptr)``: Delete the content of the data type and the
|
|
|
|
- * memory for the data type itself. */
|
|
|
|
|
|
+ * Builtin Types
|
|
|
|
+ * ------------- */
|
|
|
|
|
|
#define UA_BUILTIN_TYPES_COUNT 25U
|
|
#define UA_BUILTIN_TYPES_COUNT 25U
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Builtin Types
|
|
|
|
- * -------------
|
|
|
|
- *
|
|
|
|
* Boolean
|
|
* Boolean
|
|
* ^^^^^^^
|
|
* ^^^^^^^
|
|
* A two-state logical value (true or false). */
|
|
* A two-state logical value (true or false). */
|
|
@@ -196,6 +178,8 @@ UA_STRING(char *chars) {
|
|
#define UA_STRING_ALLOC(CHARS) UA_String_fromChars(CHARS)
|
|
#define UA_STRING_ALLOC(CHARS) UA_String_fromChars(CHARS)
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * .. _datetime:
|
|
|
|
+ *
|
|
* DateTime
|
|
* DateTime
|
|
* ^^^^^^^^
|
|
* ^^^^^^^^
|
|
* An instance in time. A DateTime value is encoded as a 64-bit signed integer
|
|
* An instance in time. A DateTime value is encoded as a 64-bit signed integer
|
|
@@ -256,8 +240,10 @@ UA_EXPORT extern const UA_Guid UA_GUID_NULL;
|
|
typedef UA_String UA_ByteString;
|
|
typedef UA_String UA_ByteString;
|
|
|
|
|
|
static UA_INLINE UA_Boolean
|
|
static UA_INLINE UA_Boolean
|
|
-UA_ByteString_equal(const UA_ByteString *string1, const UA_ByteString *string2) {
|
|
|
|
- return UA_String_equal((const UA_String*)string1, (const UA_String*)string2);
|
|
|
|
|
|
+UA_ByteString_equal(const UA_ByteString *string1,
|
|
|
|
+ const UA_ByteString *string2) {
|
|
|
|
+ return UA_String_equal((const UA_String*)string1,
|
|
|
|
+ (const UA_String*)string2);
|
|
}
|
|
}
|
|
|
|
|
|
/* Allocates memory of size length for the bytestring.
|
|
/* Allocates memory of size length for the bytestring.
|
|
@@ -504,11 +490,11 @@ typedef struct UA_NumericRange UA_NumericRange;
|
|
#define UA_EMPTY_ARRAY_SENTINEL ((void*)0x01)
|
|
#define UA_EMPTY_ARRAY_SENTINEL ((void*)0x01)
|
|
|
|
|
|
typedef enum {
|
|
typedef enum {
|
|
- UA_VARIANT_DATA, /* The data has the same lifecycle as the
|
|
|
|
- variant */
|
|
|
|
- UA_VARIANT_DATA_NODELETE, /* The data is "borrowed" by the variant and
|
|
|
|
- shall not be deleted at the end of the
|
|
|
|
- variant's lifecycle. */
|
|
|
|
|
|
+ UA_VARIANT_DATA, /* The data has the same lifecycle as the
|
|
|
|
+ variant */
|
|
|
|
+ UA_VARIANT_DATA_NODELETE, /* The data is "borrowed" by the variant and
|
|
|
|
+ shall not be deleted at the end of the
|
|
|
|
+ variant's lifecycle. */
|
|
} UA_VariantStorageType;
|
|
} UA_VariantStorageType;
|
|
|
|
|
|
typedef struct {
|
|
typedef struct {
|
|
@@ -650,13 +636,13 @@ UA_Variant_setRangeCopy(UA_Variant *v, const void *array,
|
|
* are described. If the received data type is unkown, the encoded string and
|
|
* are described. If the received data type is unkown, the encoded string and
|
|
* target NodeId is stored instead of the decoded value. */
|
|
* target NodeId is stored instead of the decoded value. */
|
|
typedef enum {
|
|
typedef enum {
|
|
- UA_EXTENSIONOBJECT_ENCODED_NOBODY = 0,
|
|
|
|
- UA_EXTENSIONOBJECT_ENCODED_BYTESTRING = 1,
|
|
|
|
- UA_EXTENSIONOBJECT_ENCODED_XML = 2,
|
|
|
|
- UA_EXTENSIONOBJECT_DECODED = 3,
|
|
|
|
- UA_EXTENSIONOBJECT_DECODED_NODELETE = 4 /* Don't delete the content
|
|
|
|
- together with the
|
|
|
|
- ExtensionObject */
|
|
|
|
|
|
+ UA_EXTENSIONOBJECT_ENCODED_NOBODY = 0,
|
|
|
|
+ UA_EXTENSIONOBJECT_ENCODED_BYTESTRING = 1,
|
|
|
|
+ UA_EXTENSIONOBJECT_ENCODED_XML = 2,
|
|
|
|
+ UA_EXTENSIONOBJECT_DECODED = 3,
|
|
|
|
+ UA_EXTENSIONOBJECT_DECODED_NODELETE = 4 /* Don't delete the content
|
|
|
|
+ together with the
|
|
|
|
+ ExtensionObject */
|
|
} UA_ExtensionObjectEncoding;
|
|
} UA_ExtensionObjectEncoding;
|
|
|
|
|
|
typedef struct {
|
|
typedef struct {
|
|
@@ -721,10 +707,28 @@ typedef struct UA_DiagnosticInfo {
|
|
*
|
|
*
|
|
* Generic Type Handling
|
|
* Generic Type Handling
|
|
* ---------------------
|
|
* ---------------------
|
|
- * The builtin types can be combined to data structures. All information about a
|
|
|
|
- * (structured) data type is stored in a ``UA_DataType``. The array ``UA_TYPES``
|
|
|
|
- * contains the description of all standard-defined types and is used for
|
|
|
|
- * handling of generic types. */
|
|
|
|
|
|
+ *
|
|
|
|
+ * All information about a (builtin/structured) data type is stored in a
|
|
|
|
+ * ``UA_DataType``. The array ``UA_TYPES`` contains the description of all
|
|
|
|
+ * standard-defined types. This type description is used for the following
|
|
|
|
+ * generic operations that work on all types:
|
|
|
|
+ *
|
|
|
|
+ * - ``void T_init(T *ptr)``: Initialize the data type. This is synonymous with
|
|
|
|
+ * zeroing out the memory, i.e. ``memset(ptr, 0, sizeof(T))``.
|
|
|
|
+ * - ``T* T_new()``: Allocate and return the memory for the data type. The
|
|
|
|
+ * value is already initialized.
|
|
|
|
+ * - ``UA_StatusCode T_copy(const T *src, T *dst)``: Copy the content of the
|
|
|
|
+ * data type. Returns ``UA_STATUSCODE_GOOD`` or
|
|
|
|
+ * ``UA_STATUSCODE_BADOUTOFMEMORY``.
|
|
|
|
+ * - ``void T_deleteMembers(T *ptr)``: Delete the dynamically allocated content
|
|
|
|
+ * of the data type and perform a ``T_init`` to reset the type.
|
|
|
|
+ * - ``void T_delete(T *ptr)``: Delete the content of the data type and the
|
|
|
|
+ * memory for the data type itself.
|
|
|
|
+ *
|
|
|
|
+ * Specializations, such as ``UA_Int32_new()`` are derived from the generic
|
|
|
|
+ * type operations as static inline functions.
|
|
|
|
+ */
|
|
|
|
+
|
|
typedef struct {
|
|
typedef struct {
|
|
#ifdef UA_ENABLE_TYPENAMES
|
|
#ifdef UA_ENABLE_TYPENAMES
|
|
const char *memberName;
|
|
const char *memberName;
|
|
@@ -869,7 +873,7 @@ typedef struct {
|
|
UA_UInt32 min;
|
|
UA_UInt32 min;
|
|
UA_UInt32 max;
|
|
UA_UInt32 max;
|
|
} UA_NumericRangeDimension;
|
|
} UA_NumericRangeDimension;
|
|
-
|
|
|
|
|
|
+
|
|
struct UA_NumericRange {
|
|
struct UA_NumericRange {
|
|
size_t dimensionsSize;
|
|
size_t dimensionsSize;
|
|
UA_NumericRangeDimension *dimensions;
|
|
UA_NumericRangeDimension *dimensions;
|