Creating a TwinCAT RT UDP device
A TwinCAT RT UDP device consists of two levels in the I/O configuration tree: an RT Ethernet adapter as the higher-level I/O device and the RT UDP module as the subordinate element. Both are created via CreateChild, but using different mechanisms: The RT Ethernet adapter is created using a SubType value, while the RT UDP module is created using a GUID, similar to the creation of TcCOM objects.
Requirements
- TwinCAT XAE is installed and started.
- A DTE connection to the target instance is active.
ITcSysManageris initialized in an STA thread.- The IO configuration tree can be accessed via the
TIIDpath.
Creating an RT UDP device
The RT Ethernet adapter is created directly as a child of the IO configuration tree (TIID). The RT UDP module is then created as a child of the adapter. For GUID-based generation, nType is set to 0; the fourth parameter of CreateChild contains the GUID as a plain string.
ITcSmTreeItem ioDevices = sysManager.LookupTreeItem("TIID");
// Step 1: Create RT Ethernet Adapter (SubType 109)
ITcSmTreeItem rtAdapter = ioDevices.CreateChild("RT-EtherNET Adapter", 109, "", null);
// Step 2: Create RT UDP module via GUID (analogous to TcCOM objects)
// GUID must be read from ProduceXml of an existing RT UDP module
// Format: plain GUID string, e.g. "{080D0399-6A65-408D-80E1-18D8F699496A}"
ITcSmTreeItem rtUdp = rtAdapter.CreateChild(
"RT UDP",
0, // 0 for GUID-based creation (as with TcCOM)
"",
"{080D0399-6A65-408D-80E1-18D8F699496A}"
);