Exemple #1
0
        private PortIO GetConnectionPort(string block, string port, bool input)
        {
            XElement e   = blocks[block];
            PortIO   pio = new PortIO(e, port, input, ports);

            return(pio);
        }
Exemple #2
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;
            }
        }
Exemple #3
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);
                }
            }
        }
Exemple #4
0
        void CreatePoints(Dictionary <XElement, Dictionary <bool, Dictionary <string, PortIO> > > dic)
        {
            List <int[]> l = new List <int[]>();

            int[] x = null;
            if (x1 != null)
            {
                x = x1;
                Add(x, l);
            }
            else if (pin != null)
            {
                x = GetDefaultPort(pin.Element, pin.Port, false, dic);
                Add(x, l);
            }
            else
            {
                PortIO pio = Root.pin;
                x = GetDefaultPort(pio.Element, pio.Port, false, dic);
            }
            int[] kk = new int[2];
            foreach (int[] pp in points)
            {
                Array.Copy(x, kk, kk.Length);
                for (int i = 0; i < kk.Length; i++)
                {
                    kk[i] += pp[i];
                }
                Add(kk, l);
            }
            if (pou != null)
            {
                int[] y = GetDefaultPort(pou.Element, pou.Port + "", true, dic);
                Add(y, l);
            }
            pointsDraw = l.ToArray();
            if (children == null)
            {
                return;
            }
            foreach (Path path in children)
            {
                path.x1 = pointsDraw[pointsDraw.Length - 1];
                path.CreatePoints(dic);
            }
        }
Exemple #5
0
 internal Path(PortIO pin)
 {
     this.pin = pin;
     children = new List <Path>();
 }