Data Type Unit (DUT)

Overview

Along with the standard data types, you can define your own data types. You can create structures, enumeration types, and references as data type units (DUTs) in a DUT editor.

For a description of the particular standard and the user-defined data types, refer to the description of the data types.

Adding a DUT Object

To add a DUT object to an existing application, select the application node in the Applications tree, click the green plus button, and select DUT.... Or right-click the respective node and execute the command Add Object > DUT. To create an application-independent DUT object, select the Global node in the Applications tree. In the Add DUT dialog box, enter a Name for the new data type unit, and choose the desired type Structure, Enumeration, Alias, or Union.

To DUT objects of type Enumeration you can add text list support. For further information, refer to the description of the Add text list support command.

In case of type Structure, you can use the principle of inheritance, thus supporting object-oriented programming. Optionally, you can specify that the DUT extends another DUT which is already defined within the project. Therefore, the definitions of the extended DUT will be automatically valid within the current one. For this purpose, activate the option Extends: and enter the name of the other DUT.

Click Add to confirm the settings. The editor view for the new DUT opens and you can start editing.

Declaring a DUT Object

Syntax

TYPE <identifier> : <DUT components declaration>END_TYPE

The DUT component declaration depends on the type of DUT, for example, a structure, or an enumeration.

Example

The following example contains 2 DUTS, defining structures struct1 and struct2; struct2 extends struct1, which means that you can use struct2.a in your implementation to access variable a.

TYPE struct1 :
    STRUCT
        a:INT;
        b:BOOL;
    END_STRUCT
END_TYPE
TYPE struct2 EXTENDS struct1 :
    STRUCT
  c:DWORD;
  d:STRING;
    END_STRUCT
END_TYPE