Main Content

piclient

Create PI Data Archive client

Since R2022a

Description

The PI client object provides access to an AVEVA® PI Data Archive so that you can search tags and read their data.

Note

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

Creation

Description

piClientObj = piclient(piServer) creates a PI client object, and connects to the AVEVA PI Data Archive specified by piServer.

example

piClientObj = piclient(piServer,Name=Value) connects to the PI Data Archive with specific Windows® credentials or domain using optional name-value arguments.

Credential information is used only to connect to the PI Data Archive, and is not retained in the PI client object properties.

example

Input Arguments

expand all

Host ID of AVEVA PI Data Archive server, specified as a string or character vector, indicating host name or IP address.

Example: "pi-host-55"

Data Types: string | char

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.

Example: piClientObj = piclient("pi-host", Username="MyUserID", Password="MyPassword", Domain="MY-NET3")

Name-value arguments can specify the Domain property; and the following options:

Windows login name for explicit connection to the PI Data Archive server, specified as a string or character vector. When you specify a Username, you must also specify the corresponding Password.

Data Types: char | string

Windows login password for explicit connection to the PI Data Archive server, specified as a string or character vector. Use the setSecret and getSecret functions to securely store and retrieve the password from your MATLAB vault. When you specify a Password, you must also specify the corresponding Username.

Data Types: char | string

Name of domain associated with user credentials, specified as a string or character vector. You can use this option if the credentials pertain to a domain different from the local machine. When you specify a Domain, you must also specify the corresponding user credentials using Username and Password.

Data Types: char | string

Output Arguments

expand all

PI client, returned as an icomm.pi.Client object, with properties such as server name and domain.

Properties

expand all

This property is read-only.

Name of the connected AVEVA PI Data Archive, represented as a string. This property takes its value from the piServer input argument to piclient.

Example: "pi-host-55"

Data Types: string

This property is read-only.

Name of the domain associated with user credentials, represented as a string.

Example: "MY-NET3"

Data Types: string

Object Functions

tagsList tags from PI Data Archive
readRead data from PI Data Archive
writeWrite data to PI Data Archive
viewerVisualize data from PI Data Archive

Examples

collapse all

Construct a PI client object and connect to the AVEVA PI Data Archive on host pi-host-55.

piClientObj = piclient("pi-host-55");

Explicit connection with a PI Data Archive requires Windows credentials. Use the setSecret and getSecret functions to securely store and retrieve the Windows login password from your MATLAB vault.

setSecret("LoginPassword")

password prompt for PI

Create a client object and connect to the AVEVA PI Data Archive server on host pi-host-55 using Windows credentials.

piClientObj = piclient("pi-host-55",Username="myID",...
              Password=getSecret("LoginPassword"));

For releases prior to R2024a, specify password as a string.

Version History

Introduced in R2022a

See Also

Functions