定义值绑定

<< 点击显示目录 >>

主页  mappVision帮助助手 > 机器视觉帮助 > mapp Vision  > 编程 > > 核心库 > ViBase  > 用例 > 产品转换用例 > 动态设计人机界面应用程序 >

定义值绑定

首先在配置视图的 "mapp View "包中添加一个绑定文件,文件名为 cPCUC.binding,id="cPCUC_binding"。

相关部件的 widgetRefIds 为

SelectedVAName、RefreshList、CompatibleVANumber、StateMachineTitle、GroupLoadVa、ClearData LoadSelectedApplication,以及

对于带有 Widget Table 的变体 A:VAStringList、VAListTableDemo、

对于带有部件 DropDownBox 的变体 B:VAListItemCollectionDemo、

现在,编辑器中为 cPCUC.content 各设置了一个 OPC UA 值绑定:

1.在编辑器中选择部件。

2.在应创建绑定的属性(如)属性窗口中,双击绑定行打开选择变量对话框。

3.根据程序和 widget 之间所需的数据流方向(只读、读/写、初始读/写)确定绑定类型。

4.为相应的 OPC UA 变量选择子节点

5.用 "确定"关闭对话框。

upcuabinding

图创建 OPC UA 值绑定,例如可视化 TextOutput StateMachineTitle 与 OPC UA 字符串变量 InfoText 的相应只读值绑定

保存cPCUC.content 中的更改后,将在文件 cPCUC.binding 中创建一个 XML 节点,代表已创建的绑定。

例如,OPC UA 字符串变量 InfoText 和文本输出部件 StateMachineTitle 之间的只读值绑定:

<?xml version="1.0" encoding="utf-8"?
<BindingsSet id="cPCUC_binding"
xmlns="http://www.br-automation.com/iat2015/binding/engineering/v2"
xmlns:bt="http://www.br-automation.com/iat2015/bindingListTypes/engineering/v2"
xmlns:be="http://www.br-automation.com/iat2015/bindingListEmbedded/engineering/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
< 绑定
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::PCUC:InfoText" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="StateMachineTitle" attribute="value" /> </p
</Binding> </p
</Bindings>
</绑定集

一般来说,会创建以下 XML 节点:

<Binding mode="oneWay"> 用于 "只读 "绑定

<Binding mode="twoWay"> 用于 "读/写 "绑定

<Binding mode="oneWayToSource"> 用于 "初始读/写 "绑定

mapp Vision 帮助文档的这一部分无法描述如何创建所有必要的绑定值。这里记录了两个变体的 cPCUC.binding 文件的 XML 内容。

引用 contentRefId、refId 和 widgetRefId 与前几节一致。任何更改都必须进行相应调整。

<?xml version="1.0" encoding="utf-8"?
<BindingsSet id="cPCUC_binding"
xmlns="http://www.br-automation.com/iat2015/binding/engineering/v2"
xmlns:bt="http://www.br-automation.com/iat2015/bindingListTypes/engineering/v2"
xmlns:be="http://www.br-automation.com/iat2015/bindingListEmbedded/engineering/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
< 绑定
 
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::PCUC:VisionApplicationName" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="SelectedVAName" attribute="value" /> </p
</Binding> </p
 
<Binding mode="twoWay">
<Source xsi:type="opcUa" refId="::PCUC:DoGenerateList" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="RefreshList" attribute="value" /> </p
</绑定
 
 
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::PCUC:ListApplication.NrEntries" attribute="value" /> </p
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="CompatibleVANumber" attribute="value" /> </p
</Binding> <Binding mode="oneW
 
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::PCUC:InfoText" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="StateMachineTitle" attribute="value" /> </p
</Binding> </p
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::PCUC:IsIdle" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="GroupLoadVa" attribute="enable" /> </p
</Binding> </p
 
<Binding mode="twoWay">
<Source xsi:type="opcUa" refId="::PCUC:DoClearData" attribute="value" /> </p
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="ClearData" attribute="value" /> </p
</绑定
 
<Binding mode="twoWay"> <Binding mode="twoWay">
<Source xsi:type="opcUa" refId="::PCUC:DoLoadApplication" attribute="value" /> </p
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="LoadSelectedApplication" attribute="value" /> </p
</Binding> <Binding mode="oneW
 
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::PCUC:IsAnApplicationSelected" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="LoadSelectedApplication" attribute="enable" /> </p
</Binding> <Binding mode="oneW
 
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::PCUC:ApplicationList" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="VAStringList" attribute="stringValue" /> </p
</Binding> </p
 
<Binding mode="twoWay">
<Source xsi:type="opcUa" refId="::PCUC:ApplicationListIndex" attribute="value" /> </p
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="VAListTableDemo" attribute="selectedRow" /> </p
</Binding> </p
</Binding> </BindingSet> </BindingSet> </BindingSet>
 
</BindingsSet>

带有小部件表格的变量 A

