Using OpcCmd Utility as OPC DA Client

From OPC Labs Knowledge Base
Jump to navigation Jump to search

For general information about the OpcCmd tool, see Category:OpcCmd Utility.


Read item value

OpcCmd> daClient readItem OPCLabs.KitServer.2 Demo.Ramp --value

Reading item value...
Result (value): 6.63516521453857

Browse nodes

OpcCmd> daClient browseNodes OPCLabs.KitServer.2 Simulation --elementNameFilter Incrementing*

Browsing nodes...
Result (sequence): OPC DA node elements: [5] {Incrementing (10 s) -> Simulation.Incrementing (10 s), ...}
│[]│Name                 │Item ID                         │Node Path│Is  │Is  │Is    │Is   │
│  │                     │                                │         │Leaf│Item│Branch│Hint │
│ 0│Incrementing (10 s)  │Simulation.Incrementing (10 s)  │         │True│True│True  │False│
│ 1│Incrementing (1 s)   │Simulation.Incrementing (1 s)   │         │True│True│False │False│
│ 2│Incrementing (1 min) │Simulation.Incrementing (1 min) │         │True│True│True  │False│
│ 3│Incrementing         │Simulation.Incrementing         │         │True│True│True  │False│
│ 4│Incrementing (10 min)│Simulation.Incrementing (10 min)│         │True│True│True  │False│

Subscribe to item

OpcCmd> daClient subscribeItem OPCLabs.KitServer.2 Demo.Ramp 200

Executing for 00:01:00 (press 'X' to stop)...
Subscribing item...
Item handle: 260000001
[0] IEasyDAClient.ItemChanged: [] 3.83842945098877 {Double} @2022-04-21T12:31:16.919; GoodNonspecific (192)
[1] IEasyDAClient.ItemChanged: [] 4.13318157196045 {Double} @2022-04-21T12:31:17.066; GoodNonspecific (192)
[2] IEasyDAClient.ItemChanged: [] 4.44940567016602 {Double} @2022-04-21T12:31:17.224; GoodNonspecific (192)
[3] IEasyDAClient.ItemChanged: [] 4.76562976837158 {Double} @2022-04-21T12:31:17.382; GoodNonspecific (192)
[4] IEasyDAClient.ItemChanged: [] 5.08185386657715 {Double} @2022-04-21T12:31:17.540; GoodNonspecific (192)

Commands, Arguments and Options

Command: daClient subscribeItem

OpcCmd -i
subscribeItem OPCLabs.KitServer.2 Demo.Ramp 200

Tips and Tricks

Using OPC NET API implementation

If you want to use the OPC NET API implementation instead of the native implementation (in OpcCmd for .NET Framework), you can do it interactively as in the following example:

OpcCmd -i
daClient --property InstanceParameters.EnableNativeClient=[Boolean]false
subscribeItem OPCLabs.KitServer.2 Demo.Ramp 200

If you want to use such setting permanently, you can modify one of the OpcCmd Intrinsic Component Configuration files (JSON, INI or XML). For example, with the JSON format, put the following into the appsettings.json or appsettings.production.json file:

  "OpcLabs.EasyOpc.DataAccess.EasyDAClient": {
    "InstanceParameters": {
      "EnableNativeClient": false

Note that in .NET Core and .NET 5.0+, OPC NET API is the only available implementation and is thus selected by default.

OPC DA Optimizer settings

Turn off request chunking: plugins configuration part DAOptimizerPluginParameters set EnableRequestChunking [Boolean]False

Turn off request merging: plugins configuration part DAOptimizerPluginParameters set EnableRequestMerging [Boolean]False

Turn off subscription blending: plugins configuration part DAOptimizerPluginParameters set EnableSubscriptionBlending [Boolean]False

Volume Testing

In order to read or subscribe to the same item many times, use the multiple sub-command with the --repeat option. You will probably need to combine this with turning off the request merging and/or subscription blending, and consider turning off request chunking.

Example 1: readItem "Dynamic/Analog Types/Double" multiple --repeat 2000

Example 2: subscribeItem "Dynamic/Analog Types/Double" multiple --repeat 2000