Пример #1
0
        /// <summary>
        /// 将数据转换为DMode,所有数据保存在QFile中的data列表中。
        /// </summary>
        /// <returns></returns>
        public bool ToDMode()
        {
            if (dataMode == QFileMode.DMode || pramters.Count == 0)
            {
                return(true);
            }
            int count = 0;

            try
            {
                //第一步,取参数中数据最多的那个。
                int max = 0;
                for (int i = 0; i < pramters.Count; i++)
                {
                    if (max <= pramters[i].data.Count)
                    {
                        max = pramters[i].data.Count;
                    }
                }

                //第二步,进行整理,把参数中带的数据,全放到数据QFile.Data中去。
                for (int i = 0; i < max; i++)
                {
                    QData qd = new QData();
                    for (int j = 0; j < pramters.Count; j++)
                    {
                        QDataItem di = new QDataItem();
                        if (i >= pramters[j].data.Count)
                        {
                            di.p1 = 256;
                        }
                        else
                        {
                            di = pramters[j].data[i];
                            count++;
                        }
                        qd.items.Add(di);
                    }
                    data.Add(qd);
                }

                //清除参数中的数据。
                for (int i = 0; i < pramters.Count; i++)
                {
                    pramters[i].data.Clear();
                }

                dataMode = QFileMode.DMode;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }
            //Console.WriteLine(count);
            return(true);
        }
Пример #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]);
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 将数据转换为DMode,所有数据保存在QFile中的data列表中。
        /// </summary>
        /// <returns></returns>
        public bool ToDMode()
        {
            // 如果已经是D模式了或者数据为空则返回。
            if (dataMode == QFileMode.DMode || Charactericstics.Count == 0)
            {
                return(true);
            }
            Data.Clear();

            //Step 1,取参数中数据最多的那个的参数个数保存在max中。
            int max = 0;

            for (int i = 0; i < Charactericstics.Count; i++)
            {
                max = max >= Charactericstics[i].data.Count ? max : Charactericstics[i].data.Count;
            }

            //Step 2,进行整理,把参数中带的数据,全放到数据QFile.Data中去。
            for (int i = 0; i < max; i++)
            {
                QData qd = new QData();
                //将参数中的数据复制到QFile的Data列表中。
                for (int j = 0; j < Charactericstics.Count; j++)
                {
                    QDataItem di = new QDataItem();
                    if (i >= Charactericstics[j].data.Count)
                    {
                        di.p1 = 255;
                    }
                    else
                    {
                        di = Charactericstics[j].data[i];
                    }
                    qd.items.Add(di);
                }
                Data.Add(qd);
            }

            //清除参数中的数据。
            for (int i = 0; i < Charactericstics.Count; i++)
            {
                Charactericstics[i].data.Clear();
            }


            dataMode = QFileMode.DMode;

            return(true);
        }
Пример #4
0
        /// <summary>
        /// 从DFX中加载数据,如果必需数据格式与当前的DFD或DFQ匹配时才能正常加载,加载后为D模式。
        /// 返回值表示是否加载成功。
        /// </summary>
        /// <param name="path"></param>
        public static bool LoadFromDFX(QFile qf, string dfxpath)
        {
            if (qf == null || qf.Charactericstics.Count == 0)
            {
                return(false);
            }

            StreamReader sr = new StreamReader(dfxpath, Encoding.Default);

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

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

                    //如果取得的数据个数与参数个数不同,则进入下一组数据。
                    QData qd = new QData(s);
                    if (qd.items.Count == qf.Charactericstics.Count)
                    {
                        qf.Data.Add(qd);
                    }
                }
                catch
                {
                }
            }


            return(true);
        }