Main Content

write

Write data to PI Data Archive

Since R2024a

    Description

    write(piClientObj,tagName,data) writes the data specified in data to the tag specified in tagName at the current timestamp. The client specified in piClientObj must be connected to AVEVA® PI Data Archive containing the specified tag. You can write data to only one tag at a time.

    write(piClientObj,tagName,data,Name=Value) writes data with additional options specified by one or more name-value arguments. For example, to overwrite data in a tag, set Overwrite to true.

    example

    Examples

    collapse all

    Write data to a single tag of the PI Data Archive at the current timestamp.

    write(piClientObj, "Plant1_Temperature_celcius", 55);

    Overwrite existing data of a tag at the specified timestamps.

    newData = [45 60];
    timeInstance = [datetime('2023-03-25 11:23:37') datetime('2023-03-25 10:45:13')];
    write(piClientObj,"Plant1_Temperature_celcius",newData,TimeInstance=timeInstance,Overwrite=true);

    Input Arguments

    collapse all

    Client connected to AVEVA PI Data Archive, specified as an icomm.pi.Client object. You can create the object with the piclient function.

    Example: piClient = piclient(_)

    Data Types: object

    Tag name to write data to, specified as a string or character vector. You can write data to only one tag at a time.

    Example: "Power_ckt2"

    Data Types: char | string

    Data to write to a specified tag of AVEVA PI Data Archive, specified as a string, numeric value or vector of numeric values.

    Example: [25, 22, 10]

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | 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.

    Example: write(piClientObj,"Plant_temperature",60,TimeInstance = datetime("2023-08-15 10:43:27"))

    Timestamp at which to write data, specified as a datetime array. By default, the function writes the data at the current timestamp in the local system time zone.

    Example: write(piClientObj,"Plant_temperature",60,TimeInstance=datetime("now",TimeZone='America/New_York'))

    Note

    When you do not specify the time zone in TimeInstance, the write function uses the local system time zone.

    Data Types: datetime

    Option to overwrite data, specified as one of these:

    • true: The new data overwrites any existing data at the specified timestamp.

    • false: The new data appends to any existing data at the specified timestamp.

    When there is no existing data at the specified timestamp, selecting true or false results in the function writing the new value at the specified timestamp.

    Example: write(piClientObj,"Plant_temperature",60,Overwrite=true)

    Data Types: logical

    Version History

    Introduced in R2024a

    See Also

    Functions