Example #1
0
        private void buttonCameraSave_Click(object sender, EventArgs e)
        {
            string error = "";
            int    temp;

            //if (!double.TryParse(textBoxImageKX.Text.Trim(), out VSGlobalControl.m_CamParam.CameraKX))
            //    error += labelKX.Text + Environment.NewLine;
            //if (!double.TryParse(textBoxImageKY.Text.Trim(), out VSGlobalControl.m_CamParam.CameraKY))
            //    error += labelKY.Text + Environment.NewLine;
            //if (!int.TryParse(textBoxImageWidth.Text.Trim(), out temp))
            //    error += labelImageWidth.Text + Environment.NewLine;
            //else
            //    VSGlobalControl.m_CamParam.CameraSize.Width = temp;
            //if (!int.TryParse(textBoxImageHeight.Text.Trim(), out temp))
            //    error += labelImageHeight.Text + Environment.NewLine;
            //else
            //    VSGlobalControl.m_CamParam.CameraSize.Height = temp;
            if (!double.TryParse(textBoxLineTolerance.Text.Trim(), out VSGlobalControl.m_CamParam.LineTolerance))
            {
                error += labelLineTol.Text + Environment.NewLine;
            }
            if (error != "")
            {
                MessageBox.Show("保存失败,数据格式有误: " + Environment.NewLine + error);
                return;
            }
            else
            {
                VSGlobalControl.ReadWriteCameraParam(false);
            }
        }
Example #2
0
 private void buttonSaveThreshold_Click(object sender, EventArgs e)
 {
     VSGlobalControl.m_VParam.ThresholdCell     = (int)numericUpDownThresholdCell.Value;
     VSGlobalControl.m_VParam.ThresholdStd      = (int)numericUpDownThresholdStd.Value;
     VSGlobalControl.m_VGaugeParam.ThresholdStd = (int)numericUpDownThresholdStd.Value;
     VSGlobalControl.ReadWriteProdVisionParam(false);
 }
Example #3
0
 private void buttonCancelRefCali_Click(object sender, EventArgs e)
 {
     IsRefSetting = false;
     RefIndex     = REF_NONE;
     refpoints.Clear();
     VSGlobalControl.CleanAllTestMark(selectBoxShowROI.Checked);
     MessageBox.Show("电芯基准设置取消。");
 }
Example #4
0
 private void buttonMeasMethodSet_Click(object sender, EventArgs e)
 {
     VSGlobalControl.m_VParam.MeasureMethod        = (MeasMethod)Enum.Parse(typeof(MeasMethod), comboBoxMeasureMethod.Text);
     VSGlobalControl.m_VParam.UseBottomAsBase      = optionBoxBottomBaseCell.Checked;
     VSGlobalControl.m_VGaugeParam.MeasureMethod   = (MeasMethod)Enum.Parse(typeof(MeasMethod), comboBoxMeasureMethod.Text);
     VSGlobalControl.m_VGaugeParam.UseBottomAsBase = optionBoxBottomBaseGauge.Checked;
     VSGlobalControl.ReadWriteProdVisionParam(false);
     VSGlobalControl.SetROI();
 }
Example #5
0
 private void buttonSave_Click(object sender, EventArgs e)
 {
     VSGlobalControl.m_CamParam.CameraKX = double.Parse(textBoxPixelWidthX.Text);
     VSGlobalControl.m_CamParam.CameraKY = double.Parse(textBoxPixelWidthY.Text);
     VSGlobalControl.ReadWriteCameraParam(false);
     if (CamUpdate != null)
     {
         CamUpdate(null, null);
     }
 }
