Aller au contenu principal

DataTypes

The dataTypes section allows to define new types for OPCUA Variables. It is possible to define enumerations, Extension Objects or to overload one of the basic dataTypes.

Enumeration

Enumeration can be defined as a list of string

dataTypes:
- browseName: SoftwareVersionFileType
enum: [Current, Pending, Fallback]
Click here to see the generated xml file
    <UADataType NodeId="ns=1;i=1015" BrowseName="1:SoftwareVersionFileType">
<DisplayName>SoftwareVersionFileType</DisplayName>
<References>
<Reference ReferenceType="HasSubtype" IsForward="false">i=29</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1016</Reference>
</References>
<Definition Name="1:SoftwareVersionFileType">
<Field Name="Current" Value="0"/>
<Field Name="Pending" Value="1"/>
<Field Name="Fallback" Value="2"/>
</Definition>
</UADataType>
<UAVariable NodeId="ns=1;i=1016" BrowseName="EnumStrings" ParentNodeId="ns=1;i=1015" AccessLevel="3" ValueRank="1" ArrayDimensions="3" DataType="LocalizedText">
<DisplayName>EnumStrings</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
<Value>
<ListOfLocalizedText xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
<LocalizedText>
<Text>Current</Text>
</LocalizedText>
<LocalizedText>
<Text>Pending</Text>
</LocalizedText>
<LocalizedText>
<Text>Fallback</Text>
</LocalizedText>
</ListOfLocalizedText>
</Value>
</UAVariable>
dataTypes:
- browseName: MachineStatus
enum:
- name: Idle
- name: Running
- name: Error
Click here to see the generated xml file
    <UADataType NodeId="ns=1;i=1017" BrowseName="1:MachineStatus">
<DisplayName>MachineStatus</DisplayName>
<References>
<Reference ReferenceType="HasSubtype" IsForward="false">i=29</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1018</Reference>
</References>
<Definition Name="1:MachineStatus">
<Field Name="Idle" Value="0"/>
<Field Name="Running" Value="1"/>
<Field Name="Error" Value="2"/>
</Definition>
</UADataType>
<UAVariable NodeId="ns=1;i=1018" BrowseName="EnumStrings" ParentNodeId="ns=1;i=1017" AccessLevel="3" ValueRank="1" ArrayDimensions="3" DataType="LocalizedText">
<DisplayName>EnumStrings</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
<Value>
<ListOfLocalizedText xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
<LocalizedText>
<Text>Idle</Text>
</LocalizedText>
<LocalizedText>
<Text>Running</Text>
</LocalizedText>
<LocalizedText>
<Text>Error</Text>
</LocalizedText>
</ListOfLocalizedText>
</Value>
</UAVariable>

Enumeration with names & values

dataTypes:
- browseName: ColorEnumType
enum:
- name: Red
value: 0xFF0000
- name: Blue
value: 0x0000FF
- name: Green
value: 0x00FF00
Click here to see the generated xml file
    <UADataType NodeId="ns=1;i=1019" BrowseName="1:ColorEnumType">
<DisplayName>ColorEnumType</DisplayName>
<References>
<Reference ReferenceType="HasSubtype" IsForward="false">i=29</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1020</Reference>
</References>
<Definition Name="1:ColorEnumType">
<Field Name="Red" Value="16711680"/>
<Field Name="Blue" Value="255"/>
<Field Name="Green" Value="65280"/>
</Definition>
</UADataType>
<UAVariable NodeId="ns=1;i=1020" BrowseName="EnumValues" ParentNodeId="ns=1;i=1019" AccessLevel="3" ValueRank="1" DataType="EnumValueType">
<DisplayName>EnumValues</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
<Value>
<ListOfExtensionObject xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
<ExtensionObject>
<TypeId>
<Identifier>i=7616</Identifier>
</TypeId>
<Body>
<EnumValueType>
<Value>16711680</Value>
<DisplayName>
<Text>Red</Text>
</DisplayName>
<Description>
<Text/>
</Description>
</EnumValueType>
</Body>
</ExtensionObject>
<ExtensionObject>
<TypeId>
<Identifier>i=7616</Identifier>
</TypeId>
<Body>
<EnumValueType>
<Value>255</Value>
<DisplayName>
<Text>Blue</Text>
</DisplayName>
<Description>
<Text/>
</Description>
</EnumValueType>
</Body>
</ExtensionObject>
<ExtensionObject>
<TypeId>
<Identifier>i=7616</Identifier>
</TypeId>
<Body>
<EnumValueType>
<Value>65280</Value>
<DisplayName>
<Text>Green</Text>
</DisplayName>
<Description>
<Text/>
</Description>
</EnumValueType>
</Body>
</ExtensionObject>
</ListOfExtensionObject>
</Value>
</UAVariable>

best practices for enumerations

  • The suffix Enumeration may be added to the enumeration name, to follow a practice commonly used in companion standards, such as DeviceHealthEnumeration.

DataType to override basic types

namespaceUri: http://sterfive.com/UA/test/
dataTypes:
- browseName: MyIdentifierType
subtypeOf: ua:String
namespaceUri: http://sterfive.com/UA/test/
objectTypes:
- browseName: MyObjectType
components:
- browseName: Identifier
dataType: MyIdentifierType

Extension Object

namespaceUri: http://sterfive.com/UA/test/
## Enumeration defined as a list of string
dataTypes:
- browseName: ThreeDVector
fields:
- name: X
dataType: ua:Float
description: the X value
- name: Y
dataType: ua:Float
description: the Y value
- name: Z
dataType: ua:Float
description: the Z value