How to use an OPC UA Client object

Introduction

An OPC UA Client object can be used to import objects and variables in design time or at runtime from the OPC UA server to create the desired application logics at runtime. To do this, Q Studio at design time and a Q Application at runtime must be able to communicate with the OPC UA server configured in the OPC UA Server object.

If imported at design time, the nodes remain synchronized with the server nodes in reading and writing even at runtime, (if the client has adequate permissions). At any time in design time, using the Q Studio dedicated editor, the nodes of interest to be imported can be selected. During import, for each node desired by the server, a corresponding project node is created.

Important

for nodes imported at design time, including object/variable types, corresponding BaseObject or BaseVariable nodes are created.

To import the nodes at runtime for more advanced uses, it is possible to choose the synchronization mode. In this case the nodes are imported when the OPC UA Client object is initialized, or at the start of the project at runtime.

Create a client

In the Project file, right-click the OPC US folder, then click New > OPC UA Client.

To know the properties of the object, refer to the Reference section of this manual.

Import nodes at design time

  1. Right-click the desired OPC UA client, then click New > OPCUAImporter: an importer is created.

  2. Double-click the importer just created:

    • Q Studio connects to the server.

    • The editor appears with the list of nodes that can be imported.

    • An Objects node is created inside the OPC UA Client object.

  3. In the editor, select the nodes of interest and click Synchronize: the project nodes corresponding to the selected nodes are added inside the just created Objects node.

Synchronize nodes already imported at design time

  1. Double-click the desired importer. In the editor, the status of each server node is indicated with respect to the corresponding project node.

  2. Click Synchronize.

Ignore the nodes imported at design time

  1. Double-click the desired importer.

  2. In the editor, select the nodes to be ignored and click Ignore: the ignored nodes are hidden by the editor.

Display the ignored nodes

  1. Double-click the desired importer.

  2. In the editor’s toolbar, click image1, then select Show ignored elements.

Configure the import of the nodes at runtime

  1. Click the OPC UA client.

  2. In the Property panel, in Runtime configurations click image2: a configuration of nodes to import is added.

  3. In the configuration just created, set the Locale destination node property and Remote source node, then set the import/synchronization mode.

    Note

    for now, the import of graphical objects and LocalizationDictionary objects only functions in Import only mode.

    Note

    the selected source node automatically selects all its child nodes. To import only the child nodes, set Include remote source nodes to False.

  4. To listen to the events generated by the selected nodes, do the following:

    1. Set Enable event synchronization to True.

    2. In Event type click image3 and in the dynamic links window, inside the Types > EventTypes node, select the event type to listen to.

  5. Repeat steps 2 to 4 for each configuration of nodes to be imported.

Set public certificate and private key

See Set up server and client public certificates and private keys.