

14:44, EET

August 20, 2014

Hi,
we want to write Data from a Ua Client (Java SDK) to any Node of a Ua Server. What is the best way to handle the dataTypes from Java to OPCUA? I read about the DataTypeConverter and have tried it out. I Tried the method: getDataTypeForJavaClass(). This worked for primitive types like int, double, float etc. But it’s not working for arrays. How should i handle a java array, which i want to write to an array variable in the UaServer?
Thanks
Best Regards
Ibrahim
15:57, EET

April 17, 2013

Hello,
How about finding out the data type of components in the array and then using the DataTypeConverter? See this link for details: http://download.oracle.com/jav…..Type%28%29
16:45, EET

April 17, 2013

17:57, EET

August 20, 2014

Hi,
this is a sample from our code, which does not work:
double[] dArray = new double[2];
dArray[0] = 3.6;
dArray[1] = 5.7;
DataTypeConverter converter = client.getAddressSpace().getDataTypeConverter();
UaDataType dataTypeValue = converter.getDataTypeForJavaClass(dArray.getClass());
The method getDataTypeForJavaClass() throws: java.lang.IllegalArgumentException: Cannot find data type of double
10:42, EET

April 17, 2013

12:24, EET

August 20, 2014

13:04, EET

April 17, 2013

15:32, EET

August 20, 2014

Hi,
i found a way to make it work with primitive types:
double[] dArray = new double[2];
dArray[0] = 3.6;
dArray[1] = 5.7;
Double[] d = ArrayUtils.toObject(dArray);
client.writeValue(nodeId, d);
This works fine. I don’t know how performant this is, but it works and it is just for very few cases.
Thanks anyway..
Ibrahim
Most Users Ever Online: 1919
Currently Online:
24 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 90
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 810
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1541
Posts: 6504
Newest Members:
Henrybal, vincent.lin1970@gmail.com, JamesLiabe, DanielMaype, RobertPrire, VirCibre, semunah, StevenMot, elinorbalke7872, CharlesGUirmModerators: Jouni Aro: 1029, Pyry: 1, Petri: 0, Bjarne Boström: 1040, Jimmy Ni: 26, Matti Siponen: 353, Lusetti: 0
Administrators: admin: 1