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(); } }
public Test_ResultForExcel(Test_Result inTestResult) { this.m_TestResult = inTestResult; }