Main Content

readItemAttributes

Read item attribute values from OPC HDA server

Description

attrStruct = readItemAttributes(hdaObj,itemID,attribute,startTime,endTime) reads item attribute values for the item with the ID specified in ItemID over the time period specified using startTime and endTime. hdaObj must represent a single OPC HDA client that is already connected to the server.

The ItemAttributes property of the hdaObj contains all valid item attributes for the server.

example

Examples

collapse all

Retrieve the current data type of the 'Random.Real8' property.

hdaObj = opchda('localhost','Matrikon.OPC.Simulation');
connect(hdaObj);
reqAttrStruct = hdaObj.readItemAttributes('Random.Real8', ...
                 hdaObj.ItemAttributes.DATA_TYPE,now,now)
reqAttrStruct = 

  struct with fields:

         ItemID: 'Random.Real8'
    AttributeID: 1
      Timestamp: 7.3952e+05
          Value: 5

Input Arguments

collapse all

OPC HDA client, specified as an OPC HDA client object. hdaObj must be a scalar OPC HDA client that is already connected to the server.

Example: hdaObj = opchda(_)

HDA item ID, specified as a character vector or string. Specify the item ID to read attributes corresponding to that item.

Example: 'Random.Real4'

Data Types: char | string

HDA item attributes, specified as a character vector or string.

Example: hdaObj.ItemAttributes.DATA_TYPE

Data Types: char | string

Time boundaries, specified as datetime values returned by datetime.

Example: datetime(2018,11,30)

Data Types: datetime

Output Arguments

collapse all

Attribute values, returned as a structure containing the fields ItemID, AttributeID, TimeStamp, and Value. ItemID is the ID of the item whose attributes you want to read. AttributeID is the ID of the attribute you want to read. TimeStamp is a vector containing the timestamps at which the attribute was updated. Value is the value of the attribute at each timestamp.

Version History

Introduced in R2011a