Example #1
0
        private void StartConsumer(TestConfig[] testConfigs, Dictionary <string, object> chartDic,
                                   AChart _aChart, FormUi formUi, Dictionary <string, plotData> spec, string saveTxtPath)
        {
            ConsumerParams cpParams = new ConsumerParams();

            cpParams.ChartDic    = chartDic;
            cpParams.AChart      = _aChart;
            cpParams.TestConfigs = testConfigs;
            cpParams.FormUi      = formUi;
            cpParams.Spec        = spec;
            cpParams.SaveTxtPath = saveTxtPath + "\\" + "TXT" + "\\1";
            if (Directory.Exists(cpParams.SaveTxtPath))
            {
                Directory.Delete(cpParams.SaveTxtPath, true);
            }
            Directory.CreateDirectory(cpParams.SaveTxtPath);


            Task taskSnpConsumer = Task.Factory.StartNew(SnpConsumer, cpParams);

            taskSnpConsumer.Wait();


            Task taskTxtConsumer = Task.Factory.StartNew(DataConsumer, cpParams);

            taskTxtConsumer.Wait();
            formUi.ProgressDisplay(300, false);
        }
Example #2
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 #3
0
 private void DataConsumer(object data)
 {
     try
     {
         ConsumerParams cpParams = (ConsumerParams)data;
         foreach (var variable in cpParams.TestConfigs)
         {
             if (variable.ItemType == ItemType.Last)
             {
                 foreach (var testItem in variable.AnalyzeItems)
                 {
                     object          tempChart     = cpParams.ChartDic[testItem];
                     List <PairData> itemPairDatas = new List <PairData>();
                     if (testItem == "MDNEXT")
                     {
                         itemPairDatas = GetMdNext();
                         _testData.Add("MDNEXT", itemPairDatas);
                     }
                     if (testItem == "MDFEXT")
                     {
                         itemPairDatas = GetMdFext();
                         _testData.Add("MDFEXT", itemPairDatas);
                     }
                     if (testItem == "ICR")
                     {
                         itemPairDatas = GetIcr();
                         _testData.Add("ICR", itemPairDatas);
                     }
                     DrawSpec(testItem, cpParams, tempChart);
                     foreach (var pairData in itemPairDatas)
                     {
                         plotData plotData = new plotData();
                         plotData.xData = pairData.XData;
                         plotData.yData = pairData.YData;
                         bool result = Code.Utility.Convert.Judge(cpParams.Spec, plotData, testItem);
                         cpParams.FormUi.AddStatus(testItem + " " + pairData.PairName + ":" + (result ? "PASS" : "Fail"));
                         InsertTestJudge(testItem, result, pairData.PairName);
                         cpParams.FormUi.SetCheckItem(testItem, ClbType.TestItem);
                         cpParams.AChart.DrawLine(tempChart, plotData, pairData.PairName, testItem.StartsWith("TDD") ? LineType.Time : LineType.Fre);
                         string savePath = cpParams.SaveTxtPath + "\\" + testItem + ".txt";
                         SaveTxt(plotData, savePath);
                         cpParams.FormUi.AddStatus(savePath + " " + LanguageHelper.GetMsgText("写入成功"));
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Ui.MessageBoxMuti(e.Message);
     }
 }
Example #4
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 #5
0
 private void DrawSpec(string testItem, ConsumerParams cpParams, object tempChart)
 {
     if (!_specLine.ContainsKey(testItem + "_UPPER"))
     {
         _specLine.Add(testItem + "_UPPER", testItem + "_UPPER");
         if (cpParams.Spec.ContainsKey(testItem + "_UPPER"))
         {
             cpParams.AChart.DrawLine(tempChart, cpParams.Spec[testItem + "_UPPER"], "UPPER", LineType.Spec);
         }
     }
     if (!_specLine.ContainsKey(testItem + "_LOWER"))
     {
         _specLine.Add(testItem + "_LOWER", testItem + "_LOWER");
         if (cpParams.Spec.ContainsKey(testItem + "_LOWER"))
         {
             cpParams.AChart.DrawLine(tempChart, cpParams.Spec[testItem + "_LOWER"], "LOWER", LineType.Spec);
         }
     }
 }
Example #6
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);
        }