Example #6
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            VSGlobalControl.InitParm();
            for (int i = 0; i < Enum.GetNames(typeof(BufferIndex)).Length; i++)
            {
                VisionList[i] = new VisionControl((BufferIndex)i);
                VisionList[i].ResPublisher.subscribeMeToResponseEvents(this);
            }
            VisionCalibration.Owner = VisionList[(int)BufferIndex.Test];

            SVS_CameraSys.getCameras();
            if (SVS_CameraSys.CameraCount > 0)
            {
                SVS_CameraSys.CameraList[0].subscribeMeToVisionEvents(this);
                SVS_CameraSys.CameraList[0].subscribeMeToVisionEvents(VisionList[0]);
                SVS_CameraSys.CameraList[0].subscribeMeToVisionEvents(VisionList[1]);
                SVS_CameraSys.CameraList[0].subscribeMeToVisionEvents(VisionList[2]);
                SVS_CameraSys.CameraList[0].subscribeMeToVisionEvents(VisionList[3]);
                SVS_CameraSys.CameraList[0].SetSVSCameraMode(1);
                VSGlobalControl.m_CamParam.CameraSize.Width  = SVS_CameraSys.CameraList[0].camWidth;
                VSGlobalControl.m_CamParam.CameraSize.Height = SVS_CameraSys.CameraList[0].camHeight;
            }

            //cameraset.cameraSetting1.SetCamera();
            cameraSetting1.SetCamera();
            VisionList[(int)BufferIndex.RightCell].VisionInit(CamDisplayRightCell, ShowPosition);
            VisionList[(int)BufferIndex.MiddleCell].VisionInit(CamDisplayMiddleCell, ShowPosition);
            VisionList[(int)BufferIndex.LeftCell].VisionInit(CamDisplayLeftCell, ShowPosition);
            VisionList[(int)BufferIndex.Test].VisionInit(CamDisplayTest, ShowPosition);

            CurrentProductName = VSGlobalControl.SysParam.CurrentProduct;
            Connect();

            VisionSetting1.VisionList = VisionList;
            VisionSetting1.CameraDispList[(int)BufferIndex.RightCell]  = CamDisplayRightCell;
            VisionSetting1.CameraDispList[(int)BufferIndex.MiddleCell] = CamDisplayMiddleCell;
            VisionSetting1.CameraDispList[(int)BufferIndex.LeftCell]   = CamDisplayLeftCell;
            VisionSetting1.CameraDispList[(int)BufferIndex.Test]       = CamDisplayTest;
            VisionSetting1.SettingInit();
        }
Example #7
0
 private void comboBoxROI_SelectedIndexChanged(object sender, EventArgs e)
 {
     selectedROI = (CamCDIRoiName)Enum.Parse(typeof(CamCDIRoiName), comboBoxROI.Text);
     Cst.Struct_Image temp = VSGlobalControl.m_VParam.Im[(int)selectedROI];
     numericUpDownIgnoreWidth1.Value   = (decimal)temp.EdgeMultiplePoint.IgnoreLength1;
     numericUpDownIgnoreWidth2.Value   = (decimal)temp.EdgeMultiplePoint.IgnoreLength2;
     numericUpDownSampleNum.Value      = (decimal)temp.EdgeMultiplePoint.Robust.RobustSampleNum;
     numericUpDownMaxRobustCount.Value = (decimal)temp.EdgeMultiplePoint.Robust.MaxRobustCount;
     selectBoxPrint.Checked            = VSGlobalControl.m_VParam.Im[(int)selectedROI].EdgeMultiplePoint.PrintMultiplePoint;
     VSGlobalControl.CleanAllTestMark(false);
     VSTest.Vision_ShowRect(VSGlobalControl.m_VParam.Im[(int)selectedROI].EdgeMultiplePoint.Rect, VSBase.COLOR_YELLOW, Cst.ViewLWidth25);
     if (VisionControl.IsXLine(temp.EdgeMultiplePoint.Dir))
     {
         labelIgnoreWidth1.Text = "左边";
         labelIgnoreWidth2.Text = "右边";
     }
     else
     {
         labelIgnoreWidth1.Text = "上边";
         labelIgnoreWidth2.Text = "下边";
     }
 }
