Beispiel #1
0
        void AddBlock(XElement element)
        {
            string name = SimulinkXmlParser.GetName(element);
            string type = element.GetAttribute(SimulinkXmlParser.BlockType);

            lBlocks.Add(name);
            if (type.Equals(SimulinkXmlParser.SubSystem))
            {
                //     XElement[] children = SimulinkXmlParser.GetChildren(element);
                //        foreach (XElement child in children)
                //        {
                //              if (child.Name.Equals(SimulinkXmlParser.SystemStr))
                //              {
                SimulinkSubsystem system = new SimulinkSubsystem(element, this, null);
                listBlocks.Add(system);
                systems[system.Name] = system;
                esystems[system]     = system.Name;
                //                 return;
                //              }
                //          }
                return;
            }
            Block block = new Block(element, this);

            blocks[name]   = block;
            eblocks[block] = name;
            listBlocks.Add(block);
        }
Beispiel #2
0
        /// <summary>
        /// Creates document from list of strings
        /// </summary>
        /// <param name="text">List of strings</param>
        /// <returns>The document</returns>
        public static XElement Create(IList <string> text)
        {
            XElement doc = XElement.Parse("<Root/>");

            int nr = text.Count - 1;
            int nc = text[nr].Length;

            --nc;
            int eRow;
            int eColumn;

            SimulinkXmlParser  parser  = new SimulinkXmlParser(doc);
            IXmlElementCreator creator = parser;

            StaticExtensionXmlParserLibrary.FindNext(text, '{', false, 0, 0, out eRow, out eColumn);
            XElement[] elements = parser.Create(text, eRow, eColumn, nr, nc);
            foreach (XElement e in elements)
            {
                doc.Add(e);
            }
            return(parser.doc);
        }
Beispiel #3
0
 void Create(XElement element)
 {
     XElement[] children = SimulinkXmlParser.GetChildren(element);
     foreach (XElement e in children)
     {
         string type = e.Name.LocalName;
         if (!type.Equals(SimulinkXmlParser.Block))
         {
             continue;
         }
         AddBlock(e);
     }
     foreach (XElement e in children)
     {
         string type = e.Name.LocalName;
         if (!type.Equals(SimulinkXmlParser.Line))
         {
             continue;
         }
         ProcessArrow(e);
     }
 }
Beispiel #4
0
        void GetChildernBranches(XElement element, List <XElement> childern)
        {
            XElement[] ch = SimulinkXmlParser.GetChildren(element);
            if (ch.Length == 0)
            {
                if (element.Name.Equals(SimulinkXmlParser.Branch))
                {
                    childern.Add(element);
                }
                return;
            }
            bool b = true;

            foreach (XElement c in ch)
            {
                string type = c.Name.LocalName;
                if (!type.Equals(SimulinkXmlParser.Branch))
                {
                    continue;
                }
                XElement[] cch = SimulinkXmlParser.GetChildren(c);
                foreach (XElement el in cch)
                {
                    string tt = el.Name.LocalName;
                    if (!tt.Equals(SimulinkXmlParser.Branch))
                    {
                        continue;
                    }
                    b = false;
                    GetChildernBranches(el, childern);
                }
                if (b)
                {
                    childern.Add(c);
                }
            }
        }