作为调用 mapp Vision 功能块并通过 OPC UA 绑定动态设计 HMI 应用程序的后端,在逻辑视图中添加了一个名为 PCUC 的 ST 程序作为示例。
除了访问上述 mapp Vision 核心库 ViBase 的功能块外,此处描述的程序还需要访问 B&R 库 AsBrStr 和 runtime 的功能块。如有必要,必须在逻辑视图中添加缺失的库。
首先介绍程序的基本框架,它调用 ViBase 功能块,从而提供基本功能。
基本程序在 Variables.var 文件中包含以下变量(变体 A 和变体 B 各一个):
在文件 Init.st 中,基本程序包含以下初始化子程序(变体 A 和变体 B 各一个):
在 Cyclic.st 文件中,基本程序包含以下循环子程序(在此扩展阶段,变体 A 和变体 B 仍然相同):
程序 _cyclic
IF DoClearData THEN
DoClearData := FALSE;
重置
ListApplication.Execute := FALSE;
LoadApplication.Execute := FALSE;
brsmemset(ADR(ApplicationList), 0, SIZEOF(ApplicationList));
brsmemset(ADR(VisionApplicationName), 0, SIZEOF(VisionApplicationName));
ELSIF DoGenerateList THEN
IF ListApplication.Execute THEN
(在上一次执行后重置功能块*)。
ListApplication.Execute := FALSE;
ELSE
DoGenerateList := FALSE;
ListApplication.Execute := TRUE;
END_IF
ELSIF DoLoadApplication THEN
IF LoadApplication.Execute THEN
(在上次执行后重置功能块*)。
LoadApplication.Execute := FALSE;
否则
DoLoadApplication := FALSE;
LoadApplication.Execute := TRUE;
END_IF
END_IF
ListApplication();
LoadApplication();
结束程序
程序的基本思想...
•BOOL 变量 DoGenerateList 和 DoLoadApplication 触发 ViBase 功能块实例 ListApplication 和 LoadApplication 的执行。
•下一节将介绍如何使用 OPC UA 值绑定将这些变量与 PushButton widget RefreshList 或 PushButton widget LoadSelectedApplication 进行功能链接。
•与摄像机关联的视觉组件的地址(默认值:gCamera)在 MpLink 输入端设置。
•数组变量 ApplicationList 的起始地址和内存大小通过 ListApplication 的输入 List 和 ListLen 设置。
•该数组的长度决定了可列出的视觉应用程序的最大数量。
•两个变量程序的基本结构在数组的数据类型和 ListApplication 的输入格式上有所不同。
•下一节将介绍如何通过 OPC UA 值绑定将数组变量 ApplicationList 与 A 变体中的表格部件 VAListTableDemo 或 B 变体中的下拉框部件 VAListItemCollectionDemo 相连,以及如何在人机界面应用程序中列出可加载的视觉应用程序。
•字符串变量 VisionApplicationName 的地址设置在 LoadApplication 的输入 Name 上。
•随着本示例人机界面应用程序的进一步实施,VisionApplicationName 的内容将由选定的列表条目填充。
•下一节将介绍如何通过 OPC UA 值绑定将 VisionApplicationName 与文本输出部件 SelectedVAName 相连,并在 HMI 应用程序中显示在 "加载应用程序 "按钮旁边。
•BOOL 变量 DoClearData 触发重置示例人机界面应用程序。
•ViBase 功能块实例 ListApplication 和 LoadApplication 以及字符串变量 VisionApplicationName 和数组变量 ApplicationList 的内存区域都会重置。
•下一节将介绍如何通过 OPC UA 值绑定将 DoClearData 与 PushButton widget ClearData 进行功能链接。
As a back end of the HMI application that calls the mapp Vision function blocks and dynamically designs the HMI application via OPC UA bindings, an ST program named PCUC is added in the Logical View as an example.
In addition to accessing the aforementioned function blocks of mapp Vision core library ViBase, the program described here also requires access to the function blocks of B&R libraries AsBrStr and runtime. If necessary, missing libraries must be added in the Logical View.
The basic framework of the program is described first; it calls the ViBase function blocks and thus provides the basic functionality.
The base program contains the following variables in file Variables.var (one each for variants A and B):
The base program contains the following initialization subroutine in file Init.st (one each for variants A and B):
The base program contains the following cyclic subroutine in file Cyclic.st file (still identical for variants A and B in this expansion stage):
PROGRAM _CYCLIC
IF DoClearData THEN
DoClearData := FALSE;
(*Reset*)
ListApplication.Execute := FALSE;
LoadApplication.Execute := FALSE;
brsmemset(ADR(ApplicationList), 0, SIZEOF(ApplicationList));
brsmemset(ADR(VisionApplicationName), 0, SIZEOF(VisionApplicationName));
ELSIF DoGenerateList THEN
IF ListApplication.Execute THEN
(*Reset Function block after previous execution*)
ListApplication.Execute := FALSE;
ELSE
DoGenerateList := FALSE;
ListApplication.Execute := TRUE;
END_IF
ELSIF DoLoadApplication THEN
IF LoadApplication.Execute THEN
(*Reset Function block after previous execution*)
LoadApplication.Execute := FALSE;
ELSE
DoLoadApplication := FALSE;
LoadApplication.Execute := TRUE;
END_IF
END_IF
ListApplication();
LoadApplication();
END_PROGRAM
Underlying ideas of the program...
•BOOL variables DoGenerateList and DoLoadApplication trigger execution of ViBase function block instances ListApplication and LoadApplication.
•The next section describes how these variables are functionally linked to PushButton widget RefreshList or PushButton widget LoadSelectedApplication using an OPC UA value binding.
•The address of the vision component associated with the camera (default: gCamera) is set on the MpLink inputs.
•The starting address and memory size of array variable ApplicationList is set on inputs List and ListLen of ListApplication.
•The length of this array determines the maximum number of vision applications that can be listed.
•The basic structure of the program differs for the two variants in the data type of the array, as well as in input format of ListApplication.
•The next section describes how array variable ApplicationList is linked to Table widget VAListTableDemo in variant A or to DropDownBox widget VAListItemCollectionDemo in variant B by an OPC UA value binding and how the loadable vision applications are listed in the HMI application.
•The address of string variable VisionApplicationName is set on input Name of LoadApplication.
•The contents of VisionApplicationName will be filled with the selected list entry with the further implementation of this sample HMI application.
•The next section describes how VisionApplicationName is linked to TextOutput widget SelectedVAName by an OPC UA value binding and thus displayed in the HMI application next to button "Load application".
•BOOL variable DoClearData triggers the reset of the sample HMI application.
•Both the ViBase function block instances ListApplication and LoadApplication as well as the memory areas of string variable VisionApplicationName and array variable ApplicationList are reset.
•The next section describes how DoClearData is functionally linked to PushButton widget ClearData by an OPC UA value binding.