private ITcSmTreeItem createItf(ItfInfo itfInfo, ITcSmTreeItem parent, IWorker worker, XmlDocument doc)
        {
            XmlNode itfNode = doc.SelectSingleNode("TcPlcObject/Itf");
            string  itfName = itfNode.Attributes["Name"].Value;

            worker.ProgressStatus = string.Format("Creating Interface '{0}' ...", itfName);

            ITcSmTreeItem item = null;
            XmlElement    node = (XmlElement)doc.SelectSingleNode("TcPlcObject/Itf/Declaration");

            string declString = node.InnerText;

            if (!TryLookupChild(parent, itfName, out item))
            {
                item = parent.CreateChild(itfName, TreeItemType.PlcInterface.AsInt32(), "", declString);
            }

            //Debug.Fail("");
            ITcXmlDocument xmlDoc = (ITcXmlDocument)item;

            xmlDoc.DocumentXml = doc.OuterXml;
            ITcPlcDeclaration decl = (ITcPlcDeclaration)item;

            //decl.DeclarationText = node.InnerText;
            return(item);
        }
Beispiel #2
0
        /* ===============================================================================================
         * 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);
                    }
                }
            }
        }