Encoding of Concrete Structures and their sub-types|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Encoding of Concrete Structures and their sub-types
Avatar
Mohit Agarwal
Member
Members
Forum Posts: 54
Member Since:
10/18/2019
sp_UserOfflineSmall Offline
1
09/22/2021 - 07:31
sp_Permalink sp_Print

Hi,

In OPC UA, the way BaseDataType encoding works compared to any other known Structures or User Defined Structures is different as I understand.

For example:

Use case:

If I have a Structure called TestStructure which is a concrete type with some mandatory and optional fields.

I also have a SubType of TestStructure called TestStructureSubtype which is also concrete type inherited from TestStructure.

In the Server, I have create a monitored item with TypeId = TestStructure but if I send TestStructureSubType as the content inside that, how does the UA Client is supposed to work.

If i think in normal programming aspect, it is possbile as Casting from Super Type to Sub Type but when I tried an example, it did NOT work.

I understand that, if I have a variable with DataType = BaseDataType, I can replace the content with anything i.e. either TestStructure or TestStructureSubtype.

But If i create a variable with DataType  = TestStructure, I cannot replace the content with TestStructureSubtype inside that.

Please suggest your inputs and correct me if my understanding is wrong.

Avatar
Randy Armstrong
Admin
Forum Posts: 1537
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
09/22/2021 - 10:41
sp_Permalink sp_Print

"Casting" subtypes to the supertype is a concept that depends on representation of a structure in memory. If a client does not recognize the subtype it cannot deserialize it which means it cannot be cast to the supertype.

Some clients will have the ability to use the DataTypeDefinition Attribute to decode arbitrary structures which would allow it to read values with subtypes of the DataType. Clients without this capability will treat the value as a ByteString.

IOW, it is always valid to expose a variable with a subtype of the DataType, however, some Clients will not be able to do anything with it.

Avatar
Mohit Agarwal
Member
Members
Forum Posts: 54
Member Since:
10/18/2019
sp_UserOfflineSmall Offline
3
09/22/2021 - 11:36
sp_Permalink sp_Print sp_EditHistory

Thank you Randy. In our case, we have both super type and sub-type in the address space i.e. client has the definition of both the types.

As you said, it depends on the client. I will try with some other clients too again to see how it works to validate.

I was trying to find an example structure in the OPC UA DataTypes if there were any OPC UA Core Structures which has two concrete types i.e. one concrete type inheriting other concrete type, i did not find anything in demo server which supports UA 1.04.

Many structures does inherit from other structures but those super types are abstract in the OPC UA Core Types.

Thanks again.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 20
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1415
Posts: 4778