10:25, EEST
March 16, 2017
Hi 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
17:04, EEST
March 16, 2017
20:09, EEST
December 21, 2011
According 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
I’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
Hello,
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
Most Users Ever Online: 1919
Currently Online:
15 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 737
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6451
Newest Members:
jonathonmcintyre, fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettingerModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1