Example for complex data types

742 views
Skip to first unread message

porsch...@gmail.com

unread,
Jul 31, 2017, 9:49:51 AM7/31/17
to open62541
Dear All - in our environment we are working with complex data types. Is there an example or documentation containing a description on how to read and write complex data types, like all information contained in GPS coordinates (latitude, longitude, quality information, speed, ...).


Muddasir shakil

unread,
Aug 1, 2017, 9:39:33 AM8/1/17
to open62541, porsch...@gmail.com
I am also looking for such solution, but i think we need to define such complex data types in DataType definition such as structural data types. Introducing new datatypes in Unified Automation SDK as one can use UAModeler to define typed model but I am not entirly sure about Open62541. If you do find a solution how to define structural, enumration or Complex DataType in Open62541. 

In your case one solution could be that you can define a new type of Variable node as parent Node and declare GPS data with HasComponent reference(latitude, longitude, etc). or You can use HasPorperty ref too. In your instance model you can create instance of that Variable. 

Stefan Profanter

unread,
Aug 2, 2017, 3:32:47 AM8/2/17
to open62541, porsch...@gmail.com
Does the following code help you:
https://github.com/open62541/open62541/blob/master/tests/check_types_custom.c

It defines a custom DataType Point.

Let us know if you have further questions! We are happy to help.

If possible please also post a minimal (non) working example where we can assist you

porsch...@gmail.com

unread,
Aug 2, 2017, 8:00:57 AM8/2/17
to open62541, porsch...@gmail.com
Thanks for your help. Unfortunately, I asked the wrong question.


We are using a (commercial) OPC UA server where the gents defined their complex data types, for instance the GPS data, I mentioned.

Would you be so kind as to point out some sample code which I can use on the OPC UA client side, when using open6241.


Sincerely, 

Roland



Am Montag, 31. Juli 2017 15:49:51 UTC+2 schrieb porsch...@gmail.com:

Stefan Profanter

unread,
Aug 3, 2017, 5:03:45 AM8/3/17
to open62541, porsch...@gmail.com
Honestly I did not work that much with complex data types.

My approach would be the following.

Look at
https://github.com/open62541/open62541/blob/master/tests/check_client_highlevel.c#L348

/* Read attribute */
UA_Variant
*val = UA_Variant_new();
retval
= UA_Client_readValueAttribute(client, nodeId, val);


Here you need to read the corresponding node ID.
The variant will then just contain the struct from the server. You need to know how it looks like an then cast it to your Coordinates struct.

So similar to this one here:
https://github.com/open62541/open62541/blob/master/tests/check_types_custom.c#L103

Point *p2 = (Point*)var.data;

Let me know if you have any success!
Stefan

porsch...@gmail.com

unread,
Aug 4, 2017, 6:05:58 AM8/4/17
to open62541, porsch...@gmail.com
Thanks for your help. Looks quite easy. I will keep you informed on the progress I make - after my holidays. :-))


Am Montag, 31. Juli 2017 15:49:51 UTC+2 schrieb porsch...@gmail.com:
Reply all
Reply to author
Forward
0 new messages