Beispiel #1
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;
            }
        }
Beispiel #2
0
        public void AutoRun(SystemHardware inSys, Test_Paramter testParam, out TestExecutionResult outTestExecuteResultFlag)
        {
            try
            {
                outTestExecuteResultFlag = TestExecutionResult.Init;
                if (CurCtrlDut == null)
                {
                    MessageBox.Show("被测件没有连接!");
                    outTestExecuteResultFlag = TestExecutionResult.Error;
                    return;
                }
                else
                {
                    //需要获取测试项内容
                    //初始化结果
                    this.m_CurResult           = new Test_Result(testParam);
                    m_CurResult.TestParam      = testParam;
                    m_CurResult.TestResultList = new List <TestResultByFreq>();

                    //inSys.SpectrumAnalyzer.Preset();
                    int freqN = (int)Math.Floor(1 + (testParam.SGAndPxaParamter.StopFreq - testParam.SGAndPxaParamter.StartFreq) / testParam.SGAndPxaParamter.FreqSpac);
                    TestStructParameters inParam = new TestStructParameters();
                    inParam = Get_testParam(testParam);
                    List <TestResultByFreq> resultList = new List <TestResultByFreq>();
                    List <double>           freqList   = new List <double>();

                    CurCtrlDut.SETChannel(testParam.ChannelNumber);
                    //todo

                    //
                    for (int i = 0; i < freqN; i++)
                    {
                        freqList.Add(testParam.SGAndPxaParamter.StartFreq + i * testParam.SGAndPxaParamter.FreqSpac);
                    }

                    if (testParam.isTxWork)//是否是发射
                    {
                        CurCtrlDut.CtrlTWork();
                        Thread.Sleep((int)(testParam.sleepTime * 1000));
                    }
                    else
                    {
                        CurCtrlDut.CtrlRWork();
                        Thread.Sleep((int)(testParam.sleepTime * 1000));
                    }

                    if (testParam.IsPowerTest || testParam.IsClutterTest)
                    {
                        for (int i = 0; i < freqN; i++)
                        {
                            if (stopRun)
                            {
                                if (MessageBoxResult.Yes == MessageBox.Show("测试强行停止,是否停止?", "提 示", MessageBoxButton.YesNo))
                                {
                                    outTestExecuteResultFlag = TestExecutionResult.Error;
                                    return;
                                }
                            }
                            if (i == 0)
                            {
                                inParam.m_FirstTest = true;
                                inParam.m_LastTest  = false;
                            }
                            else
                            {
                                inParam.m_FirstTest = false;
                            }
                            if (i == freqN - 1)
                            {
                                inParam.m_LastTest = true;
                            }
                            if (testParam.isTxWork)//是否是发射
                            {
                                inParam.m_SGFreq = testParam.DUTOutFreq;
                                inParam.m_SAFreq = freqList[i];

                                Thread.Sleep((int)(testParam.sleepTime * 1000));
                            }
                            else
                            {
                                inParam.m_SAFreq = testParam.DUTOutFreq;
                                inParam.m_SGFreq = freqList[i];
                            }
                            //设置本振频率
                            CurCtrlDut.CtrlFreq(freqList[i]);
                            Thread.Sleep((int)(testParam.sleepTime * 1000));

                            TestStructResults rest      = new TestStructResults();
                            TestResultByFreq  oneResult = new TestResultByFreq();
                            inParam.m_SGOffsetValue = this.GetOFFset(inParam.m_SGFreq, testParam.InputFileoffst);
                            double outputloss = this.GetOFFset(inParam.m_SAFreq, testParam.OutputFileoffst);
                            double inputloss  = this.GetOFFset(inParam.m_SAFreq, testParam.InputFileoffst);
                            inParam.m_SAGlobalOffset = outputloss - inputloss;


                            this.ExecuteTestSpurious(inSys, inParam, out rest);
                            oneResult.TestFreq = freqList[i];

                            oneResult.MaxClutter       = rest.m_NOSourcePower;
                            oneResult.OutPower         = rest.m_CarrierPower;
                            oneResult.ClutterRejection = rest.m_SpuriousSuppression;
                            oneResult.Gain             = rest.m_CarrierPower - inParam.m_InputPower;
                            resultList.Add(oneResult);
                        }
                    }

                    CurResult.TestResultList = resultList;
                    outTestExecuteResultFlag = TestExecutionResult.Complete;
                }
                outTestExecuteResultFlag = TestExecutionResult.Complete;
            }
            catch (Exception ex)
            {
                outTestExecuteResultFlag = TestExecutionResult.Error;
                throw new Exception(ex.ToString());
            }
            finally
            {
                GC.Collect();
            }
        }