Creating User Defined Types (UDTs)

Complex Tags, also referred to as UDTs (user defined types), offer the ability to leverage object-oriented data design principles in Ignition. Using complex tags, you can dramatically reduce the amount of work necessary to create robust systems by essentially creating parameterized "data templates".

By defining UDTs and using these essentially “data templates”, you can generate tag instances to rapidly build complex screens. A change to the type definition is then inherited by all instances, drastically saving time when making routine changes.

The UDT data types are fully supported by Vision templates, which means you can configure templates for your custom data types and take advantage of drag-and-drop binding to rapidly build complex screens.

Primary UDT Features

The primary features of UDTs are as follows:

Central Definition
Once you define your data type, you can then create instances of it. If at a later time you want to change some aspect of the tag, you can simply edit the type definition, and all instances of it are automatically updated.

Parameterized Settings
Define custom parameters on your data type, and then reference them inside your member tags. When it comes time to create instances, you can simply modify their parameter values in order to change where the underlying data comes from.

Extendable
Data types can inherit from other data types in order to add additional members, or override settings. Instances can also override settings, allowing for flexibility for dealing with irregular data and corner cases.

UDT Terminology

Many terms are frequently used when discussing complex tags:

UDT or UDDT
User Defined Type or User Defined Data Type. The definition of the data type is: its structure, tags, attributes and settings.

Instances
Instances are running copies of a data type with specific data for all members. Instances are linked to their parent types and are reloaded when their parent type changes. Besides specifically overridden settings, all settings are inherited from the type definition.

Parameters
Parameters are custom properties on data types that you can use inside the type or instance definition to create parameterized data templates. For example, if a data type consists of 3 OPC tags that only differ by a number in the path, you can use a parameter for the "base address", allowing instances to be created with only 1 setting.

Members
Members are the tags inside of a data type or instance.

Defining Data Types

Creating a new data type is very similar to creating standard tags.

To create a new data type

  1. Simply select the Tags folder in the Tag Browser.

  2. Click the Tag icon on the Tag Browser toolbar.
    The tag creation menu is displayed.

  3. Select New Data Type from the menu.
    The Tag Editor is displayed.
    When editing complex tags, the Tag Editor window appears a bit differently. The member tree structure is presented in the upper left. By selecting a member, the tag property categories are displayed below the member area, and the editor for the selected category appears to the right.

To extend other Types

Data types can extend other data types, to add additional members, or override default values. The parent data type can be modified by selecting the data type itself in the tag member tree. Note that the data type can only be selected when the tag is first created. After that, it is not possible to modify the parent tag type.

To add members to a data type

Simply click the green + icon at the toolbar above the member tree. Data types can contain standard tags like OPC and DB, as well as folders and instance of other complex types.

To add parameters

Parameters, which can be used for property expansion in member tags, can be added by selecting the data type in the member tree. If a data type contains other complex types in it, there may be various points in the tree with custom parameters. While a data type can override the parameter values inherited from a parent, new parameters can only be added to the root node of the new data type.

Configuring Member Properties

The tags inside of data types are configured much like normal tags. However, in this case, the values can be thought of more as "default values", which will be used unless other values are specified when the instance is created. Most of the values configured in the data type can be modified later in sub types or instances. Furthermore, unlike normal tags, in the context of a data type many properties (general the string based properties) can reference the custom attributes of the type in order to build parameterized types.

Attribute Referencing and Parameterized Types

As mentioned above, many properties in the member tag configuration can reference the parameters available in the data type. When instances are created, these references are replaced with the values defined for the type. Parameter references also support basic offsets and numerical formatting, providing a great deal of flexibility. To reference a parameter, use the syntax {ParameterName}, or use Ctrl-Space to display a list of available parameters to choose from.

To offset a value, use the form {ParameterName+offset}.
To format a value, use the form {ParameterName|format}. The format pattern is the same as that used for the numberFormat expression function. In short, "0" can be used to require a digit, and "#" can be used for optional digits.

Example:

For this example, we'll assume that we're parameterizing the OPC Item Path, and that the data type has an integer attribute named BaseAddress defined. We'll pretend the OPC Server provides tags named like DataPoint1.

Standard referencing

OPC Item Path: DataPoint{BaseAddress}

Offset

Imagine that our data type had three fields, and these were laid out sequentially in the device.
Instead of specifying each address for each tag, we can simply offset from the base address:

Member 1: DataPoint{BaseAddress+0}
Member 2: DataPoint{BaseAddress+1}
Member 3: DataPoint{BaseAddress+2}

