/* =============================================================================================== * 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 createGvl(GvlInfo gvlInfo, ITcSmTreeItem parent, IWorker worker, XmlDocument doc) { XmlNode gvlNode = doc.SelectSingleNode("TcPlcObject/GVL"); string gvlName = gvlNode.Attributes["Name"].Value; worker.ProgressStatus = string.Format("Creating GlobalVariable Sheet '{0}' ...", gvlName); ITcSmTreeItem item = null; if (!TryLookupChild(parent, gvlName, out item)) { item = parent.CreateChild(gvlName, TreeItemType.PlcGvl.AsInt32()); } ITcXmlDocument xmlDoc = (ITcXmlDocument)item; ITcPlcDeclaration decl = (ITcPlcDeclaration)item; XmlElement node = (XmlElement)doc.SelectSingleNode("TcPlcObject/GVL/Declaration"); decl.DeclarationText = node.InnerText; return(item); }