Example #1
0
        ///// <summary>
        ///// 导入输出校准文件
        ///// </summary>
        //private void btnOutput_Click(object sender, RoutedEventArgs e)
        //{
        //    OpenFileDialog ofd = new OpenFileDialog();
        //    ofd.Filter = "(*.txt)|*.txt";
        //    //ofd.DefaultExt = "*.txt";
        //    ofd.FilterIndex = 1;
        //    //记忆上次打开的文件路径
        //    ofd.RestoreDirectory = true;
        //    DialogResult dialogResult = ofd.ShowDialog();
        //    //if (DialogResult.OK != dialogResult && DialogResult.Yes != dialogResult)
        //    //{
        //    //    return;
        //    //}

        //    //选择的文件名称
        //    string tmpFilePathAndName = ofd.FileName;
        //    textBoxOutput.Text = tmpFilePathAndName;
        //    TextReader reader = null;
        //    try
        //    {
        //        reader = new StreamReader(File.Open(tmpFilePathAndName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
        //        string text = reader.ReadToEnd();
        //        reader.Close();
        //        string[] textArray = text.Split(new char[] { ' ', '\t', ',', '\n', '\r' });
        //        ArrayList list = new ArrayList();
        //        foreach (string text2 in textArray)
        //        {
        //            if (text2.Length > 0)
        //            {
        //                list.Add(Convert.ToDouble(text2, NumberFormatInfo.InvariantInfo));
        //            }
        //        }
        //        int num = ((int)Math.Floor((double)(list.Count / 2))) * 2;
        //        int num2 = num / 2;
        //        double[] numArray = (double[])list.ToArray(typeof(double));
        //        double[] DataFreq = new double[num2];
        //        double[] DataFreqOffset = new double[num2];
        //        //DUTHandler.CurDUT.AntennaInfo.OffsetBaseFreqList.Clear();

        //         List < offsetFreq > offset=new List<offsetFreq>();
        //        int index = 0;
        //        for (int j = 0; j < num; j += 2)
        //        {
        //            DataFreq[index] = numArray[j];
        //            DataFreqOffset[index] = numArray[j + 1];
        //            index++;
        //            offset.Add
        //                (
        //                    new offsetFreq()
        //                    {
        //                        FreqInMHz = numArray[j],
        //                        ReceiverOffsetFreqInMHz = numArray[j + 1]
        //                    }
        //                );
        //        }
        //        Test_Paramter.CurPWDCPowerInfo.OutputFileoffst = offset;

        //    }
        //    catch (Exception)
        //    {
        //        if (reader != null)
        //        {
        //            reader.Close();
        //        }
        //        System.Windows.MessageBox.Show("输出校准文件解析错误,请检查文件内容是否符合相应规范。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
        //    }
        //}

        ///// <summary>
        ///// 导入输入校准文件
        ///// </summary>
        //private void btnInput_Click(object sender, RoutedEventArgs e)
        //{
        //    OpenFileDialog ofd = new OpenFileDialog();
        //    ofd.Filter = "(*.txt)|*.txt";
        //    //ofd.DefaultExt = "*.txt";
        //    ofd.FilterIndex = 1;
        //    //记忆上次打开的文件路径
        //    ofd.RestoreDirectory = true;
        //    DialogResult dialogResult = ofd.ShowDialog();
        //    //if (DialogResult.OK != dialogResult && DialogResult.Yes != dialogResult)
        //    //{
        //    //    return;
        //    //}

        //    //选择的文件名称
        //    string tmpFilePathAndName = ofd.FileName;
        //    textBoxInput.Text = tmpFilePathAndName;
        //    TextReader reader = null;
        //    try
        //    {
        //        reader = new StreamReader(File.Open(tmpFilePathAndName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
        //        string text = reader.ReadToEnd();
        //        reader.Close();
        //        string[] textArray = text.Split(new char[] { ' ', '\t', ',', '\n', '\r' });
        //        ArrayList list = new ArrayList();
        //        foreach (string text2 in textArray)
        //        {
        //            if (text2.Length > 0)
        //            {
        //                list.Add(Convert.ToDouble(text2, NumberFormatInfo.InvariantInfo));
        //            }
        //        }
        //        int num = ((int)Math.Floor((double)(list.Count / 2))) * 2;
        //        int num2 = num / 2;
        //        double[] numArray = (double[])list.ToArray(typeof(double));
        //        double[] DataFreq = new double[num2];
        //        double[] DataFreqOffset = new double[num2];
        //        //DUTHandler.CurDUT.AntennaInfo.OffsetBaseFreqList.Clear();

        //         List < offsetFreq >  offlist=new List<offsetFreq>();
        //        int index = 0;
        //        for (int j = 0; j < num; j += 2)
        //        {
        //            DataFreq[index] = numArray[j];
        //            DataFreqOffset[index] = numArray[j + 1];
        //            index++;
        //            offlist.Add
        //                (
        //                    new offsetFreq()
        //                    {
        //                        FreqInMHz = numArray[j],
        //                        ReceiverOffsetFreqInMHz = numArray[j + 1]
        //                    }
        //                );
        //        }
        //        Test_Paramter.CurPWDCPowerInfo.InputFileoffst = offlist;
        //    }
        //    catch (Exception)
        //    {
        //        if (reader != null)
        //        {
        //            reader.Close();
        //        }
        //        System.Windows.MessageBox.Show("输入校准文件解析错误,请检查文件内容是否符合相应规范。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
        //    }

        //}

        private void btnCheck_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SystemHardware systemHardware = SystemHardware.SysHardware;
                systemHardware.Connect();
            }
            catch (TargetInvocationException ex)
            {
                GlobalStatusReport.ReportError(ex);
            }
        }
