/* =============================================================================================== * Helper method to iterate over all child nodes of Plc\PlcObjects in Orders.xml * =============================================================================================== */ private void addPlcElements(ref List <PlcObjectInfo> list, XmlNodeList xmlElements) { if (xmlElements != null) { foreach (XmlElement element in xmlElements) { PlcObjectType type = (PlcObjectType)Enum.Parse(typeof(PlcObjectType), element.Attributes["type"].Value); PlcObjectInfo info = null; switch (type) { case PlcObjectType.Library: info = new LibraryInfo(element); break; case PlcObjectType.Placeholder: info = new PlaceholderInfo(element); break; case PlcObjectType.DataType: info = new DataTypeInfo(element); break; case PlcObjectType.POU: info = new POUInfo(element); break; case PlcObjectType.Itf: info = new ItfInfo(element); break; case PlcObjectType.Gvl: info = new GvlInfo(element); break; default: Debug.Fail(""); break; } if (info != null) { list.Add(info); } } } }
private ITcSmTreeItem createPou(POUInfo pouInfo, ITcSmTreeItem parent, IWorker worker, XmlDocument doc) { XmlNode pouNode = doc.SelectSingleNode("TcPlcObject/POU"); string pouName = pouNode.Attributes["Name"].Value; worker.ProgressStatus = string.Format("Creating POU '{0}' ...", pouName); ITcSmTreeItem item = null; if (!TryLookupChild(parent, pouName, out item)) { item = parent.CreateChild(pouName, TreeItemType.PlcPouFunctionBlock.AsInt32(), "", null); } // some items need to be casted to a more special interface to gain access to all of their methods and properties, for example POUs which need // to be casted to the interface ITcPlcPou to get access to their unique methods and properties. ITcPlcPou pou = (ITcPlcPou)item; pou.DocumentXml = doc.OuterXml; // get/set PLC code of a POU in XML Format return(item); }