public void ToolRun(int toolIndex, int inputItemNum, TreeNode selectNode, FormLog myFormLog, FormImageWindow myFormWindow, List <IToolInfo> L_toolList) { HalconTool.HalconTool myHalconTool = (HalconTool.HalconTool)L_toolList[toolIndex].tool; myHalconTool.Run(SoftwareRunState.Release); if (myHalconTool.outputImage == null) { GlobalParams.myVisionJob.FormLogDisp(L_toolList[toolIndex].toolName + " 运行失败", Color.Red, selectNode); } else { GlobalParams.myVisionJob.FormLogDisp(L_toolList[toolIndex].toolName + " 运行成功", Color.Green, selectNode); GlobalParams.myVisionJob.myFormImageWindow.myHWindow.HobjectToHimage(myHalconTool.outputImage); } }
public void Run() { for (int i = 0; i < L_toolList.Count; i++) { TreeNode treeNode = GetToolNodeByNodeText(L_toolList[i].toolName); inputItemNum = (L_toolList[i]).toolInput.Count; outputItemNum = (L_toolList[i]).toolOutput.Count; switch (L_toolList[i].toolType) { #region halconTool case ToolType.HalconTool: HalconTool.HalconTool myHalconTool = (HalconTool.HalconTool)L_toolList[i].tool; myHalconTool.Run(SoftwareRunState.Release); if (myHalconTool.outputImage == null) { FormLogDisp(L_toolList[i].toolName + " 运行失败", Color.Red, treeNode); } else { FormLogDisp(L_toolList[i].toolName + " 运行成功", Color.Green, treeNode); myFormImageWindow.myHWindow.HobjectToHimage(myHalconTool.outputImage); } break; #endregion #region FindLine case ToolType.FindLine: FindLine myFindLine = (FindLine)L_toolList[i].tool; for (int j = 0; j < inputItemNum; j++) { if (L_toolList[i].GetInput(L_toolList[i].toolInput[j].IOName).value == null) { treeNode.ForeColor = Color.Red; myFormLog.ShowLog(L_toolList[i].toolName + " 无输入图像"); } else { string sourceFrom = L_toolList[i].GetInput(L_toolList[i].toolInput[j].IOName).value.ToString(); if (L_toolList[i].toolInput[j].IOName == "InputImage") { string sourceToolName = Regex.Split(sourceFrom, " . ")[0]; sourceToolName = sourceToolName.Substring(3, Regex.Split(sourceFrom, " . ")[0].Length - 3); string toolItem = Regex.Split(sourceFrom, " . ")[1]; myFindLine.inputImage = GetToolInfoByToolName(GlobalParams.myVisionJob.JobName, sourceToolName).GetOutput(toolItem).value as HObject; } } } myFindLine.Run(SoftwareRunState.Release); if (myFindLine.toolRunStatu == ToolRunStatu.Succeed) { myFindLine.DispMainWindow(myFormImageWindow.myHWindow); FormLogDisp(L_toolList[i].toolName + " 运行成功", Color.Green, treeNode); } else { FormLogDisp(L_toolList[i].toolName + " 运行失败", Color.Red, treeNode); } break; #endregion case ToolType.Caliper: Caliper myCaliper = (Caliper)L_toolList[i].tool; //if(L_toolList[i].FormTool == null) //{ // FormLogDisp(L_toolList[i].toolName + " 运行失败", Color.Red, treeNode); // continue; //} for (int j = 0; j < inputItemNum; j++) { if (L_toolList[i].toolInput[j].IOName == "InputImage" && L_toolList[i].GetInput(L_toolList[i].toolInput[j].IOName).value == null) { treeNode.ForeColor = Color.Red; myFormLog.ShowLog(L_toolList[i].toolName + " 无输入图像"); break; } else { if (L_toolList[i].GetInput(L_toolList[i].toolInput[j].IOName).value != null) { string sourceFrom = L_toolList[i].GetInput(L_toolList[i].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[i].toolInput[j].IOName == "InputImage") { myCaliper.inputImage = GetToolInfoByToolName(GlobalParams.myVisionJob.JobName, sourceToolName).GetOutput(toolItem).value as HObject; } if (L_toolList[i].toolInput[j].IOName == "inputCenterRow") { myCaliper.expectRecStartRow = GetToolInfoByToolName(GlobalParams.myVisionJob.JobName, sourceToolName).GetOutput(toolItem).value as HTuple; } if (L_toolList[i].toolInput[j].IOName == "inputCenterCol") { myCaliper.expectRecStartColumn = GetToolInfoByToolName(GlobalParams.myVisionJob.JobName, sourceToolName).GetOutput(toolItem).value as HTuple; } if (L_toolList[i].toolInput[j].IOName == "inputPhi") { myCaliper.expectAngle = GetToolInfoByToolName(GlobalParams.myVisionJob.JobName, sourceToolName).GetOutput(toolItem).value as HTuple; } } } } myCaliper.Run(SoftwareRunState.Release); if (myCaliper.toolRunStatu == ToolRunStatu.Succeed) { myCaliper.DispMainWindow(myFormImageWindow.myHWindow); FormLogDisp(L_toolList[i].toolName + " 运行成功", Color.Green, treeNode); } else { FormLogDisp(L_toolList[i].toolName + " 运行失败", Color.Red, treeNode); } break; } } }