예제 #1
0
파일: SITest.cs 프로젝트: xiexiaojun/HPMS
        /// <summary>
        /// 控制仪器生成SNP文件
        /// </summary>
        /// <param name="testConfigs">测试参数配置</param>
        /// <param name="formUi">回调操作</param>
        /// <param name="testDataPath">SNP保存路径</param>
        private void StartProducer(TestConfig[] testConfigs, FormUi formUi, string testDataPath)
        {
            ProducerParams producerParams = new ProducerParams();

            producerParams.TestConfigs  = testConfigs;
            producerParams.FormUi       = formUi;
            producerParams.TestDataPath = testDataPath;
            //Thread t = new Thread(new ParameterizedThreadStart(SnpProducer));
            //t.Start(producerParams);
            Task.Factory.StartNew(SnpProducer, producerParams);
        }
예제 #2
0
파일: SITest.cs 프로젝트: xiexiaojun/HPMS
        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);
        }