Main Content

opcda

(To be removed) Create OPC data access object

Support for the OPC Data Access (DA) standard will be removed in a future release. Instead use OPC Unified Architecture (UA). See Version History.

Description

DAobj = opcda(HostID,ServerID) creates an OPC data access object, DAobj, for the host specified by Host and the OPC server ID specified by ServerID. When you create DAobj, its initial Status property value is 'disconnected'. To communicate with the server, you must connect DAobj to the server with the connect function.

DAobj = opcda(HostID,ServerID,Name,Value) creates an OPC DA object, DAobj, for the host specified by Host and the OPC server ID specified by ServerID, applying the specified property values. If you specify an invalid property name or value, the function does not create an object.

For a complete listing of OPC functions and properties, type opchelp.

example

Examples

collapse all

These examples show how to create OPC DA clients for local and remote servers.

Create an OPC DA client for a local server.

daObj1 = opcda('localhost','Dummy.Server.ID');

Create an OPC DA client for a remote server.

daObj2 = opcda('ServerHost1','OPCServer.ID');

Input Arguments

collapse all

OPC server host name or IP address, specified as a character vector or string.

Example: 'localhost'

Data Types: char | string

OPC server ID, specified as a character vector or string.

Example: 'OPCsrvhost'

Data Types: char | string

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'Timeout',60

The property name-value pairs can be any format of name-value pairs, structures, and name-value cell array pairs. You can specify the writeable properties described in Output Arguments, including the following.

Maximum time to wait for completion of instruction to server, specified in seconds.

Example: 60

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

Data to associate with object, specified as any MATLAB data type. UserData stores any data that you want to associate with the object. The object does not use this data directly, but you can use the data for identification or other purposes.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | struct | string | cell

Output Arguments

collapse all

OPC DA client, returned as an opcda object, with the properties described in opcda Properties.

For information on any of these properties, type opchelp opcda.PropName, for example:

opchelp opcda.TimerPeriod

Version History

Introduced before R2006a

expand all

See Also

Functions

Properties