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
Array element
October 9, 2020
13:31, EEST
Avatar
ZigoZago
Member
Members
Forum Posts: 9
Member Since:
April 11, 2020
sp_UserOfflineSmall Offline

Hello everybody,
is it possible to read / write a single element of an array?
If so what is the syntax?

Thanks.
Regards.

Cool

October 9, 2020
14:28, EEST
Avatar
Matti Siponen
Moderator
Members

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

Hello,

You can use NumericRange to select a subset or a single element of an array when reading or writing. See the Javadoc for UaClient.readValue(NodeId nodeId, NumericRange indexRange) and UaClient.writeValue(NodeId nodeId, Object value, NumericRange indexRange) for more information on how to use NumericRange when reading and writing respectively. See https://reference.opcfoundation.org/v104/Core/docs/Part4/7.22/ for the formal specification of NumericRange.

If you want to select a single element of a one-dimensional array, you would construct a NumericRange with new NumericRange(x) where x is the index of the element you want to select and 1 is the index of the first element in the array. For multidimensional arrays, you would construct a NumericRange with new NumericRange(new int[]{x1,x2,x3,…}) where x1,x2,x3,… is the index of the element you want to select.

October 9, 2020
16:04, EEST
Avatar
ZigoZago
Member
Members
Forum Posts: 9
Member Since:
April 11, 2020
sp_UserOfflineSmall Offline

Sorry but if i want just write a single element with OPC UA client (i make a test with SCADA system) is there a possibility?

October 12, 2020
8:24, EEST
Avatar
Matti Siponen
Moderator
Members

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

Yes, you can write to a single element.

If you’re using the OPC UA SDK for Java, you can use UaClient.writeValue(NodeId nodeId, Object value, NumericRange indexRange), where nodeId is the NodeId of the Node, value is the Value to be written and indexRange is the NumericRange that specifies the location of the element(s) in the Array. See my previous message for how to construct the NumericRange when using one-dimensional or multi-dimensional arrays.

October 12, 2020
15:20, EEST
Avatar
ZigoZago
Member
Members
Forum Posts: 9
Member Since:
April 11, 2020
sp_UserOfflineSmall Offline

Hello Matti,

ok i understand problem is i don’t use OPC UA SDK for Java.

Sorry.

October 12, 2020
17:16, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

Basically you will need to consult the makers of your client application, or the creators of the SDK you would be using to build an application if that is the case.

The NumericRange Matti mentioned is specified in the Write ServiceRequest: https://reference.opcfoundation.org/v104/Core/docs/Part4/5.10.4/#5.10.4.2 (the name is indexRange and it is of type NumericRange), which then points to https://reference.opcfoundation.org/v104/Core/docs/Part4/7.22/, which displays examples of some syntax.

There should be some way to define that, or it is also possible, that your client implementation doesn’t support that at all. Note that even if you write a single element, with that, the value must still be an array (of a single element), not a scalar.

In our Prosys OPC UA SDK for Java, the equivalent parameter would of type com.prosysopc.ua.stack.utils.NumericRange, that has constructors for a single element, single dimension range or multidimensional range.

I would assume most client applications to have some kind of way to define the index range, though it should be mentioned that e.g. our https://www.prosysopc.com/products/opc-ua-browser/ yet cannot write array values, I would recommend to use https://www.unified-automation.com/products/development-tools/uaexpert.html instead if you need that (though, I fail to find an NumericRange setting there either.., maybe it is not so common in actual applications).

I should probably also mention, that there exist some servers (I think I have only seen this in some Siemens’ servers) that seem to make a node per array element, and if the NodeId of the main node is of String IdType (there other types as well of NodeIds), then the subnodes had a square brackets naming scheme that matches typical programming languages array accessors syntax. That is not something specified in OPC UA, but a server implementation is technically free to do so (the e.g. “[0]” etc. is just a set of characters in this case as part of a String, not any operator), so I would not recommend to use it, but if your server happened to be like that, it would be possible to use it. And as an second confusing clarification, there exists a standard modelling rule, ExposesItsArray, that defines that the elements exists also as single nodes, but the specification specifically mentions, that any naming logic is defined on a type level individually, and thus nothing that can really be used in general level implementations.

October 12, 2020
17:27, EEST
Avatar
ZigoZago
Member
Members
Forum Posts: 9
Member Since:
April 11, 2020
sp_UserOfflineSmall Offline

Yes normally for example with Siemens Array in OPC UA Server inside of client is enough use Array[0].
Thanks.
Regards.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
14 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: 726

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7, franciscagrimwad, adult_gallery

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0

Administrators: admin: 1