10/18/2019
Hi,
This query has a relation to another post: https://opcfoundation.org/foru.....pes/#p4786
In UA 1.05.02, we introduced, AllowSubTypes option, but based on the above post, the answer was, it is NOT a change over the wire but ONLY for code generation.
Question: In UA 1.04, if we have a complex structure, then is it allowed to send the content of a sub-type for a given instance of complex structure?
Example: ResultDataType { ResultMetaDataType resultMetaData; }
ResultMetaDataType extended as ResultMetaExtendedDataType. Now, in the instance of ResultDataType, can I pass an instance of ResultMetaExtendedDataType to resultMetaData field as per UA 1.04?
05/30/2017
In 1.04 AllowSubtypes was implemented by setting the DataType to Structure when subtypes are allowed (i.e. the DataTypeDefinition loses information and descriptive text is used to explain what is actually allowed).
In 1.04 if the DataType is not Structure then only instances of that type are allowed.
If a Server wants to publish a DataTypeDefinition using AllowSubtypes that a 1.04 client can understand then it needs replace the supertype with Structure when it creates the DataTypeDefinition that is returned in a Read.
10/18/2019
I have a linked question and wanted to confirm my understanding for the same. In the following structure, can you please suggest you inputs on it?
ResultDataType
{
ResultMetaDataType resultMetaData;
Array<BaseDataType> resultContent;
}
We should be able to populate resultContent with instances of ResultDataType (the parent Result) also as it is an array of BaseDataType. I hope it is correct to do that since we have a use case of several parent and child results.
Or if my assumption is wrong, are there any restrictions which needs to be handled apart from application logic?
10/18/2019
I am using C++ based SDK and it is more like Array of Variant (BaseDataType).
Hence, my assumption is, we can have parent-child relationship since in the end ResultContent is an array of BaseDataType.
ResultDataType.ResultContent[] should be able to point to an element of type ResultDataType?
Technically, Structure (ExtensionObject) is a sub-type of BaseDataType, hence logically, I assume that BaseDataType[] ResultContent[] can still hold ResultDataType.
Additional Information:
When I passed, ResultDataType.ResultContent[] = Some other Structure, it WORKED but when I passed ResultDataType.ResultContent[] = elements of ResultDataType, then I was facing some issues which I am still troubleshooting.
But wanted to understand, if there are any restrictions on this use case in UA 1.04 which are resolved in later version of UA?
05/30/2017
Technically, Structure (ExtensionObject) is a sub-type of BaseDataType, hence logically, I assume that BaseDataType[] ResultContent[] can still hold ResultDataType.
The binary encoding of a ExtensionObject[] is different from the binary encoding of Variant[]. If you want to replicate the effect of the AllowSubtypes flag with tools that do not understand it then you need to use ExtensionObject[] as the field DataType.
I passed ResultDataType.ResultContent[] = elements of ResultDataType, then I was facing some issues which I am still troubleshooting.
You need to create an ExtensionObject[] which wraps an instance of ResultDataType in each element. If you use a SDK with a BaseDataType in the API you could be accidently creating a 1 element Variant[] which contains a ExtensionObject[] instead of an ExtensionObject[].
10/18/2019
Yes, the current C++ SDK does NOT understand AllowSubTypes and is based on UA 1.04. Hence, is the following change correct?
Ok, in that case, if I understand you correctly, the following is the recommendation.
Current Schema:
ResultDataType
{
ResultMetaDataType resultMetaData;
Array<BaseDataType> resultContent;
}
Updated Schema:
ResultDataType
{
ResultMetaDataType resultMetaData;
Array<Structure> resultContent; //Updated from BaseDataType to Structure so that it is PARSED as ExtensionObject. I should now be able to pass element of ResultDataType in resultContent?
}
Second Question: I guess, parent-child structures can exists. I want to cofirm this since all our information model from the CS is based on Parent-Child, where resultContent will point to an element of parent type only?
Third Question: When, it was Array<BaseDataType> resultContent, I passed some other Array of Structure and that worked. In that case, it means, Array of Variants was pointing to Array of Extension Objects. But, the same did NOT work when I passed parent type. Not Sure of the reason as of now and still troubleshooting it.
05/30/2017
Array<Structure> resultContent; //Updated from BaseDataType to Structure so that it is PARSED as ExtensionObject. I should now be able to pass element of ResultDataType in resultContent?
This should work if the C++ SDK serializes as an Array of ExtenionObjects. See https://reference.opcfoundatio.....s/5.2.2.15
Second Question: I guess, parent-child structures can exists. I want to cofirm this since all our information model from the CS is based on Parent-Child, where resultContent will point to an element of parent type only?
An ExtensionObject is a wrapper that includes the DataTypeEncodingId and the actual Object. The DataTypeEncodingId allows you to know what the Object is so you can cast it to the correct type. If the DataTypeEncodingId is a subtype of ResultDataType then you can cast it to the subtype or ResultDataType depending on what you need.
Third Question: When, it was Array<BaseDataType> resultContent, I passed some other Array of Structure and that worked. In that case, it means, Array of Variants was pointing to Array of Extension Objects. But, the same did NOT work when I passed parent type. Not Sure of the reason as of now and still troubleshooting it.
A Variant can contain Arrays so care must be taken to ensure you do not set the value of a single Variant to an Array when you intended to have an array of Variants with each element containing a scalar value.
10/18/2019
Thanks a lot Randy, please find the updates on the troubleshooting and can you please suggest your inputs for following case?
- I have tried parent-child recursion and it works with both BaseDataType[] array and Structure[] array as long as I ensure that Variant[] array is mapped to ExtensionObject[] array instead of scalar ExtensionObject/scalar Variant.
- Last Pending Thing:
- ResultDataType //Contains 2 fields shown below:
- ResultMetaDataType resultMetaData //Contains 1 Mandatory field and 19 optional fields.
- Array<BaseDataType> resultContent;
- ResultDataType //Contains 2 fields shown below:
- NEXT STEP: Extension of ResultMetaDataType Field
- JoiningResultMetaDataType : inherits ResultMetaDataType //It contains additional 11 optional fields.
- In total ResultMetaDataType (Parent Type) contains 20 fields and JoiningResultMetaDataType (Sub-type) contains 11 additional fields.
- Now, when I created instances of JoiningResultMetaDataType, the DataTypeDefinition ONLY points to 11 fields and does NOT show 20 fields of the ResultMetaDataType (Parent Type).
- The only workaround what I can see right now is to to DUPLICATE all the properties defined in ResultMetaDataType (20 fields) inside JoiningResultMetaDataType (which will be 20 + 11 fields = 31 fields).
- Questions:
- Is it due to lack of support of UA 1.05.02 by both Server and Client?
- In UA 1.04, Is it NOT possible to have sub-types where it can include all the parent-type properties?
- Will marking ResultMetaDataType (Parent Type) to Structure work?
- I tried this but it was giving some other issue and can check again.
05/30/2017
I don't really understand what the SDK you are using is doing.
There are no optional fields in these structures so your comments about optional fields make no sense.
Subtypes always inherit parent properties but ANSI C code generators have to copy properties because there are no supertypes in ANSI C.
10/18/2019
It is C++ based SDK.
ResultMetaDataType (First field in ResultDataType) has 19 OPTIONAL fields and 1 Mandatory Field
I am creating JoiningResultMetaDataType (with additional 11 OPTIONAL fields) which inherits ResultMetaDataType. Basically it is a structure with StructureType = 1 (StructureWithOptionalFields)
If parent type has all mandatory fields, then SDK creates it correctly where it copies all the parent type fields in the DataTypeDefinition
Hence, my question was, in UA 1.04, is there any different way to handle Sub-Types of StructureWithOptionalFields?
Basically, before the code-generation, the DataTypeDefinition of the sub-type does NOT include the parent properties.
[Image Can Not Be Found]
1 Guest(s)