Esempio n. 1
0
        private void getGroupingInfo(StringBuilder sb)
        {
            sb.AppendLine("K5111/1 1");
            for (int i = 0; i < Charactericstics.Count; i++)
            {
                sb.AppendLine(string.Format("K5112/{0} {1}", i + 2, Charactericstics[i].id));                 //K5112/2 1
            }
            sb.AppendLine();

            for (int i = 0; i < Charactericstics.Count; i++)
            {
                QCharacteristic qc = Charactericstics[i];

                if (qc.children.Count == 0)
                {
                    sb.AppendLine("K5102/1 " + qc.id);
                }
                else
                {
                    sb.AppendLine("K5103/1 " + (qc.id + 1));
                    foreach (QCharacteristic qch in qc.children)
                    {
                        sb.AppendLine(string.Format("K5102/{0} {1}", qc.id + 1, qch.id));
                    }
                    i += qc.children.Count;
                }
            }
        }
Esempio n. 2
0
        public void Analyze()
        {
            //获得参数的个数。
            QLineInfo line = GetPram("K0100");

            //默认为-1,如果没读取值还是-1.
            int count = -1;

            if (line != null)
            {
                count = int.Parse(line.value);
                for (int j = 0; j < count; j++)
                {
                    Charactericstics.Add(new QCharacteristic());
                }
            }

            //小于0的话就退出。
            if (count < 0)
            {
                return;
            }

            //对每一个参数进行初始化。
            for (int i = 0; i < Lines.Count; i++)
            {
                line = Lines[i];
                int id = line.pid;

                if (id > 0)
                {
                    QCharacteristic p = Charactericstics[id - 1];
                    p.DealLine(line);
                }
            }

            //参数进行调整
            for (int i = 0; i < Charactericstics.Count; i++)
            {
                //pramters[i].Adjust();
            }

            //对数据进行调整,移除第1个参数为256的项。
            for (int i = 0; i < Data.Count; i++)
            {
                QData qd = Data[i];
                for (int j = 0; j < qd.items.Count; j++)
                {
                    if (!qd.items[j].addon[1].Equals("256"))
                    {
                        Charactericstics[j].data.Add(qd.items[j]);
                    }
                }
            }
        }
