OPC UA Client - SEB103/QtOpcUaManager GitHub Wiki

English · Deutsch · Français · Italiano · Русский · Українська

OPC UA Client

The client half of the application connects to an OPC UA server, browses its address space, and reads, writes, subscribes to, and plots variable values. Under the hood the UI talks to the OpcUaManager facade, which delegates the network work to the worker-thread OpcUaService (see Architecture).

Connecting to a server

A connection is described by:

  • a discovery/endpoint URL, for example opc.tcp://127.0.0.1:4840;
  • a security policy (for example None or Basic256Sha256 with signing and encryption);
  • an identity: anonymous, or a username and password.

Enter these in the connection form and connect. The client performs discovery and endpoint selection, then opens a session. Certificate-based security uses the application's PKI store (see Configuration). While connecting and after connecting, the state is shown in the status area and logged in the log panel.

The Discovery URL field lists the ten most recently connected servers; you can also type a host, an IP address, or an opc.tcp:// URL.

Finding servers on the network

If you do not know the address of a server, click Scan network… in the connection form. The scanner suggests the IPv4 subnets this PC is connected to, for example 10.10.1.0/24 (Ethernet 3). You can also enter a range such as 10.10.1.1-254, 10.10.1.5-10.10.1.40, or a single address. Only port 4840, the standard OPC UA port, is checked by default; enter further ports as a list or range, for example 4840, 48010-48012.

One scan covers at most 1024 addresses and 16 ports. The scanner first checks which addresses accept a TCP connection and then asks each of them for its OPC UA server description and endpoints. Rows appear while the scan runs: an OPC UA server shows its name, security policies, and supported logins; a port that accepts connections but does not answer as an OPC UA server is shown dimmed.

Double-click a server, or select it and click Use, to copy its address into the Discovery URL field. The client then finds the server and requests its endpoints automatically; choose the authentication and click Connect.

Browsing the address space

Once connected, the server's address space is shown as a tree of nodes, fetched lazily as you expand branches (backed by OpcUaModel). Selecting a node shows its attributes — node id, node class, data type, access level, value, and so on (AttributesModel).

Attribute names and values can be selected with the mouse and copied with Ctrl+C; Ctrl+A selects a whole field.

Variable nodes whose values are structured (for example CODESYS structures that do not publish a full type definition) are decoded by browsing their instance subtree, so you see the individual fields rather than an opaque blob.

Reading, writing, and subscribing

  • Read — request the current value of a variable node.
  • Write — send a new value to a writable variable (subject to its access level).
  • Subscribe — register interest in a variable so the server pushes value changes. Subscribed variables appear in the Data Access view (DataAccessModel), which shows live value, status, and timestamp, and can be sorted and filtered (DataViewFilterModel).

To add a variable to the Data Access view, tick its check box in the address space tree, or drag the node from the address space, or from a segment opened with Open as segment, and drop it onto the DATA VIEW panel. While you drag, a preview with the node's icon and name follows the pointer. On a touch screen, press and hold the node until its row is highlighted, then drag it; a plain swipe keeps scrolling the tree. A node that is already in the view is not added again.

Unticking the check box removes the variable from the view. Removing a row from the view also clears the check box in the tree, so the node can be added again later.

Monitored variables can be persisted so they are restored on the next connection (see Configuration).

Trends

Selected variables can be plotted over time in the trend panel. The trend keeps a bounded history of samples and computes the plot geometry (TrendModel); it can be paused and resumed.

Logging

Client activity — connection state, errors, and notable operations — is written to the log panel and to the application log file. The log file's folder can be opened from the UI, which is the starting point for Troubleshooting.