Object: DUT
A DUT (Data Unit Type) declares a user-defined data type which extends beyond the predefined standard types.
DUT for the data type categories of structure, enumeration, alias, and union
You can add these kinds of objects below the application or in the POUs view. When you create the object, the Add DUT dialog opens. There you can name the new data type and choose from the categories (structure, enumeration, alias, and union).
Categories of user-defined data types
TYPE <identifier> :
<data type declaration>
END_TYPE | A DUT declaration is enclosed between |
TYPE <identifier> :
STRUCT
<member deklaration>
END_STRUCT
END_TYPE | Declaration of a structure In the case of a structure, the (at least) two members are enclosed between |
TYPE <identifier> :
(
<list of members>
) <base data type> := <inittialization> ;
END_TYPE | Declaration of an enumeration In the case of an enumeration, the (at least) two members are enclosed in parentheses. The individual members are separated by commas. All members have the same data type. An enumeration can also be supported by a text list. For more information, see the following: Enum with Text List Support The text list is used to localize the values of the enumeration. As a result, the object also has a localization view. |
TYPE <identifier> : <data type name> ; END_TYPE | Declaration of an alias An alias is an alternative identifier. |
TYPE <identifier> :
UNION
<member declaration>
END_UNION
END_TYPE | Declaration of a union A union allows the simultaneous storage of multiple different data types in the same memory area. The size of a union corresponds to the size of the largest data type which it contains. Always the value of the last written member is stored in memory at any given time. In the case of a union, the (at least) two members are enclosed between |
Declaration of the structure S_POLYGONLINE with partial initialization of members
TYPE S_POLYGONLINE :
STRUCT
aiStart : ARRAY[1..2] OF INT := [-99, -99];
aiPoint1 : ARRAY[1..2] OF INT;
aiPoint2 : ARRAY[1..2] OF INT;
aiPoint3 : ARRAY[1..2] OF INT;
aiPoint4 : ARRAY[1..2] OF INT;
aiEnd : ARRAY[1..2] OF INT := [99, 99];
END_STRUCT
END_TYPEDeclaration of the structure S_PENTAGON as an extension of S_POLYGONLINE
TYPE S_PENTAGON EXTENDS S_POLYGONLINE :
STRUCT
aiPoint5 : ARRAY[1..2] OF INT;
END_STRUCT
END_TYPEDeclaration of the enumeration E_TRAFFICSIGNAL
{attribute 'qualified_only'}
{attribute 'strict'}
TYPE E_TRAFFICSIGNAL :
(
eRed,
eYellow,
eGreen := 10
);
END_TYPEEnumeration with text list support in the localization view

The
Textual View and
Localization View buttons are located on the right edge of the editor. Click the buttons to toggle between the views.
Declaration of an alias
TYPE A_MESSAGE : STRING[50]; END_TYPE
Declaration of a UNION
TYPE U_DATA :
UNION
lrA : LREAL;
liA : LINT;
dwA : DWORD;
END_UNION
END_TYPEDialog: Add DUT
Function: The dialog is used to configure a new DUT object (Data Unit Type).
Call: Project → Add Object → DUT menu; context menu of the application object
Name | Name of the new DUT data type Example: |
Structure | Creates an object which declares a structure that combines multiple variables with different data types into a logical unit The variables declared within the structure are called members. Example: |
Advanced |
In the input field, specify an existing structure. The members of the existing structure are automatically available in the new structure. Example: |
Enumeration | Creates an object which declares an enumeration that combines multiple integer constants into a logical unit The constants declared within an enumeration are also called enumeration values. Example: An enumeration can also have a text list. This is used to localize the values of the enumeration. As a result, the object also has a localization view. |
Add Text List Support |
|
Alias | Creates an object which declares an alias with which an alternative name is declared for a base type, data type, or function block Example: |
Union | Creates an object which declares a union that combines multiple members with mostly different data types into a logical unit All members have the same offset so that they are occupy the same memory. The memory requirement of a union is determined by the memory requirement of its "largest" member. Example: |
Add | Closes the dialog and creates the new object The object is displayed with the |


