/// <summary> /// 处理接收到的客户端数据 /// </summary> private void ProcessReceive() { if (m_readWriteEventArg.BytesTransferred > 0 && m_readWriteEventArg.SocketError == SocketError.Success) { // 处理接收到的数据 m_receiveBuffer.count = m_readWriteEventArg.BytesTransferred; UserCode.GetInstance().mainCodeRun(); // 填充发送缓冲区 string sendStr = UserCode.GetInstance().SendBuf; TcpBuffer sendPack = new TcpBuffer(Encoding.Default.GetBytes(sendStr)); TcpBuffer sendBuffer = sendPack;//TcpProtocol.Pack(sendPack, 0); System.Buffer.BlockCopy(sendBuffer.bytes, sendBuffer.offset, m_sendBuffer.bytes, m_sendBuffer.offset, sendBuffer.count); m_sendBuffer.count = sendBuffer.count; // 设置发送缓冲区 m_readWriteEventArg.SetBuffer(m_sendBuffer.bytes, m_sendBuffer.offset, m_sendBuffer.count); // 异步发送 bool willRaiseEvent = m_socket.SendAsync(m_readWriteEventArg); if (!willRaiseEvent) { ProcessSend(); } } else { Close(); } }
public ThresholdFBDForm(int tCIdx) { InitializeComponent(); this.trackBarMaxGray.SetRange(0, 255); this.trackBarMinGray.SetRange(0, 255); currentIdx = tCIdx; numericUpDownMaxGray.Value = (decimal)UserCode.GetInstance().gProCd[currentIdx].gTP.maxValue; numericUpDownMinGray.Value = (decimal)UserCode.GetInstance().gProCd[currentIdx].gTP.minValue; }
private void buttonGetImage_Click(object sender, EventArgs e) { try { //oriRowNumber = rowNumber; //oriColumnNumber = columnNumber; if (image != null) { image.Dispose(); } //Svision.GetMe().baslerCamera.getFrameImage(out image); UserCode.GetInstance().getImageFromProcess(out image, currentIndex); basicClass.getImageSize(image, out rowNumber, out columnNumber); double widRat = pictureBoxBackgroundRemove.Width / ((double)columnNumber); double heiRat = pictureBoxBackgroundRemove.Height / ((double)rowNumber); resizerate = widRat < heiRat ? widRat : heiRat; if (oriPictureBoxShowImageWidth != pictureBoxBackgroundRemove.Width) { basicClass.displayClear(BackgroundRemoveHWHandle); } if (oriPictureBoxShowImageHeight != pictureBoxBackgroundRemove.Height) { basicClass.displayClear(BackgroundRemoveHWHandle); } showResultImage(); } catch (System.Exception ex) { System.Threading.Thread.Sleep(100); if (Svision.GetMe().baslerCamera != null && Svision.GetMe().baslerCamera.camera.IsOpen&& Svision.GetMe().baslerCamera.camera.IsConnected) { Svision.GetMe().textBoxIsCameraOpenedAndConnected.Text = "是"; MessageBox.Show(ex.Message); } else { Cursor = Cursors.WaitCursor; Svision.GetMe().textBoxIsCameraOpenedAndConnected.Text = "否"; MessageBox.Show("相机连接已断开,请检查连接网线!开始自动刷新相机状态!"); Svision.GetMe().textBoxIsCameraOpenedAndConnected.Text = "正在刷新"; Svision.GetMe().cameraRefresh(); Svision.GetMe().textBoxIsCameraOpenedAndConnected.Text = "是"; Cursor = Cursors.Default; } } }
private void buttonConfirm_Click(object sender, EventArgs e) { UserCode.GetInstance().gProCd[currentIndex].gMPP.processID = comboBoxMorphology.SelectedIndex; if (radioButtonRectangle.Checked == true) { UserCode.GetInstance().gProCd[currentIndex].gMPP.elementID = 0; } else { UserCode.GetInstance().gProCd[currentIndex].gMPP.elementID = 1; } UserCode.GetInstance().gProCd[currentIndex].gMPP.width = (int)numericUpDownWidth.Value; UserCode.GetInstance().gProCd[currentIndex].gMPP.height = (int)numericUpDownHeight.Value; UserCode.GetInstance().gProCd[currentIndex].gMPP.radius = (double)numericUpDownRadius.Value; this.Hide(); }
public void buttonConfirm_Click(object sender, EventArgs e) { float tMaxGray = (float)numericUpDownMaxGray.Value; float tMinGray = (float)numericUpDownMinGray.Value; if (tMinGray < tMaxGray) { UserCode.GetInstance().gProCd[currentIdx].gTP.maxValue = tMaxGray; UserCode.GetInstance().gProCd[currentIdx].gTP.minValue = tMinGray; this.Close(); } else { MessageBox.Show("输入的最小灰度值需要大于最大灰度值!"); } }
public MorphologyProcessingFBDForm(int idx) { InitializeComponent(); currentIndex = idx; comboBoxMorphology.SelectedIndex = UserCode.GetInstance().gProCd[currentIndex].gMPP.processID; if (UserCode.GetInstance().gProCd[currentIndex].gMPP.elementID == 0) { radioButtonRectangle.Checked = true; } else { radioButtonCircle.Checked = true; } numericUpDownWidth.Value = (decimal)UserCode.GetInstance().gProCd[currentIndex].gMPP.width; numericUpDownHeight.Value = (decimal)UserCode.GetInstance().gProCd[currentIndex].gMPP.height; numericUpDownRadius.Value = (decimal)UserCode.GetInstance().gProCd[currentIndex].gMPP.radius; }
private void btnDelete_Click(object sender, EventArgs e) { try { if (0 == gCurrentDataGridRow) { MessageBox.Show("首行为图像输入,不可修改"); return; } UserCode.GetInstance().isOverFlag[gCurrentDataGridRow] = 0; if ((string)this.DgvMainCode.Rows[gCurrentDataGridRow].Cells[1].Value != UserCode.GetInstance().codeInfoValToKey[ProCodeCls.MainFunction.NullFBD]) { if (Svision.GetMe().listBoxProcess.Items[gCurrentDataGridRow].ToString() == "") { } else if (int.Parse(Svision.GetMe().listBoxProcess.Items[gCurrentDataGridRow].ToString().Split('.')[0]) == gCurrentDataGridRow) { Svision.GetMe().listBoxProcess.SelectedIndex = 0; Svision.GetMe().listBoxProcess.Items.RemoveAt(gCurrentDataGridRow); Svision.GetMe().listBoxProcess.Items.Insert(gCurrentDataGridRow, ""); } UserCode.GetInstance().gProCd[gCurrentDataGridRow].clear(); this.DgvMainCode.Rows[gCurrentDataGridRow].Cells[1].Value = ""; UserCode.GetInstance().gProCd[gCurrentDataGridRow].FuncID = ProCodeCls.MainFunction.NullFBD; } for (int i = 19; i >= 0; i--) { if (UserCode.GetInstance().gProCd[i].FuncID != ProCodeCls.MainFunction.NullFBD && UserCode.GetInstance().gProCd[i].FuncID != ProCodeCls.MainFunction.OutputSerialOutputFBD) { UserCode.GetInstance().showCurIdx = i; break; } } Svision.GetMe().listBoxProcess.SelectedIndex = UserCode.GetInstance().showCurIdx; } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
public NewProcessEdit() { try { InitializeComponent(); FuncName = new String[20]; mDt = new DataTable(); gCurrentDataGridRow = 0xFF; gCurrentTreeViewStr = ""; UIInit(); String tCode = ""; for (int i = 0; i < 20; i++) { if (UserCode.GetInstance().gProCd[i].FuncID == ProCodeCls.MainFunction.NullFBD) { continue; } this.DgvMainCode.Rows[i].Cells[1].Value = UserCode.GetInstance().codeInfoValToKey[UserCode.GetInstance().gProCd[i].FuncID]; } this.DgvMainCode.Rows[0].ReadOnly = true; if (Svision.GetMe().checkBoxIsFile.Checked) { UserCode.GetInstance().gProCd[0].FuncID = ProCodeCls.MainFunction.InputFileInputFBD; this.DgvMainCode.Rows[0].Cells[1].Value = UserCode.GetInstance().codeInfoValToKey[ProCodeCls.MainFunction.InputFileInputFBD]; } else { UserCode.GetInstance().gProCd[0].FuncID = ProCodeCls.MainFunction.InputCameraInputFBD; this.DgvMainCode.Rows[0].Cells[1].Value = UserCode.GetInstance().codeInfoValToKey[ProCodeCls.MainFunction.InputCameraInputFBD]; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public MedianFilterFBDForm(int cIdx) { InitializeComponent(); currentIndex = cIdx; switch (UserCode.GetInstance().gProCd[currentIndex].gMFP.maskSize) { case 0: radioButtonMedianFilter3.Checked = true; maskLength = 3; break; case 1: radioButtonMedianFilter5.Checked = true; maskLength = 5; break; case 2: radioButtonMedianFilter7.Checked = true; maskLength = 7; break; case 3: radioButtonMedianFilter9.Checked = true; maskLength = 9; break; case 4: radioButtonMedianFilter11.Checked = true; maskLength = 11; break; default: ; break; } }
public BackgroundRemoveFBDForm(int idx) { InitializeComponent(); currentIndex = idx; numericUpDownMaxGray.Value = (decimal)UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[0]; numericUpDownMinGray.Value = (decimal)UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[1]; if (Svision.GetMe().baslerCamera.getChannelNumber() == 1) { isColor = false; } else { isColor = true;//isColor } //isColor = UserCode.GetInstance().gProCd[currentIndex].boolData[0]; checkBoxAllColor.Checked = UserCode.GetInstance().gProCd[currentIndex].gBRP.isAllColor; numericUpDownRedMaxGray.Value = (decimal)UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[2]; numericUpDownRedMinGray.Value = (decimal)UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[3]; numericUpDownGreenMaxGray.Value = (decimal)UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[4]; numericUpDownGreenMinGray.Value = (decimal)UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[5]; numericUpDownBlueMaxGray.Value = (decimal)UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[6]; numericUpDownBlueMinGray.Value = (decimal)UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[7]; }
private void buttonConfirm_Click(object sender, EventArgs e) { try { UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[0] = (float)numericUpDownMaxGray.Value; UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[1] = (float)numericUpDownMinGray.Value; UserCode.GetInstance().gProCd[currentIndex].gBRP.isAllColor = checkBoxAllColor.Checked; UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[2] = (float)numericUpDownRedMaxGray.Value; UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[3] = (float)numericUpDownRedMinGray.Value; UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[4] = (float)numericUpDownGreenMaxGray.Value; UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[5] = (float)numericUpDownGreenMinGray.Value; UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[6] = (float)numericUpDownBlueMaxGray.Value; UserCode.GetInstance().gProCd[currentIndex].gBRP.grayValue[7] = (float)numericUpDownBlueMinGray.Value; this.Hide(); } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonMedianFilterFBDConfirm_Click(object sender, EventArgs e) { if (radioButtonMedianFilter3.Checked == true) { UserCode.GetInstance().gProCd[currentIndex].gMFP.maskSize = 0; } else if (radioButtonMedianFilter5.Checked == true) { UserCode.GetInstance().gProCd[currentIndex].gMFP.maskSize = 1; } else if (radioButtonMedianFilter7.Checked == true) { UserCode.GetInstance().gProCd[currentIndex].gMFP.maskSize = 2; } else if (radioButtonMedianFilter9.Checked == true) { UserCode.GetInstance().gProCd[currentIndex].gMFP.maskSize = 3; } else if (radioButtonMedianFilter11.Checked == true) { UserCode.GetInstance().gProCd[currentIndex].gMFP.maskSize = 4; } this.Hide(); }
private void buttonGetImageFrame_Click(object sender, EventArgs e) { try { //oriRowNumber = rowNumber; //oriColumnNumber = columnNumber; if (image != null) { image.Dispose(); } //Svision.GetMe().baslerCamera.getFrameImage(out image); UserCode.GetInstance().getImageFromProcess(out image, currentIdx); basicClass.getImageSize(image, out rowNumber, out columnNumber); double widRat = pictureBoxThreshold.Width / ((double)columnNumber); double heiRat = pictureBoxThreshold.Height / ((double)rowNumber); resizerate = widRat < heiRat ? widRat : heiRat; if (img != null) { img.Dispose(); } basicClass.resizeImage(image, out img, resizerate); //if (oriRowNumber != rowNumber || oriColumnNumber != columnNumber) //{ // basicClass.displayClear(ThresholdHWHandle); //} if (oriPictureBoxShowImageWidth != pictureBoxThreshold.Width) { basicClass.displayClear(ThresholdHWHandle); } if (oriPictureBoxShowImageHeight != pictureBoxThreshold.Height) { basicClass.displayClear(ThresholdHWHandle); } int rown, columnn; basicClass.thresholdImage(img, out imgRegionResult, (float)numericUpDownMinGray.Value, (float)numericUpDownMaxGray.Value); basicClass.getImageSize(img, out rown, out columnn); if (imgResult != null) { imgResult.Dispose(); } HOperatorSet.RegionToBin(imgRegionResult, out imgResult, 255, 0, columnn, rown); basicClass.displayhobject(imgResult, ThresholdHWHandle); panelenable.Enabled = true; } catch (System.Exception ex) { System.Threading.Thread.Sleep(100); if (Svision.GetMe().baslerCamera != null && Svision.GetMe().baslerCamera.camera.IsOpen&& Svision.GetMe().baslerCamera.camera.IsConnected) { Svision.GetMe().textBoxIsCameraOpenedAndConnected.Text = "是"; MessageBox.Show(ex.Message); } else { Cursor = Cursors.WaitCursor; Svision.GetMe().textBoxIsCameraOpenedAndConnected.Text = "否"; MessageBox.Show("相机连接已断开,请检查连接网线!开始自动刷新相机状态!"); Svision.GetMe().textBoxIsCameraOpenedAndConnected.Text = "正在刷新"; Svision.GetMe().cameraRefresh(); Svision.GetMe().textBoxIsCameraOpenedAndConnected.Text = "是"; Cursor = Cursors.Default; } } }
private void checkListBoxOutputParameters_ItemCheck(object sender, ItemCheckEventArgs e) { try { if (e.CurrentValue == CheckState.Checked && e.NewValue == CheckState.Unchecked) { switch (UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].FuncID) { case ProCodeCls.MainFunction.InputCameraInputFBD: break; case ProCodeCls.MainFunction.CalibrationThresholdFBD: break; case ProCodeCls.MainFunction.CalibrationBackgroundRemoveFBD: break; case ProCodeCls.MainFunction.CalibrationMedianFilterFBD: break; case ProCodeCls.MainFunction.CalibrationMorphologyProcessingFBD: break; case ProCodeCls.MainFunction.MeasureBlobAnalysisFBD: { UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gBP.showOutputResultFlag[showTempFlag[e.Index]] = false; } break; case ProCodeCls.MainFunction.MeasureShapeSearchFBD: { UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gSSP.showOutputResultFlag[e.Index] = false; } break; case ProCodeCls.MainFunction.MeasureAnisoShapeSearchFBD: { UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].tAShpSrh.showOutputResultFlag[e.Index] = false; } break; default: break; } } if (e.NewValue == CheckState.Checked && e.CurrentValue == CheckState.Unchecked) { switch (UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].FuncID) { case ProCodeCls.MainFunction.InputCameraInputFBD: break; case ProCodeCls.MainFunction.CalibrationThresholdFBD: break; case ProCodeCls.MainFunction.CalibrationBackgroundRemoveFBD: break; case ProCodeCls.MainFunction.CalibrationMedianFilterFBD: break; case ProCodeCls.MainFunction.CalibrationMorphologyProcessingFBD: break; case ProCodeCls.MainFunction.MeasureBlobAnalysisFBD: { UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gBP.showOutputResultFlag[showTempFlag[e.Index]] = true; } break; case ProCodeCls.MainFunction.MeasureShapeSearchFBD: { UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gSSP.showOutputResultFlag[e.Index] = true; } break; case ProCodeCls.MainFunction.MeasureAnisoShapeSearchFBD: { UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].tAShpSrh.showOutputResultFlag[e.Index] = true; } break; default: break; } } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonConfirm_Click(object sender, EventArgs e) { try { int channeltest; if (comboBoxChannel.SelectedIndex == 0) { channeltest = 1; } else { channeltest = 3; } int rNum, cNum; HTuple imgCNum; HOperatorSet.ReadImage(out image, (HTuple)fnFileNameList[listBoxFileList.SelectedIndex]); basicClass.getImageSize(image, out rNum, out cNum); HOperatorSet.CountChannels(image, out imgCNum); labelImageInfo.Text = rNum.ToString() + "行 " + cNum.ToString() + "列 " + ((int)imgCNum).ToString() + "通道 "; if (rNum == (int)numericUpDownRow.Value && cNum == (int)numericUpDownColumn.Value && imgCNum == channeltest) { double widRat = pictureBoxImage.Width / ((double)cNum); double heiRat = pictureBoxImage.Height / ((double)rNum); resizerate = widRat < heiRat ? widRat : heiRat; if (img != null) { img.Dispose(); } basicClass.resizeImage(image, out img, resizerate); basicClass.displayClear(FileInputHWHandle); basicClass.displayhobject(img, FileInputHWHandle); HOperatorSet.CopyImage(image, out UserCode.GetInstance().fileImages); Svision.GetMe().fileNameList.Clear(); Svision.GetMe().fileNameList = fnFileNameList; ConfigInformation.GetInstance().tFileCfg.columns = (int)numericUpDownColumn.Value; ConfigInformation.GetInstance().tFileCfg.rows = (int)numericUpDownRow.Value; if (comboBoxChannel.SelectedIndex == 0) { ConfigInformation.GetInstance().tFileCfg.channelNum = 1; } else { ConfigInformation.GetInstance().tFileCfg.channelNum = 3; } Svision.GetMe().fileNumIdx = listBoxFileList.SelectedIndex; Svision.GetMe().textBoxFileNum.Text = (Svision.GetMe().fileNumIdx + 1).ToString(); Svision.GetMe().textBoxAllFileNum.Text = ImageNum.ToString(); if (Svision.GetMe().checkBoxIsFile.Checked) { Svision.GetMe().oriRowNumber = ConfigInformation.GetInstance().tFileCfg.rows; Svision.GetMe().oriColumnNumber = ConfigInformation.GetInstance().tFileCfg.columns; } if (image != null) { image.Dispose(); } if (img != null) { img.Dispose(); } this.Close(); } else { if (image != null) { image.Dispose(); } if (img != null) { img.Dispose(); } throw new Exception("所选择图像参数与当前图像文件参数设置不符!请修改!"); } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
private void buttongetImageFrame_Click(object sender, System.EventArgs e) { try { //oriRowNumber = rowNumber; //oriColumnNumber = columnNumber; if (image != null) { image.Dispose(); } //Svision.GetMe().baslerCamera.getFrameImage(out image); UserCode.GetInstance().getImageFromProcess(out image, currentIndex); basicClass.getImageSize(image, out rowNumber, out columnNumber); double widRat = pictureBoxMedian.Width / ((double)columnNumber); double heiRat = pictureBoxMedian.Height / ((double)rowNumber); resizerate = widRat < heiRat ? widRat : heiRat; if (img != null) { img.Dispose(); } basicClass.resizeImage(image, out img, resizerate); //if (oriRowNumber != rowNumber || oriColumnNumber != columnNumber) //{ // basicClass.displayClear(MedianHWHandle); //} if (oriPictureBoxShowImageWidth != pictureBoxMedian.Width) { basicClass.displayClear(MedianHWHandle); } if (oriPictureBoxShowImageHeight != pictureBoxMedian.Height) { basicClass.displayClear(MedianHWHandle); } if (imgResult != null) { imgResult.Dispose(); } HOperatorSet.MedianImage(img, out imgResult, "square", maskLength, "mirrored"); basicClass.displayhobject(imgResult, MedianHWHandle); groupBoxMedianFilterFBDMaskSize.Enabled = true; } catch (System.Exception ex) { System.Threading.Thread.Sleep(100); if (Svision.GetMe().baslerCamera != null && Svision.GetMe().baslerCamera.camera.IsOpen&& Svision.GetMe().baslerCamera.camera.IsConnected) { Svision.GetMe().textBoxIsCameraOpenedAndConnected.Text = "是"; MessageBox.Show(ex.Message); } else { Cursor = Cursors.WaitCursor; Svision.GetMe().textBoxIsCameraOpenedAndConnected.Text = "否"; MessageBox.Show("相机连接已断开,请检查连接网线!开始自动刷新相机状态!"); Svision.GetMe().textBoxIsCameraOpenedAndConnected.Text = "正在刷新"; Svision.GetMe().cameraRefresh(); Svision.GetMe().textBoxIsCameraOpenedAndConnected.Text = "是"; Cursor = Cursors.Default; } } }
private void DgvMainCode_CellMouseDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (UserCode.GetInstance().gProCd[e.RowIndex].FuncID != ProCodeCls.MainFunction.NullFBD) { switch (UserCode.GetInstance().gProCd[e.RowIndex].FuncID) { case ProCodeCls.MainFunction.InputCameraInputFBD: //CameraInput break; case ProCodeCls.MainFunction.InputFileInputFBD: //FileInput break; case ProCodeCls.MainFunction.CalibrationBackgroundRemoveFBD: //Filter BackgroundRemoveFBDForm tBackFbd = new BackgroundRemoveFBDForm(e.RowIndex); tBackFbd.ShowDialog(); break; case ProCodeCls.MainFunction.CalibrationThresholdFBD: //Threshold ThresholdFBDForm tThreFbd = new ThresholdFBDForm(e.RowIndex); tThreFbd.ShowDialog(); break; case ProCodeCls.MainFunction.MeasureShapeSearchFBD: //Match FindShapeModelFBDForm tFdMdFbd = new FindShapeModelFBDForm(e.RowIndex); tFdMdFbd.ShowDialog(); break; case ProCodeCls.MainFunction.MeasureAnisoShapeSearchFBD: //Match FindAnisoShapeModelFBDForm tFdAMdFbd = new FindAnisoShapeModelFBDForm(e.RowIndex); tFdAMdFbd.ShowDialog(); break; case ProCodeCls.MainFunction.OutputSerialOutputFBD: //SerialCom SerialOutputFBDForm tSerOptFbd = new SerialOutputFBDForm(e.RowIndex); tSerOptFbd.ShowDialog(); break; case ProCodeCls.MainFunction.CalibrationMedianFilterFBD: MedianFilterFBDForm tMeFltFbd = new MedianFilterFBDForm(e.RowIndex); tMeFltFbd.ShowDialog(); break; case ProCodeCls.MainFunction.CalibrationMorphologyProcessingFBD: MorphologyProcessingFBDForm tMorFbd = new MorphologyProcessingFBDForm(e.RowIndex); tMorFbd.ShowDialog(); break; case ProCodeCls.MainFunction.MeasureBlobAnalysisFBD: BlobAnalysisFBDForm tBlobFbd = new BlobAnalysisFBDForm(e.RowIndex); tBlobFbd.ShowDialog(); break; case ProCodeCls.MainFunction.MeasureSurfaceBasedMatchFBD: SurfaceBasedMatchFBDForm tSBMFbd = new SurfaceBasedMatchFBDForm(e.RowIndex); tSBMFbd.ShowDialog(); break; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnInsert_Click(object sender, EventArgs e) { try { if (0 == gCurrentDataGridRow) { MessageBox.Show("首行为图像输入,不可修改"); return; } if ((gCurrentDataGridRow != 0xFF) && (gCurrentTreeViewStr != "Null")) { UserCode.GetInstance().isOverFlag[gCurrentDataGridRow] = 1; this.DgvMainCode.Rows[gCurrentDataGridRow].Cells[1].Value = gCurrentTreeViewStr; UserCode.GetInstance().gProCd[gCurrentDataGridRow].FuncID = UserCode.GetInstance().codeInfo[gCurrentTreeViewStr]; if (Svision.GetMe().listBoxProcess.Items.Count > gCurrentDataGridRow) { if (Svision.GetMe().listBoxProcess.Items[gCurrentDataGridRow].ToString() == "") { Svision.GetMe().listBoxProcess.SelectedIndex = 0; Svision.GetMe().listBoxProcess.Items.RemoveAt(gCurrentDataGridRow); Svision.GetMe().listBoxProcess.Items.Insert(gCurrentDataGridRow, gCurrentDataGridRow.ToString() + "." + gCurrentTreeViewStr); } else if (int.Parse(Svision.GetMe().listBoxProcess.Items[gCurrentDataGridRow].ToString().Split('.')[0]) == gCurrentDataGridRow) { Svision.GetMe().listBoxProcess.SelectedIndex = 0; Svision.GetMe().listBoxProcess.Items.RemoveAt(gCurrentDataGridRow); Svision.GetMe().listBoxProcess.Items.Insert(gCurrentDataGridRow, gCurrentDataGridRow.ToString() + "." + gCurrentTreeViewStr); } else { Svision.GetMe().listBoxProcess.Items.Insert(gCurrentDataGridRow, gCurrentDataGridRow.ToString() + "." + gCurrentTreeViewStr); } } else { Svision.GetMe().listBoxProcess.Items.Insert(gCurrentDataGridRow, gCurrentDataGridRow.ToString() + "." + gCurrentTreeViewStr); } switch (UserCode.GetInstance().gProCd[gCurrentDataGridRow].FuncID) { case ProCodeCls.MainFunction.CalibrationBackgroundRemoveFBD: UserCode.GetInstance().CalibrationBackgroundRemoveInit(gCurrentDataGridRow); break; case ProCodeCls.MainFunction.CalibrationMedianFilterFBD: UserCode.GetInstance().CalibrationMedianFilterInit(gCurrentDataGridRow); break; case ProCodeCls.MainFunction.CalibrationMorphologyProcessingFBD: UserCode.GetInstance().CalibrationMorphologyProcessingInit(gCurrentDataGridRow); break; case ProCodeCls.MainFunction.MeasureBlobAnalysisFBD: UserCode.GetInstance().isOverFlag[gCurrentDataGridRow] = 10; UserCode.GetInstance().BlobAnalysisInit(gCurrentDataGridRow); break; case ProCodeCls.MainFunction.CalibrationThresholdFBD: UserCode.GetInstance().CalibrationThresholdInit(gCurrentDataGridRow); break; case ProCodeCls.MainFunction.OutputSerialOutputFBD: UserCode.GetInstance().isOverFlag[gCurrentDataGridRow] = 31; UserCode.GetInstance().OutputSerialOutputInit(gCurrentDataGridRow); break; case ProCodeCls.MainFunction.MeasureShapeSearchFBD: UserCode.GetInstance().isOverFlag[gCurrentDataGridRow] = 11; UserCode.GetInstance().ShapeSearchInit(gCurrentDataGridRow); break; case ProCodeCls.MainFunction.MeasureAnisoShapeSearchFBD: UserCode.GetInstance().isOverFlag[gCurrentDataGridRow] = 12; UserCode.GetInstance().AnisoShapeSearchInit(gCurrentDataGridRow); break; case ProCodeCls.MainFunction.MeasureSurfaceBasedMatchFBD: //新添加的三维模板匹配 //UserCode.GetInstance().isOverFlag[gCurrentDataGridRow] = 19; UserCode.GetInstance().SurfaceBasedMatchInit(gCurrentDataGridRow); break; } } for (int i = 19; i >= 0; i--) { if (UserCode.GetInstance().gProCd[i].FuncID != ProCodeCls.MainFunction.NullFBD && UserCode.GetInstance().gProCd[i].FuncID != ProCodeCls.MainFunction.OutputSerialOutputFBD) { UserCode.GetInstance().showCurIdx = i; break; } } Svision.GetMe().listBoxProcess.SelectedIndex = UserCode.GetInstance().showCurIdx; } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
private void OutputParameters_Load(object sender, EventArgs e) { try{ switch (UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].FuncID) { case ProCodeCls.MainFunction.InputCameraInputFBD: break; case ProCodeCls.MainFunction.CalibrationThresholdFBD: break; case ProCodeCls.MainFunction.CalibrationBackgroundRemoveFBD: break; case ProCodeCls.MainFunction.CalibrationMedianFilterFBD: break; case ProCodeCls.MainFunction.CalibrationMorphologyProcessingFBD: break; case ProCodeCls.MainFunction.MeasureBlobAnalysisFBD: { showTempFlag = 0; if (UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gBP.showOutputResultFlag[0]) { checkListBoxOutputParameters.Items.Add(UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gBP.showOutputResultStr[0], true); } else { checkListBoxOutputParameters.Items.Add(UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gBP.showOutputResultStr[0], false); } showTempFlag = showTempFlag.TupleConcat(1); if (UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gBP.showOutputResultFlag[1]) { checkListBoxOutputParameters.Items.Add(UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gBP.showOutputResultStr[1], true); } else { checkListBoxOutputParameters.Items.Add(UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gBP.showOutputResultStr[1], false); } //checkListBoxOutputParameters.Items.Add(UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gBP.showOutputResultStr[0], true); //checkListBoxOutputParameters.Items.Add(UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gBP.showOutputResultStr[1], true); for (int i = 0; i < 34; i++) { if (UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gBP.outputIDIsChecked[i]) { showTempFlag = showTempFlag.TupleConcat(i + 2); if (UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gBP.showOutputResultFlag[i + 2]) { checkListBoxOutputParameters.Items.Add(UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gBP.showOutputResultStr[i + 2], true); } else { checkListBoxOutputParameters.Items.Add(UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gBP.showOutputResultStr[i + 2], false); } } } } break; case ProCodeCls.MainFunction.MeasureShapeSearchFBD: { for (int i = 0; i < 5; i++) { if (UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gSSP.showOutputResultFlag[i]) { checkListBoxOutputParameters.Items.Add(UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gSSP.showOutputResultStr[i], true); } else { checkListBoxOutputParameters.Items.Add(UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gSSP.showOutputResultStr[i], false); } } } break; case ProCodeCls.MainFunction.MeasureAnisoShapeSearchFBD: { for (int i = 0; i < 7; i++) { if (UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gASSP.showOutputResultFlag[i]) { checkListBoxOutputParameters.Items.Add(UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gASSP.showOutputResultStr[i], true); } else { checkListBoxOutputParameters.Items.Add(UserCode.GetInstance().gProCd[UserCode.GetInstance().showCurIdx].gASSP.showOutputResultStr[i], false); } } } break; default: break; } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } //checkListBoxOutputParameters.SetItemChecked(0, Svision.GetMe().showImageResult); //checkListBoxOutputParameters.SetItemChecked(1, Svision.GetMe().showScore); //checkListBoxOutputParameters.SetItemChecked(2, Svision.GetMe().showPosition); //checkListBoxOutputParameters.SetItemChecked(3, Svision.GetMe().showAngle); //checkListBoxOutputParameters.SetItemChecked(4, Svision.GetMe().showTime); //checkListBoxOutputParameters.SetItemChecked(5, Svision.GetMe().showClass); }