<< 点击显示目录 >> 主页
mappVision帮助助手 > 机器视觉帮助 > mapp Vision > 编程 > 库 > 核心库 > ViBase > 功能块 功能说明 |
功能块 ViBaseListApplication 可用于列出当前可从控制器加载到相机模块的所有现有视觉应用程序。
当前在相关视觉组件中设置为引用的视觉应用程序(也称为 "活动视觉应用程序 "或 "机器视觉应用程序")是列表中的第一个条目。如果适用,设计时在 AS 中创建的其他兼容视觉应用程序或运行时在 mapp Vision HMI 应用程序中创建的其他兼容视觉应用程序按字母顺序紧随其后。)
视觉组件的引用(参见ViComponentType)设置在功能块的输入 MpLink 上。
此外,还必须预留一个合适的内存区域,以便功能块可以将视觉应用程序的名称填入其中。必须在功能块的输入 List 和 ListLen 中指定该内存区域的起始地址和大小。
输入格式可用于确定创建列表的文本格式。
默认情况下,viBASE_FORMAT_PLAIN_TEXT(0)处于激活状态。视觉程序的名称将以纯文本格式写入内存区域。这种格式非常有用,可在 IEC 或 ANSI C/C++ 程序中进一步应用。此外,还可以使用值绑定功能,在 mapp 视图表部件中轻松显示列表。
使用viBASE_FORMAT_ITEMCOLLECTION(1),视觉应用程序的名称将以 ItemCollection 格式写入内存区域。通过这种格式,可以使用值绑定功能在 mapp 视图选择器部件中轻松显示列表。
•格式的选择会影响内存区域所需的大小:
•对于 viBASE_FORMAT_PLAIN_TEXT,每个视觉应用程序需要一个ViBaseFormatPlainTextType条目(51 字节)的空间。
•对于 viBASE_FORMAT_ITEMCOLLECTION,每个视觉应用程序需要为一个ViBaseFormatItemCollectionType项(131 字节)留出空间。
•必须在输入 ListLen 中设置这些数据类型大小的整数倍。
内存区域通常以数组的形式创建,其数据类型与格式上的选择相匹配;数组的起始地址在输入 List 中设置,数组的数据大小在输入 ListLen 中设置。
例如,以纯文本格式列出多达 10 个视觉应用程序:
VAR
...
MyListApplicationFub : ViBaseListApplication;
MyPlaintextArray : ARRAY[0...9] OF ViBaseFormatPlainTextType;
...
END_VAR
循环程序
...
MyListApplicationFub.List := ADR(MyPlaintextArray);
MyListApplicationFub.ListLen := SIZEOF(MyPlaintextArray); (* 即 510 *)
...
结束程序
如果提供的内存区域合适,功能块将在成功执行后进入所有可加载的视觉应用程序,并在输出 StatusID 上显示值 0。
如果内存区域大于所需值,则功能块会删除多余的条目(例如之前的调用),并在输出 StatusID 上显示值 0。
如果所提供的内存区域不足以列出完整的列表,功能块会尽可能填满内存区域,并在输出 StatusID 上显示状态信息viBASE_INF_APP_LIST_NOT_COMPLETE= 1102315666,说明无法列出所有可加载的视觉应用程序。
在上述所有情况下,都可以从输出 NrEntries 中读出实际可以列出的视觉应用程序的数量。这一信息可用于确定内存中当前有效的数据区域,或在必要时调整内存大小,以便在调用新的功能块时获得完整的列表。
功能块的执行错误会在输出端 Error 上显示,并在输出端 StatusID 上显示相应的错误状态编号。发生错误时,功能块不会修改内存区域的内容。
图功能块 ViBaseListApplication
1) 每次通过功能块ViBaseLoadApplication 更改机器视觉应用程序后,建议调用 ViBaseListApplication 更新列表。
Function block ViBaseListApplication can be used to list all existing vision applications that can currently be loaded from the controller to a camera module.
The vision application currently set as a reference in the associated vision component (also referred to as "active vision application" or "machine vision application") is the first entry in the list. If applicable, other compatible vision applications that were created in Automation Studio at design time or the mapp Vision HMI application at runtime follow in alphabetical order.1)
The reference to the vision component (see ViComponentType) is set on input MpLink of the function block.
In addition, a suitable memory area must be reserved that the function block can fill with the names of the vision applications. The starting address and size of this memory area must be specified on inputs List and ListLen of the function block.
Input Format can be used to determine the text format that will be used to create the list.
By default, viBASE_FORMAT_PLAIN_TEXT (0) is active. The names of vision applications are written to the memory area in plain text format. This format is useful and intended for further applicative use in IEC or ANSI C/C++ programs. In addition, the list can be easily displayed in mapp View Table widgets using value binding.
With viBASE_FORMAT_ITEMCOLLECTION (1), the names of vision applications are written to the memory area in ItemCollection format. This format makes it possible to easily display the list in mapp View Selector widgets using values binding.
•The selection for Format influences the required size of the memory area:
•For viBASE_FORMAT_PLAIN_TEXT, space is required for one ViBaseFormatPlainTextType entry (51 bytes) for each vision application.
•For viBASE_FORMAT_ITEMCOLLECTION, space is required for one ViBaseFormatItemCollectionType entry (131 bytes) for each vision application.
•Integer multiples of these data type sizes must be set on input ListLen.
The memory area is typically created as an array of the data type that matches the selection on Format; the starting address of the array is set on input List, and the data size of the array is set on input ListLen.
For example, to list up to 10 vision applications in plain text format:
VAR
...
MyListApplicationFub : ViBaseListApplication;
MyPlaintextArray : ARRAY[0..9] OF ViBaseFormatPlainTextType;
...
END_VAR
PROGRAM _CYCLIC
...
MyListApplicationFub.List := ADR(MyPlaintextArray);
MyListApplicationFub.ListLen := SIZEOF(MyPlaintextArray); (* i.e 510 *)
...
END_PROGRAM
If the memory area provided is suitable, the function block enters all loadable vision applications when successfully executed and indicates value 0 on output StatusID.
If the memory area is larger than required, the function block deletes any excess entries (e.g. from a previous call) and also indicates value 0 on output StatusID.
If the memory area provided is not sufficient for the complete list, the function block fills it as far as possible and indicates with status information viBASE_INF_APP_LIST_NOT_COMPLETE = 1102315666 on output StatusID that not all loadable vision applications could be listed.
In all of the above cases, the number of vision applications that can actually be listed can be read out on output NrEntries. This information can be used to determine the currently valid data area in the memory or to adjust the memory size, if necessary, in order to obtain a complete list with a new call of the function block.
An execution error of the function block is indicated on output Error and with a corresponding error status number on output StatusID. In the event of error, the contents of the memory area are not modified by the function block.
Fig.: Function block ViBaseListApplication
1) After each change of the machine vision application via function block ViBaseLoadApplication, it is therefore recommended to update the list by calling ViBaseListApplication.