Topic RSS10:25, EEST
March 16, 2017
OfflineHi all,
I’m trying to find out how to write single (or a range) of values to a multidimensional array. For the tests I’m using the Unified Automation Demo Server with the node ‘AllDataTypesStatic/StaticInt32Matrix’ in the namepace DemoNodeManager.
I’m able to write a full multidimensional array like:
Integer[][][] initial = {
{new Integer[] {0, 1, 2 }},
{new Integer[] {3, 4, 5 }},
{new Integer[] {6, 7, 8 }},
{new Integer[] {9, 10, 11}}
};
_client.writeValue(nodeId, initial);
So when reading this node I get the result as expected
LOGGER.info("readAndWriteMatrix(0): staticInt32Matrix value = " + Arrays.deepToString(value));
// readAndWriteMatrix(0): staticInt32Matrix value = [[[0, 1, 2]], [[3, 4, 5]], [[6, 7, 8]], [[9, 10, 11]]]
But what I did not find out yet is on how to modify just a single value or a range of values of the multidimensional array
e.g. just modify 0 to 100 or [0,1,2] to [100,101,102]
I’ve tried different stuff like the examples below, but I get the exceptions which I posted below each write operation:
_client.writeValue(nodeId, new Integer[] {100}, new NumericRange(new int[]{0,0,0}));
com.prosysopc.ua.StatusException: Bad_TypeMismatch (0x80740000) "The value supplied for the attribute is not of the same type as the attribute’s value." StatusCode=Bad_TypeMismatch (0x80740000) "The value supplied for the attribute is not of the same type as the attribute’s value."
_client.writeValue(nodeId, new Integer[][] {{100}}, new NumericRange(new int[]{0}));
com.prosysopc.ua.StatusException: Bad_IndexRangeNoData (0x80370000) "No data exists within the range of indexes specified." StatusCode=Bad_IndexRangeNoData (0x80370000) "No data exists within the range of indexes specified."
_client.writeValue(nodeId, new Integer[][] {{100}}, new NumericRange(new int[]{0,0,0}));
com.prosysopc.ua.StatusException: Bad_IndexRangeNoData (0x80370000) "No data exists within the range of indexes specified." StatusCode=Bad_IndexRangeNoData (0x80370000) "No data exists within the range of indexes specified."
Integer[][][] write = {
{new Integer[] {200, 201}},
{new Integer[] {300, 301}},
{new Integer[] {400, 401}}
};
_client.writeValue(nodeId, write, new NumericRange(new int[]{0, 1}, new int[]{2, 3}, new int[]{4, 5}));
com.prosysopc.ua.StatusException: Bad_IndexRangeNoData (0x80370000) "No data exists within the range of indexes specified." StatusCode=Bad_IndexRangeNoData (0x80370000) "No data exists within the range of indexes specified."
12:27, EEST
Moderators
February 11, 2020
Offline17:04, EEST
March 16, 2017
Offline20:09, EEST
December 21, 2011
OfflineAccording to the BuildInfo, it looks pretty old, so the first thing I would recommend to do is to update it to a newer version. You should be able to download a new one from Unified Automation
13:25, EEST
March 16, 2017
OfflineI’ll try with a newer version of the DemoServer,
but in general, what would be the syntax to set a single value in a multidimensional array?
So e.g. if I have following array:
staticInt32Matrix value = [[[0, 1, 2]], [[3, 4, 5]], [[6, 7, 8]], [[9, 10, 11]]]
and I would like to set the value 4 to e.g. 44
then what would be the correct syntax for the client.writeValue(….) call?
14:01, EEST
Moderators
February 11, 2020
OfflineHello,
You have a 3-dimensional array and the index of 4 is 0,1,1 or [0][1][1] depending on the notation you prefer. Indices in NumericRanges also start from 0, so the numeric range you need would be created by calling
new NumericRange(new int[] {0, 0}, new int[] {1, 1}, new int[] {1, 1})
This specifies a 3-dimensional NumericRange where the first and the last index for each dimension are same, which effectively selects exactly one entry from the entire 3-dimensional array.
You will also need to provide the value to be written as a 3-dimensional array where the length of each dimension is 1.
I attached a snippet from Wireshark demonstrating writing to a 3-dimensional array such that the value at index 0,1,0 is changed. The NumericRange is displayed as IndexRange in Wireshark. In your case, its value would be 0,1,1.
[0]: WriteValue
NodeId: NodeId
.... 0011 = EncodingMask: String (0x3)
Namespace Index: 3
Identifier String: Int32_3DMultidimensionalArray
AttributeId: Value (0x0000000d)
IndexRange: 0,1,0
Value: DataValue
EncodingMask: 0x01, has value
.... ...1 = has value: True
.... ..0. = has statuscode: False
.... .0.. = has source timestamp: False
.... 0... = has server timestamp: False
...0 .... = has source picoseconds: False
..0. .... = has server picoseconds: False
Value: Variant
Variant Type: Matrix of Int32 (0xc6)
Int32: Array of Int32
ArraySize: 1
[0]: Int32: 5
ArrayDimensions
ArraySize: 3
Int32: 1
Int32: 1
Int32: 1
1 Guest(s)

Log In
Register