设置首页收藏本站
开启左侧

看视频,记笔记

[复制链接]
wenluderen 发表于 2018-4-12 13:48:01 | 显示全部楼层 |阅读模式
一:VP的四种开发模式
A,quickbuild视觉+向导生成的操作界面(没有源代码的)
向导工具见下图
2018-04-12_132241.jpg

B,quickbuild视觉+修改的操作的界面(有源代码)

C,quickbuild视觉+自定义的操作界面(有源代码的)

D,自定义应用程序
在VS里面直接调用VP的API函数。这种方式有最大的自由化,但是对编程能力要求极高,一般没有人采取这个方式
****************************
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| wenluderen 发表于 2018-4-12 14:06:12 | 显示全部楼层
VP里面各种文件彼此的包含关系。

*****************
quickbuild工程下面是 Cogjob(视频教程里面的老师称之为作业),一个quickbuild下面可以多个Cogjob。 而且这些Cogjob都是并行的。
2018-04-12_135155.jpg
***************双击Cogjob(作业)进入到内部。一个作业里是一个工具组(Toolgroup)
工具组里就是具体的函数。函数应该就是VP最小的单位了。







*************************
视频教程里面让我打开作业返范例,结果我打不开。提示如下,
2018-04-12_140026.jpg
难道说版本为VPRO-PLUS这个版本的许可,是无法支持作业范例的???

*************************88
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| wenluderen 发表于 2018-4-12 14:19:02 | 显示全部楼层
已发送项:将quickbuild里面数据 配置成接口, 这些接口可以被高级语言(C# VB.net)等交互

通讯管理器:VP可以使用一些板卡, 或是以太网 和外部硬件交互数据。
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| wenluderen 发表于 2018-4-15 15:59:49 | 显示全部楼层
本帖最后由 wenluderen 于 2018-4-15 16:10 编辑


由于VP是一种图形化的编程语言,必然会丧失一些灵活性,VP是使用脚本解决这个问题的

VP里面有三种脚本

1)作业(JOb)脚本
配置-作业属性
2018-04-15_150258.jpg

2)工具组(ToolGroup)脚本



3)工具块(ToolBlock)脚本
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| wenluderen 发表于 2018-4-15 16:09:21 | 显示全部楼层
using System;
using Cognex.VisionPro;
using Cognex.VisionPro3D;
using Cognex.VisionPro.ToolGroup;
using Cognex.VisionPro.Dimensioning;
public class UserScript : CogToolGroupBaseScript
{
  
  private double  Distance = 0;
  private CogDistancePointPointTool DistancePointPointToolOject;
  
  // The GroupRun function is called when the tool group is run.  The default
  // implementation provided here is equivalent to the normal behavior of the
  // tool group.  Modifying this function will allow you to change the behavior
  // when the tool group is run.
  //运行工具的时候调用该函数,该函数允许修改工具组运行时的动作
  public override bool GroupRun(ref string message, ref CogToolResultConstants result)
  {
    // To let the execution stop in this script when a debugger is attached, uncomment the following lines.
    // #if DEBUG
    // if (System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debugger.Break();
    // #endif

    // Run each tool in the tool group using the RunTool function
    for (Int32 toolIdx = 0; toolIdx < toolGroup.Tools.Count; toolIdx++)
      toolGroup.RunTool(toolGroup.Tools[toolIdx], ref message, ref result);

    // Returning False indicates we ran the tools in script, and they should not be
    // run by VisionPro
    DistancePointPointToolOject = (CogDistancePointPointTool) toolGroup.Tools["CogDistancePointPointTool1"];
    Distance = DistancePointPointToolOject.Distance;
   
    return false;
  }

#region "When the Current Run Record is Created"
  public override void ModifyCurrentRunRecord(Cognex.VisionPro.ICogRecord currentRecord)
  {
  }
#endregion

#region "When the Last Run Record is Created"
  //最后运行记录创建的时候调用该方法,允许向最后的运行记录修改和添加内容:图像或是文字
  // Allows you to add or modify the contents of the last run record when it is
  // created.  For example, you might add custom graphics to the run record here.
  public override void ModifyLastRunRecord(Cognex.VisionPro.ICogRecord lastRecord)
  {
    CogGraphicLabel ResultLable = new CogGraphicLabel();
    string labelStr = string.Format("Distance ={0:F2} pixel", Distance);
    ResultLable.SetXYText((DistancePointPointToolOject.StartX + DistancePointPointToolOject.EndX) / 2, DistancePointPointToolOject.EndY, labelStr);
    ResultLable.Color = Cognex.VisionPro.CogColorConstants.Blue;
    toolGroup.AddGraphicToRunRecord(ResultLable,lastRecord,"CogImageConvertTool1.OutputImage","Script");
  }
#endregion

#region "When the Script is Initialized"
  //当脚本初始化的时候会调用这个函数
  // Perform any initialization required by your script here
  public override void Initialize(CogToolGroup host)
  {
    // DO NOT REMOVE - Call the base class implementation first - DO NOT REMOVE
    base.Initialize(host);
  }
#endregion

}
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| wenluderen 发表于 2018-4-17 10:20:47 | 显示全部楼层
关于已发送项
***********************
在高级语言调VP(quickbuild)程序的时候,如果高级语言需要访问VP里面的变量,就需要“已发送项”里面做出一些配置
**
A:

2018-04-17_101727.jpg

B:
2018-04-17_101825.jpg

C:
2018-04-17_102023.jpg
***************************


奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
majy198802 发表于 2018-7-2 15:29:27 | 显示全部楼层
厉害了,学习
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| wenluderen 发表于 2018-7-3 15:30:13 | 显示全部楼层
电子模式.jpg
电子模式
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| wenluderen 发表于 2018-7-3 15:35:19 | 显示全部楼层
关于卡尺工具的几个变量说明
电子模式.jpg
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
半分雨 发表于 2018-8-15 17:39:50 | 显示全部楼层
我怎么感觉第四种用的挺多的,这种方法可以提高很多处理速度
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表