Example #1
0
        private void Analyze(TaskSnp taskSnp, ConsumerParams cpParams)
        {
            SNP temp = new SNP(taskSnp.SnpPath, SNPPort.X1324);

            // Thread.Sleep(2000);

            foreach (var testItem in taskSnp.AnalyzeItem)
            {
                object   tempChart = cpParams.ChartDic[testItem];
                plotData offset    = new plotData();
                if (cpParams.Spec.ContainsKey(testItem + "_OFFSET"))
                {
                    offset = cpParams.Spec[testItem + "_OFFSET"];
                }

                plotData plotData = GetPlotdata(temp, testItem, taskSnp, cpParams, offset);
                string   savePath = cpParams.SaveTxtPath + "\\" + testItem + ".txt";
                SaveTxt(plotData, savePath);
                cpParams.FormUi.AddStatus(savePath + " " + LanguageHelper.GetMsgText("写入成功"));

                InsertTestData(plotData, testItem, taskSnp.PairName);

                DrawSpec(testItem, cpParams, tempChart);
                bool result = Code.Utility.Convert.Judge(cpParams.Spec, plotData, testItem);
                cpParams.FormUi.AddStatus(testItem + " " + taskSnp.PairName + ":" + (result ? "PASS" : "Fail"));

                InsertTestJudge(testItem, result, taskSnp.PairName);


                cpParams.FormUi.SetCheckItem(taskSnp.PairName, taskSnp.ClbType);
                cpParams.FormUi.SetCheckItem(testItem, ClbType.TestItem);
                cpParams.AChart.DrawLine(tempChart, plotData, taskSnp.PairName, testItem.StartsWith("TDD") ? LineType.Time : LineType.Fre);
            }
        }
Example #2
0
        // 消费者
        private void SnpConsumer(object data)
        {
            ConsumerParams cpParams = (ConsumerParams)data;

            while (true && !stop)
            {
                TaskSnp GetTask = null;
                //TaskSemaphore.WaitOne();
                lock (myLock)
                {
                    if (TaskQueue.Count > 0)
                    {
                        GetTask = TaskQueue.Dequeue();
                        if (GetTask == null)
                        {
                            stop = true;
                            return;
                        }
                    }
                }



                if (GetTask != null)
                {
                    string msg        = "";
                    int    iChecktime = 0;
                    bool   bFileExist = Tool.FileCheck.FileIsUsing(GetTask.SnpPath, 10000, 10000, ref msg, ref iChecktime);
                    if (!bFileExist)
                    {
                        stop         = true;
                        _totalResult = false;

                        cpParams.FormUi.AddStatus(string.Format("SNP {0}:{1} {2}: {3}", LanguageHelper.GetMsgText("文件"), GetTask.SnpPath, LanguageHelper.GetMsgText("不存在"), msg));
                        return;
                    }

                    Analyze(GetTask, cpParams);

                    cpParams.FormUi.AddStatus(string.Format("{0} SNP {1}:{2} {3}", LanguageHelper.GetMsgText("分析"),
                                                            LanguageHelper.GetMsgText("文件"), GetTask.SnpPath, LanguageHelper.GetMsgText("完毕")));
                    cpParams.FormUi.ProgressDisplay(GetTask.ProgressValue, true);
                }
            }
        }
Example #3
0
        private void SnpProducer(object action)
        {
            ProducerParams producerParams = (ProducerParams)action;
            bool           multiChannel   = false;
            bool           nextByTrace    = false;
            ClbType        clbType        = ClbType.TestItem;

            foreach (TestConfig testConfig in producerParams.TestConfigs)
            {
                if (stop)
                {
                    break;
                }
                switch (testConfig.ItemType)
                {
                case ItemType.Loss:
                    producerParams.FormUi.AddStatus(LanguageHelper.GetMsgText("直通测试开始"));
                    multiChannel = true;
                    clbType      = ClbType.DiffPair;
                    break;

                case ItemType.Next:
                    producerParams.FormUi.AddStatus(LanguageHelper.GetMsgText("近串测试开始"));
                    multiChannel = false;
                    nextByTrace  = true;
                    clbType      = ClbType.NextPair;
                    break;

                case ItemType.Fext:
                    producerParams.FormUi.AddStatus(LanguageHelper.GetMsgText("远串测试开始"));
                    multiChannel = false;
                    nextByTrace  = true;
                    clbType      = ClbType.FextPair;
                    break;

                case ItemType.Last:
                    break;
                }

                int pairIndex = 0;
                if (testConfig.Pairs != null)
                {
                    int pairNum = testConfig.Pairs.Count;
                    foreach (Pair pair in testConfig.Pairs)
                    {
                        if (stop || producerParams.FormUi.StopEnabbled())
                        {
                            stop         = true;
                            _totalResult = false;
                            return;
                        }
                        producerParams.FormUi.AddStatus(pair.PairName + ":start");
                        TaskSnp task = new TaskSnp();
                        task.ItemType      = testConfig.ItemType;
                        task.SnpPath       = GetSnpPath(producerParams.TestDataPath, pair.PairName, testConfig.ItemType);
                        task.AnalyzeItem   = testConfig.AnalyzeItems;
                        task.PairName      = pair.PairName;
                        task.ProgressValue = pair.ProgressValue;
                        task.FirstHalf     = pairIndex < pairNum / 2;
                        task.Srevert       = testConfig.Sreverse;
                        task.Trevert       = testConfig.Treverse;
                        task.ClbType       = clbType;


                        string switchMsg = "";
                        try
                        {
                            //string switchIndex=JsonConvert.SerializeObject(pair.SwitchIndex);
                            //producerParams.FormUi.AddStatus("打开开关:" + switchIndex);
                            if (!_analyzer.SaveSnp(task.SnpPath, pair.SwitchIndex, pairIndex, multiChannel, nextByTrace, ref switchMsg))
                            {
                                producerParams.FormUi.AddStatus(switchMsg);
                                stop         = true;
                                _totalResult = false;
                                return;
                            }
                        }
                        catch (Exception e)
                        {
                            stop         = true;
                            _totalResult = false;
                            //Console.WriteLine(e);
                            producerParams.FormUi.AddStatus(e.Message);
                            return;
                        }

                        if (!stop)
                        {
                            //producerParams.FormUi.SetCheckItem(pair.PairName, clbType);
                            producerParams.FormUi.AddStatus(String.Format("SNP {0} {1}:{2}", LanguageHelper.GetMsgText("文件生成成功"), LanguageHelper.GetMsgText("路径"), task.SnpPath));
                            producerParams.FormUi.ProgressDisplay(pair.ProgressValue, true);
                        }



                        lock (myLock)
                        {
                            TaskQueue.Enqueue(task);
                        }

                        pairIndex++;
                    }
                }
            }



            lock (myLock)
            {
                TaskQueue.Enqueue(null);
            }
            //TaskSemaphore.Release(1);
        }
