Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Writing single values to a multidimensional array
April 21, 2022
10:25, EEST
Avatar
rocket science
Member
Members
Forum Posts: 75
Member Since:
March 16, 2017
sp_UserOfflineSmall Offline

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:

NodeId nodeId = NodeId.get(IdType.String, _client.getNamespaceTable().getIndex("DemoNodeManager"), "AllDataTypesStatic/StaticInt32Matrix");

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

Integer[][][] value = (Integer[][][]) dataValue.getValue().getValue();
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."

April 25, 2022
12:27, EEST
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 319
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline

Hello,

We would recommend you to ask Unified Automation this question. The Bad_IndexRangeNoData StatusCode comes from their Server.

We could also check if we can replicate this error. Can you tell us which Unified Automation’s SDK’s Demo Server you’re testing with?

April 26, 2022
17:04, EEST
Avatar
rocket science
Member
Members
Forum Posts: 75
Member Since:
March 16, 2017
sp_UserOfflineSmall Offline

Hi,

seems to be the C++ SDK Demo Server

Value BuildInfo [
ProductUri=”urn:UnifiedAutomation:UaDemoserver”,
ManufacturerName=”Unified Automation GmbH”,
ProductName=”C++ SDK UaDemoserver”,
SoftwareVersion=”1.3.3″, BuildNumber=”206″,
BuildDate=”10/10/13 14:55:28.0000000 GMT”]

April 26, 2022
20:09, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

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

May 4, 2022
13:25, EEST
Avatar
rocket science
Member
Members
Forum Posts: 75
Member Since:
March 16, 2017
sp_UserOfflineSmall Offline

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?

May 4, 2022
14:01, EEST
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 319
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline

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
Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
20 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 75

ibrahim: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 707

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1466

Posts: 6253

Newest Members:

christi10l, ahamad1, Flores Frederick, ellenmoss, harriettscherer, shanonhumphreys, KupimotoblokfuB, tamhollander5, paulinafcf, bridgette18l

Moderators: Jouni Aro: 1009, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 982, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 319, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1