<< 点击显示目录 >> 主页 mappView帮助助手 > mapp View帮助信息 > 工程 > 变量和数据 > Session变量 > 使用案例 > 显示所有客户的客户信息 |
这个例子显示了所有连接的客户端的信息如何被绑定到一个OPC UA结构并在客户端上输出。
•配置一个OPC UA结构
•配置一个OPC UA的客户端信息的列表绑定
•配置一个用于在客户端显示客户端信息的内容
•配置一个用于在客户端显示的列表绑定
配置客户端信息的结构类型
配置客户端信息的结构类型:userId, isValid, ipAddress, languageId, screenResolution 和 slotId。
Creation of an array of variables of the created structure type:
Sharing of variables via OPC UA:
我们假设在 mapp View配置中,可能的客户的最大数量被设置为3 。这就要求数组 ClientInfo的长度为3 。
重要的是要确保所有角色都有对变量 ClientInfo的写入权限 ,以确保客户信息可以被每个客户写入该结构中。
在下面的列表绑定中,所有连接的客户端的信息被绑定到服务器上的一个结构变量。
通过使用slotId作为选择器,每个客户端写到与其槽位ID对应的数组元素。
<Binding mode="oneWayToSource">
<Source xsi:type="listElement">
<Selector xsi:type="session" refId="::SYSTEM:clientInfo.slotId" attribute="value" />
<be:List xsi:type="be:opcUa" attribute="value" >
<bt:Element index="0" refId="::AsGlobalPV:ClientInfo[0].isValid" />
<bt:Element index="1" refId="::AsGlobalPV:ClientInfo[1].isValid" />
<bt:Element index="2" refId="::AsGlobalPV:ClientInfo[2].isValid" />
</be:List>
</Source>
<Target xsi:type="session" refId="::SYSTEM:clientInfo.isValid" attribute="value" />
</Binding>
<Binding mode="oneWayToSource">
<Source xsi:type="listElement">
<Selector xsi:type="session" refId="::SYSTEM:clientInfo.slotId" attribute="value" />
<be:List xsi:type="be:opcUa" attribute="value" >
<bt:Element index="0" refId="::AsGlobalPV:ClientInfo[0].userId" />
<bt:Element index="1" refId="::AsGlobalPV:ClientInfo[1].userId" />
<bt:Element index="2" refId="::AsGlobalPV:ClientInfo[2].userId" />
</be:List>
</Source>
<Target xsi:type="session" refId="::SYSTEM:clientInfo.userId" attribute="value" />
</Binding>
<Binding mode="oneWayToSource">
<Source xsi:type="listElement">
<Selector xsi:type="session" refId="::SYSTEM:clientInfo.slotId" attribute="value" />
<be:List xsi:type="be:opcUa" attribute="value" >
<bt:Element index="0" refId="::AsGlobalPV:ClientInfo[0].ipAddress" />
<bt:Element index="1" refId="::AsGlobalPV:ClientInfo[1].ipAddress" />
<bt:Element index="2" refId="::AsGlobalPV:ClientInfo[2].ipAddress" />
</be:List>
</Source>
<Target xsi:type="session" refId="::SYSTEM:clientInfo.ipAddress" attribute="value" />
</Binding>
<Binding mode="oneWayToSource">
<Source xsi:type="listElement">
<Selector xsi:type="session" refId="::SYSTEM:clientInfo.slotId" attribute="value" />
<be:List xsi:type="be:opcUa" attribute="value" >
<bt:Element index="0" refId="::AsGlobalPV:ClientInfo[0].languageId" />
<bt:Element index="1" refId="::AsGlobalPV:ClientInfo[1].languageId" />
<bt:Element index="2" refId="::AsGlobalPV:ClientInfo[2].languageId" />
</be:List>
</Source>
<Target xsi:type="session" refId="::SYSTEM:clientInfo.languageId" attribute="value" />
</Binding>
<Binding mode="oneWayToSource">
<Source xsi:type="listElement">
<Selector xsi:type="session" refId="::SYSTEM:clientInfo.slotId" attribute="value" />
<be:List xsi:type="be:opcUa" attribute="value" >
<bt:Element index="0" refId="::AsGlobalPV:ClientInfo[0].screenResolution" />
<bt:Element index="1" refId="::AsGlobalPV:ClientInfo[1].screenResolution" />
<bt:Element index="2" refId="::AsGlobalPV:ClientInfo[2].screenResolution" />
</be:List>
</Source>
<Target xsi:type="session" refId="::SYSTEM:clientInfo.screenResolution" attribute="value" />
</Binding>
<Binding mode="oneWayToSource">
<Source xsi:type="listElement">
<Selector xsi:type="session" refId="::SYSTEM:clientInfo.slotId" attribute="value" />
<be:List xsi:type="be:opcUa" attribute="value" >
<bt:Element index="0" refId="::AsGlobalPV:ClientInfo[0].slotId" />
<bt:Element index="1" refId="::AsGlobalPV:ClientInfo[1].slotId" />
<bt:Element index="2" refId="::AsGlobalPV:ClientInfo[2].slotId" />
</be:List>
</Source>
<Target xsi:type="session" refId="::SYSTEM:clientInfo.slotId" attribute="value" />
</Binding>
在下面这段内容中,小部件被配置为输出来自 userId、 isValid、 ipAddress、 languageId、 screenResolution 和 slotId的信息 。
还配置了一个下拉框,它将在下面的列表绑定中作为选择器使用。
<Content id="Content1" width="800" height="800" xmlns="http://www.br-automation.com/iat2015/contentDefinition/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<Widgets>
<Widget xsi:type="widgets.brease.Label" id="Label1" height="30" width="180" left="0" top="10" text="isValid:" zIndex="0" />
<Widget xsi:type="widgets.brease.CheckBox" id="out_isValid" enable="false" height="30" width="30" left="200" top="10" zIndex="1" />
<Widget xsi:type="widgets.brease.Label" id="Label2" height="30" width="180" left="0" top="50" text="slotId:" zIndex="2" />
<Widget xsi:type="widgets.brease.NumericOutput" id="out_slotId" height="30" width="150" left="200" top="50" zIndex="3" />
<Widget xsi:type="widgets.brease.Label" id="Label3" height="30" width="180" left="0" top="90" text="userId:" zIndex="4" />
<Widget xsi:type="widgets.brease.TextOutput" id="out_userId" height="30" width="150" left="200" top="90" zIndex="5" />
<Widget xsi:type="widgets.brease.Label" id="Label4" height="30" width="180" left="0" top="130" text="ipAddress:" zIndex="6" />
<Widget xsi:type="widgets.brease.TextOutput" id="out_ipAddress" height="30" width="150" left="200" top="130" zIndex="7" />
<Widget xsi:type="widgets.brease.Label" id="Label5" height="30" width="180" left="0" top="170" text="languageId:" zIndex="8" />
<Widget xsi:type="widgets.brease.TextOutput" id="out_languageId" height="30" width="150" left="200" top="170" zIndex="9" />
<Widget xsi:type="widgets.brease.Label" id="Label6" height="30" width="180" left="0" top="210" text="screenResolution:" zIndex="10" />
<Widget xsi:type="widgets.brease.TextOutput" id="out_screenResolution" height="30" width="150" left="200" top="210" zIndex="11" />
<Widget xsi:type="widgets.brease.Label" id="Label7" height="30" width="180" left="0" top="340" text="select slotId:" zIndex="12" />
<Widget xsi:type="widgets.brease.DropDownBox" id="slotSelector" height="30" width="150" left="200" top="340" zIndex="13"
dataProvider="[{’value’:0,’text’:’0’},{’value’:1,’text’:’1’},{’value’:2,’text’:’2’}]" />
<Widget xsi:type="widgets.brease.Label" id="Label8" height="30" width="180" left="0" top="390" text="select language:" zIndex="14" />
<Widget xsi:type="widgets.brease.LanguageSelector" id="LanguageSelector1" height="30" width="150" left="200" top="390" zIndex="15" />
</Widgets>
</Content>
在下面的列表绑定中,被写入OPC UA变量的信息被绑定到配置的输出元素。
使用 下拉框的selectedIndex 作为选择器,可以选择在客户端查看哪个槽。
<Binding mode="oneWay">
<Source xsi:type="listElement">
<Selector xsi:type="brease" contentRefId="Content1" widgetRefId="slotSelector" attribute="selectedIndex" />
<be:List xsi:type="be:opcUa" attribute="value" >
<bt:Element index="0" refId="::AsGlobalPV:ClientInfo[0].isValid" />
<bt:Element index="1" refId="::AsGlobalPV:ClientInfo[1].isValid" />
<bt:Element index="2" refId="::AsGlobalPV:ClientInfo[2].isValid" />
</be:List>
</Source>
<Target xsi:type="brease" contentRefId="Content1" widgetRefId="out_isValid" attribute="value"/>
</Binding>
<Binding mode="oneWay">
<Source xsi:type="listElement">
<Selector xsi:type="brease" contentRefId="Content1" widgetRefId="slotSelector" attribute="selectedIndex" />
<be:List xsi:type="be:opcUa" attribute="value" >
<bt:Element index="0" refId="::AsGlobalPV:ClientInfo[0].slotId" />
<bt:Element index="1" refId="::AsGlobalPV:ClientInfo[1].slotId" />
<bt:Element index="2" refId="::AsGlobalPV:ClientInfo[2].slotId" />
</be:List>
</Source>
<Target xsi:type="brease" contentRefId="Content1" widgetRefId="out_slotId" attribute="value"/>
</Binding>
<Binding mode="oneWay">
<Source xsi:type="listElement">
<Selector xsi:type="brease" contentRefId="Content1" widgetRefId="slotSelector" attribute="selectedIndex" />
<be:List xsi:type="be:opcUa" attribute="value" >
<bt:Element index="0" refId="::AsGlobalPV:ClientInfo[0].userId" />
<bt:Element index="1" refId="::AsGlobalPV:ClientInfo[1].userId" />
<bt:Element index="2" refId="::AsGlobalPV:ClientInfo[2].userId" />
</be:List>
</Source>
<Target xsi:type="brease" contentRefId="Content1" widgetRefId="out_userId" attribute="value"/>
</Binding>
<Binding mode="oneWay">
<Source xsi:type="listElement">
<Selector xsi:type="brease" contentRefId="Content1" widgetRefId="slotSelector" attribute="selectedIndex" />
<be:List xsi:type="be:opcUa" attribute="value" >
<bt:Element index="0" refId="::AsGlobalPV:ClientInfo[0].ipAddress" />
<bt:Element index="1" refId="::AsGlobalPV:ClientInfo[1].ipAddress" />
<bt:Element index="2" refId="::AsGlobalPV:ClientInfo[2].ipAddress" />
</be:List>
</Source>
<Target xsi:type="brease" contentRefId="Content1" widgetRefId="out_ipAddress" attribute="value"/>
</Binding>
<Binding mode="oneWay">
<Source xsi:type="listElement">
<Selector xsi:type="brease" contentRefId="Content1" widgetRefId="slotSelector" attribute="selectedIndex" />
<be:List xsi:type="be:opcUa" attribute="value" >
<bt:Element index="0" refId="::AsGlobalPV:ClientInfo[0].languageId" />
<bt:Element index="1" refId="::AsGlobalPV:ClientInfo[1].languageId" />
<bt:Element index="2" refId="::AsGlobalPV:ClientInfo[2].languageId" />
</be:List>
</Source>
<Target xsi:type="brease" contentRefId="Content1" widgetRefId="out_languageId" attribute="value"/>
</Binding>
<Binding mode="oneWay">
<Source xsi:type="listElement">
<Selector xsi:type="brease" contentRefId="Content1" widgetRefId="slotSelector" attribute="selectedIndex" />
<be:List xsi:type="be:opcUa" attribute="value" >
<bt:Element index="0" refId="::AsGlobalPV:ClientInfo[0].screenResolution" />
<bt:Element index="1" refId="::AsGlobalPV:ClientInfo[1].screenResolution" />
<bt:Element index="2" refId="::AsGlobalPV:ClientInfo[2].screenResolution" />
</be:List>
</Source>
<Target xsi:type="brease" contentRefId="Content1" widgetRefId="out_screenResolution" attribute="value"/>
</Binding>