5 Connecting to a foreign server¶
This section shows how to add a foreign server, browse a foreign server and how to create local data variables that are mirrored against a foreign server.
5.1 Starting the OPC UA test server
First, we have to start the OPC UA test server, which is necessary to import a data structure. This test server will be added as a foreign server in the next section.
Therefore, go to the atvise entry in the Windows start menu and choose "OPC UA testserver".
Starting the OPC UA test server¶
5.2 Adding a foreign server
Open "Servers -> My Server -> Data Sources"
Right-click on "Data Sources".
Choose "Add Data Source" and then "OpcUa" to open the dialog for adding a data source to the list.
The test server runs on port 4841, so we type in "TestServer" as the server name and "opc.tcp://localhost:4841" as the server URL in the dialog which appears.
Apply the dialog by clicking on the "OK" button to add the data source.
5.3 Browsing a foreign server
Right-click on the new entry in the server list.
Choose "Browse" from the menu which appears to open a browsing window for this server.
Browsing a foreign server¶
Hint
Browsing in the structure of a foreign server is very useful for copying browse paths and node IDs for creating mirrored variables.
5.4 Creating mirrored data variables
Now we want to display the value of a foreign variable in our visualization. It is not possible to access variables on a foreign server directly from the visualization, so we have to create a mirrored local counterpart for them. The atvise builder includes some functions for creating mirrored variables easily.
Open the structure of the "TestServer" and browse into the folder "Objects".
Right-click on "VariableString".
Choose "Copy" from the menu which appears.
Copying a variable from a foreign server¶
Right-click on "Server -> My Server -> OBJECTS".
Choose "Paste & Mirror -> Input -> node" from the menu which appears. Name the variable "VariableString_input".
Right-click again on "Server -> My Server -> OBJECTS" and choose "Paste & Mirror -> Output -> node" from the menu which appears. Name the variable "VariableString_output".
Hint
Now the value of VariableString on the "TestServer" is mirrored to the local "VariableString_input". If you change the value of "VariableString_output", this value is written to "VariableString" on the "TestServer".
Display the value of "VariableString_input" directly in the visualization as described in section 4.3.
Change the value of "VariableString_output". This value is written to "VariableString" on the "TestServer". After the change of "VariableString" on the other server, our local "VariableString_input" is set to this value which will be displayed in the visualization.
Pasting a variable from a foreign server¶