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
Arrays of Complex Types
July 10, 2012
19:56, EEST
Avatar
TimK
Member
Members
Forum Posts: 41
Member Since:
June 27, 2012
sp_UserOfflineSmall Offline

Is it possible to create nested complex types with arrays?
For example, I would like to be able to define a type Name, which would contain two strings- First Name and Last Name.
Then I would like to be able to define a type that contains an array of names and also an integer or some other member.

Name:
FirstName (String)
LastName (String)

OuterType:
Id (Integer)
People (Array of 5 Name objects)

July 11, 2012
7:21, EEST
Avatar
Otso Palonen
Espoo, Finland
Moderator
Moderators
Forum Posts: 32
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Hi Tim,

If I understand you correctly, you want to define a DataType Name, which consists of two strings (FirstName and LastName). Then you want to define OuterType (either an ObjectType or VariableType) that has two components, Id and People. Once you’ve defined a custom DataType Name, you can simply create an array of them in a Node. So People would have as its value an array of Names.

However, using a custom DataType has the drawback of most UA clients not being able to understand it. Another option is to simply create FirstName and LastName as two Properties for Name. You can see an example in any UA server address space in ServerStatus node (Root -> Objects -> Server – ServerStatus), where the same information is available as a single value of ServerStatus and as Property nodes of it. While all UA clients can understand ServerStatusDataType, if they didn’t, they’d be able to access the same information in the Property nodes (CurrentTime, State, etc.) The exact same goes for the Property BuildInfo, and actually ServerStatusDataType contains also BuildInfo! So you have some choice on how to do this.

I hope this clarified DataTypes and Properties as two choices in exposing this information. Depending on your application and the expected clients the best practice may vary.

July 11, 2012
13:35, EEST
Avatar
TimK
Member
Members
Forum Posts: 41
Member Since:
June 27, 2012
sp_UserOfflineSmall Offline

Ideally I would like clients who understand the complex types to be able to read OuterType or Name nodes as a single value, and clients who don’t to be able to read the pieces as properties. I think I understand how to do this if there aren’t any arrays involved:

OuterObject (OuterType)
HasComponent Id(Integer)
HasComponent Person

Person (NameType)
HasComponent FirstName(String)
HasComponent LastName(String)

If I want OuterObject to contain an array of names called people, I’m not clear on how that would work. I can create a node People of NameType that is a component of OuterObject, and give it array dimensions, but then how can I give each element of the array a FirstName and LastName property?

July 13, 2012
11:20, EEST
Avatar
Otso Palonen
Espoo, Finland
Moderator
Moderators
Forum Posts: 32
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Yes, that is what could be considered as best practice since it allows quick and efficient access (via the custom DataType) as well as interoperability (via the Properties which all clients can understand). I wrote a blog post about using custom DataTypes, check it out if you haven’t already: http://www.prosysopc.com/blog/…..datatypes/

There are a few ways to model this:

1) OuterObject has HasComponent references to several Person nodes (so there is no single People node) and each of these Person nodes has as its DataType NameDataType (distinct from NameType, which is a VariableType with the two properties) and has the two Properties with DataType String. All the Person nodes have the same BrowseName, so TranslateBrowsePathsToNodeIds service calls involving these nodes will return all of them.

2) Have the DataType of People to be NameDataType and for People to contain an array of NameDataType. So once you have defined NameDataType, just create an array of those and place it as the value. FirstName and LastName then contains arrays of strings.

The spec is not completely clear about what the best practice in this kind of use case (with arrays) is. I would recommend approach 1), even though it involves more nodes.

January 16, 2013
19:33, EEST
Avatar
TimK
Member
Members
Forum Posts: 41
Member Since:
June 27, 2012
sp_UserOfflineSmall Offline

The example above is exactly what I needed. Now I can expose my custom types, and the client can read them if it knows their format in advance.
Now I would like to set up the information a client would need to discover the format.
It looks like I need to add things in a few places for this to work. For example, I need to add a new type under Structure:

Types
DataTypes
BaseDataType
Structure
(MyDataType)

MyDataType needs to have a HasEncoding reference to a description of the type.
Do you have an example of setting something like this up? Also, do you know of any clients that can read the encoding description nodes and take custom types apart using them?

January 21, 2013
14:00, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 853
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Sorry for the late response.

We have not worked with the encodings yet and I am not aware of any client applications that would use the data.

However, if you find out how to do this I would also be interested to learn more about it.

January 25, 2013
7:32, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 853
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

I got this confirmed. In principle, you can expose the information through the server side Data Dictionary, but we don’t have any example yet on how to do that. Also there are no known client applications yet that can use the information from there.

We will get back to the topic later.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 267

Currently Online:
10 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 103

pramanj: 86

ibrahim: 70

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 38

Rainer Versteeg: 32

Thomas Reuther: 31

Member Stats:

Guest Posters: 0

Members: 1118

Moderators: 14

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1034

Posts: 4352

Newest Members:

aldayr, Python techie, emanuel45q, Patrick, sammycontrols, hellema, linoy, subranna, ray, richN9177

Moderators: Jouni Aro: 853, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 559, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 21, Markus Johansson: 24, Matti Siponen: 64, Lusetti: 0

Administrators: admin: 1