Add / modify / delete data types

Data types used by TwinCAT C++ modules can be added, edited and deleted with the help of the TwinCAT Module Class (TMC) editor.

This article describes:

Step 1: Generate a new type

1. After starting the TMC Editor, select the Data Types node.
2. Extend the list of data types and interfaces by a new data type by clicking on the + button Add a new data area.
A new data type is then listed as a new entry:
Add / modify / delete data types 1:
3. Select the generated "Data Type1" in order to obtain details of the new data type.
Add / modify / delete data types 2:
4. Specify the data type.
See here for more precise details.
5. Rename the data type.
In this sample stSensorData, select the specification STRUCT and click on Edit Struct.
Add / modify / delete data types 3:
6. Insert new sub-elements in the structure by clicking on the Add a new sub item button.
Add / modify / delete data types 4:
7. You can edit the properties by double-clicking on the sub-element. Give the sub-element a new name and select a suitable data type.
Add / modify / delete data types 5:
8. Give the other sub-elements a new name and select a suitable data type.
9. Save the changes you have made in the TMC file.

Step 2: Start the TwinCAT TMC Code Generator to generate code for the module description.

1. Right-click on your project file and select TwinCAT TMC Code Generator to generate the source code for your data type:
Add / modify / delete data types 6:
You can see the data type declaration in the module header file "Untitled1Services.h"
Add / modify / delete data types 7:
If you add a further data type or a further sub-element, run the TwinCAT TMC Code Generator again.