Configuration test = xmlDoc.SelectSingleNode("TreeItem/DeviceDef/AddressInfo/Pnp/DeviceData") deviceDataString = test.InnerText; print deviceDataString # Print the MacID of the Device (contains 000105015c2a here) Writing Properties In this example, the Adapter settings should also be written to the configuration. Shortening the original XML to the following form and changing the Adapter parameters, will activate the new parameter set within the configuration (as long the parameters are correct). To test the settings before writing the script code, the "Import Xml Descriptions" Menu function is very helpful.
After the parameter change has been tested from within TwinCAT XAE, it is easy to write the script code that creates the valid parameterset and feeds the ITcTreeItem [ } 37] via the method ITcTreeItem::ConsumeXml(xml) [ } 61] , for example: xml = ' \ \ \ \ TCIXPNPE2 \ TCIXPNPE2 \ 00010501958f \ \ \ \ ' device = sysMan.LookupTreeItem("TIID^RTEthernet") device.ConsumeXml(xml) Calling Methods In some cases, specific methods should be triggered, for example the ScanBoxes functionality from TwinCAT XAE, which scans the device for all connected boxes. Looking at the XML-example from the above chapter Reading-Properties, the XML-Content contains a flag 0 .
This sort of XmlElement is called a "Method Trigger" and should indicate that the "ScanBoxes" functionality is currently not triggered. Consuming the following XML-Code at the device item will start a "ScanBoxes" and insert all found Boxes / Terminals into the configuration. Xml Data: Code Snippet (IronPython): xml = ' \ \ 1 \ \ Automation Interface 22 Version: 1.2