Representation Of Enum as ExtensionObject in NodeSet XML|OPC UA Companion Standards|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
Representation Of Enum as ExtensionObject in NodeSet XML
Avatar
Shubhi Gogna Shubhi Gogna
Member
Members
Forum Posts: 27
Member Since:
04/01/2014
sp_UserOfflineSmall Offline
1
01/24/2022 - 22:58
sp_Permalink sp_Print

Hi Team,

I have a created a new Custom Structure as DataType. This structure contains one Enum (DiagnosticLevel) and one Int Variables as below:

<UADataType NodeId="ns=1;i=3002" BrowseName="1:MyCustomStructure">
<DisplayName>MyCustomStructure</DisplayName>
<References>
<Reference ReferenceType="HasEncoding">ns=1;i=5002</Reference>
<Reference ReferenceType="HasEncoding">ns=1;i=5004</Reference>
<Reference ReferenceType="HasEncoding">ns=1;i=5003</Reference>
<Reference ReferenceType="HasSubtype" IsForward="false">i=22</Reference>
</References>
<Definition Name="1:MyCustomStructure">
<Field DataType="DiagnosticsLevel" Name="TestEnum"/>
<Field DataType="Int16" Name="TestInt"/>
</Definition>
</UADataType>

Now, when I create Instance (Variable node with value) for this Customer Structure, it looks like this:

The Enum in this contains value in form of name_value where ‘name’ is the field name and ‘0’ is the value of that field. Is this correct or should it be only 2.

<UAVariable DataType="MyCustomStructure" NodeId="ns=1;i=6001" BrowseName="1:MyTestVariable" AccessLevel="3">
<DisplayName>MyTestVariable</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
<Reference ReferenceType="Organizes" IsForward="false">i=85</Reference>
</References>
<Value>
<uax:ExtensionObject>
<uax:TypeId>
<uax:Identifier>ns=1;i=5003</uax:Identifier>
</uax:TypeId>
<uax:Body>
<MyCustomStructure xmlns="http://shubhi.org/testproject/Types.xsd">
<TestEnum>Info_2</TestEnum>
<TestInt>125</TestInt>
</MyCustomStructure>
</uax:Body>
</uax:ExtensionObject>
</Value>
</UAVariable>

Regards,

Shubhi Gogna

Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
02/04/2022 - 02:35
sp_Permalink sp_Print

In the NodeSet values are encoded using the XML encoding.

In the XML encoding the enumerations are strings of the form "name_value".

In the binary encoding the enums are Int32 values.

You can find the formal definition of the XML encoding in the XSD that is published with the NodeSet:
https://files.opcfoundation.or......Types.xsd

<xs:simpleType name="DiagnosticsLevel">
    <xs:restriction base="xs:string">
        <xs:enumeration value="Basic_0"/>
        <xs:enumeration value="Advanced_1"/>
        <xs:enumeration value="Info_2"/>
        <xs:enumeration value="Log_3"/>
        <xs:enumeration value="Debug_4"/>
    </xs:restriction>
</xs:simpleType>
Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 52
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1435
Posts: 4855