Top  | Previous | Next

Defining Data Types

Creating a new data type is very similar to creating standard tags. Simply select New Data Type from the tag creation menu to open the editor. When editing complex tags, the tag edit window appears a bit differently. The member structure is presented in the upper left. By selecting a member, the tag property categories are displayed below, and the editor for the selected category appears to the right.

 

Extending 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.

Adding Members

To add members to a data type, simply select the type of tag from 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.

 

Adding 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 require 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.

 

Create 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 Selection" udtdef_from_sel_16

The standard type editor will appear with the selected tags pre-populated as members. From here you can modify the tags, add parameters, etc. 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.