Serializing structures with optional fields|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
Serializing structures with optional fields
Avatar
Sascha Kattelmann
Member
Members
Forum Posts: 16
Member Since:
07/09/2019
sp_UserOfflineSmall Offline
1
08/23/2019 - 02:39
sp_Permalink sp_Print

Hi,

following the spec (part 6) on the serialization about structures with optional fields there is an encoding mask prefixed to the binary blob which contains the encoded fields. This encoding mask is 32 bits long and contains bit flags which show which fields are actually present in the blob.

I am wondering if that part of the spec is true. Having a look into the core model for some structure with optional fields we can see something like this:

<UADataType NodeId="i=15904" BrowseName="DataSetFieldFlags">
  <DisplayName>DataSetFieldFlags</DisplayName>
  <References>
    <Reference ReferenceType="HasProperty">i=15577</Reference>
    <Reference ReferenceType="HasSubtype" IsForward="false">i=5</Reference>
  </References>
  <Definition Name="DataSetFieldFlags" IsOptionSet="true">
    <Field Name="PromotedField" Value="0" />
  </Definition>
</UADataType>

And looking at the parent data type we can see that we got an UInt16 (i=5) which kind of makes no sense regarding inheritance on structures. In fact every structure with optional fields seem to have a Byte, UInt16 or UInt32 as parent. This suggests that the parent data type is here actually not used in terms of inheritance but rather as the datatype for the encoding mask. Is that correct?

Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
08/23/2019 - 08:25
sp_Permalink sp_Print

There are no examples of optional fields or unions in the base specification.

You are looking at OptionSets which simply assign meaning to individual bits in an integer.

Avatar
Sascha Kattelmann
Member
Members
Forum Posts: 16
Member Since:
07/09/2019
sp_UserOfflineSmall Offline
3
08/26/2019 - 02:11
sp_Permalink sp_Print sp_EditHistory

Many thanks for clearing this up, I got misguided by the naming. What you said is well explained in chap 3 8.41.

Another thing: what contributed to my misunderstanding was that option sets are not part of the serialization explanations in chap 6. Maybe this should be added there.

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