Skip to content

(Use case) Getting client information from all clients

Stephan Stricker edited this page Dec 19, 2018 · 3 revisions

Requirements

  • Automation Studio 4.4
  • mappView 5.4

Description

This example shows how the client information of all connected clients is bound to an OPC UA structure. This structure can then be used in the PLC code or displayed in mappView.

Implementation

  • Configuration of an OPC UA structure
  • Configuration of a list binding of client information on OPC UA

Configuration of a structure type for the client information

userId, isValid, ipAddress, languageId, screenResolution and slotId: Image

Create an array of variables "ClientInfo" of the created structure type. We assume that the number of maximum possible clients has been set to 3 in the mappView configuration. A length of 3 is therefore required for the ClientInfo array. Note that all roles have permission to write to variable ClientInfo in order to guarantee that the client information from each client can be written to the structure.

Configuration of a list binding of client information on OPC UA

In the following list binding, the client information of all connected clients is bound to a structure variable on the server. By using "slotId" as the selector, each client writes to the array element corresponding to its slot 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>
Clone this wiki locally