The following rules describe how the SerializationScope and the SerializationProperties impact the layout of the SerializationFieldDataType.
If Variables are serialized, the Value of the Variable is mapped also into the SerializationValue DataType of the SerializedData Variable. The Value is inserted as field into the Structure DataType of the SerializedData Variable which has the SerializationFieldDataType of the Variable.
If the Variable has no children, the Variable is represented by a single Structure field with the BrowseName of the Variable as field name. The SerializationFieldDataType of the Variable equals the DataType of the Variable. As shown in Figure 11, the Variable V1 is mapped into the Structure field V1 with the SerializationFieldDataType V1DataType (left column with IncludeStatus, IncludeSourceTimestamp and IncludeDictionaryReference Properties equal to False).
Figure 11 – IncludeStatus and IncludeSourceTimestamp Properties Example for Variable without child Node
If some of the IncludeStatus, IncludeSourceTimestamp and IncludeDictionaryReference Properties (“Include-Properties”) are True, the Variable is also represented by a single Structure field, but the SerializationFieldDataType is a Structure DataType.
This Structure contains a “Value” field which has the same DataType as the Value of the Variable. Dependent on the Value of the “Include-Properties”, the Structure can contain a “Status” field with the DataType StatusCode, a “SourceTimestamp” field with the DataType UtcTime and an entry in the DictionaryReferences array field as shown in Figure 11 (middle and right column, V1Type, examples for the IncludeStatus, IncludeSourceTimestamp and IncludeDictionaryReference Properties).
Note: The SerializationValue DataType for a SerializationScope only consisting of one Variable and a SerializationScope consisting of one Object with this Variable as child Node are identical.
If the Variable has child nodes, the fields of the SerializationFieldDataType representing the Variable are generated as shown in Figure 12 for the V1 Variable (V1Type):
- The Value of the Variable is mapped into a field with the name “Value” with the DataType of the Value of the V1 Variable.
- A field with name “Children” is inserted after the “Value” field. Its DataType is a new Structure DataType containing as many fields as there are children of the serialized Variable. The name of each of those fields equals the BrowseName of the mapped child. Servers shall make sure that field names are unique (e.g., two BrowseNames can have the same text field but different namespaces). The SerializationFieldDataType of each of those fields equals the DataType of the mapped child Variable if the respective child is a “leaf” of the Object tree. This is the case for Properties and “childless” Variables (see Figure 12, left column, V1Type and V1ChildrenType with “Include-Properties” set to False). If the child Variable itself has child nodes, the SerializationFieldDataType of the field representing the Variable is a Structure DataType generated according to the same rules which were applied to the parent Variable (recursiveness).
If “Include-Properties” are True, the SerializationFieldDataType is always a Structure DataType and contains additional fields mapping the corresponding Properties as shown in Figure 12 (middle and right column, V1Type and V2Type, examples for IncludeStatus and IncludeSourceTimestamp Properties).
Figure 12 – IncludeStatus and IncludeSourceTimestamp Properties Example with child Node
Figure 13, Figure 14 and Figure 15 demonstrate the SerializationFieldDataType generated if the “Include-Properties” (see 6.3.9) are set to False, which allows representing “leaves” of the Object tree as “simple” fields.
Figure 13 shows the SerializationFieldDataType for Variables with Properties and Variables.
Figure 13 – Serialization of Variables with children
The rules described above apply in the same way to Objects, with the exception that the Object level itself has no Value and therefore the SerializationFieldDataTypes do not contain a “Value”-field. Figure 14 shows the SerializationFieldDataType needed to serialize an Object and its children. The fields representing the children are inserted directly into the SerializationFieldDataType of the Object, without an intermediate “Children” structure used in case of Variables with children.
The SerializationFieldDataType for Variables with children are created according to chapter 6.4.3
Figure 14 – Serialization of Objects with children
Figure 15 shows a nested subtree where members of the subtree are again subtrees. Each subtree has its own DataTypeDefinition Node. Since“Variable1” has no children, it is mapped to the field “Variable1” with the same DataType. Since “Object1” has children, it is mapped to the “Object1DataType” Structure DataType with the field “Property1”.
Figure 15 – Nested subtrees represented by one SerializationValue