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
Using Complex DataTypes
November 20, 2015
12:53, EET
Avatar
msaala
Member
Members
Forum Posts: 3
Member Since:
November 16, 2015
sp_UserOfflineSmall Offline

Hello everybody,

I’ve got the job to program a opc-ua client for an existing machine interface. At that I have to read the value from a node that has a complex data type. For this I use a code similar to

nodeId = new NodeId(2, “Measurements”);
DataValue dv = client.readValue(nodeId));
System.out.println(dv.getValue());

Furthermore I found that it is possible to get a instance of an ‘ExtensionObject’
ExtensionObject eo = (ExtensionObject) (dv.getValue().getValue());

But now I do not know how I can evaluate the data further. As usual with complex data the structure of the content is not simple but consists of nested arrays of further complex sturctures.
With the common OPC UA Client from Prosys I also cannot further investigate the data, I only see that there is a object of the type ExtensionObject.
On the other hand it is possible to investigate the data with the free Softing OPC UA client (I know that the machine OPC UA server is build using the Softing SDK…). With this tool it is possible to drill into the arrays and the containing complex structures. Therefore, it seems to me to be possible in principle.
I have only found the document ‘Using Complex DataTypes’ from Otso Palonen, but I don’t understand how to adapt this example to my problem.
Are there any other sources I can use? Is it possible in principle to develop a Java Client with the Prosys SDK and complex data types for an existing OPC UA server that is developed in an other tool set?

Thanks for any advice
Michael

November 23, 2015
8:17, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

ExtensionObject in most cases means the data is as (java) byte[]. This could happen if we do encounter unknown type, i.e. one for which we do not have a serializer. If this happens you will get info level log from the stack level (org.opcfoundation.ua.encoding.binary.BinaryDecoder) “Failed to decode ExtensionObject …” The sample programs that come in the SDK bundle by default have stack level only as error, see log.properties file.

What is the DataType of that Node?

In case that is from the Device Information model (the “di” in the package name), you need to call UaClient.registerModel(com.prosysopc.ua.types.di.client.MODEL). Similar ones are “plc” for PLCopen and “adi” for “OPC UA for Analyzer Devices” but they do not seem to contain any complex types (also there is the “opcua” for the standard model, this is always loaded).

In case that is from another model, if you have the NodeSet2 format XML file for the model, you can use the codegenerator in the SDK to create java types for the complex data types (remember to load the model like above).

If those wont work, you need to create the Serializer for that datatype. You need to know which fields are in that complex type and in which order. Probably the easiest is to look at the SampleTypes.xml in the codegen sample and try to adapt that.

– Bjarne

November 23, 2015
17:08, EET
Avatar
msaala
Member
Members
Forum Posts: 3
Member Since:
November 16, 2015
sp_UserOfflineSmall Offline

The question “What is the DataType of that Node?” seems simple, but to be honest, I’m not sure.
I find no way to detect the datatype of the node in the application. Do you have a code snippet for this? Your OPC UA Client displays the Datatype ‘Structure’. The Softing Client shows a Datatype that seems to reference a Node in the namespace /Types/DataTypes/OPCBinary. If it helps I can send you screenshots of the Clients.
My next try was to generate java code to decode the binary data. I received a XML format file that should describe the datatype, but again, I’m not sure if the XML file is valid (can be provided). At least the codegen task throws an Exception (Exception in thread “main” java.lang.IllegalArgumentException: No method in multimethod ‘parse-nodeid’ for dispatch value: null)

Michael

November 24, 2015
9:07, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

DataType: It is the DataType Attribute of that node. It defines the type for the Value Attribute (note that as with object oriented programming languare, you can put sub-types to it too). To check it you can use e.g. the following snippet:

NodeId nodeId = (NodeId for the node)
UaClient client = (the client)
DataValue dv = client.readAttribute(nodeId, Attributes.DataType); //org.opcfoundation.ua.core.Attributes
dv.getValue().toString();

‘Structure’ is the supertype for all complex datatypes.

“The Softing Client shows a Datatype that seems to reference a Node in the namespace /Types/DataTypes/OPCBinary.”
Hmm.. usually it should point to Types/DataTypes/BaseDataType/Structure/??? if it is a complex type.

The schema for the NodeSet2 format should be https://opcfoundation.org/UA/2011/03/UANodeSet.xsd

– Bjarne

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online: atdemir
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: 683

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

Kickbiche, karrimacvitie5, graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer

Moderators: 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