11/06/2023
Hi
According to UA1.05, Can a StructureWithSubtypedValues Structure Type have optional field?
If Not than what if -
Question 1: If the parent is a "StructureWithOptionalField" and the child has a field with "AllowSubtypes" set to true, then the child should treat the parent's optional field as mandatory. Alternatively, the child should ignore "AllowSubtypes" for its own field. And same situation if parent is "StructureWithSubtypedValue" and child has optional field.
Question 2: For a perticular field in a structure if both "Allowsubtypes" as well as "IsOptional" specified as true what should we consider at first place.
Thanks
Rahul
05/30/2017
Q1) OptionalField and AllowSubtypes are mutually exclusive. i.e. if StructureWithOptionalField is set then no fields can have AllowSubtypes.
See https://reference.opcfoundatio...../docs/8.51
If the structureType is StructureWithOptionalFields this field indicates if a data type field in a Structure is optional. In this case a value of FALSE means the StructureField is always present in all occurances of the Structure DataType and a value of TRUE means the StructureField may be present in an occurance of the Structure DataType.
If the structureType is Structure or Union this field shall be FALSE and shall be ignored.
If the structureType is StructureWithSubtypedValues, or UnionWithSubTypedValues this field is used to indicate if the data type field allows subtyping. Subtyping is allowed when set to TRUE.
Q2) See Q1
If a modeller needs to use optional fields and AllowSubtypes then it should create nested structures.
10/18/2019
Hi Rahul, Randy,
Adding a special case too.
A structure can have a BaseDataType field for which AllowSubTypes = FALSE. But as the Data Type is abstract, it implicitly means, sub-types are allowed.
Example: https://reference.opcfoundatio...../docs/10.5
This is JUST information and clarify on additional use case interpretation.
08/18/2014
Randy, are you saying that the following is not allowed because A would be a StructureWithOptionalType = True.
Structure Type A has three fields, A1, A2, and A3 (A3 is optional).
Structure Type B is derived from A and Adds a B1 field (this part is what you say is not allowed).
So you get:
MyAInstance - A1, A2, A3(o)
MyBInstance - A1, A2, A3(o), B1
What you are saying is because A has an optional filed you would need to do this:
A is the same
B is a new type with a field of B1 and a field of A (nested structure). No subtyping, just structure nesting giving you:
MyAInstance - A1, A2, A3(o)
MyBInstance - B1, MyAInstance
05/30/2017
The AllowSubtypes flag restricts the field - not the containing type.
So a type { A1, A2, A3(o) } could have subtype { A1, A2, A3(o), B1 } provided the DataType of B1 is concrete.
But it could not have a field B1 where instances of C1 or any subtype of C1 are allowed
If you needed a field B1 with an abstract DataType C1 then you could use Structure or BaseDataType instead of C1.
If you really wanted to preserve the C1 DataType then you could use the aggregation scheme you proposed:
{ A: Type A, B1: Type C1 }
1 Guest(s)