Formatting (with offset)

Continuing from the example above, imagine that our OPC server actually provided addresses in the form DataPoint001, in order to stay consistent up to "DataPoint999". This can be accommodated
using number formatting in the reference:

Member 1: DataPoint{BaseAddress+0|000}
Member 2: DataPoint{BaseAddress+1|000}
Member 3: DataPoint{BaseAddress+2|000}

This format of three zeros means "three required digits". If our instance has a base address of 98, the resulting paths will be DataPoint098, DataPoint099, DataPoint100.

Properties that can be parameterized

The following tag properties can reference parameters:

  • Value (for string data type only)

  • OPC Server

  • OPC Item Path

  • Tooltip

  • Documentation

  • Expression/SQL Query

  • Bindable Alarm Properties (Note: you can bind a property directly to the parameter, or use parameters in the binding expression, or directly in string property values)

Overriding Properties

Sub types and instances can override the properties defined in parent types. To do this, simply select the override control (the small grey ball) next to the property to override in the member editor.
Conversely, to remove the override, simply unselect the control.

Custom parameters can be overridden as well, but it is not required to specify that the value is an override. Simply provide a new value for the property. For inherited parameters, the delete button next to the parameter table will simply remove the override. The parameter can only truly be delete from the type that defines it.

Creating Data Types from Existing Tags or OPC

You can save time and quickly generate data types from existing structures. This is particularly useful, for example, when data types are already defined in the PLC.

Converting from existing Tags

To create a data type from existing Tags, simply select the tags or folders you wish to include, right-click and select Create Data Type from Selected.

The Tag Editor window is displayed with the selected tags pre-populated as members. From here you can modify the tags, add parameters, and so on. The original tags will not be affected.

Tip: If you select a single folder as the root to create the type from, its sub-members will be added, and its name will be the basis for the type (that is, the folder itself won't be included in the structure).

Creating from OPC

If you have data types defined in your PLC (or OPC server), you can short-cut the conversion step outlined above by simply dragging the tags (or the folder for the type) from the OPC Browser
directly onto the Data Types folder, and selecting Create Type from the subsequent dialog.

Creating Instances of Complex Types

Creating instances of complex types is virtually identical to creating other types of tags using the New Tag menu. Unlike standard tags, it is likely that you'll have to modify attribute values or override certain member properties in order to make the instance unique. The process for doing this is the same to that used when creating data types. Once created, instances run very much like standard Tags. If the parent data type is updated, the instance will automatically receive the updates and refresh.

Using the Multi-Instance Wizard

The multi-instance wizard provides a powerful but simple mechanism for rapidly generating many instances of a data type, by specifying patterns for parameters. To get started right-click a tag in the Tag Browser, then select New Tag > Data Type Instance > Multi-instance Wizard from the menu. The Instance Creation Wizard window is displayed. Once you select a data type, you will see its parameters come into the table, where you can specify values for them. The size of the parameter patterns dictate how many tags are created, or if only single values are specified, you can choose to create multiple copies of the same configuration.

Value Patterns

In order to define values for parameters (and the tag names), you can use several different types of patterns (and combinations of patterns):

Range number1-number2[/step]
A numeric range of values, such as 1-10. Optionally, a step parameter can be included, in order to only generate numbers at certain multiples. For example, 0-100/10 would generate 0,10,20, and so on.

Repeat value*count
A value (numerical or string), and the number of times to use it. For example, North Area*10 would use the parameter North Area for 10 items.

List value1, value2, value3
A comma separated list of values (or other patterns) to use.


Examples:

1-10,20-30,30-40 Results in 30 tags being created, with the specified value ranges (so, for example, there would be no parameter 15).
A,B,C Results in 3 tags, with each of the values.
0-100/5 Results in 21 tags (because range is inclusive), with values 0, 5, 10...100.

As mentioned, the size of the pattern will dictate how many tags will be created. If some patterns are smaller than others, the last value will be repeated for the other tags.

Tag Names

The names of the generated instances can be specified using a system similar to that of the parameter patterns. If you just want to use sequential names, you don't need to specify a pattern, as values will be generated automatically starting at one. You can also set the pattern to simply be the starting number to generate sequential names from there.

Base Name
A string base for the tag name. This can also be a list of names, in which case the names will be used directly, and the name pattern won't be used.

Name Pattern
A pattern that will be used to generate values that will be appended to the base name.

At any time, you can use the preview button to view the tag names and parameters that will be created. Once you are satisfied, click OK to generate the tags under the selected folder in the tag provider.

In this section ...