04/09/2019
I have a few questions around reading and parsing the ValueRank and ArrayDimensions. So referring to Part 3, version 1.04 of the Spec., on page number 27, Table 13, I see the following:
ValueRank:
This Attribute indicates whether the Value Attribute of the Variable is an array and how many dimensions the array has. It may have the following values:
n > 1: the Value is an array with the specified number of dimensions.
OneDimension (1): The value is an array with one dimension. OneOrMoreDimensions (0): The value is an array with one or more dimensions.
Scalar (−1): The value is not an array.
Any (−2): The value can be a scalar or an array with any number of dimensions.
ScalarOrOneDimension (−3): The value can be a scalar or a one dimensional array.
All DataTypes are considered to be scalar, even if they have array-like semantics like ByteString and String.
ArrayDimensions:
This Attribute specifies the maximum supported length of each dimension. If the maximum is unknown the value shall be 0. The number of elements shall be equal to the value of the ValueRank Attribute. This Attribute shall be null if ValueRank ≤ 0.
For example, if a Variable is defined by the following C array: Int32 myArray[346];
then this Variable’s DataType would point to an Int32 and the Variable’s ValueRank has the value 1 and the ArrayDimensions is an array with one entry having the value 346.
The maximum number of elements of an array transferred on the wire is 2147483647 (max Int32).
I have the following sample data. For simplicity, I have discarded some data and the sample given below starts from ValueRank:
255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 5, 0, 0, 0, 95, 116
So the first 4 bytes which is 255, 255, 255, 255 would be the ValueRank which then evaluates to -1. The spec also says that if the ValueRank is <= 0 which in my case is, the ArrayDimensions shall be null. I’m not sure what this means, but looking at my example., I have another 4 bytes of 255, 255, 255, 255 which would also evaluate to -1. So does this mean that the ArrayDimensions is -1? Should I understand it like this?
Please help!
04/09/2019
The data is from an actual device! This is the OPC UA Pub Sub binary structure!
So the ValueRank in my case is -1 and you say the next set of elements with 255 255 255 255 could be a String? But what String is this? I thought I have to go sequentially as per the Specification when parsing the binary data. So the next element to be parsed as per Spec is the ArrayDimensions. So how do you say that this could be a second array? Where in the Spec is this said?
05/30/2017
The ValueRank does not appear as a literal value on the wire. It tells you what is put on the wire.
If the ValueRank >= 0 the wire encoding is a Int32 value with the Length followed by that number of elements.
In this case, -1 for the length means the array has no elements.
If the ValueRank == -1 then there is no Int32 length.
1 Guest(s)