Example #8
0
 private void buttonSaveROI_Click(object sender, EventArgs e)
 {
     if (comboBoxROI.SelectedIndex >= 0)
     {
         selectedROI = (CamCDIRoiName)Enum.Parse(typeof(CamCDIRoiName), comboBoxROI.Text);
         if (selectedROI == CamCDIRoiName.左边缘)
         {
             numericUpDownIgnoreWidth1.Value = 0;
             numericUpDownIgnoreWidth2.Value = 0;
         }
         VSGlobalControl.m_VParam.Im[(int)selectedROI].EdgeMultiplePoint.IgnoreLength1               = (double)numericUpDownIgnoreWidth1.Value;
         VSGlobalControl.m_VParam.Im[(int)selectedROI].EdgeMultiplePoint.IgnoreLength2               = (double)numericUpDownIgnoreWidth2.Value;
         VSGlobalControl.m_VParam.Im[(int)selectedROI].EdgeMultiplePoint.Robust.RobustSampleNum      = (int)numericUpDownSampleNum.Value;
         VSGlobalControl.m_VParam.Im[(int)selectedROI].EdgeMultiplePoint.Robust.MaxRobustCount       = (int)numericUpDownMaxRobustCount.Value;
         VSGlobalControl.m_VParam.Im[(int)selectedROI].EdgeMultiplePoint.PrintMultiplePoint          = selectBoxPrint.Checked;
         VSGlobalControl.m_VGaugeParam.Im[(int)selectedROI].EdgeMultiplePoint.IgnoreLength1          = (double)numericUpDownIgnoreWidth1.Value;
         VSGlobalControl.m_VGaugeParam.Im[(int)selectedROI].EdgeMultiplePoint.IgnoreLength2          = (double)numericUpDownIgnoreWidth2.Value;
         VSGlobalControl.m_VGaugeParam.Im[(int)selectedROI].EdgeMultiplePoint.Robust.RobustSampleNum = (int)numericUpDownSampleNum.Value;
         VSGlobalControl.m_VGaugeParam.Im[(int)selectedROI].EdgeMultiplePoint.Robust.MaxRobustCount  = (int)numericUpDownMaxRobustCount.Value;
         VSGlobalControl.m_VGaugeParam.Im[(int)selectedROI].EdgeMultiplePoint.PrintMultiplePoint     = selectBoxPrint.Checked;
     }
     VSGlobalControl.ReadWriteProdVisionParam(false);
 }
Example #9
0
 private void buttonShot_Click(object sender, EventArgs e)
 {
     VSGlobalControl.ShotOneCallBack(3, null);
 }
Example #10
0
 public void ClearMark()
 {
     IsRefSetting = false;
     refpoints.Clear();
     VSGlobalControl.CleanAllTestMark(selectBoxShowROI.Checked, optionBoxDispCellRef.Checked);
 }
