UDT Features
There are many features of UDTs that allow more control over the definition and instances
Extending Other Types
User Defined Types can extend other UDTs to add additional members, or override default values. The Parent Type property (with the main/top UDT member selected) can be modified by selecting another UDT from the dropdown. This will add all members of the selected UDT to this UDT, and you can add additional Tags or change default properties.
Adding Members to a Data Type
Simply click the Tag
icon on right side of the Type Structure. Data types can contain standard Tags like OPC and DB Tags, as well as folders and instances 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.
The following feature is new in Ignition version
8.0.15
Click here to check out the other new features
As of release 8.0.15, UDT parameters can be saved as specific data types.
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 subtypes or instances. Furthermore, unlike normal Tags, in the context of a data type many properties (generaly the string based properties) can reference the custom attributes of the type in order to build parameterized Tags.
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}.
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. ie: ##0
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}
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
.
The following feature is new in Ignition version
8.0.3
Click here to check out the other new features
Parameters support more mathematical operators in addition to offsets and formatting. There is a simple expression language available that can be used in conjunction with formatting. The following table shows all available operators in their order of operations (they are evaluated starting at the top of the table).Operator | Description | Example |
---|
() | Parenthesis. These operators are used for grouping any number of values. Also used to change the order of operations. | {Baseaddress*(2+3)} |
^ | Power. This operator is used to raise a number to a power. | {BaseAddress^2} |
- | Negative. Used to create a negative value from one number. | {BaseAddress*-2} |
* | Multiplication. Multiply two numbers. | {BaseAddress*2} |
/ | Division. Dividing the first number by the second number. | {BaseAddress/2} |
% | Modulus. This operator returns the remainder of a division operation. IE: 7/3 = 2 with a remainder of 1, so 7%3 = 1 | {BaseAddress%2} |
+ | Addition. Add two numbers. | {BaseAddress+2} |
- | Subtraction. Subtract two numbers | {BaseAddress-2} |
# This dynamic OPC Item path takes in three parameters to determine the tag path
ns=1;s=[DeviceName]Path/to/tag{BaseAddress+(ParamNum*Multiplier)|0000}
# The OPC Item path resolves to the following assuming the following values:
# BaseAddress = 5
# ParamNum = 8
# Multiplier = 2
ns=1;s=[DeviceName]Path/to/tag0021
Calculations and numerical parameter names
If the parameter names are purely numerical values (we don't recommend this: it gets confusing), then quotation marks must encase the parameter to run any sort of calculations on the value of the parameter.
For example, if a UDT contains a parameter named 0, and its value is 10:
// This will evaluate to 0, because it thinks you mean the integer 0, not the parameter named "0"
{0 * 1000}
// This will evaluate to 10000, because the quotation marks denote a parameter named "0"
{"0" * 1000}
Overriding Properties
Subtypes 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.