The TypeDictionaryelement is the root element of an OPC Binary Dictionary. The components of this element are described in Table E.1.

Table E.1TypeDictionary Components

Name

Type

Description

Documentation

Documentation

An element that contains human-readable text and XML that provides an overview of what is contained in the dictionary.

Import

ImportDirective[]

Zero or more elements that specify other TypeDictionariesthat are referenced by StructuredTypesdefined in the dictionary. Each import element specifies the NamespaceUriof the TypeDictionarybeing imported. The TypeDictionaryelement shall declare an XML namespace prefix for each imported namespace.

TargetNamespace

xs:string

Specifies the URI that qualifies all TypeDescriptionsdefined in the dictionary.

DefaultByteOrder

ByteOrder

Specifies the default ByteOrderfor all TypeDescriptionsthat have the ByteOrderSignificantattribute set to “true”.

This value overrides the setting in any imported TypeDictionary.

This value is overridden by the DefaultByteOrderspecified on a TypeDescription.

TypeDescription

TypeDescription[]

One or more elements that describe the structure of a binary encoded value.

A TypeDescription is an abstract type. A dictionary may only contain the OpaqueType, EnumeratedTypeand StructuredTypeelements.

A TypeDescriptiondescribes the structure of a binary encoded value. A TypeDescriptionis an abstract base type and only instances of subtypes may appear in a TypeDictionary. The components of a TypeDescriptionare described in Table E.2.

Table E.2– TypeDescription Components

Name

Type

Description

Documentation

Documentation

An element that contains human readable text and XML that describes the type. This element should capture any semantic information that would help a human to understand what is contained in the value.

Name

xs: NCName

An attribute that specifies a name for the TypeDescriptionthat is unique within the dictionary. The fields of structured types reference TypeDescriptionsby using this name qualified with the dictionary namespace URI.

DefaultByteOrder

ByteOrder

An attribute that specifies the default ByteOrderfor the type description.

This value overrides the setting in any TypeDictionaryor in any StructuredType that references the type description.

anyAttribute

*

Authors of a TypeDictionarymay add their own attributes to any TypeDescription that shall be qualified with a namespace defined by the author. Applications should not be required to understand these attributes in order to interpret a binary encoded instance of the type.

An OpaqueTypedescribes a binary encoded value that is either a primitive fixed length type or that has a structure too complex to capture in an OPC Binary type dictionary. Authors of type dictionaries should avoid defining OpaqueTypes that do not have a fixed length because it would prevent applications from interpreting values that use these types without having built-in knowledge of the OpaqueType.The OPC Binary Type Description System defines many standard OpaqueTypesthat should allow authors to describe most binary encoded values as StructuredTypes.

The components of an OpaqueTypeare described in Table E.3.

Table E.3– OpaqueType Components

Name

Type

Description

TypeDescription

TypeDescription

An OpaqueTypeinherits all elements and attributes defined for a TypeDescriptionin Table E.2.

LengthInBits

xs:string

An attribute which specifies the length of the OpaqueTypein bits. This value should always be specified. If this value is not specified the Documentationelement should describe the encoding in a way that a human understands.

ByteOrderSignificant

xs:boolean

An attribute that indicates whether byte order is significant for the type.

If byte order is significant then the application shall determine the byte order to use for the current context before interpreting the encoded value. The application determines the byte order by looking for the DefaultByteOrderattribute specified for containing StructuredTypesor the TypeDictionary. If StructuredTypes are nested the inner StructuredTypes override the byte order of the outer descriptions.

If the DefaultByteOrder attribute is specified for theOpaqueType,then theByteOrder is fixed and does not change according to context.

If this attribute is “true”, then the LengthInBitsattribute shall be specified and it shall be an integer multiple of 8 bits.

An EnumeratedTypedescribes a binary-encoded numeric value that has a fixed set of valid values. The encoded binary value described by an EnumeratedTypeis always an unsigned integer with a length specified by the LengthInBitsattribute.

The names for each of the enumerated values are not required to interpret the binary encoding, however, they form part of the documentation for the type.

The components of an EnumeratedType are described in Table E.4.

Table E.4– EnumeratedType Components

Name

Type

Description

OpaqueType

OpaqueTypeDescription

An EnumeratedTypeinherits all elements and attributes defined for a TypeDescriptionin Table E.2and for an OpaqueTypedefined in Table E.3.

The LengthInBits attribute shall always be specified.

EnumeratedValue

EnumeratedValue

One or more elements that describe the possible values for the instances of the type.

A StructuredTypedescribes a type as a sequence of binary-encoded values. Each value in the sequence is called a Field. Each Field references aTypeDescription that describes the binary-encoded value that appears in the field. A Fieldmay specify that zero, one or multiple instances of the type appear within the sequence described by the StructuredType.

Authors of type dictionaries should use StructuredTypesto describe a variety of common data constructs including arrays, unions and structures.

Some fields have lengths that are not multiples of 8 bits. Several of these fields may appear in a sequence in a structure, however, the total number of bits used in the sequence shall be fixed and it shall be a multiple of 8 bits. Any field which does not have a fixed length shall be aligned on a byte boundary.

A sequence of fields which do not line up on byte boundaries are specified from the least significant bit to the most significant bit. Sequences which are longer than one byte overflow from the most significant bit of the first byte into the least significant bit of the next byte.

The components of a StructuredTypeare described in Table E.5.

Table E.5– StructuredType Components

Name

Type

Description

TypeDescription

TypeDescription

A StructuredTypeinherits all elements and attributes defined for a TypeDescriptionin Table E.2.

Field

FieldType