Example #2
0
        public int ExecuteTestSpurious(SystemHardware inSys, TestStructParameters m_Parameters, out TestStructResults m_Results)
        {
#if Simulate
            m_Results = new TestStructResults();
            m_Results.m_MonitorInfo = new DUTMonitorInfo();
            #region 获取遥测数据
            DUTCtrl.CaptureDUTMonitorinfo(out m_Results.m_MonitorInfo);
            #endregion
            m_Results.m_SpuriousSuppression = 30;//杂波抑制度
            m_Results.m_CarrierPower        = m_Parameters.m_InputPower;
            m_Results.m_SpuriousPower       = m_Parameters.m_InputPower + 30;
            m_Results.m_SpuriousFreq        = m_Parameters.m_Freq + 100 * 1e6;
            m_Results.m_TraceData           = new KeyValuePair <double, double> [201];
            for (int i = 0; i < 201; i++)
            {
                m_Results.m_TraceData[i] = new KeyValuePair <double, double>(10 * 1e6 + 200 * 1e6 * i, 10 * Math.Tan(Math.PI * i / 100));
            }
            return(0);
#endif
            try
            {
                double m_StartFreq = m_Parameters.m_StartFreq;
                double m_StopFreq  = m_Parameters.m_StopFreq;
                double Temp_LeftSideSpuriousFreq   = -999;
                double Temp_LeftSideSpuriousPower  = -999;
                double Temp_RightSideSpuriousFreq  = -999;
                double Temp_RightSideSpuriousPower = -999;
                double Temp_RefLevle = -999; //参考功率,调节时功率测量时使用
                double Temp_MaxPower = -999; //频谱中出现的最大功率
                double Temp_Scale    = 10;   //频谱仪当前垂直尺度
                double Temp_MarkerValue;     //当前游标值
                string Temp_SAFDOList = string.Empty;

                m_Results = new TestStructResults();

                #region 设备复位
                m_SG = SystemHardware.Hardware <SignalGenerator> .GetElmentByName("RackSys.TestLab.Instrument.SignalGenerator1");

                if (m_Parameters.m_FirstTest)
                {
                    //信号源复位
                    //inSys.AnalogSignalGenerator.Preset();
                    //inSys.CurrentInstruments
                    m_SG.Preset();
                    //频谱仪复位
                    inSys.SpectrumAnalyzer.AutoAlignEnabled = false;
                    inSys.SpectrumAnalyzer.WaitOpc();
                    inSys.SpectrumAnalyzer.ModePreset();
                    inSys.SpectrumAnalyzer.WaitOpc();
                }
                #endregion 设备复位

                #region 设备基础设置

                //信号源设置
                if (m_Parameters.m_FirstTest)
                {
                    m_SG.RFFrequency = m_Parameters.m_SGFreq;
                    m_SG.AmplOffset  = m_Parameters.m_SGOffsetValue;
                    m_SG.RFPower     = m_Parameters.m_InputPower;
                }
                inSys.SpectrumAnalyzer.StartFrequency = m_Parameters.m_StartFreq;
                inSys.SpectrumAnalyzer.StopFrequency  = m_Parameters.m_StopFreq;
                //频谱仪设置
                if (m_Parameters.m_FirstTest)
                {
                    //RBW设置
                    if (!m_Parameters.m_AutoRBW)
                    {
                        inSys.SpectrumAnalyzer.RBW = m_Parameters.m_RBW;
                    }

                    //VBW设置
                    if (!m_Parameters.m_AutoVBW)
                    {
                        inSys.SpectrumAnalyzer.VBW = m_Parameters.m_VBW;
                    }

                    //Scale设置
                    if (m_Parameters.m_AutoScale)
                    {
                        inSys.SpectrumAnalyzer.dBperDiv = 10;
                    }
                    else
                    {
                        inSys.SpectrumAnalyzer.dBperDiv = m_Parameters.m_Scale;
                    }
                    Temp_Scale = inSys.SpectrumAnalyzer.dBperDiv;//记录实际垂直标尺

                    //补偿表设置
                    for (int i = 0; i < 6; i++)
                    {
                        inSys.SpectrumAnalyzer.Set_CorrectionState(i + 1, false);
                    }
                    inSys.SpectrumAnalyzer.Set_CorrectionState(1, true);

                    //inSys.SpectrumAnalyzer.SetTraceMode(1, SpectrumAnalyzer.TriggerMode.);
                    inSys.SpectrumAnalyzer.SetDetectorMode(1, SpectrumAnalyzer.DetectorMode.POS);
                    inSys.SpectrumAnalyzer.SetMarkerModeByIndex(SpectrumAnalyzer.MarkerModeType.Position, 1);
                    //inSys.SpectrumAnalyzer.PeakExcursionStateOfNxtPkCriteria = false;

                    //扫描时间设置
                    if (m_Parameters.m_AutoSweepTime)
                    {
                    }
                    else
                    {
                        inSys.SpectrumAnalyzer.SweepTime = m_Parameters.m_SweepTime;
                    }

                    inSys.SpectrumAnalyzer.ContinuousSweepEnabled = true;
                }

                #endregion 设备基础设置

                #region 设置变更
                //偏置与补偿变更设置
                if (m_Parameters.m_EditSGOffset)
                {
                    m_SG.AmplOffset = -m_Parameters.m_SGOffsetValue;
                    m_SG.RFPower    = m_Parameters.m_InputPower;
                    //m_DUTProtection.Sg_RFPower(inSys.AnalogSignalGenerator, m_Parameters.m_InputPower);
                }
                //频率变更设置
                m_SG.RFFrequency = m_Parameters.m_SGFreq;
                double ampoffset = m_Parameters.m_SAGlobalOffset;
                inSys.SpectrumAnalyzer.AMP_Offset = -ampoffset;

                #endregion
                //inSys.SpectrumAnalyzer.MarkerToCenterFreq(1);
                //inSys.SpectrumAnalyzer.ContinuousSweepEnabled = false;
                inSys.SpectrumAnalyzer.Sweep(100000);
                inSys.SpectrumAnalyzer.WaitOpc();
                inSys.SpectrumAnalyzer.MarkerPeakSearch(1);
                m_Results.m_NOSourcePower = inSys.SpectrumAnalyzer.Marker1Value;
                m_SG.RFOutputEnabled      = true;
                inSys.SpectrumAnalyzer.WaitOpc();
                Thread.Sleep(50);
                //inSys.SpectrumAnalyzer.MarkerPeakSearch(1);
                #region 测试载波参数
                //inSys.SpectrumAnalyzer.CenterFrequency = m_Parameters.m_Freq;
                //inSys.SpectrumAnalyzer.Span = m_Parameters.m_IgnoreBWidth;
                //inSys.SpectrumAnalyzer.SetMarkerPositionByIndex(m_Parameters., 1);

                #region 关闭平均以快速调整RefLvl
                inSys.SpectrumAnalyzer.Averages = 1;
                inSys.SpectrumAnalyzer.WaitOpc();

                inSys.SpectrumAnalyzer.Sweep(100000);
                inSys.SpectrumAnalyzer.WaitOpc();

                for (int i = 0; i < 20; i++)
                {
                    inSys.SpectrumAnalyzer.MarkerPeakSearch(1);
                    Temp_RefLevle = inSys.SpectrumAnalyzer.Marker1Value;
                    if (Temp_RefLevle < -170)
                    {
                        Temp_RefLevle = -170;
                    }
                    inSys.SpectrumAnalyzer.ReferenceLevel = Temp_RefLevle;

                    inSys.SpectrumAnalyzer.Sweep(100000);
                    inSys.SpectrumAnalyzer.WaitOpc();
                    Temp_MarkerValue = inSys.SpectrumAnalyzer.Marker1Value;
                    //检查markertoRef功能,是都已经调整到位。
                    if ((Temp_RefLevle - Temp_MarkerValue) > (Temp_Scale * -0.25) && (Temp_RefLevle - Temp_MarkerValue) < (Temp_Scale * 0.5))
                    {
                        break;
                    }
                }
                Temp_RefLevle = inSys.SpectrumAnalyzer.ReferenceLevel;
                inSys.SpectrumAnalyzer.ReferenceLevel = Temp_RefLevle + Temp_Scale;
                #endregion

                //平均设置
                if (m_Parameters.m_AverageFactor > 0)
                {
                    inSys.SpectrumAnalyzer.Averages = (uint)m_Parameters.m_AverageFactor;
                }
                inSys.SpectrumAnalyzer.ContinuousSweepEnabled = false;
                //扫描测量
                inSys.SpectrumAnalyzer.Sweep(100000);
                inSys.SpectrumAnalyzer.WaitOpc();
                Thread.Sleep(50);
                inSys.SpectrumAnalyzer.MarkerPeakSearch(1);
                m_Results.m_CarrierPower = inSys.SpectrumAnalyzer.Marker1Value;
                #endregion 测试载波参数
                //通过计算获取杂波信号
                //double[] Ytracedate=inSys.SpectrumAnalyzer.TraceDataByIndex(1);
                //double[] Xtracedata= inSys.SpectrumAnalyzer.TraceXaxis;
                //List<double> SpuriousList = new List<double>();

                //for (int i = 0; i < Xtracedata.Count(); i++)
                //{
                //    if (Xtracedata[i]< m_Parameters.m_SAFreq - m_Parameters.m_IgnoreBWidth / 2||
                //        Xtracedata[i] > m_Parameters.m_SAFreq + m_Parameters.m_IgnoreBWidth / 2)
                //    {
                //        SpuriousList.Add(Ytracedate[i]);
                //    }
                //}
                //m_Results.m_SpuriousPower = SpuriousList.Max();
                //#region 测试左侧参数

                if (m_StartFreq < (m_Parameters.m_SAFreq - m_Parameters.m_IgnoreBWidth / 2))
                {
                    inSys.SpectrumAnalyzer.StartFrequency = m_StartFreq;
                    inSys.SpectrumAnalyzer.StopFrequency  = m_Parameters.m_SAFreq - m_Parameters.m_IgnoreBWidth / 2;
                    if (m_Parameters.m_SweepPoints > 1001)
                    {
                        inSys.SpectrumAnalyzer.SweepPoints = 1001;
                    }
                    else
                    {
                        inSys.SpectrumAnalyzer.SweepPoints = m_Parameters.m_SweepPoints;
                    }

                    inSys.SpectrumAnalyzer.Sweep(100000 * (int)m_Parameters.m_AverageFactor);
                    inSys.SpectrumAnalyzer.WaitOpc();

                    inSys.SpectrumAnalyzer.MarkerPeakSearch(1);
                    Temp_LeftSideSpuriousPower = inSys.SpectrumAnalyzer.Marker1Value;
                    Temp_LeftSideSpuriousFreq  = inSys.SpectrumAnalyzer.Marker1Position;
                }
                #endregion 测试左侧参数

                #region 测试右侧参数
                if (m_StopFreq > (m_Parameters.m_SAFreq + m_Parameters.m_IgnoreBWidth / 2))
                {
                    inSys.SpectrumAnalyzer.StartFrequency = m_Parameters.m_SAFreq + m_Parameters.m_IgnoreBWidth / 2;
                    inSys.SpectrumAnalyzer.StopFrequency  = m_StopFreq;
                    if (m_Parameters.m_SweepPoints > 1001)
                    {
                        inSys.SpectrumAnalyzer.SweepPoints = 1001;
                    }
                    else
                    {
                        inSys.SpectrumAnalyzer.SweepPoints = m_Parameters.m_SweepPoints;
                    }

                    inSys.SpectrumAnalyzer.Sweep(100000 * (int)m_Parameters.m_AverageFactor);
                    inSys.SpectrumAnalyzer.WaitOpc();

                    inSys.SpectrumAnalyzer.MarkerPeakSearch(1);
                    Temp_RightSideSpuriousPower = inSys.SpectrumAnalyzer.Marker1Value;
                    Temp_RightSideSpuriousFreq  = inSys.SpectrumAnalyzer.Marker1Position;
                }
                #endregion 测试右侧参数

                m_SG.RFOutputEnabled = false;

                //#region 完成测试
                //if (m_Parameters.m_LastTest)
                //{
                //    if (m_Parameters.m_ContinueMeasAfterTest)//继续测量
                //    {
                //        inSys.SpectrumAnalyzer.ContinuousSweepEnabled = true;
                //        m_SG.RFOutputEnabled = true;
                //    }
                //    else//关闭信号源输出
                //    {
                //        m_SG.RFOutputEnabled = false;
                //    }
                //}
                //#endregion

                #region 计算抑制度
                if (Temp_LeftSideSpuriousPower >= Temp_RightSideSpuriousPower)
                {
                    m_Results.m_SpuriousPower = Temp_LeftSideSpuriousPower;
                    m_Results.m_SpuriousFreq  = Temp_LeftSideSpuriousFreq;
                }
                else
                {
                    m_Results.m_SpuriousPower = Temp_RightSideSpuriousPower;
                    m_Results.m_SpuriousFreq  = Temp_RightSideSpuriousFreq;
                }
                m_Results.m_SpuriousSuppression = m_Results.m_CarrierPower - m_Results.m_SpuriousPower;
                #endregion 计算抑制度

                return(0);
            }
            catch (Exception ex)
            {
                GlobalStatusReport.ReportError("[信号源 + 频谱仪] 杂波特性 核心测试异常:" + ex.StackTrace, ex);
                throw ex;
            }
        }
