/// <summary> /// 更新当前测试项目和对数 /// </summary> /// <param name="itemName"></param> /// <param name="clbType"></param> private void SetCheckItem(string itemName, ClbType clbType) { CheckedListBox targetCheckedListBox = new CheckedListBox(); switch (clbType) { case ClbType.TestItem: targetCheckedListBox = chkList_TestItem; break; case ClbType.DiffPair: targetCheckedListBox = chkList_LossPair; break; case ClbType.NextPair: targetCheckedListBox = chkList_NextPair; break; case ClbType.FextPair: targetCheckedListBox = chkList_FextPair; break; } if (targetCheckedListBox.InvokeRequired) { Action <string, ClbType> d = SetCheckItem; this.Invoke(d, new object[] { itemName, clbType }); } else { int index = targetCheckedListBox.FindString(itemName); targetCheckedListBox.SelectedIndex = index; targetCheckedListBox.SetItemChecked(index, true); Extende.SelectTab(targetCheckedListBox); } }
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); }