ITcSmTreeItem::CreateChild
Creates a child item on a parent node. The child is being specified by its subtype.
HRESULT CreateChild(BSTRbstrName,long nSubType, BSTRbstrBefore, VARIANT vInfo, ITcSmTreeItem**pipItem);
The following example demonstrates this behavior in better detail.
In this example, an EK1100 coupler is being added to an EtherCAT Master device (Device 1) in TwinCAT XAE. In Automation Interface, this could be done with the CreateChild() method. The parent node (Device 1 EtherCAT) has the item type '2' (TREEITEMTYPE_DEVICE). The sub type specifies the child item and therefore the EK1100, which is sub type '9099' (BOXTYPE_EXXXXX).
Parameters
bstrName | [in] Item name of the new child item. |
nSubtype: | [in] Sub type of the new child item. The usable sub type depends on the item type (the category)of the parent tree item. For example, a PLC Functionblock may only be added to the item type PLCFOLDER and not to a DEVICE. |
bstrBefore | [in, defaultvalue("")] If set, the parameter contains the name of another child item before that the new item should be inserted. |
vInfo | [in, optional] An optional parameter with additional creation information, which depends on the sub type. The different dependencies are listed in the table below. |
pipItem | [out, retval] Points to the location of a ITcSmTreeItem interface pointer that receives the result. |
Return Values
S_OK |
function returns successfully. |
E_POINTER |
the location of the returning pointer is invalid |
TSM_E_INVALIDITEMSUBTYPE (0x98510003) |
the given sub type is invalid. |
TSM_E_ITEMNOTFOUND (0x98510001) |
The item bstrBefore was not found. |
Optional vInfo parameter
Depending on theitem subtypeof the new child item,someadditional informationmay berequiredto create the child item. This information can be provided via the vInfo parameter.
Untergeordnetes Element: Element-Subtyp |
vInfo-Parameter |
---|---|
E-Bus Box / Klemme / Modul (Element-Subtyp 9099) |
Contains the Identity Object (CoE 1018h, VendorId, ProductCode and optional RevisionNo and SerialNo) of the EtherCAT box. The type of the variant must be an array of LONG (VT_I4|VT_ARRAY, 2-4 elements). Alternatively contains a BSTR of the following formats (with %X = value in hex notation, e.g. "V00000002_P044c2c52_R00000000"): |
Interbus-Box. (Element-Subtyp 2002) |
Contains the IdentCode and LengthCode of the Interbus box. The type of the variant must be an unsigned short (VT_I2), the low byte contains the IdentCode the high byte the LengthCode. |
AX2000 (Element-Subtyp 5007) |
Optionally contains a bool value (VT_BOOL) and if set an additional variable for the `Following Error`will be created. |
DeviceNET (Element-Subtyp 5203) |
Optionally contains the file path to an EDS file (VT_BSTR). |
BK3000 und alle übrigen PROFIBUS-Box-Typen |
Optionally contains the file path to an GSD file (VT_BSTR). |
Variable |
Optionally contains the bit address of the new variable. The type of the variant can be a SHORT or a LONG (VT_I2 or VT_I4). |
SPS-POU Funktionsblock (Element-Subtyp 604) |
Contains IEC language type as Integer, as defined by IECLANGUAGETYPES. |
SPS-POU Funktion (Element-Subtyp 603) |
Contains a string[2] array, which hols the following values:
|