Using OpcCmd Utility for Static OPC UA Operations: Difference between revisions

From OPC Labs Knowledge Base
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:OPC UA]] [[Category:OpcCmd Utility]] [[Category:Tools and Online Services]]
= Introduction =
{{Note|OpcCmd allows to enter the commands and options using "long" and "short" forms. For example, "nodeId" is a long form of the command, and it can be shortened to "ni". In the examples below, we use both forms interchangeably.}}
= Command, Arguments and Options =
= Command, Arguments and Options =
== Command: ua nodeId ==
== Command: ua nodeId ==
=== Get standard name that corresponds to OPC UA Node ID ===
Example: Figure out standard name of a node ID in namespace 0 (reserved by OPC Foundation):
Example: Figure out standard name of a node ID in namespace 0 (reserved by OPC Foundation):
<pre>ua nodeId i=2253</pre>
<pre>ua nodeId i=2253</pre>
Line 6: Line 10:
<pre>Standard name: Server
<pre>Standard name: Server
Expanded text: nsu=http://opcfoundation.org/UA/ ;i=2253</pre>
Expanded text: nsu=http://opcfoundation.org/UA/ ;i=2253</pre>
=== Get the OPC UA Node ID that corresponds to a  given standard name ===
Example: Find out a full node ID from its standard name (for nodes defined by OPC Foundation):
Example: Find out a full node ID from its standard name (for nodes defined by OPC Foundation):
<pre>ua ni -sn=Server_NamespaceArray</pre>
<pre>ua ni -sn=Server_NamespaceArray</pre>
Line 11: Line 16:
<pre>Standard name: Server_NamespaceArray
<pre>Standard name: Server_NamespaceArray
Expanded text: nsu=http://opcfoundation.org/UA/ ;i=2255</pre>
Expanded text: nsu=http://opcfoundation.org/UA/ ;i=2255</pre>
=== Display tables of node IDs and their standard names ===
Example: Display a table of all node IDs defined by OPC Foundation, sorted by their identifier.
Example: Display a table of all node IDs defined by OPC Foundation, sorted by their identifier.
<pre>ua nodeId listNames?</pre>
<pre>ua nodeId listNames?</pre>
Line 25: Line 31:
...</pre>
...</pre>
The output sequence is truncated by default; in order to obtain the full table, use:
The output sequence is truncated by default; in order to obtain the full table, use:
<pre>ua nodeId listNames? -!vs=:N99999</pre>
<pre>ua nodeId listNames? -!vs=::N99999</pre>
Example: Display a table of all node IDs defined by OPC Foundation, sorted by their class and standard name (alphabetically):
<pre>ua nodeId listValues?</pre>
Output:
<pre>
Result (sequence):
╒══════════════════════════════════════════════╤═════════════════════════════════════════╕
│[]                                            │Value                                    │
╞══════════════════════════════════════════════╪═════════════════════════════════════════╡
│DataTypes.AccessLevelExType                  │nsu=http://opcfoundation.org/UA/ ;i=15406│
│DataTypes.AccessLevelType                    │nsu=http://opcfoundation.org/UA/ ;i=15031│
│DataTypes.AccessRestrictionType              │nsu=http://opcfoundation.org/UA/ ;i=95  │
│DataTypes.ActivateSessionRequest              │nsu=http://opcfoundation.org/UA/ ;i=465  │
│DataTypes.ActivateSessionResponse            │nsu=http://opcfoundation.org/UA/ ;i=468  │
...</pre>
The output sequence is truncated by default; in order to obtain the full table, use:
<pre>ua nodeId listValues? -!vs=::N99999</pre>
 
=== Filter the tables to find out matching names ===
If you are unsure about the standard name of the node you are looking for, but you know at least part of the name, you can display the table of names or table values, and filter the results so that only nodes whose names contain a specified string are listed.
 
For example, to list all standard nodes (sorted by their identifier) whose name contain the string "redundan" (case-insensitive, in default state), use the following command:
<pre>ua nodeId listNames? -c redundan</pre>
To list all standard nodes (sorted by their name) whose name contain the string "SubscriptionCount", use the following command:
<pre>ua nodeId listValues? --contains SubscriptionCount</pre>
 
== Command: ua qualifiedName ==
Similarly to the nodeId command, you can use this command e.g. to obtain tables of qualified names defined by the OPC Foundation.
 
Example:
<pre>ua qn ln?</pre>
which is an abbreviated form of:
<pre>ua qualifiedName listNames?</pre>
== Command: ua statusCode ==
The statusCode command decodes and encodes OPC UA status codes.
 
