Main Content

read

Read data from PI Data Archive

Since R2022a

Description

piValues = read(piClient,tagName) reads the latest data value from each of the specified tags of the AVEVA® PI Data Archive that the PI client piClient is connected to. tagName can be a string or vector of strings. The data is returned to piValues as a timetable.

piValues = read(piClient,tagName,Earliest=true) reads the earliest value from each of the specified tags.

piValues = read(piClient,tagName,DateRange=[startDate,endDate]) reads data points in the range between the start and end dates, specified by the datetime values of [startDate,endDate].

piValues = read(piClient,tagName,DateRange=[startDate,endDate],Interval=timeStep) reads the data points in the given time range interpolated for each interval specified by the duration timeStep.

example

Examples

collapse all

Read the latest data point of a single tag.

piValues = read(piClient, "Plant1_generator1_voltage");

Read the earliest data point of a single tag.

piValues = read(piClient, "Plant1_generator1_voltage", Earliest=true);

Read data points of a single tag over the past one-day period.

startDate = datetime("now") - days(1);
endDate = datetime("now");
piValues = read(piClient, "Plant1_generator1_voltage", DateRange=[startDate,endDate]);

Read all data points of multiple tags over a 6-hour period, interpolating every 5 minutes.

startDate = datetime(2021,6,12,14,10,30); % 12-Jun-2021 14:10:30
endDate = startDate + hours(6);
piValues = read(piClient,["Plant1_generator1_voltage","Plant1_generator1_current"], ...
           DateRange=[startDate,endDate], Interval=minutes(5));

Input Arguments

collapse all

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

Example: piClient = piclient(_)

Data Types: object

Tag names to read from, specified as a string, string array, character vector, or cell array of character vectors. You can also specify tags with a table, in the format returned by the tags function.

Example: "Power_ckt2"

Data Types: char | string | table | cell

Date range of data to read, specified as a 2-element vector of datetime values.

Example: [datetime("1-Jan-2020"),datetime("31-Jan-2020")]

Data Types: datetime

Interval span for data interpolation, specified as a duration value.

Example: hours(1)

Data Types: duration

Output Arguments

collapse all

Data point values read from PI Data Archive, returned as a timetable.

Version History

Introduced in R2022a

See Also

Functions