10/18/2019
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.
05/30/2017
"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.
10/18/2019
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.
1 Guest(s)