Example #3
0
        /// <summary>
        /// 执行测试过程
        /// </summary>
        /// <param name="inSys">SystemHardware</param>
        /// <param name="m_NoiseFigureParameter">参数</param>
        /// <param name="m_NoiseFigureTestResult">结果</param>
        /// <returns>0:正常返回,,,,-1:强制中断</returns>
        public static int ExecuteTest(
            SystemHardware inSys,
            NoiseFigureTestStructParameter m_NoiseFigureParameter,
            out NoiseFigureTestStructResult m_NoiseFigureTestResult
            )
        {
            try
            {
#if Simulate
                m_NoiseFigureTestResult               = new NoiseFigureTestStructResult();
                m_NoiseFigureTestResult.m_FreqList    = m_NoiseFigureParameter.m_FreqList;
                m_NoiseFigureTestResult.m_Gain        = new double[m_NoiseFigureParameter.m_FreqList.Length];
                m_NoiseFigureTestResult.m_NoiseFigure = new double[m_NoiseFigureParameter.m_FreqList.Length];
                for (int i = 0; i < m_NoiseFigureTestResult.m_NoiseFigure.Length; i++)
                {
                    m_NoiseFigureTestResult.m_NoiseFigure[i] = 3 + 0.1 * i;
                }
                //噪声系数最大值的仿真处理
                m_NoiseFigureTestResult.m_NoiseFigureMax = 3 + 0.1 * (m_NoiseFigureTestResult.m_NoiseFigure.Length - 1);
                //最大值频点位置
                m_NoiseFigureTestResult.m_FreqForNoiseFigureMax
                    = m_NoiseFigureTestResult.m_FreqList[m_NoiseFigureTestResult.m_FreqList.Length - 1];

                string ImagefileName = AppDomain.CurrentDomain.BaseDirectory + @"\屏幕截图仿真\噪声系数测试样图.png";

                m_NoiseFigureTestResult.m_ScreenImage = Image.FromFile(ImagefileName);

                Thread.Sleep(100);
                DUTCtrl.CaptureDUTMonitorinfo(out tmpDutMonitorInfo);

                GlobalStatusReport.Report("噪声系数测试:仿真测试结果");
                return(0);
#endif
                m_NoiseFigureTestResult               = new NoiseFigureTestStructResult();
                m_NoiseFigureTestResult.m_FreqList    = m_NoiseFigureParameter.m_FreqList;
                m_NoiseFigureTestResult.m_NoiseFigure = new double[m_NoiseFigureParameter.m_FreqList.Length];
                m_NoiseFigureTestResult.m_Gain        = new double[m_NoiseFigureParameter.m_FreqList.Length];
                inSys.SpectrumAnalyzer.Timeout        = 30 * 1000;

                //inSys.SpectrumAnalyzer.SaveStateToPath("D:/User_My_Documents/Instrument/My Documents/SA/state/CalStateTemp.state");
                //inSys.SpectrumAnalyzer.WaitOpc();
                //频谱仪复位
                inSys.SpectrumAnalyzer.AutoAlignEnabled = false;
                inSys.SpectrumAnalyzer.WaitOpc();
                inSys.SpectrumAnalyzer.Preset();
                inSys.SpectrumAnalyzer.WaitOpc();
                inSys.SpectrumAnalyzer.NoiseFigureMode();
                inSys.SpectrumAnalyzer.WaitOpc();
                inSys.SpectrumAnalyzer.ModePreset();
                inSys.SpectrumAnalyzer.WaitOpc();

                if (m_NoiseFigureParameter.m_RecallStateFileEnable)
                {
                    inSys.SpectrumAnalyzer.LoadStateFromPath(m_NoiseFigureParameter.m_RecallStateFileName);
                }
                else
                {
                    //无需调用原有的状态文件时,则重新调用当前状态,抵消仪表reset带来的影响。
                    inSys.SpectrumAnalyzer.LoadState("CalStateTemp");
                }
                inSys.SpectrumAnalyzer.SendSCPI(":NFIG:CAL:STAT ON");
                inSys.SpectrumAnalyzer.WaitOpc();
                //次数设置测试所使用的参数
                //频谱仪设置
                inSys.SpectrumAnalyzer.StartFrequency = m_NoiseFigureParameter.m_StartFerq;
                inSys.SpectrumAnalyzer.WaitOpc();
                inSys.SpectrumAnalyzer.StopFrequency = m_NoiseFigureParameter.m_StopFerq;
                inSys.SpectrumAnalyzer.WaitOpc();
                inSys.SpectrumAnalyzer.NF_RBW = m_NoiseFigureParameter.m_RBW;
                inSys.SpectrumAnalyzer.WaitOpc();
                inSys.SpectrumAnalyzer.Averages = m_NoiseFigureParameter.m_AverageNum;
                inSys.SpectrumAnalyzer.WaitOpc();
                inSys.SpectrumAnalyzer.SweepPoints = m_NoiseFigureParameter.m_SweepPoints;
                inSys.SpectrumAnalyzer.WaitOpc();


                //关闭连续扫描
                inSys.SpectrumAnalyzer.ContinuousSweepEnabled = false;
                inSys.SpectrumAnalyzer.WaitOpc();

                //设置显示窗口Zoom,将Gain的曲线隐藏,调试时请屏蔽代码,用于观察信号。
                //inSys.SpectrumAnalyzer.SelectDisplayWindow(1);
                //inSys.SpectrumAnalyzer.WaitOpc();
                //inSys.SpectrumAnalyzer.SetWindowZoom(true);
                //inSys.SpectrumAnalyzer.WaitOpc();
                inSys.SpectrumAnalyzer.SetNFWindowAutoScale(1, true);
                inSys.SpectrumAnalyzer.WaitOpc();
                inSys.SpectrumAnalyzer.SetNFWindowAutoScale(2, true);
                inSys.SpectrumAnalyzer.WaitOpc();
                inSys.SpectrumAnalyzer.SetDisPlayFormat(SpectrumAnalyzer.DisPlayModeType.GRAPh);
                inSys.SpectrumAnalyzer.WaitOpc();


                //路径补偿数据
                //inSys.SpectrumAnalyzer.NoiseFigureLossCompModeBeforeDUT(SpectrumAnalyzer.NoiseFigureLossCompMode.TABL);
                //inSys.SpectrumAnalyzer.WaitOpc();
                //inSys.SpectrumAnalyzer.NoiseFigureLossCompModeAfterDUT(SpectrumAnalyzer.NoiseFigureLossCompMode.TABL);
                //inSys.SpectrumAnalyzer.WaitOpc();
                //inSys.SpectrumAnalyzer.SetLossCompTableBeforeDUT(m_NoiseFigureParameter.m_LossCompTabelBeforeDUT);        //2014.3.11改变噪声系数补偿方式,不采用beforeDUT,afterDUT的补偿方式,改为程序自己计算。苏渊红。
                //inSys.SpectrumAnalyzer.WaitOpc();
                //inSys.SpectrumAnalyzer.SetLossCompTableAfterDUT(m_NoiseFigureParameter.m_LossCompTabelAfterDUT);
                //inSys.SpectrumAnalyzer.WaitOpc();

                //启动扫描一次
                inSys.SpectrumAnalyzer.Sweep();
                //inSys.SpectrumAnalyzer.WaitOpc();

                inSys.SpectrumAnalyzer.WaitOpc(Convert.ToInt32(m_NoiseFigureParameter.m_SweepPoints * m_NoiseFigureParameter.m_AverageNum * 1000));

                //读取噪声系数测试结果
                inSys.SpectrumAnalyzer.SetMarkerModeByIndex(SpectrumAnalyzer.MarkerModeType.Position, 1);
                inSys.SpectrumAnalyzer.WaitOpc();
                double temp_maxNF     = 0;
                double temp_maxNFFreq = 0;



                for (int i = 0; i < m_NoiseFigureParameter.m_FreqList.Length; i++)
                {
                    inSys.SpectrumAnalyzer.SetMarkerPositionByIndex(m_NoiseFigureParameter.m_FreqList[i], 1);
                    inSys.SpectrumAnalyzer.WaitOpc();
                    double tempNF = inSys.SpectrumAnalyzer.GetMarkerNFValueByIndex(1);
                    inSys.SpectrumAnalyzer.WaitOpc();
                    double tempGain = inSys.SpectrumAnalyzer.GetMarkerGainValueByIndex(1);
                    inSys.SpectrumAnalyzer.WaitOpc();
                    m_NoiseFigureTestResult.m_NoiseFigure[i] = Math.Round(tempNF, 2);
                    m_NoiseFigureTestResult.m_Gain[i]        = Math.Round(tempGain, 2);



                    //add 2014.03.11,噪声系数计算公式--根据总的噪声系数和增益,计算被测DUT实际的噪声系数
                    #region 真实噪声系数计算
                    NoseFigureCalResult RealNFResult = new NoseFigureCalResult();
                    //todo
                    double inputRouteLossIndB = 0;
                    //m_NoiseFigureParameter.m_InputRouteLossCalResultForOnePath.GetRouteLossIndBAtFreq(m_NoiseFigureParameter.m_FreqList[i]);
                    double outputRouteLossIndB =
                        0;
                    NoisFigureCalculation(inputRouteLossIndB, outputRouteLossIndB, tempNF, tempGain, out RealNFResult);
                    m_NoiseFigureTestResult.m_NoiseFigure[i] = Math.Round(RealNFResult.RealNoiseFigure, 2);
                    m_NoiseFigureTestResult.m_Gain[i]        = Math.Round(RealNFResult.RealGain, 2);
                    if (m_NoiseFigureTestResult.m_NoiseFigure[i] > temp_maxNF)//追踪最大噪声系数的点
                    {
                        temp_maxNF     = m_NoiseFigureTestResult.m_NoiseFigure[i];
                        temp_maxNFFreq = m_NoiseFigureParameter.m_FreqList[i];
                    }
                    #endregion 真实噪声系数计算
                }


                if (m_NoiseFigureParameter.m_IsReadMaxNoiseFigure)
                {
                    m_NoiseFigureTestResult.m_NoiseFigureMax        = temp_maxNF;
                    m_NoiseFigureTestResult.m_FreqForNoiseFigureMax = temp_maxNFFreq;
                }
                if (m_NoiseFigureParameter.Yscale > 0)    //  Scale大于零这进行设置,如果不是大于0,代表采用Auto
                {
                    string YscaleString = m_NoiseFigureParameter.Yscale.ToString();
                    inSys.SpectrumAnalyzer.SendSCPI("DISP:WIND:TRAC:Y:PDIV " + YscaleString);
                    inSys.SpectrumAnalyzer.WaitOpc();
                }
                m_NoiseFigureTestResult.m_ScreenImage = inSys.SpectrumAnalyzer.CaptureScreenImage();

                //重置仪表
                //inSys.SpectrumAnalyzer.Preset();
                //inSys.SpectrumAnalyzer.WaitOpc();
                //判断是否进行调试模式,如果是,则不关闭激励,并且将仪器扫描方式改成连续扫描
                if (m_NoiseFigureParameter.m_NeedContinuousScanning)
                {
                    inSys.SpectrumAnalyzer.ContinuousSweepEnabled = true;
                    inSys.SpectrumAnalyzer.WaitOpc();
                }
                inSys.SpectrumAnalyzer.Timeout = 10 * 1000;
                return(0);
            }
            catch (Exception ex)
            {
                GlobalStatusReport.ReportError(ex);
                throw ex;
            }
        }