public void ToolRun(string jobName, int toolIndex, int inputItemNum, TreeNode selectNode, List <IToolInfo> L_toolList) { Caliper myCaliper = (Caliper)L_toolList[toolIndex].tool; VisionJob myJob = VisionJobParams.pVisionProject.Project[jobName]; for (int j = 0; j < inputItemNum; j++) { if (L_toolList[toolIndex].toolInput[j].IOName == "InputImage" && L_toolList[toolIndex].GetInput(L_toolList[toolIndex].toolInput[j].IOName).value == null) { selectNode.ForeColor = Color.Red; Logger.LoggerClass.WriteLog($"{L_toolList[toolIndex].toolName} 无输入图像"); break; } else { if (L_toolList[toolIndex].GetInput(L_toolList[toolIndex].toolInput[j].IOName).value != null) { string sourceFrom = L_toolList[toolIndex].GetInput(L_toolList[toolIndex].toolInput[j].IOName).value.ToString(); string sourceToolName = Regex.Split(sourceFrom, " . ")[0]; sourceToolName = sourceToolName.Substring(3, Regex.Split(sourceFrom, " . ")[0].Length - 3); string toolItem = Regex.Split(sourceFrom, " . ")[1]; if (L_toolList[toolIndex].toolInput[j].IOName == "InputImage") { myCaliper.inputImage = myJob.GetToolInfoByToolName(sourceToolName).GetOutput(toolItem).value as HObject; } if (L_toolList[toolIndex].toolInput[j].IOName == "inputCenterRow") { myCaliper.expectRecStartRow = myJob.GetToolInfoByToolName(sourceToolName).GetOutput(toolItem).value as HTuple; } if (L_toolList[toolIndex].toolInput[j].IOName == "inputCenterCol") { myCaliper.expectRecStartColumn = myJob.GetToolInfoByToolName(sourceToolName).GetOutput(toolItem).value as HTuple; } if (L_toolList[toolIndex].toolInput[j].IOName == "inputPhi") { myCaliper.expectAngle = myJob.GetToolInfoByToolName(sourceToolName).GetOutput(toolItem).value as HTuple; } } } } myCaliper.Run(SoftwareRunState.Release); if (myCaliper.toolRunStatu == ToolRunStatu.Succeed) { myCaliper.DispMainWindow(FormImageWindow.Instance.myHWindow); myJob.FormLogDisp(L_toolList[toolIndex].toolName + " 运行成功", Color.Green, selectNode); } else { myJob.FormLogDisp(L_toolList[toolIndex].toolName + " 运行失败", Color.Red, selectNode); } }
private void btn_runCaliperool_Click(object sender, EventArgs e) { // 更改界面中参数,实时更新类中参数 myCaliper.expectRecStartRow = Convert.ToDouble(tbx_expectCenterRow.Text.Trim()); myCaliper.expectRecStartColumn = Convert.ToDouble(tbx_expectCenterCol.Text.Trim()); myCaliper.expectAngle = Convert.ToDouble(tbx_expectPhi.Text.Trim()); // 运行参数 myCaliper.threshold = Convert.ToInt16(tbx_threshold.Text.Trim()); myCaliper.length1 = Convert.ToDouble(tbx_caliperLength1.Text.Trim()); myCaliper.length2 = Convert.ToDouble(tbx_caliperLength2.Text.Trim()); myCaliper.polarity = cbx_polarity.SelectedItem.ToString() == "从明到暗" ? "negative" : "positive"; myCaliper.edgeSelect = cbx_edgeSelect.SelectedItem.ToString(); myCaliper.sigma = Convert.ToDouble(tbx_Sigma.Text.Trim()); myCaliper.Run(SoftwareRunState.Debug); }