private void ManualCheck() { WaitBox wb = null; var t = new Thread(() => { wb = new WaitBox(); wb.ShowDialog();//不能用Show }); t.SetApartmentState(ApartmentState.STA); t.Start(); int pointNo; int circuitNo; List <string[]> shortCircuitList; List <string[]> openCircuitList; if (!SampleCheck.ManualCheck(_circuitLoop, out pointNo, out circuitNo, out shortCircuitList, out openCircuitList)) { wb.Dispatcher.Invoke((Action)(() => wb.Close())); return; } List <List <string> > shortCircuitResult; List <List <string> > openCircuitResult; CpldControl.DataParser.CommonParser.PointToCircuit(shortCircuitList, out shortCircuitResult); CpldControl.DataParser.CommonParser.PointToPair(openCircuitList, out openCircuitResult); RemoveErrorLine(); var isCheckOk = true; //0-NG, 1-OK if (!(shortCircuitList.Count == 0 && openCircuitList.Count == 0)) { isCheckOk = false; DrawErrorLines(shortCircuitResult, openCircuitResult); } string tmp; InfoBox.RichTextMsg(out tmp, isCheckOk, pointNo, circuitNo, shortCircuitResult, openCircuitList, _phyAddrMapToDot); TbInfo.Text = tmp; wb.Dispatcher.Invoke((Action)(() => wb.Close())); HandleCheckResult(isCheckOk, shortCircuitResult, openCircuitList); }
private void OkWaitCheck() { var pointNo = 0; var circuitNo = 0; List <string[]> openCircuitList; List <List <string> > shortCircuitResult = null; List <List <string> > openCircuitResult = null; var isCheckOk = false; var currErrorMsg = ""; var prevErrorMsg = ""; Dispatcher.Invoke(new Action(delegate { LblStartMode.Content = "OK等待中......"; })); while (_autoStartFlag) { List <string[]> shortCircuitList; if (!SampleCheck.ManualCheck(_circuitLoop, out pointNo, out circuitNo, out shortCircuitList, out openCircuitList)) { InfoBox.ErrorMsg("检测失败,请检查设备连接"); Dispatcher.Invoke(new Action(delegate { LblStartMode.Content = "当前工作模式:OK等待,第一次请手动点击开始"; BtnStart.Content = "开 始"; BtnStart.Background = Brushes.LightGreen; })); return; } CpldControl.DataParser.CommonParser.PointToCircuit(shortCircuitList, out shortCircuitResult); while (_needStopFlag) { if (!CpldControl.Check.SampleCheck.ManualCheck(_circuitLoop, out pointNo, out circuitNo, out shortCircuitList, out openCircuitList)) { InfoBox.ErrorMsg("检测失败,请检查设备连接"); Dispatcher.Invoke(new Action(delegate { LblStartMode.Content = "当前工作模式:OK等待,第一次请手动点击开始"; BtnStart.Content = "开 始"; BtnStart.Background = Brushes.LightGreen; })); return; } if (pointNo == 0) { Dispatcher.Invoke(new Action(delegate { LblStartMode.Content = "请插上电缆"; })); } else { Dispatcher.Invoke(new Action(delegate { LblStartMode.Content = "OK等待中......"; })); _needStopFlag = false; } //Thread.Sleep(200); } if (shortCircuitList.Count == 0 && openCircuitList.Count == 0) { isCheckOk = true; Dispatcher.Invoke(new Action(delegate { RemoveErrorLine(); TbInfo.Text = "检测结果:OK"; LblStartMode.Content = "请取下电缆"; })); Dispatcher.Invoke(new Action(delegate { HandleCheckResult(isCheckOk, shortCircuitResult, openCircuitList); })); while (pointNo != 0 && _manualStopFlag) { if (!CpldControl.Check.SampleCheck.ManualCheck(_circuitLoop, out pointNo, out circuitNo, out shortCircuitList, out openCircuitList)) { CpldBase.InfoBox.ErrorMsg("检测失败,请检查设备连接"); Dispatcher.Invoke(new Action(delegate { LblStartMode.Content = "当前工作模式:OK等待,第一次请手动点击开始"; BtnStart.Content = "开 始"; BtnStart.Background = Brushes.LightGreen; })); return; } //Thread.Sleep(200); } _needStopFlag = true; } else { isCheckOk = false; var list = shortCircuitList; Dispatcher.Invoke(new Action(delegate { try { CpldControl.DataParser.CommonParser.PointToCircuit(list, out shortCircuitResult); CpldControl.DataParser.CommonParser.PointToPair(openCircuitList, out openCircuitResult); InfoBox.RichTextMsg(out currErrorMsg, isCheckOk, pointNo, circuitNo, shortCircuitResult, openCircuitList, _phyAddrMapToDot); TbInfo.Text = currErrorMsg; if (_manualStartOnce != true) { return; } if (prevErrorMsg.Equals(currErrorMsg)) { return; } RemoveErrorLine(); DrawErrorLines(shortCircuitResult, openCircuitResult); if (list.Count != 0) { InfoBox.PlaySound(isCheckOk); //new ResultPopUp(isCheckOk, okAutoRelease, ngAutoRelease).ShowDialog(); } prevErrorMsg = currErrorMsg; } catch (Exception e) { InfoBox.ErrorMsg(e.ToString()); throw; } })); } //Thread.Sleep(200); } }