Example #11
0
        private void CamDisplay4_MouseUp(object sender, MouseEventArgs e)
        {
            if (IsRefSetting)
            {
                Cst.dPoint temp = new Cst.dPoint(e.X, e.Y);
                refpoints.Add(temp);
                switch (refpoints.Count)
                {
                case 1:
                    VisionList[(int)BufferIndex.Test].Vision_DrawCross(e.X * 100 / VisionList[(int)BufferIndex.Test].Zoom, e.Y * 100 / VisionList[(int)BufferIndex.Test].Zoom, 40, VSBase.COLOR_CYAN, Cst.ViewLWidth50);
                    MessageBox.Show("已经设置第一个基准点。还有三个基准点。");
                    break;

                case 2:
                    VisionList[(int)BufferIndex.Test].Vision_DrawCross(e.X * 100 / VisionList[(int)BufferIndex.Test].Zoom, e.Y * 100 / VisionList[(int)BufferIndex.Test].Zoom, 40, VSBase.COLOR_CYAN, Cst.ViewLWidth50);
                    MessageBox.Show("已经设置第二个基准点。还有两个基准点。");
                    break;

                case 3:
                    VisionList[(int)BufferIndex.Test].Vision_DrawCross(e.X * 100 / VisionList[(int)BufferIndex.Test].Zoom, e.Y * 100 / VisionList[(int)BufferIndex.Test].Zoom, 40, VSBase.COLOR_CYAN, Cst.ViewLWidth50);
                    MessageBox.Show("已经设置第三个基准点。还有一个基准点。");
                    break;

                case 4:
                    Cst.dPoint centpoint = Cst.dPoint.GetAvg(refpoints.ToArray());
                    for (int i = 0; i < refpoints.Count; i++)
                    {
                        if (refpoints[i].X < centpoint.X)
                        {
                            if (refpoints[i].Y < centpoint.Y)
                            {
                                //左上
                                if (RefIndex == REF_GAUGE)
                                {
                                    VSGlobalControl.m_VGaugeParam.TopLeft = refpoints[i];
                                }
                                else
                                {
                                    VSGlobalControl.m_VParam.TopLeft = refpoints[i];
                                }
                            }
                            else
                            {
                                //左下
                                if (RefIndex == REF_GAUGE)
                                {
                                    VSGlobalControl.m_VGaugeParam.BottomLeft = refpoints[i];
                                }
                                else
                                {
                                    VSGlobalControl.m_VParam.BottomLeft = refpoints[i];
                                }
                            }
                        }
                        else
                        {
                            if (refpoints[i].Y < centpoint.Y)
                            {
                                //右上
                                if (RefIndex == REF_GAUGE)
                                {
                                    VSGlobalControl.m_VGaugeParam.TopRef = refpoints[i];
                                }
                                else
                                {
                                    VSGlobalControl.m_VParam.TopRef = refpoints[i];
                                }
                            }
                            else
                            {
                                //右下
                                if (RefIndex == REF_GAUGE)
                                {
                                    VSGlobalControl.m_VGaugeParam.BottomRef = refpoints[i];
                                }
                                else
                                {
                                    VSGlobalControl.m_VParam.BottomRef = refpoints[i];
                                }
                            }
                        }
                    }
                    //if (refpoints[0].Y > refpoints[1].Y)
                    //{
                    //    VSGlobalControl.m_VParam.BottomRef = refpoints[0];
                    //    VSGlobalControl.m_VParam.TopRef = refpoints[1];
                    //}
                    //else
                    //{
                    //    VSGlobalControl.m_VParam.BottomRef = refpoints[1];
                    //    VSGlobalControl.m_VParam.TopRef = refpoints[0];
                    //}
                    if (RefIndex == REF_GAUGE)
                    {
                        VSGlobalControl.m_VGaugeParam.BottomRef  *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VGaugeParam.TopRef     *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VGaugeParam.TopLeft    *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VGaugeParam.BottomLeft *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VGaugeParam.AvgRef      = Cst.dPoint.GetAvg(new Cst.dPoint[] { VSGlobalControl.m_VGaugeParam.BottomRef, VSGlobalControl.m_VGaugeParam.TopRef });
                        VSGlobalControl.SetROIByRef(MessageBox.Show("是否用当前标准块生成新模板?", "保存模板", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes);
                        MessageBox.Show("标准块基准设置完成。可点击“开始设置”重新设置基准。");
                        if (MessageBox.Show("是否需要对电芯基准进行设置?如果需要则先放置好电芯,然后点“是”开始电芯基准设置,需要略过则点“否”。", "电芯基准设置", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            RefIndex = REF_CELL;
                            MessageBox.Show("请先确定电芯已放好,点”确定“开始电芯基准设置。用鼠标点击图像中电芯主体边缘四个顶点。");
                        }
                        else
                        {
                            RefIndex = REF_NONE;
                        }
                    }
                    else
                    {
                        VSGlobalControl.m_VParam.BottomRef  *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VParam.TopRef     *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VParam.TopLeft    *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VParam.BottomLeft *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VParam.AvgRef      = Cst.dPoint.GetAvg(new Cst.dPoint[] { VSGlobalControl.m_VParam.BottomRef, VSGlobalControl.m_VParam.TopRef });
                        VSGlobalControl.SetROIByRef(false);
                        RefIndex = REF_NONE;
                        MessageBox.Show("电芯基准设置完成。可点击“开始设置”重新设置电芯基准。");
                    }
                    VSGlobalControl.ReadWriteProdVisionParam(false);
                    VSGlobalControl.CleanAllTestMark();
                    IsRefSetting = false;
                    break;
                }
            }
        }