主要内容

opchda

Create OPC historical data access client

    Description

    An opc.hda.Client object represents an OPC HDA client in MATLAB® that connects to an OPC HDA server.

    Creation

    Description

    hdaObj = opchda(serverInfoObj) constructs an OPC HDA client object, hdaObj, for the information provided in the OPC HDA ServerInfo object, serverInfoObj, obtained from an opchdaserverinfo function call.

    example

    hdaObj = opchda(hostName,serverID) constructs hdaObj for the host specified by hostName and the OPC server ID specified by serverID.

    When you construct hdaObj, its initial Status property value is 'disconnected'. To communicate with the server, connect hdaObj to the server using the connect function.

    example

    hdaObj = opchda(hostName,serverID,Name=Value) applies the specified property values to the client created with the Host and ServerID parameters. If you specify an invalid property name or value, the function does not create an object.

    hdaObj = opchda(serverInfoObj,Name=Value) applies the specified property values to the client created with the ServerInfo object, serverInfoObj. If you specify an invalid property name or value, the function does not create an object.

    Input Arguments

    expand all

    OPC HDA server information, specified as an OPC HDA ServerInfo object. This object is returned from the function opchdaserverinfo.

    Example: SIOjb = opchdaserverinfo

    OPC HDA server host name specified as a character vector or string.

    Example: 'host-name'

    Data Types: char | string

    Identifier of OPC HDA server, specified as a character vector or string.

    Example: 'MyHDAServer.1'

    Data Types: char | string

    Name-Value Arguments

    expand all

    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.

    The argument name identifies a property of the created OPC HDA client object. Note that the name-value pairs can be any format that the set function supports, i.e., name-value pairs, structures, and name-value cell array pairs.

    Example: 'Timeout',60

    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

    expand all

    OPC HDA client, returned as an OPC HDA client object.

    Examples

    collapse all

    Create an OPC HDA client object for a specific client on the local host.

    hdaObj = opchda('localhost','MyHDAServer.1');
    

    Create OPC HDA client objects for all clients on the local host.

    SIObj  = opchdaserverinfo('localhost');
    hdaObj = opchda(SIObj);

    Version History

    Introduced in R2013a

    See Also

    Functions