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
Moderators
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
Moderators
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
Moderators
April 17, 2013
12:24, EET
August 20, 2014
13:04, EET
Moderators
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: 518
Currently Online:
17 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
TimK: 41
Member Stats:
Guest Posters: 0
Members: 683
Moderators: 16
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1467
Posts: 6261
Newest Members:
digitechroshni, LouieWreve, Kickbiche, karrimacvitie5, graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPoomaModerators: 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