예제 #1
0
        void ProcessBrunch(Path path, int[] begin, XElement element)
        {
            int[] x = new int[begin.Length];
            Array.Copy(begin, x, x.Length);
            int[]   y  = new int[] { 0, 0 };//x[0], x[1]};
            int[][] pp = SimulinkXmlParser.GetPoints(element);
            path.Add(y);
            if (pp != null)
            {
                foreach (int[] p in pp)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        y[i] += p[i];
                    }
                    path.Add(y);
                }
            }
            string b  = element.GetAttributeLocal(SimulinkXmlParser.SourceTarget[1]);
            string pb = element.GetAttributeLocal(SimulinkXmlParser.SourceTargetPorts[1]);

            if (b.Length > 0)
            {
                PortIO ff = GetConnectionPort(b, pb, true);
                path.Out = ff;
            }
        }
예제 #2
0
        void ProcessArrow(XElement element)
        {
            List <int[]> pstl = new List <int[]>();

            int[] xx   = null;
            Path  path = null;

            for (int i = 0; i < 2; i++)
            {
                string b = element.GetAttributeLocal(SimulinkXmlParser.SourceTarget[i]);
                string p = element.GetAttributeLocal(SimulinkXmlParser.SourceTargetPorts[i]);
                if (b.Length == 0)
                {
                    break;
                }
                PortIO pio = GetConnectionPort(b, p, i == 1);
                if (i == 0)
                {
                    path           = new Path(pio);
                    paths[element] = path;
                }
                else
                {
                    path.Out = pio;
                }
            }
            int[][] pp = SimulinkXmlParser.GetPoints(element);
            xx = new int[] { 0, 0 };
            if (pp != null)
            {
                //   Array.Copy(pp[0], xx, xx.Length);
                //  path.Add(pp[0]);
                foreach (int[] p in pp)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        xx[i] += p[i];
                    }
                    path.Add(xx);
                }
            }
            XElement[] children = SimulinkXmlParser.GetChildren(element);
            foreach (XElement child in children)
            {
                if (child.Name.Equals("Branch"))
                {
                    Path pn = path.Create();
                    ProcessBrunch(pn, xx, child);
                }
            }
        }