Read value of Array of Int

Questions regarding the use of the UaExpert.

Moderator: uaexpert

Post Reply
loic3484
Jr. Member
Jr. Member
Posts: 3
Joined: 06 Sep 2023, 15:31

Read value of Array of Int

Post by loic3484 »

Hello everyone,
I would like to know if it is possible with uaExpert to read a value of an Array of int.

For example:
I have a variable CurrentError which is uInt16 Array[5].

When I add a custom node if I do:

4 -- String -- OpcUa.AllDataR.PTR[1].AX_INV[1].CurrentError[0] It is not working

What should be the identifier ?

Thx

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Read value of Array of Int

Post by Support Team »

Hi,

the UaExpert can read the value of an array of any type (including the uint16) !

When you double-click on the value (in DA-View or in Attribute-Window) you will see all the elements in a pop-up window and you can dig down to the element of interest.

Which server are you asking with your "self made" syntax of arbitrarily adding some square bracket "[5]" notation, and hoping you get the fifth (or six) element of the array, just by manipulating the unique string-identifyer of a node? How should this syntax work with numeric or guid identifyers? What is the answer of the server? My educated guess is: "BadInvalidNodeID" (see log window in UaExpert).

However if you want to get some breakout copy of single element, or maybe some but not all elements, or maybe a subset of an array again as an array (e.g. a range of elements over the index of an array), there is some OPC UA feature/paramenter you might be interested in so-called: "IndexRange". Check out the user-manual of your server if it supports the "read array with IndexRange"

The UaExpert has no need to read single elements, because it can read the full array and "display" all the elements of that array.
Best regards
Unified Automation Support Team

loic3484
Jr. Member
Jr. Member
Posts: 3
Joined: 06 Sep 2023, 15:31

Re: Read value of Array of Int

Post by loic3484 »

OK,
I am using Beckhoff OPC UA Server. The last version

I am was trying to read element by element with telegraf, that why I was looking to a specific path or something like that.

I am going to read IndexRange,

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Read value of Array of Int

Post by Support Team »

Hi,

agreed, index range is the only (and correct) way to look into sub ranges of an array (from start element to end element). The index range from element "5" to element "5" gives you one single element, which is element six, because arrays in OPC UA always start at "0".

Of course it would be more efficient if you read the whole array and look at the elements of interest within your client application, instead of doing hundrets of Read-wt-IndexRange, one by one for every single element. But if perfomance is of no interest you may do it.

If the PLC programmer would have wanted you to read single tag, they would have modeled as single variable. However, if they want to express that the array elements belong together in an array, they most probably have a reason for it and "modeled" the data as an array (consistent set of data).
Best regards
Unified Automation Support Team

loic3484
Jr. Member
Jr. Member
Posts: 3
Joined: 06 Sep 2023, 15:31

Re: Read value of Array of Int

Post by loic3484 »

Hello,

Fully understand :)

Thx a lot, I am the one that who created the PLC code :)
I used array because I was lazy, it was easier to do a loop instead of a copy and past ;)

Have a good day,
Loic,

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Read value of Array of Int

Post by Support Team »

Hi,

putting data into an array, even though they do not belong to eachother (just lazyness) is not very smart, because in OPC we try to reduce bandwith by transmitting individual variables on change individually. By this we reduce the bandwith to just the few tags that have changed, which can be just 10 out of 10.000. However if you put all your tags into one single array with 10.000 elements, the complete array has changed, even if just one element has changed. You force the Server to transmit the whole piece and all the nice bandwith saving advantage is gone. You will end up in hight CPU load and high network load. In your client you loop over it and skip all the data that was (costly) transferred to you for nothing.

So, please carefully think about how to structure and model your data at the source, because it may have an impact on performance, throughput, and bandwith.
Best regards
Unified Automation Support Team

Post Reply