Main Content

opcua

Create OPC UA client object

Description

example

UaClient = opcua(ServerInfoObj) creates an OPC UA client associated with the server specified by ServerInfoObj. You can create server objects with the opcuaserverinfo function.

UaClient = opcua(ServerUrl) creates a client associated with the server referenced by the URL specified in ServerUrl.

UaClient = opcua(Hostname,Portnum) creates an OPC UA client object associated with the server at port Portnum on the host identified by Hostname.

By default, the client attempts to retrieve available connection configurations (called Endpoints) from the server and chooses the most secure possible security settings from those configurations. If the attempt to retrieve endpoints fails, an error is generated. You can override the default settings by using setSecurityModel to change the MessageSecurityMode or ChannelSecurityPolicy settings.

Examples

collapse all

Create a client for the first server found on the local host.

S = opcuaserverinfo('localhost');
UaClient = opcua(S(1));

Create a client for the server at port 53530 on the local host.

UaClient = opcua('localhost',53530)
UaClient = 

OPC UA Client:

   Server Information:
                     Name: 'SimulationServer@localhost'
                 Hostname: 'localhost'
                     Port: 53530
              EndpointUrl: 'opc.tcp://localhost:53530/OPCUA/SimulationServer'

   Connection Information:
                  Timeout: 10
                   Status: 'Disconnected'
              ServerState: '<Not connected>'

   Security Information:
      MessageSecurityMode: SignAndEncrypt
    ChannelSecurityPolicy: Aes256_Sha256_RsaPss
                Endpoints: [1×11 opc.ua.EndpointDescription]

Create a client using the Discovery URL of the server.

UaClient = opcua('opc.tcp://localhost:53530/OPCUA/SimulationServer');

Input Arguments

collapse all

OPC UA server, specified as an OPC UA server object.

Data Types: object

OPC UA server URL, specified as a character vector or string. The server URL must use the opc.tcp protocol; Industrial Communication Toolbox™ does not support http or https connections to an OPC UA server.

Data Types: char | string

Server host name or IP address, specified as a character vector or string. A host name can be short or a fully qualified domain name.

Example: 'localhost'

Data Types: char | string

Server host port number, specified as a numeric value.

Example: 5000

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

OPC UA client, returned as an opc.ua.Client object, with the following properties.

PropertyDescription
Server Information
NameServer description.
HostnameServer host name or IP address.
PortPort number used for TCP/IP connections to the server.
EndpointUrlURL to use for connection to the server.
Connection Information
TimeoutTime to wait for all operations on the server to complete.
StatusStatus of the client: 'Connected' or 'Disconnected'.
ServerStateState of the server: 'Running', 'Failed', 'No Configuration','Suspended', 'Shutdown', 'Test', 'Comms Fault', 'Unknown'.
Security Information
MessageSecurityModeMessage security mode specified for connection.
ChannelSecurityPolicyChannel security policy specified for connection.
EndpointsAvailable endpoints for server.
Server Limits (The following properties are available only after the client is connected to the server)
MinSampleRateMinimum sample rate in seconds that the server can generally support.
MaxReadNodesMaximum number of nodes supported per read operation.
MaxWriteNodesMaximum number of nodes supported per write operation.
MaxHistoryValuesPerNodeMaximum number of nodes supported by historical read operations.
MaxHistoryValuesPerNodeMaximum history values returned per node in historical read operations.

Version History

Introduced in R2015b