Skip to main content

Defining Extension Object

Defining Extension Object Data Types in Sterfive OPCUA Modeler's YAML File

In the Sterfive OPCUA Modeler, extension objects are custom data structures that represent complex types. You can define an extension object data type in the YAML file under the dataTypes section.

The first note emphasizes that the modeler understands the data type represents an ExtensionObject thanks to the fields property list. Simply put, if you include the fields keyword with a list of elements in a data type, the modeler will infer that this data type is an ExtensionObject.

The second note is about the format of the dataType of fields. If a dataType is presented in the format ua:Float, it signifies that the data type of the field is a Float, as defined in the namespace ua (where 'ua' is the alias of the primary OPC UA namespace 0). There's no need to prefix the dataType with the namespace alias if the DataType is defined in the same YAML file.

Let's delve into two examples provided:

Example 1:

namespaceUri: http://sterfive.com/UA/test/
dataTypes:
- browseName: MotorInfoDataType
fields:
- name: Acceleration
dataType: ua:Float
description: the motor acceleration
- name: Velocity
dataType: ua:Float
description: the motor velocity
- name: Torque
dataType: ua:Float
description: the Z value

In the above YAML file:

  • A custom data type MotorInfoDataType is defined.
  • The MotorInfoDataType data type includes three fields: Acceleration, Velocity, and Torque.
  • Each field is defined with its name, dataType, and a description.
  • The data type for all three fields is ua:Float, which is a basic data type from the primary OPC UA namespace.

Example 2:

namespaceUri: http://sterfive.com/UA/test/
dataTypes:
- browseName: MotorInfoDataType
fields:
- name: Motor
dataType: ControllerDataType
description: the motor acceleration

In this YAML file:

  • A custom data type MotorInfoDataType is defined.
  • The MotorInfoDataType data type includes one field: Motor.
  • The data type of the Motor field is ControllerDataType. It is not prefixed with a namespace alias, indicating that it is a custom data type defined elsewhere in the same YAML file.

In summary, defining an extension object data type involves setting up a browseName and then specifying its fields. Each field is comprised of a name, a dataType, and a description. The dataType can be a basic type from the OPC UA namespace or a custom data type defined within the same YAML file. By understanding these elements and their arrangement, you can effectively describe complex data structures in your OPC UA model.

namespaceUri: http://sterfive.com/UA/test/
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