Example #4
0
        private plotData GetPlotdata(SNP snp, string itemName, TaskSnp taskSnp, ConsumerParams cpParams, plotData offset)
        {
            plotData        dataSeries = new plotData();
            List <TdrParam> tdrParams  = cpParams.TestConfigs[0].TdrParams;

            switch (taskSnp.ItemType)
            {
            case   ItemType.Loss:

                if (itemName.StartsWith("S"))
                {
                    itemName = GetReverseItem(itemName, !taskSnp.FirstHalf && taskSnp.Srevert);
                    // cpParams.FormUi.AddStatus("analyze:"+itemName);
                    string[] outPairs = new string[1];
                    var      data     = snp.EasyGetfreData(itemName, out outPairs);
                    float[]  x        = SConvert.indexArray(data.dB, 0, false);
                    dataSeries.xData = data.fre;
                    dataSeries.yData = x;
                }
                else if (itemName.StartsWith("TDD"))
                {
                    itemName = GetReverseItem(itemName, !taskSnp.FirstHalf && taskSnp.Trevert);
                    // cpParams.FormUi.AddStatus("analyze:" + itemName);
                    TdrParam tdrParam = tdrParams[int.Parse(itemName.Substring(3, 1)) - 1];
                    string[] outPairs = new string[1];
                    double   timeStep = (tdrParam.EndTime - tdrParam.StartTime) / (tdrParam.Points - 1);
                    var      data     = snp.EasyGetTimeData(itemName, out outPairs, tdrParam.RiseTime, timeStep, tdrParam.Points, tdrParam.Offset);
                    float[]  x        = SConvert.indexArray(data.resistance, 0, false);
                    dataSeries.xData = data.time;
                    dataSeries.yData = x;
                }
                else if (itemName.Equals("ILD", StringComparison.OrdinalIgnoreCase))
                {
                    string[] outPairs = new string[1];
                    var      data     = snp.EasyGetILD(cpParams.TestConfigs[0].IldSpec, out outPairs);
                    float[]  x        = SConvert.indexArray(data.dB, 0, false);
                    dataSeries.xData = data.fre;
                    dataSeries.yData = x;
                }
                break;

            case ItemType.Next:
                if (itemName.StartsWith("NEXT"))
                {
                    // cpParams.FormUi.AddStatus("analyze:" + itemName);
                    string[] outPairs = new string[1];
                    var      data     = snp.EasyGetfreData("SDD21", out outPairs);
                    float[]  x        = SConvert.indexArray(data.dB, 0, false);
                    dataSeries.xData = data.fre;
                    dataSeries.yData = x;
                }
                break;

            case ItemType.Fext:
                if (itemName.StartsWith("FEXT"))
                {
                    // cpParams.FormUi.AddStatus("analyze:" + itemName);
                    string[] outPairs = new string[1];
                    var      data     = snp.EasyGetfreData("SDD21", out outPairs);
                    float[]  x        = SConvert.indexArray(data.dB, 0, false);
                    dataSeries.xData = data.fre;
                    dataSeries.yData = x;
                }
                break;
            }

            if (offset.yData != null)
            {
                int length = dataSeries.yData.Length < offset.yData.Length
                    ? dataSeries.yData.Length
                    : offset.yData.Length;
                for (int i = 0; i < length; i++)
                {
                    dataSeries.yData[i] = dataSeries.yData[i] + offset.yData[i];
                }
            }

            return(dataSeries);
        }