18:05, EEST
March 16, 2017
Hi,
I wonder how to determine exactly that a data type is an array.
According to the reference (https://reference.opcfoundation.org/v104/Core/docs/Part3/5.6.2/) the value rank can be used to determine if the data type is an array or a scalar type.
For valueRank == -1 it is a scalar data type, for valueRank == 1 it is a one dimensional array and for valueRank > 1 it is an array with the specified number of dimensions-
But for others like 0, -2, -3 the reference points out that it can be scalar, one dimensional or any number of dimensions.
So if I have a node on the server, where the DataType is String and the ValueRank is -2, how can I find out if it will be a scalar data type or an array with how many dimensions?
Thanks!
10:39, EEST
April 3, 2012
Hi,
We have some helpers in the Variant class:
Variant.getDimension() (delegates to MultiDimensionArrayUtils.getDimension(class), returns 0 if scalar)
Variant.getArrayDimensions() (delegates to MultiDimensionArrayUtils.getArrayLengths(value), return dimensions in array with length of dimensions or 0 if scalar)
It should be noted that apparently these wont work for null value (results NPE; could probably be improved in a future version), thus please check that first.
This is to say, you only know after you have Read it. As for Writing, it shouldn’t need to be the same dimension, if ValueRank allows (what will actually happen would be server-specific though, but spec-wise any of them should like work).
P.S.
Also I would guess most of the time it will be a scalar, since -2 is the default (it has to be) in the basic VariableTypes, thus an instantiation of those would result in -2 unless changed after that.
Most Users Ever Online: 518
Currently Online:
24 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
hbrackel: 135
pramanj: 86
Francesco Zambon: 81
rocket science: 77
Ibrahim: 76
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
fred: 41
Member Stats:
Guest Posters: 0
Members: 681
Moderators: 16
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1467
Posts: 6261
Newest Members:
graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.comModerators: Jouni Aro: 1010, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5
Administrators: admin: 1