High Performance OPC UA Server SDK
1.7.1.383
|
OPC UA Variants can store scalar values, arrays, multidimensional arrays (aka matrix) and also nested arrays. A nested array is simply an array of type UA_VT_VARIANT, where each elements is again an array. This allows to use different array lengths for each element (hence the name "jagged array") and also different types.
The following example shows how to create such an array using ua_variant utility functions.
The downside of the example above are the memory allocations and deep-copy operations, which are not efficient in terms of performance or resource consumption. When you need better efficiency you can make use of ua_variant_attach_array as shown in the next example.
This avoids the deep copy of the ua_variant_set_array call, but still you have the copy operations of the single array variables. It is possible to replace this as well using ua_variant_attach_array function. But this would require to dynamically allocate all the variables (ints5, ints4, ints4, floats5, floats4), which would make the code more complicated.