コード例 #1
0
        public void ToolRun(string jobName, int toolIndex, int inputItemNum, TreeNode selectNode, List <IToolInfo> L_toolList)
        {
            FindLine  myFindLine = (FindLine)L_toolList[toolIndex].tool;
            VisionJob myJob      = VisionJobParams.pVisionProject.Project[jobName];

            for (int j = 0; j < inputItemNum; j++)
            {
                if (L_toolList[toolIndex].GetInput(L_toolList[toolIndex].toolInput[j].IOName).value == null)
                {
                    selectNode.ForeColor = Color.Red;
                    Logger.LoggerClass.WriteLog(L_toolList[toolIndex].toolName + "  无输入图像", Logger.MsgLevel.Exception);
                }
                else
                {
                    string sourceFrom = L_toolList[toolIndex].GetInput(L_toolList[toolIndex].toolInput[j].IOName).value.ToString();
                    if (L_toolList[toolIndex].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 = myJob.GetToolInfoByToolName(sourceToolName).GetOutput(toolItem).value as HObject;
                    }
                }
            }
            myFindLine.Run(SoftwareRunState.Release);
            if (myFindLine.toolRunStatu == ToolRunStatu.Succeed)
            {
                myFindLine.DispMainWindow(FormImageWindow.Instance.myHWindow);
                myJob.FormLogDisp(L_toolList[toolIndex].toolName + "  运行成功", Color.Green, selectNode);
            }
            else
            {
                myJob.FormLogDisp(L_toolList[toolIndex].toolName + "  运行失败", Color.Red, selectNode, Logger.MsgLevel.Exception);
            }
        }
コード例 #2
0
 private void btn_runFindLineTool_Click(object sender, EventArgs e)
 {
     // 更改界面中参数,实时更新类中参数
     myFindLine.expectLineStartRow = Convert.ToDouble(tbx_expectLineStartRow.Text.Trim());
     myFindLine.expectLineStartCol = Convert.ToDouble(tbx_expectLineStartCol.Text.Trim());
     myFindLine.expectLineEndRow   = Convert.ToDouble(tbx_expectLineEndRow.Text.Trim());
     myFindLine.expectLineEndCol   = Convert.ToDouble(tbx_expectLineEndCol.Text.Trim());
     // 运行参数
     myFindLine.minScore   = Convert.ToDouble(tbx_minScore.Text.Trim());
     myFindLine.cliperNum  = Convert.ToInt16(tbx_caliperNum.Text.Trim());
     myFindLine.threshold  = Convert.ToInt16(tbx_threshold.Text.Trim());
     myFindLine.length     = Convert.ToInt16(tbx_caliperLength.Text.Trim());
     myFindLine.weidth     = Convert.ToInt16(tbx_caliperLength2.Text.Trim());
     myFindLine.polarity   = cbx_polarity.SelectedItem.ToString() == "从明到暗" ? "negative":"positive";
     myFindLine.edgeSelect = cbx_edgeSelect.SelectedItem.ToString();
     myFindLine.sigma      = Convert.ToDouble(tbx_Sigma.Text.Trim());
     // Run
     myFindLine.Run(SoftwareRunState.Debug);
 }