beckhoff TE1000 TwinCAT 3 — 6.6.2 Performing a device scan

Samples | I/O 1 3 0000 5000 Activating the EtherCAT configuration To activate a TwinCAT configuration via the Automation Interface, you can use ITcSysManager::ActivateConfiguration() . Since the previous steps create an offline configuration without real addresses, the real addresses must be determined and entered using ScanDevices + ProduceXml / ConsumeXml before activation. 6.6.2 Performing a device scan | Performing a device scan A device scan detects the connected hardware and adds it to the I/O configuration. The scan is triggered on the I/O node via ProduceXml(false) . This call implicitly starts the scan and returns the detected devices synchronously as XML.

The devices are then read from the XML file, created individually using CreateChild , and their addresses are set using ConsumeXml . In the final step, a box scan on each device loads the subordinate terminals. Requirements A TwinCAT solution is open, and a DTE connection is active. ITcSysManager was initialized as a COM object in an STA thread. TwinCAT is in Config mode. The hardware is connected and turned on. C# sample: scanning using ProduceXml as a complete workflow If the scan is to run on a remote target system, the target NetID must first be set via SetTargetNetId . This step is not necessary when running the application locally.

ProduceXml(false) returns the detected devices under the path TreeItem/DeviceGrpDef/FoundDevices/Device . For each device node, the values ItemSubType and AddressInfo are read; the device is created using CreateChild , and its address is set using ConsumeXml . Finally, ScanBoxes loads the terminals for each device. ITcSysManager3 systemManager = /* ...

*/; systemManager.SetTargetNetId("1.2.3.4.5.6"); // remote target (omit for local) ITcSmTreeItem ioDevicesItem = systemManager.LookupTreeItem("TIID"); // ProduceXml(false) triggers an implicit ScanDevices and returns found devices string scannedXml = ioDevicesItem.ProduceXml(false); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(scannedXml); // Extract found devices from XML XmlNodeList xmlDeviceList = xmlDoc.SelectNodes("TreeItem/DeviceGrpDef/FoundDevices/Device"); List devices = new List (); int deviceCount = 0; foreach (XmlNode node in xmlDeviceList) { int itemSubType = int.Parse(node.SelectSingleNode("ItemSubType").InnerText); XmlNode xmlAddress = node.SelectSingleNode("AddressInfo"); // Create device in I/O configuration ITcSmTreeItem device = ioDevicesItem.CreateChild( string.Format("Device_{0}", ++deviceCount), itemSubType, TE1000 247 Version:

1.7.0