How to exchange a fieldbus device and move all childs to the new one

Requirements

To exchange a fieldbus device and move all childs to the new one, an instance of the TwinCAT System Manager must be created and a configuration has to be opened. The LookupTreeItem method of the ITcSysManager interface returns a ITcSmTreeItem interface pointer implemented by the old fieldbus device. This interface contains a ExportChild and a ImportChild method of the tree item.

Procedure

The ProgId "TCatSysManager.TcSysManager" can be used to create an instance of the System Manager that implements the ITcSysManager interface.

Sample (vbscript):

set tsm = CreateObject("TCatSysManager.TcSysManager")
call tsm.OpenConfiguration("c:\exchange.wsm")
set item = tsm.LookupTreeItem("TIID")
set itemNew = item.CreateChild("Device 2 (FC310x)",38)
set itemOld = tsm.LookupTreeItem("TIID^Device 1(CP5412)")
for i = 1 to itemOld.ChildCount
    call itemOld.ExportChild(itemOld.Child(i).Name)
    call itemNew.ImportChild()
next
set itemOld = nothing
call item.DeleteChild("Device 1 (CP5412)")
call tsm.SaveConfiguration("c:\exchange2.wsm")

See Also

How to... section, ITcSysManager, LookupTreeItem, ITcSmTreeItem, ExportChild, ImportChild

Built on Tuesday, Mai 01, 2001