<?xml version="1.0" encoding="utf-8"?
<BindingsSet id="cPCUC_binding"
xmlns="http://www.br-automation.com/iat2015/binding/engineering/v2"
xmlns:bt="http://www.br-automation.com/iat2015/bindingListTypes/engineering/v2"
xmlns:be="http://www.br-automation.com/iat2015/bindingListEmbedded/engineering/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
< 绑定
 
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::PCUC:VisionApplicationName" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="SelectedVAName" attribute="value" /> </p
</Binding> </p
 
<Binding mode="twoWay">
<Source xsi:type="opcUa" refId="::PCUC:DoGenerateList" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="RefreshList" attribute="value" /> </p
</绑定
 
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::PCUC:ListApplication.NrEntries" attribute="value" /> </p
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="CompatibleVANumber" attribute="value" /> </p
</Binding> <Binding mode="oneW
 
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::PCUC:InfoText" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="StateMachineTitle" attribute="value" /> </p
</Binding> </p
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::PCUC:IsIdle" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="GroupLoadVa" attribute="enable" /> </p
</Binding> </p
 
<Binding mode="twoWay">
<Source xsi:type="opcUa" refId="::PCUC:DoClearData" attribute="value" /> </p
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="ClearData" attribute="value" /> </p
</绑定
 
<Binding mode="twoWay"> <Binding mode="twoWay">
<Source xsi:type="opcUa" refId="::PCUC:DoLoadApplication" attribute="value" /> </p
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="LoadSelectedApplication" attribute="value" /> </p
</Binding> <Binding mode="oneW
 
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::PCUC:IsAnApplicationSelected" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="LoadSelectedApplication" attribute="enable" /> </p
</Binding> <Binding mode="oneW
 
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::PCUC:ApplicationList" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="VAListItemCollectionDemo" attribute="dataProvider" /> </p
</Binding>
<Binding mode="oneWayToSource">
<Source xsi:type="opcUa" refId="::PCUC:ApplicationListIndex" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="VAListItemCollectionDemo" attribute="selectedIndex" /> </Binding> <Source xsi:type="opcUa" refId="::PCUC:ApplicationListIndex" attribute="value" /> <Source xsi:type="opcUa" refId="::PCUC:ApplicationListIndex" attribute="value
<Binding mode="oneWayToSource">
<Source xsi:type="opcUa" refId="::PCUC:VisionApplicationName" attribute="value" />
<Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="VAListItemCollectionDemo" attribute="selectedValue" /> </p
</Binding> </p
</Binding> </BindingSet> </BindingSet> </BindingSet>
 
</绑定集

带有小部件 DropDownBox 的变体 B


A binding file with filename cPCUC.binding and id="cPCUC_binding" is first added to package "mapp View" in the Configuration View.

For the relevant widgets with the widgetRefIds

SelectedVAName, RefreshList, CompatibleVANumber, StateMachineTitle, GroupLoadVa, ClearData LoadSelectedApplication, as well as

For variant A with widget Table: VAStringList,VAListTableDemo,

For variant B with widget DropDownBox: VAListItemCollectionDemo,

Now one OPC UA value binding each is set in the editor for cPCUC.content:

1.Select the widget in the editor.

2.In the properties window for the attribute for which the binding should be created (e.g. value), double-click on the Binding line to open the Select variable dialog box.

3.Determine the type of binding depending on the required data flow direction between the program and widget (Read only, Read/Write, Init read/write).

4.Select subnode value for the appropriate OPC UA variable.

5.Close the dialog box with OK.

upcuabinding

Fig.: Creating an OPC UA value binding,´for example visualized on TextOutput StateMachineTitle with the corresponding read-only value binding to the OPC UA string variable InfoText

After saving the changes in cPCUC.content, an XML node is created in file cPCUC.binding representing the created binding.

For example, for the read-only value binding between OPC UA string variable InfoText and TextOutput widget StateMachineTitle:

<?xml version="1.0" encoding="utf-8"?>
<BindingsSet id="cPCUC_binding"
   xmlns="http://www.br-automation.com/iat2015/binding/engineering/v2"
   xmlns:bt="http://www.br-automation.com/iat2015/bindingListTypes/engineering/v2"
   xmlns:be="http://www.br-automation.com/iat2015/bindingListEmbedded/engineering/v2"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <Bindings>
  <Binding mode="oneWay">
   <Source xsi:type="opcUa" refId="::PCUC:InfoText" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="StateMachineTitle" attribute="value" />
  </Binding>
 </Bindings>
</BindingsSet>

In general, the following XML nodes are created:

<Binding mode="oneWay"> for a "Read only" binding

<Binding mode="twoWay"> for a "Read/Write" binding

<Binding mode="oneWayToSource"> for an "Init read/write" binding

It is beyond the scope of this section of the mapp Vision help documentation to describe how to create all of the required values binding. The resulting XML contents of file cPCUC.binding for the two variants are recorded here.

References contentRefId, refId and widgetRefId are consistent with the previous sections. Any changes must be adjusted accordingly.

