Пример #1
0
        /// <summary>
        /// 处理扫描结果,并绘制曲线
        /// </summary>
        private void SweepProcessing()
        {
            SweepProcesing2();

            #region 准备CSV数据项,并添加到数据项数组中
            CsvReport_IVH_Entry entry = new CsvReport_IVH_Entry();

            entry.No = PointsDone;

            entry.P = this.settings.Tx;

            if (sweep_or_time == SweepType.Freq_Sweep)
            {
                entry.F = sweep_points[0].X;
            }
            else
            {
                entry.F = this.settings.F;
            }

            entry.IVH_Value = sweep_points[0].Y;

            entry.Noise = sr.dBmNosie;

            entry.Rl = 0.0f;

            //将数据项添加到数组
            csv_entries[PointsDone] = entry;
            #endregion


            #region 更新扫描计数器
            PointsDone++;
            #endregion
        }
Пример #2
0
        /// <summary>
        /// 从IVH的CSV文件fileName读取信息,并将头部信息填充到header,将扫描项填充到列表entries
        /// 若成功则返回TRUE,
        /// 若出现文件被破坏(格式),或者读文件异常,转换异常等,则返回FALSE
        /// </summary>
        /// <param name="entries"></param>
        /// <param name="header"></param>
        /// <returns></returns>
        internal static bool Read_Csv_IVH(string fileName, out List <CsvReport_IVH_Entry> entries, out CsvReport_PIVH_Header header)
        {
            int    v, ln;
            string sLine;

            char[]              chars;
            string[]            sArray;
            CsvReport_IVH_Entry ivh_entry;

            StreamReader sr = null;

            //文件损坏指示
            bool bCrashed = false;

            try
            {
                //构造CSV文件的头部对象
                header = new CsvReport_PIVH_Header();

                //建立流
                sr = new StreamReader(fileName, Encoding.ASCII);

                //略过第一行
                sr.ReadLine();

                //读取第二行的日期与时间值
                header.Date_Time = sr.ReadLine();

                //略过第三、四行
                sr.ReadLine();
                sr.ReadLine();

                //读取第五行,测试参数
                //从左到右,以params开头,每个参数项以空格隔开
                //依次为扫描类型指示字、互调方案指示字、扫描点数、扫描参考值
                chars    = new char[1];
                chars[0] = ' ';
                sArray   = sr.ReadLine().Split(chars);

                v = int.Parse(sArray[1]);
                if (v == 0)
                {
                    header.Swp_Type = SweepType.Time_Sweep;
                }
                else
                {
                    header.Swp_Type = SweepType.Freq_Sweep;
                }

                v = int.Parse(sArray[2]);
                if (v == 0)
                {
                    header.Im_Schema = ImSchema.REV;
                }
                else
                {
                    header.Im_Schema = ImSchema.FWD;
                }

                header.Im_Order = (ImOrder)Enum.Parse(typeof(ImOrder),
                                                      Enum.GetName(typeof(ImOrder), int.Parse(sArray[3])));

                header.Sweep_Start = float.Parse(sArray[4]);

                header.Sweep_Stop = float.Parse(sArray[5]);

                header.Point_Num = int.Parse(sArray[6]);

                header.Limit_Value = float.Parse(sArray[7]);

                header.Y_Max_RL = float.Parse(sArray[8]);

                header.Y_Min_RL = float.Parse(sArray[9]);

                header.Y_Max_VSWR = float.Parse(sArray[10]);

                header.Y_Min_VSWR = float.Parse(sArray[11]);

                //略过第六、七行
                sr.ReadLine();
                sr.ReadLine();

                //一行文本包含的扫描项数量
                ln = 6;

                chars[0] = ',';
                entries  = new List <CsvReport_IVH_Entry>();

                //从第八行开始,读取扫描项数据
                sLine = sr.ReadLine();
                while (!String.IsNullOrEmpty(sLine))
                {
                    sArray = sLine.Split(chars);

                    if (sArray.Length != ln)
                    {
                        bCrashed = true;
                        break;
                    }

                    ivh_entry = new CsvReport_IVH_Entry();

                    ivh_entry.No        = int.Parse(sArray[0]);
                    ivh_entry.P         = float.Parse(sArray[1]);
                    ivh_entry.F         = float.Parse(sArray[2]);
                    ivh_entry.IVH_Value = float.Parse(sArray[3]);
                    ivh_entry.Noise     = float.Parse(sArray[4]);
                    ivh_entry.Rl        = float.Parse(sArray[5]);

                    entries.Add(ivh_entry);

                    //读取下一行,直到文件结束
                    sLine = sr.ReadLine();
                }

                sr.Close();
                sr.Dispose();
            }
            catch
            {
                entries  = null;
                header   = null;
                bCrashed = true;
                if (sr != null)
                {
                    sr.Close();
                    sr.Dispose();
                }
            }

            //返回值
            return(!bCrashed);
        }