主要内容

read

Read current values from attributes on PI AF server

Since R2026a

    Description

    attributeValues = read(attributeObj) reads the current values of the AF attributes identified by attributeObj.

    attributeValues = read(attributeObj,Unit=unitOfMeasure) returns the current values of the AF attributes in the specified unit of measure. If the specified unit is not supported for any of the specified input attributes, the function returns the current values for those attributes in the default unit of measure.

    Note

    You must install the AF SDK library to connect to a PI AF server from MATLAB®. For more information, see AF SDK Overview.

    example

    Examples

    collapse all

    Create an AF client. The client is associated with the default database of the PI AF server.

    afclientObj = afclient("EVS-Hydroplant");

    Find the required attributes by specifying the attribute path.

    minAttributePath = "\\EVS-HydroPlant\OSIDemo_PG_HydroPlant\Flynn River Hydro\Flynn I\GU1\GU1 Turbine|Water Flow|Minimum";
    maxAttributePath = "\\EVS-HydroPlant\OSIDemo_PG_HydroPlant\Flynn River Hydro\Flynn I\GU1\GU1 Turbine|Water Flow|Maximum";
    guAttribute = findAttributeByPath(afclientObj,[minAttributePath,maxAttributePath])
    guAttribute = 
    
      1×2 Attribute array:
        Index   Name                                                   Path                                                    ServerDataType
        -----  -------  -----------------------------------------------------------------------------------------------------  --------------
          1    Minimum   \\EVS-HydroPlant\OSIDemo_PG_HydroPlant\Flynn River Hydro\Flynn I\GU1\GU1 Turbine|Water Flow|Minimum      Double
          2    Maximum   \\EVS-HydroPlant\OSIDemo_PG_HydroPlant\Flynn River Hydro\Flynn I\GU1\GU1 Turbine|Water Flow|Maximum      Double

    Read current values of the specified AF attributes.

    attributeValues = read(guAttribute)
    attributeValues =
    
      2×5 table
        Attribute       Element       Value               Unit              Status
        _________    _____________    ______    ________________________    ______
    
        "Minimum"    "GU1 Turbine"    {[ 0]}    "cubic meter per second"    "Good"
        "Maximum"    "GU1 Turbine"    {[20]}    "cubic meter per second"    "Good"

    Read current values of the attributes with the specified unit of measure. In this example, the function converts the attribute values to the specified unit of measure liter per second.

    targetValues = read(guAttribute,Unit="liter per second")
    targetValues =
    
      2×5 table
    
        Attribute       Element         Value             Unit           Status
        _________    _____________    _________    __________________    ______
    
        "Minimum"    "GU1 Turbine"    {[    0]}    "liter per second"    "Good"
        "Maximum"    "GU1 Turbine"    {[20000]}    "liter per second"    "Good"

    Input Arguments

    collapse all

    AF attribute, specified as an icomm.af.Attribute object or an array of icomm.af.Attribute objects. You can create attribute objects using functions like getAttributes or findAttributeByPath. Or, you can use the Asset Framework Browser to graphically browse the AF database, and then select an attribute or attributes to create an icomm.af.Attribute object or array of AF attribute objects, respectively.

    Unit of measure for the input AF attribute, specified as a string or character vector. If you do not specify Unit, or if you specify an unsupported unit, read returns values in the default unit for the attribute. To find the list of supported units for an attribute, use the listSupportedUnits function.

    Output Arguments

    collapse all

    Current value of the input AF attributes, returned in a table with current information of the attributes. For information about how MATLAB interprets the Value of each AF attribute, see PI Asset Framework Server Data Types. The returned table has these variables.

    VariableDescriptionVariable Data Type
    AttributeName of the AF attributeString array
    ElementParent Element of the AF attributeString array
    ValueCurrent value of the AF attributeCell array of current value. Data type of each value depends on the server data type of the corresponding attribute.
    UnitUnit of measure of the current valueString array
    StatusData quality of the current valueString array

    Version History

    Introduced in R2026a