<?xml version="1.0" encoding="utf-8"?>
<BindingsSet id="cPCUC_binding"
 xmlns="http://www.br-automation.com/iat2015/binding/engineering/v2"
xmlns:bt="http://www.br-automation.com/iat2015/bindingListTypes/engineering/v2"
xmlns:be="http://www.br-automation.com/iat2015/bindingListEmbedded/engineering/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <Bindings>
  
  <Binding mode="oneWay">
   <Source xsi:type="opcUa" refId="::PCUC:VisionApplicationName" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="SelectedVAName" attribute="value" />
  </Binding>
 
  <Binding mode="twoWay">
   <Source xsi:type="opcUa" refId="::PCUC:DoGenerateList" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="RefreshList" attribute="value" />
  </Binding>
  
  
  <Binding mode="oneWay">
   <Source xsi:type="opcUa" refId="::PCUC:ListApplication.NrEntries" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="CompatibleVANumber" attribute="value" />
  </Binding>
  
  <Binding mode="oneWay">
   <Source xsi:type="opcUa" refId="::PCUC:InfoText" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="StateMachineTitle" attribute="value" />
  </Binding>
  <Binding mode="oneWay">
   <Source xsi:type="opcUa" refId="::PCUC:IsIdle" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="GroupLoadVa" attribute="enable" />
  </Binding>
  
  <Binding mode="twoWay">
   <Source xsi:type="opcUa" refId="::PCUC:DoClearData" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="ClearData" attribute="value" />
  </Binding>
   
  <Binding mode="twoWay">
   <Source xsi:type="opcUa" refId="::PCUC:DoLoadApplication" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="LoadSelectedApplication" attribute="value" />
  </Binding>
  
  <Binding mode="oneWay">
   <Source xsi:type="opcUa" refId="::PCUC:IsAnApplicationSelected" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="LoadSelectedApplication" attribute="enable" />
  </Binding>
  
  <Binding mode="oneWay">
   <Source xsi:type="opcUa" refId="::PCUC:ApplicationList" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="VAStringList" attribute="stringValue" />
  </Binding>
  
  <Binding mode="twoWay">
   <Source xsi:type="opcUa" refId="::PCUC:ApplicationListIndex" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="VAListTableDemo" attribute="selectedRow" />
  </Binding>
 </Bindings>
 
</BindingsSet>

Variant A with widget Table

<?xml version="1.0" encoding="utf-8"?>
<BindingsSet id="cPCUC_binding"
xmlns="http://www.br-automation.com/iat2015/binding/engineering/v2"
xmlns:bt="http://www.br-automation.com/iat2015/bindingListTypes/engineering/v2"
xmlns:be="http://www.br-automation.com/iat2015/bindingListEmbedded/engineering/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <Bindings>
  
  <Binding mode="oneWay">
   <Source xsi:type="opcUa" refId="::PCUC:VisionApplicationName" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="SelectedVAName" attribute="value" />
  </Binding>
 
  <Binding mode="twoWay">
   <Source xsi:type="opcUa" refId="::PCUC:DoGenerateList" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="RefreshList" attribute="value" />
  </Binding>
  
  <Binding mode="oneWay">
   <Source xsi:type="opcUa" refId="::PCUC:ListApplication.NrEntries" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="CompatibleVANumber" attribute="value" />
  </Binding>
  
  <Binding mode="oneWay">
   <Source xsi:type="opcUa" refId="::PCUC:InfoText" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="StateMachineTitle" attribute="value" />
  </Binding>
  <Binding mode="oneWay">
   <Source xsi:type="opcUa" refId="::PCUC:IsIdle" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="GroupLoadVa" attribute="enable" />
  </Binding>
  
  <Binding mode="twoWay">
   <Source xsi:type="opcUa" refId="::PCUC:DoClearData" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="ClearData" attribute="value" />
  </Binding>
   
  <Binding mode="twoWay">
   <Source xsi:type="opcUa" refId="::PCUC:DoLoadApplication" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="LoadSelectedApplication" attribute="value" />
  </Binding>
  
  <Binding mode="oneWay">
   <Source xsi:type="opcUa" refId="::PCUC:IsAnApplicationSelected" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="LoadSelectedApplication" attribute="enable" />
  </Binding>
  
  <Binding mode="oneWay">
   <Source xsi:type="opcUa"  refId="::PCUC:ApplicationList" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="VAListItemCollectionDemo" attribute="dataProvider" />
  </Binding>
  <Binding mode="oneWayToSource">
   <Source xsi:type="opcUa"  refId="::PCUC:ApplicationListIndex" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="VAListItemCollectionDemo" attribute="selectedIndex" /> </Binding>
  <Binding mode="oneWayToSource">
   <Source xsi:type="opcUa"  refId="::PCUC:VisionApplicationName" attribute="value" />
   <Target xsi:type="brease" contentRefId="cPCUC" widgetRefId="VAListItemCollectionDemo" attribute="selectedValue" />
  </Binding>
 </Bindings>
 
</BindingsSet>

Variant B with widget DropDownBox