Esempio n. 3
0
        //定义了2种模式,PMode和DMode
        //其中PMode是指数据保证在参数的数据列表中,
        //而DMode是指数据放置在数据列表中。
        /// <summary>
        /// PMode是指数据保证在参数的数据列表中
        /// </summary>
        public bool ToPMode()
        {
            if (dataMode == QFileMode.PMode || data.Count == 0)
            {
                return(true);
            }

            int count = 0;

            try
            {
                //将data中的第一个QData分别给对应的参数赋值。
                for (int i = 0; i < data.Count; i++)
                {
                    for (int j = 0; j < pramters.Count; j++)
                    {
                        QCharacteristic p  = pramters[j];
                        QDataItem       di = data[i].items[j];
                        if (di.p1 == 0)
                        {
                            p.data.Add(di);
                            count++;
                        }
                    }
                }

                data.Clear();
                dataMode = QFileMode.PMode;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }


            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// 用于从文件中加载DFQ文件。
        /// </summary>
        /// <param name="path">DFQ文件的完整路径。</param>
        /// <returns></returns>
        public static QFile LoadFile(string path)
        {
            QFile qf = new QFile();

            //参数列表
            List <QCharacteristic> ps = new List <QCharacteristic>();


            // 文件读取部分,完成了以下几件事:
            // 1、读取每行,生成每行的QLineInfo对象
            // 2、先交给对应的参数处理,如果处理失败,再交给QFile处理
            // 3、如果不是QlineInfo对象,那么交给QFile的Data
            StreamReader sr = new StreamReader(path, Encoding.Default);

            while (!sr.EndOfStream)
            {
                try
                {
                    //先读取一行进来。
                    string s = sr.ReadLine();

                    //如果为空或长度为0,则继续下一次循环。
                    if (string.IsNullOrEmpty(s))
                    {
                        continue;
                    }

                    //去除前缀的空格,如果长度为0,则继续下一次循环。
                    s = s.TrimStart();
                    if (s.Length == 0)
                    {
                        continue;
                    }

                    //如果是K开头,那么就是定义,如果是‘/’那么就是注释,取消,否则就是数据。
                    if (s[0] == 'K' || s[0] == 'k')
                    {
                        QLineInfo line = new QLineInfo(s);

                        //如果是零配件信息,交由QF处理。"K1001 jet2013"
                        if (s[1] == '1')
                        {
                            qf.DealLine(line);
                        }
                        //否则是参数信息,交由参数层处理
                        else if (line.pid > 0)
                        {
                            if (line.pid > ps.Count)
                            {
                                for (int j = ps.Count; j < line.pid; j++)
                                {
                                    QCharacteristic p = new QCharacteristic();
                                    p.id = j + 1;
                                    ps.Add(p);
                                }
                            }
                            ps[line.pid - 1].DealLine(line);
                        }
                    }
                    //如果是/,那么就是注释,忽略。
                    else if (s[0] == '/')
                    {
                    }
                    else
                    {
                        qf.Data.Add(new QData(s));
                    }
                }
                catch { }
            }
            sr.Close();

            //取出生成的参数,添加至QFile中
            for (int i = 0; i < ps.Count; i++)
            {
                if (ps[i].id > 0)
                {
                    qf.Charactericstics.Add(ps[i]);
                }
            }

            //此处将QFile中的Data中的DataItem与
            //每个QPramater的QDataItem数据组一一对应。
            for (int i = 0; i < qf.Data.Count; i++)
            {
                for (int j = 0; j < qf.Data[i].items.Count; j++)
                {
                    qf.Charactericstics[j].data.Add(qf.Data[i].items[j]);
                }
            }

            return(qf);
        }
Esempio n. 5
0
        public static QFile LoadFromStrings(string[] data)
        {
            QFile qf = new QFile();

            //开始默认加载100个参数,方便下面的ps[line.pid - 1]的调用
            List <QCharacteristic> ps = new List <QCharacteristic>();

            for (int i = 0; i < 100; i++)
            {
                ps.Add(new QCharacteristic());
            }

            // 文件读取部分,完成了以下几件事:
            // 1、读取每行,生成每行的QLineInfo对象
            // 2、先交给对应的参数处理,如果处理失败,再交给QFile处理
            // 3、如果不是QlineInfo对象,那么交给QFile的Data


            for (int i = 0; i < data.Length; i++)
            {
                string s = data[i];

                if (s == null || s.Length == 0)
                {
                    continue;
                }

                if (s[s.Length - 1] == '\r')
                {
                    s = s.Substring(0, s.Length - 1);
                }

                //如果是K开头,那么就是定义,如果是‘/’那么就是注释,取消,否则就是数据。
                if (s[0] == 'K' || s[0] == 'k')
                {
                    QLineInfo line = new QLineInfo(s);

                    //如果是零配件信息,交由QF处理。
                    if (s[1] == '1')
                    {
                        qf.DealLine(line);
                    }
                    //否则是参数信息,交由参数层处理
                    else if (line.pid > 0)
                    {
                        QCharacteristic p = ps[line.pid - 1];
                        p.DealLine(line);
                    }
                }
                //如果是/,那么就是注释,忽略。
                else if (s[0] == '/')
                {
                }
                else
                {
                    qf.Data.Add(new QData(s));
                }
            }


            //取出生成的参数,添加至QFile中
            for (int i = 0; i < ps.Count; i++)
            {
                if (ps[i].id > 0)
                {
                    qf.Charactericstics.Add(ps[i]);
                }
            }

            //此处将QFile中的Data中的DataItem与
            //每个QPramater的QDataItem数据组一一对应。
            for (int i = 0; i < qf.Data.Count; i++)
            {
                for (int j = 0; j < qf.Data[i].items.Count; j++)
                {
                    qf.Charactericstics[j].data.Add(qf.Data[i].items[j]);
                }
            }

            return(qf);
        }
Esempio n. 6
0
        public bool LoadFile(string path)
        {
            //参数列表
            List <QCharacteristic> ps = new List <QCharacteristic>();

            // 文件读取部分,完成了以下几件事:
            // 1、读取每行,生成每行的QLineInfo对象
            // 2、先交给对应的参数处理,如果处理失败,再交给QFile处理
            // 3、如果不是QlineInfo对象,那么交给QFile的Data
            List <string> strs = GetLines(path);


            int   partid = 0;
            QPart part   = new QPart();

            foreach (string str in strs)
            {
                try
                {
                    //如果是K开头,那么就是定义,如果是‘/’那么就是注释,取消,否则就是数据。
                    if (str[0] == 'K' || str[0] == 'k')
                    {
                        QLineInfo line = new QLineInfo(str);

                        //如果是零配件信息,交由QF处理。"K1001 jet2013"
                        if (str[1] == '1')
                        {
                            partid = line.pid > 0 ? line.pid - 1 : 0;
                            if (partid + 1 > parts.Count)
                            {
                                QPart pt = new QPart();
                                pt.partid = line.pid;
                                parts.Add(pt);
                            }
                            parts[partid].DealLine(line);
                        }
                        //否则是参数信息,交由参数层处理
                        else if (str[1] == '2')
                        {
                            if (line.pid > ps.Count)
                            {
                                for (int j = ps.Count; j < line.pid; j++)
                                {
                                    QCharacteristic p = new QCharacteristic();
                                    p.partId = partid + 1;
                                    p.id     = j + 1;
                                    ps.Add(p);
                                    parts[partid].pramters.Add(p);
                                }
                            }
                            ps[line.pid - 1].DealLine(line);
                        }
                    }
                    //如果是/,那么就是注释,忽略。
                    else if (str[0] == '/')
                    {
                    }
                    else
                    {
                        this.data.Add(new QData(str));
                    }
                }
                catch { }
            }

            //取出生成的参数,添加至QFile中
            for (int i = 0; i < ps.Count; i++)
            {
                if (ps[i].id > 0)
                {
                    this.pramters.Add(ps[i]);
                }
            }

            //此处将QFile中的Data中的DataItem与
            //每个QPramater的QDataItem数据组一一对应。
            for (int i = 0; i < this.data.Count; i++)
            {
                for (int j = 0; j < this.data[i].items.Count; j++)
                {
                    this.pramters[j].data.Add(this.data[i].items[j]);
                }
            }


            return(true);
        }