One or more elements that describe the fields of the structure. Each field shall have a name that is unique within the StructuredType. Some fields may reference other fields in the StructuredTypeby using this name.

A FieldTypedescribes a binary encoded value that appears in sequence within a StructuredType. Every FieldTypeshall reference a TypeDescriptionthat describes the encoded value for the field.

A FieldTypemay specify an array of encoded values.

Fields may be optional and they reference other FieldTypes,whichindicate if they are present in any specific instance of the type.

The components of a FieldTypeare described in Table E.6.

Table E.6– FieldType Components

Name

Type

Description

Documentation

Documentation

An element that contains human readable text and XML that describes the field. This element should capture any semantic information that would help a human to understand what is contained in the field.

Name

xs:string

An attribute that specifies a name for the Field that is unique within the StructuredType.

Other fields in the structured type reference aField by using this name.

TypeName

xs:QName

An attribute that specifies the TypeDescriptionthat describes the contents of the field. A field may contain zero or more instances of this type depending on the settings for the other attributes and the values in other fields.

Length

xs:unsignedInt

An attribute that indicates the length of the field. This value may be the total number of encoded bytes or it may be the number of instances of the type referenced by the field. The IsLengthInBytesattributes specifies which of these definitions applies.

LengthField

xs:string

An attribute that indicates which other field in the StructuredTypespecifies the length of the field. The length of the field may be in bytes or it may be the number of instances of the type referenced by the field. The IsLengthInBytesattributes specify which of these definitions applies.

If this attribute refers to a field that is not present in an encoded value, then the default value for the length is 1. This situation could occur if the field referenced is an optional field (see the SwitchFieldattribute).

The length field shall be a fixed length Base-2 representation of an integer. If the length field is one of the standard signed integer types and the value is a negative integer, then the field is not present in the encoded stream.

The FieldTypereferenced by this attribute shall precede the field with the StructuredType.

IsLengthInBytes

xs:boolean

An attribute that indicates whether the Lengthor LengthFieldattributes specify the length of the field in bytes or in the number of instances of the type referenced by the field.

SwitchField

xs:string

If this attribute is specified, then the field is optional and may not appear in every instance of the encoded value.

This attribute specifies the name of another Field that controls whether this field is present in the encoded value. The field referenced by this attribute shall be an integer value (see the LengthFieldattribute).

The current value of the switch field is compared to the SwitchValueattribute using the SwitchOperand.If the condition evaluates to true then the field appears in the stream.

If the SwitchValue attribute is not specified, then this field is present if the value of the switch field is non-zero. The SwitchOperandfield is ignored if it is present.

If the SwitchOperandattribute is missing, then the field is present if the value of the switch field is equal to the value of the SwitchValue attribute.

The Fieldreferenced by this attribute shall precede the field with the StructuredType.

SwitchValue

xs:unsignedInt

This attribute specifies when the field appears in the encoded value. The value of the field referenced by the SwitchField attribute is compared using the SwitchOperandattribute to this value. The field is present if the expression evaluates to true. The field is not present otherwise.

SwitchOperand

xs:string

This attribute specifies how the value of the switch field should be compared to the switch value attribute. This field is an enumeration with the following values:

Equal

SwitchFieldis equal to the SwitchValue.

GreaterThan

SwitchFieldis greater than the SwitchValue.

LessThan

SwitchFieldis less than the SwitchValue.

GreaterThanOrEqual

SwitchFieldis greater than or equal to the SwitchValue.

LessThanOrEqual

SwitchFieldis less than or equal to the SwitchValue.

NotEqual

SwitchFieldis not equal to the SwitchValue.

In each case the field is present if the expression is true.

Terminator

xs:hexBinary

This attribute indicates that the field contains one or more instances of TypeDescriptionreferenced by this field and that the last value has the binary encoding specified by the value of this attribute.

If this attribute is specified then the TypeDescriptionreferenced by this field shall either have a fixed byte order (i.e. byte order is not significant or explicitly specified) or the containing StructuredTypeshall explicitly specify the byte order.

Examples:

Field Data TypeTerminatorByte OrderHexadecimal String

Char tab characternot applicable09

WideChartab characterBigEndian0009

WideChartab characterLittleEndian0900

Int16 1 BigEndian0001

Int16 1 LittleEndian0100

anyAttribute

*

Authors of a TypeDictionarymay add their own attributes to any FieldType which shall be qualified with a namespace defined by the authors. Applications should not be required to understand these attributes in order to interpret a binary encoded field value.

An EnumeratedValuedescribes a possible value for an EnumeratedType.

The components of an EnumeratedValueare described in Table E.7.

Table E.7– EnumeratedValue Components

Name

Type

Description

Name

xs:string

This attribute specifies a descriptive name for the enumerated value.

Value

xs:int

This attribute specifies the numeric value that could appear in the binary encoding.

A ByteOrderis an enumeration that describes a possible value byte orders for TypeDescriptionsthat allow different byte orders to be used. There are two possible values: BigEndian and LittleEndian. BigEndian indicates the most significant byte appears first in the binary encoding. LittleEndian indicates that the least significant byte appears first.

An ImportDirectivespecifies a TypeDictionarythat is referenced by types defined in the current dictionary.

The components of an ImportDirectiveare described in Table E.8.

Table E.8– ImportDirective Components

Name

Type

Description

Namespace

xs:string

This attribute specifies the TargetNamespacefor the TypeDictionarybeing imported. This may be a well-known URI which means applications need not have access to the physical file to recognise types that are referenced.

Location

xs:string

This attribute specifies the physical location of the XML file containing the TypeDictionaryto import. This value could be a URL for a network resource, a NodeId in an OPC UA Serveraddress space or a local file path.