private void buttonStartRefCali_Click(object sender, EventArgs e) { if (UseGauge == "") { MessageBox.Show("当前产品没有标准块,不能进行基准设置。需要在CDI产品设置中选择标准块并保存后,再重新进行基准设置。"); return; } IsRefSetting = true; refpoints.Clear(); VSTest.Vision_MarkClean(); if (CameraLive != null) { foreach (EventHandler handler in CameraLive.GetInvocationList()) { CameraLive(sender, e); } } MessageBox.Show("相机已打开。将开始分别对电芯和标准块进行基准的设置。"); if (MessageBox.Show("是否需要对标准块基准进行设置?如果需要则先放置好标准块,然后点“是”开始标准块基准设置,需要略过则点“否”。", "标准块基准设置", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { RefIndex = REF_GAUGE; MessageBox.Show("请先确定标准块已放好,点”确定“开始标准块基准设置。用鼠标点击图像中标准块主体边缘四个顶点。"); } else if (MessageBox.Show("是否需要对电芯基准进行设置?如果需要则先放置好电芯,然后点“是”开始电芯基准设置,需要略过则点“否”。", "电芯基准设置", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { RefIndex = REF_CELL; MessageBox.Show("请先确定电芯已放好,点”确定“开始电芯基准设置。用鼠标点击图像中电芯主体边缘四个顶点。"); } else { IsRefSetting = false; } }
private void buttonGetBlob_Click(object sender, EventArgs e) { double cx = 0; double cy = 0; double Area = 0; int ret = 0; int pos; pos = this.BlobBar.Value; matrix = new bool[col, row]; blobmatrix = new BlobPoint[col, row]; minx = miny = 100000; maxx = maxy = -1; blobs.Clear(); VSTest.Vision_MarkClean(); ret = VSTest.Vision_FindBlobMultiplePoint(false, pos, BlobMinArea, BlobMaxArea, BlobSearchRect); for (int i = 0; i < ret; i++) { VSTest.Vision_GetBlobMultiplePointResult(i, ref cx, ref cy, ref Area); VSTest.Vision_DrawCross(Convert.ToInt32(cx), Convert.ToInt32(cy), 5, 250, 2); AddData(cx, cy); } GetPitch(); CalcPixelWidth(); MessageBox.Show("标定完成。"); }
public void TestThatPublishResultsCreatedtheCorrectLoggerInCommandLine() { var process = new Mock <IProcess>(); var buildDetail = new Mock <IBuildDetail>(); buildDetail.SetupGet(b => b.BuildNumber).Returns("1.0.0.1"); buildDetail.SetupGet(b => b.TeamProject).Returns("MyTeamProject"); var target = new VSTest(process.Object) { PublishTestResults = true, ProjectCollectionUrl = @"http://*****:*****@"C:\Projects\Test\TestAssembly.dll" }); parameters.Add("Build", buildDetail.Object); WorkflowInvoker invoker = new WorkflowInvoker(target); invoker.Invoke(parameters); process.Verify(s => s.Execute(It.IsAny <string>(), It.Is <string>(e => e.IndexOf(@"/Logger:TfsPublisher;Collection=""http://tfsserver:8080/collection1/abcd"";BuildName=""1.0.0.1"";TeamProject=""MyTeamProject"";Flavor=""Release"";Platform=""Any CPU""", StringComparison.InvariantCultureIgnoreCase) > 0), It.IsAny <string>())); }
private void LoadPic(string picfile) { textBoxBarcode.Text = VSTest.LoadPicture(picfile); VisionList[(int)BufferIndex.Test].Barcode = textBoxBarcode.Text; if (SetVisionIndex != null) { SetVisionIndex(BufferIndex.Test); } }
private void BlobBar_Scroll(object sender, EventArgs e) { int pos; pos = this.BlobBar.Value; this.Thres.Text = pos.ToString(); VSTest.Vision_Binary(pos); }
private void buttonSet_Click(object sender, EventArgs e) { row = int.Parse(textBoxRow.Text); col = int.Parse(textBoxCol.Text); rowPitch = double.Parse(textBoxRowPitch.Text); colPitch = double.Parse(textBoxColPitch.Text); BlobThres = this.BlobBar.Value; BlobMinArea = int.Parse(TextBoxMinArea.Text); BlobMaxArea = int.Parse(TextBoxMaxArea.Text); BlobWhiteBlob = CheckBoxWhiteBlob.Checked; VSTest.Vision_MarkClean(); VSTest.Vision_ShowRect(BlobSearchRect, VSBase.COLOR_BLUE, 2); }
public void TestThatMultipleTestAssembliesArePassedCorrectlyInCommandLine() { var process = new Mock<IProcess>(); var target = new VSTest(process.Object) { PublishTestResults = false }; var parameters = new Dictionary<string, object> { { "TestAssemblies", new[] { @"C:\Projects\Test\TestAssembly.dll", @"C:\Projects\Test\TestAssembly2.dll" } } }; WorkflowInvoker invoker = new WorkflowInvoker(target); invoker.Invoke(parameters); process.Verify(s => s.Execute(It.IsAny<string>(), It.Is<string>(e => e == @"""C:\Projects\Test\TestAssembly.dll"" ""C:\Projects\Test\TestAssembly2.dll"""), It.IsAny<string>())); }
public void TestThatMultipleTestAssembliesArePassedCorrectlyInCommandLine() { var process = new Mock <IProcess>(); var target = new VSTest(process.Object) { PublishTestResults = false }; var parameters = new Dictionary <string, object> { { "TestAssemblies", new[] { @"C:\Projects\Test\TestAssembly.dll", @"C:\Projects\Test\TestAssembly2.dll" } } }; WorkflowInvoker invoker = new WorkflowInvoker(target); invoker.Invoke(parameters); process.Verify(s => s.Execute(It.IsAny <string>(), It.Is <string>(e => e == @"""C:\Projects\Test\TestAssembly.dll"" ""C:\Projects\Test\TestAssembly2.dll"""), It.IsAny <string>())); }
public void TestThatCorrectExecutableIsCalled() { string vsTestConsoleExePath = @"%VS110COMNTOOLS%\..\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"; var process = new Mock<IProcess>(); var target = new VSTest(process.Object) { PublishTestResults = false }; var parameters = new Dictionary<string, object> { { "TestAssemblies", new[] { @"C:\Projects\Test\TestAssembly.dll" } } }; WorkflowInvoker invoker = new WorkflowInvoker(target); invoker.Invoke(parameters); process.Verify(s => s.Execute(It.Is<string>( e => e==Environment.ExpandEnvironmentVariables(vsTestConsoleExePath)), It.IsAny<string>(), It.IsAny<string>())); }
public void TestThatTestCaseFilterIsPassedCorrectlyInCommandLine() { var process = new Mock <IProcess>(); var target = new VSTest(process.Object) { PublishTestResults = false, TestCaseFilter = "Category1" }; var parameters = new Dictionary <string, object> { { "TestAssemblies", new[] { @"C:\Projects\Test\TestAssembly.dll" } } }; WorkflowInvoker invoker = new WorkflowInvoker(target); invoker.Invoke(parameters); process.Verify(s => s.Execute(It.IsAny <string>(), It.Is <string>(e => e.IndexOf(@"/testcasefilter:""Category1""", StringComparison.InvariantCultureIgnoreCase) > 0), It.IsAny <string>())); }
public void TestThatCorrectExecutableIsCalled() { string vsTestConsoleExePath = @"%VS110COMNTOOLS%\..\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"; var process = new Mock <IProcess>(); var target = new VSTest(process.Object) { PublishTestResults = false }; var parameters = new Dictionary <string, object> { { "TestAssemblies", new[] { @"C:\Projects\Test\TestAssembly.dll" } } }; WorkflowInvoker invoker = new WorkflowInvoker(target); invoker.Invoke(parameters); process.Verify(s => s.Execute(It.Is <string>(e => e == Environment.ExpandEnvironmentVariables(vsTestConsoleExePath)), It.IsAny <string>(), It.IsAny <string>())); }
public void BatchMeas(string folderpath) { if (!IsBatchRunning) { IsBatchRunning = true; files = GetFiles(folderpath, "*.bmp|*.png|*.jpg"); count = 0; } if (IsBatchRunning) { for (; count < files.Length;) { if (!IsBatchRunning) { return; } labelFileCounter.Text = string.Format("{0}/{1}", count + 1, files.Length); Application.DoEvents(); textBoxBarcode.Text = VSTest.LoadPicture(files[count]); if (textBoxBarcode.Text != "") { VisionList[(int)BufferIndex.Test].StartMeas(textBoxBarcode.Text, false); } count++; if (selectBoxPause.Checked) { break; } } if (count == files.Length) { if (isFromButton) { MessageBox.Show("批量测试完成。"); } isFromButton = false; IsBatchRunning = false; } } }
private void ID_OPEN_BMP_Click(object sender, EventArgs e) { IntPtr hW; switch (((Button)sender).Name) { case "buttonFromRight": hW = VSRightCell.Vision_GetHwnd(0, 0, VisionList[(int)BufferIndex.RightCell].imgWidth, VisionList[(int)BufferIndex.RightCell].imgHeight); VSTest.Vision_CKCopy(hW, VisionList[(int)BufferIndex.RightCell].imgWidth, VisionList[(int)BufferIndex.RightCell].imgHeight); VSTest.Vision_CopyImageToBuffer(1); break; case "buttonFromMiddle": hW = VSMiddleCell.Vision_GetHwnd(0, 0, VisionList[(int)BufferIndex.MiddleCell].imgWidth, VisionList[(int)BufferIndex.MiddleCell].imgHeight); VSTest.Vision_CKCopy(hW, VisionList[(int)BufferIndex.MiddleCell].imgWidth, VisionList[(int)BufferIndex.MiddleCell].imgHeight); VSTest.Vision_CopyImageToBuffer(1); break; case "buttonFromLeft": hW = VSLeftCell.Vision_GetHwnd(0, 0, VisionList[(int)BufferIndex.LeftCell].imgWidth, VisionList[(int)BufferIndex.LeftCell].imgHeight); VSTest.Vision_CKCopy(hW, VisionList[(int)BufferIndex.LeftCell].imgWidth, VisionList[(int)BufferIndex.LeftCell].imgHeight); VSTest.Vision_CopyImageToBuffer(1); break; case "buttonFromFile": if (openFileDialog1.ShowDialog() == DialogResult.OK) { string szpath = openFileDialog1.FileName; LoadPic(szpath); } break; case "buttonFromCamera": if (ShotOneFrame != null) { ShotOneFrame((int)BufferIndex.Test, null); } break; } }
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 = "下边"; } }
private void optionBox100_Click(object sender, EventArgs e) { VSTest.Control_Zoom(100); }
private void buttonZoom_Click(object sender, EventArgs e) { int zoom = int.Parse(((Button)sender).Text.Replace("%", "")); VSTest.Control_Zoom(zoom); }
private void numericUpDownThresholdCell_Click(object sender, EventArgs e) { VSTest.Vision_Binary((int)numericUpDownThresholdCell.Value); }
public void TestThatTestCaseFilterIsPassedCorrectlyInCommandLine() { var process = new Mock<IProcess>(); var target = new VSTest(process.Object) { PublishTestResults = false, TestCaseFilter = "Category1" }; var parameters = new Dictionary<string, object> { { "TestAssemblies", new[] { @"C:\Projects\Test\TestAssembly.dll"}} }; WorkflowInvoker invoker = new WorkflowInvoker(target); invoker.Invoke(parameters); process.Verify(s => s.Execute(It.IsAny<string>(), It.Is<string>(e => e.IndexOf(@"/testcasefilter:""Category1""", StringComparison.InvariantCultureIgnoreCase) > 0), It.IsAny<string>())); }
public void TestThatPublishResultsCreatedtheCorrectLoggerInCommandLine() { var process = new Mock<IProcess>(); var buildDetail = new Mock<IBuildDetail>(); buildDetail.SetupGet(b=> b.BuildNumber).Returns("1.0.0.1"); buildDetail.SetupGet(b => b.TeamProject).Returns("MyTeamProject"); var target = new VSTest(process.Object) { PublishTestResults = true, ProjectCollectionUrl = @"http://*****:*****@"C:\Projects\Test\TestAssembly.dll"}); parameters.Add("Build", buildDetail.Object); WorkflowInvoker invoker = new WorkflowInvoker(target); invoker.Invoke(parameters); process.Verify(s => s.Execute(It.IsAny<string>(), It.Is<string>(e => e.IndexOf(@"/Logger:TfsPublisher;Collection=""http://tfsserver:8080/collection1/abcd"";BuildName=""1.0.0.1"";TeamProject=""MyTeamProject"";Flavor=""Release"";Platform=""Any CPU""", StringComparison.InvariantCultureIgnoreCase) > 0), It.IsAny<string>())); }