Using OpcCmd Utility as OPC UA Server
This article describes how to turn the OPC Labs OpcCmd utility into an OPC UA server for experiments, testing and troubleshooting.
For general information about the OpcCmd tool, see Category:OpcCmd Utility.
The OpcCmd Docker image exposes port 48040 (TCP), which is the default port when you use OpcCmd as an OPC UA Server. This makes it easy to map this port to the host when running the tool.
Getting Started
There are multiple ways to invoke and work with the OPC UA Server in OpcCmd. Here is one approach, good for interactive experiments:
- Install OpcCmd utility: OpcCmd Utility Download. Choose the Docker container, or Windows ClickOnce.
- Start OpcCmd utility in interactive mode. The OpcCmd> prompt appears.
- Enter command
uaServer. A new prompt appears, uaServer>. - Optional: Enter additional commands to configure the server.
- Enter command
start. The server will start. - Connect clients to the server and perform your work.
- Press X to stop the server and return to the uaServer> prompt.
Example: The following sequence of commands, entered at the OpcCmd> prompt, starts an OPC UA server with a pre-defined set of users, and 20000 nodes for performance testing.
uaServer
users addFrom PermissionsDemo
mesh addFrom PerformanceNodes 20000
start
Command: uaServer
This command creates an OPC UA server with pre-defined content (data variables with various behavior and data types under the standard Objects folder). By default, it will open its endpoint (when started) on "opc.tcp://localhost:48040/".
If you simply enter the uaServer command (optionally with some arguments, but no sub-commands), the OpcCmd enters an interactive mode for this command, and you can continue by issuing one or more sub-commands, each on a separate line. Alternatively, you can include some sub-command directly following the uaServer command (with its optional arguments), in which case the sub-command will be performed immediately.
CAUTION: Each uaServer command invocation works on a separate, new server component. If you want to perform multiple operations with the same server, issue the uaServer command (and its arguments) just once, entering its interactive mode (manifested by the uaServer> prompt on the console). Then, issue the sub-commands (such as start), leaving out the uaServer command prefix.
Command: start
This command starts the OPC UA server.
While the start command is executing, events related to the edge node operations are displayed on the console.
Command: !wait
By default, the server runs until the you press X on the keyboard. Use the !wait sub-command (on the same command line as the start command) to specify a finite duration.
Command: mesh addFrom
This command adds nodes to the OPC UA server address space mesh. You need to specify the mesh name, and optionally a mesh-specific parameter. Currently, only one mesh is available, named PerformanceNodes. The optional parameter is an integer specifying the count of shared counter nodes (defaults to 10000).
The mesh(es) need to be added before you start the server.
Example:
uaServer
mesh addFrom PerformanceNodes 20000
start
Command: users
This commands allows work with OPC UA server users.
Command: addFrom
This command adds users to the OPC UA server. You need to specify the userset name, and optionally a userset-specific parameter.
Currently, only one userset is available, named PermisssionsDemo. There is no optional parameter for this userset. The userset contains following users: alpha, bravo, configureadmin, engineer, godadmin, observer, operator, securityadmin, supervisor, user1, user2. They all have the same password, "pass".
The userset(s) need to be added before you start the server.
Example:
uaServer
users addFrom PermisssionsDemo
start
Command: nameAndPassword
This command allows work with the OPC UA server users.
Command: get NameAndPassword
This command displays a table with all users that are being authenticated using username and password, together with their security role IDs.
Tips and Tricks
In order to enable the console interaction (so that, for example, the user can accept unknown client certificates interactively), execute the following command before starting the OPC UA server:
uaServer manage plugins setup UAConsoleInteraction set Enabled [Boolean]True
