

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

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
1 Guest(s)