Example (using hexadecimal value):
<pre>ua statusCode 0x80010000</pre>
or (using decimal value)
<pre>ua statusCode 2147549184</pre>
Output:
<pre>Status code: BadUnexpectedError
Internal value: 2147549184 (0x80010000)</pre>
Example: Encode the status code, given its code bits symbolically:
<pre>ua statusCode -cbs BadNodeIdUnknown</pre>
Output:
<pre>Status code: BadNodeIdUnknown
Internal value: 2150891520 (0x80340000)</pre>

Latest revision as of 19:10, 10 March 2021

Introduction

Note2-icon.png

Note: OpcCmd allows to enter the commands and options using "long" and "short" forms. For example, "nodeId" is a long form of the command, and it can be shortened to "ni". In the examples below, we use both forms interchangeably.

Command, Arguments and Options

Command: ua nodeId

Get standard name that corresponds to OPC UA Node ID

Example: Figure out standard name of a node ID in namespace 0 (reserved by OPC Foundation):

ua nodeId i=2253

Output:

Standard name: Server
Expanded text: nsu=http://opcfoundation.org/UA/ ;i=2253

Get the OPC UA Node ID that corresponds to a given standard name

Example: Find out a full node ID from its standard name (for nodes defined by OPC Foundation):

ua ni -sn=Server_NamespaceArray

Output:

Standard name: Server_NamespaceArray
Expanded text: nsu=http://opcfoundation.org/UA/ ;i=2255

Display tables of node IDs and their standard names

Example: Display a table of all node IDs defined by OPC Foundation, sorted by their identifier.

ua nodeId listNames?

Output:

Result (sequence):
╒═══════════════════════════════════════╤══════════════════════════════════════════╕
│[]                                     │Value                                     │
╞═══════════════════════════════════════╪══════════════════════════════════════════╡
│nsu=http://opcfoundation.org/UA/ ;i=1  │Boolean                                   │
│nsu=http://opcfoundation.org/UA/ ;i=2  │SByte                                     │
│nsu=http://opcfoundation.org/UA/ ;i=3  │Byte                                      │
│nsu=http://opcfoundation.org/UA/ ;i=4  │Int16                                     │
│nsu=http://opcfoundation.org/UA/ ;i=5  │UInt16                                    │
...

The output sequence is truncated by default; in order to obtain the full table, use:

ua nodeId listNames? -!vs=::N99999

Example: Display a table of all node IDs defined by OPC Foundation, sorted by their class and standard name (alphabetically):

ua nodeId listValues?

Output:

Result (sequence):
╒══════════════════════════════════════════════╤═════════════════════════════════════════╕
│[]                                            │Value                                    │
╞══════════════════════════════════════════════╪═════════════════════════════════════════╡
│DataTypes.AccessLevelExType                   │nsu=http://opcfoundation.org/UA/ ;i=15406│
│DataTypes.AccessLevelType                     │nsu=http://opcfoundation.org/UA/ ;i=15031│
│DataTypes.AccessRestrictionType               │nsu=http://opcfoundation.org/UA/ ;i=95   │
│DataTypes.ActivateSessionRequest              │nsu=http://opcfoundation.org/UA/ ;i=465  │
│DataTypes.ActivateSessionResponse             │nsu=http://opcfoundation.org/UA/ ;i=468  │
...

The output sequence is truncated by default; in order to obtain the full table, use:

ua nodeId listValues? -!vs=::N99999

Filter the tables to find out matching names

If you are unsure about the standard name of the node you are looking for, but you know at least part of the name, you can display the table of names or table values, and filter the results so that only nodes whose names contain a specified string are listed.

For example, to list all standard nodes (sorted by their identifier) whose name contain the string "redundan" (case-insensitive, in default state), use the following command:

ua nodeId listNames? -c redundan

To list all standard nodes (sorted by their name) whose name contain the string "SubscriptionCount", use the following command:

ua nodeId listValues? --contains SubscriptionCount

Command: ua qualifiedName

Similarly to the nodeId command, you can use this command e.g. to obtain tables of qualified names defined by the OPC Foundation.

Example:

ua qn ln?

which is an abbreviated form of:

ua qualifiedName listNames?

Command: ua statusCode

The statusCode command decodes and encodes OPC UA status codes.

Example (using hexadecimal value):

ua statusCode 0x80010000

or (using decimal value)

ua statusCode 2147549184

Output:

Status code: BadUnexpectedError
Internal value: 2147549184 (0x80010000)

Example: Encode the status code, given its code bits symbolically:

ua statusCode -cbs BadNodeIdUnknown

Output:

Status code: BadNodeIdUnknown
Internal value: 2150891520 (0x80340000)