PI DataLink User Guide
PI DataLink User Guide
Version 3.1.6
12/18/2006
OSIsoft, Inc.
OSIsoft Australia
Perth, Australia
Auckland, New Zealand
http://techsupport.osisoft.com
techsupport@osisoft.com
Singapore
Houston, TX
Johnson City, TN
Mayfield Heights, OH
Phoenix, AZ
Savannah, GA
Seattle, WA
Yardley, PA
OSIsoft Japan KK
Tokyo, Japan
Sales Outlets/Distributors
Brazil
Middle East/North Africa
Republic of South Africa
Russia/Central Asia
South America/Caribbean
Southeast Asia
South Korea Taiwan
www.osisoft.com
OSIsoft, Inc. is the owner of the following trademarks and registered trademarks: PI System,
PI ProcessBook, Sequencia, Sigmafine, gRecipe, sRecipe, and RLINK. All terms mentioned
in this book that are known to be trademarks or service marks have been appropriately
capitalized. Any trademark that appears in this book that is not owned by OSIsoft, Inc. is the
property of its owner and use herein in no way indicates an endorsement, recommendation, or
warranty of such party's products or any affiliation with such party of any kind.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions as set forth in
subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at
DFARS 252.227-7013
Table of Contents
Chapter 1:
Introduction ..............................................................................................................1
Contents of PI DataLink.............................................................................................1
System Requirements ...............................................................................................2
Installation..................................................................................................................3
For the PI System Manager.......................................................................................6
Chapter 2:
Add-in to Excel.......................................................................................................11
Overview ..................................................................................................................11
Tutorial .....................................................................................................................12
PI Menu....................................................................................................................20
Dialog Boxes............................................................................................................22
Time in PI DataLink .................................................................................................24
PI DataLink Functions..............................................................................................29
Details for PI DataLink Functions and Dialog Boxes...............................................32
Writing Data from Excel to PI...................................................................................84
Limits from Excel for PI DataLink ............................................................................86
Chapter 3:
Appendix A:
Troubleshooting ..................................................................................................137
DataLink Add-in Doesn't Load Properly.................................................................137
Appendix B:
Expression Syntax...............................................................................................143
Calculation Expressions ........................................................................................143
Filter Expressions ..................................................................................................146
Page iii
Contents
Appendix C:
Appendix D:
Setup.ini Arguments............................................................................................151
Silent Installs..........................................................................................................151
PI SDK Installation.................................................................................................151
PI DataLink Installation ..........................................................................................152
Appendix E:
Outcodes ..............................................................................................................153
Example .................................................................................................................154
Appendix F:
Index ............................................................................................................................................159
Page iv
Chapter 1: Introduction
PI DataLink provides a link between OSIsoft's PI 3 or PI 2 Server, and spreadsheet programs
running on Microsoft Windows platforms. With PI DataLink, a user running Microsoft Excel
or Lotus 1-2-3 can exchange information directly with the PI System databases. Combined
with the functionality of the spreadsheet programs, this feature makes PI DataLink a
powerful, yet easy-to-use tool for gathering, analyzing, and reporting PI data.
Contents of PI DataLink
PI DataLink consists of the following two modules:
An add-in for Microsoft Excel
An add-in for Lotus 1-2-3
PI DataLink for Excel is built with OSIsoft's PI SDK product. It allows users who have
experience using Microsoft Visual Basic for Applications (VBA) to develop Excel routines
that call PI SDK functions.
PI DataLink for Lotus 1-2-3 is built with OSIsoft's PI API product. It allows users who have
experience using 1-2-3 LotusScript programming to develop Lotus spreadsheet routines that
call PI API functions.
However, users who wish to develop programs outside of Excel or Lotus 1-2-3 must purchase
a separate PI SDK or PI API license. Please contact an OSIsoft sales representative for more
information.
Page 1
Introduction
System Requirements
PI DataLink runs within a suitable spreadsheet application on a Microsoft Windows PC client
machine and retrieves information stored on a PI Server through standard network software.
Users of Microsoft Windows should use the TCP/IP layer built into the operating system.
TCP/IP on OpenVMS
If the PI Server runs on OpenVMS, one of the following TCP/IP software packages is
necessary on the VMS machine:
DEC TCP/IP Services for OpenVMS, version 2.0+
Process Software TCPWare, version 3.1+
Cisco MultiNet, version 3.4+
Attachmate Pathway, runtime release 1.1+
Page 2
Installation
Installation
Note: Before installation, each user of PI DataLink must be licensed to use this product.
Contact OSIsoft Sales for more information.
The user may install PI DataLink from the distribution CD, either locally to a PC, or globally
to a network file server. A System Administrator normally performs the latter.
After a successful installation of PI DataLink to a network file server, other users will be able
to install from the network drive to a local PC either a complete standalone version or a
shared version of PI DataLink.
Installation of a standalone version places a copy of all the PI DataLink files onto the user's
local PC. In an installation of the shared version, the main PI DataLink files remain on the
network file server and users run the program files off the server.
Page 3
Introduction
Page 4
Installation
Bug Fixes
A list of known problems that are fixed in this version of PI DataLink is in the
...\PIPC\readme_datalink.txt file.
Page 5
Introduction
PI Server Service
If PI DataLink communicates with the PI Server via TCP/IP, the PI System Manager must
perform a one-time configuration of the PI Server service. This PI Server service is used by
not only PI DataLink, but by all OSIsoft PC client applications. Please consult the
PIBuild:PIServer.txt file on the VAX/Alpha machine.
Security File
The PI Server service supports a combination of node authentication and username/password
security for PC client applications. The PI Server access file, PISysDat:PIServer.Dat,
determines which machines have access to PI data. This file should be created if it does not
currently exist.
For node authentication security, add entries for particular machines. For example:
[USERDATABASE] DEFAULT=PI [CLIENTACCESS] DEFAULT=R PINET1=RW
PINET2=RW PC1=RW PC2=NONE
Page 6
5. For username/password security, add the letter L after the access type as follows:
[USERDATABASE] DEFAULT=PI [CLIENTACCESS] DEFAULT=RL PINET1=RW
PINET2=RW PC1=RLWL PC2=NONE
This PIServer.Dat is the same as the previous example except in two cases:
The machine named "PC1" has conditional read and write access. This level of
security means that only user with proper user name and password can read and write
on "PC1" via PI DataLink.
All other PCs have conditional access to PI data. This level of security means that
users must provide a valid PI username and password to access PI data and no user
can write data back into PI.
Be aware that TCP/IP node names are case-sensitive. In addition, the values for the entries in
the CLIENTACCESS section (that is, R and W) are also case-sensitive.
For node or username/password security to function properly, it is essential that the PI Server
be able to determine the name of the PC client running PI DataLink. The following sections
provide specific information for DECNet and different vendor's TCP/IP.
Name Translation - UCX (or TCPIP for VMS 7.2+)
Under DEC TCP/IP Services for VMS, the PI 2 Server asks UCX to supply the hostname for
a given PI DataLink connection. UCX in turn queries the UCX host database on the
VAX/Alpha or the Domain Name Server (if configured).
To confirm that UCX is determining the PC name properly, type the following from DCL
after PI DataLink has connected to the PI 2 Server:
$ ucx show device /port=545
You should see the remote hostname listed under Remote. It is this hostname whose access
level to PI data is being controlled by PISysDat:PIServer.Dat.
If instead, you see a number (for example, 192.168.100.77) for the remote host, this means
that UCX (and hence the PI 2 Server) cannot determine the name of the PC client.
Accordingly, the PI 2 Server uses the DEFAULT level access in
PISysDat:PIServer.Dat.
To add an entry in the UCX host table for a PC:
$ ucx set host "mypc" /addr=192.168.100.77
Page 7
Introduction
You should then see the name of the local host as well as the name of the foreign (PC) host. It
is this latter hostname whose access level to PI data is being controlled by
PISysDat:PIServer.Dat.
If instead, you see a number (for example, 192.168.100.77) for the foreign host, this means
that MultiNet (and hence the PI 2 Server) cannot determine the name of the PC client.
Accordingly, the PI 2 Server is using the DEFAULT level access in
PISysDat:PIServer.Dat.
To add an entry in the MultiNet host table on the VAX/Alpha for a PC, you need to edit the
MultiNet:Hosts.Local file. After editing, you should run the following commands:
$ multinet host_table compile $ @multinet:install_databases
You should then see the name of the local host as well as the name of the foreign (PC) host. It
is this latter host name whose access level to PI data is being controlled by
PISysDat:PIServer.Dat.
If instead, you see a number (for example, 192.168.100.77) for the foreign host, this means
that PathWay (and hence the PI 2 Server) cannot determine the name of the PC client.
Accordingly, the PI 2 Server is using the DEFAULT level access in PISysDat:PIServer.Dat.
To add an entry in the PathWay host table on the VAX for a PC, you need to edit the
twg$etc:Hosts.file. Consult your PathWay documentation for more details.
Page 8
You should then see the name of the local host as well as the name of the remote (PC) host. It
is this latter host name whose access level to PI data is being controlled by
PISysDat:PIServer.Dat.
If instead, you see a number (for example, 192.168.100.77) for the remote host, this means
that TCPWare (and hence the PI 2 Server) cannot determine the name of the PC client.
Accordingly, the PI 2 Server is using the DEFAULT level access in
PISysDat:PIServer.Dat.
To add an entry in the TCPWare host table on the VAX/Alpha for a PC, you need to edit the
TCPWare:Hosts file. You may need to restart TCPWare in order for the change to take
effect. Consult your TCPWare documentation for more details.
PI 3 Server
Firewall Database
The firewall database on the machine on which PI 3 Server is running must be configured to
allow access by PCs on which PI DataLink is running. For example,
PIConfig> @table pi_gen,pifirewall PIConfig> @ostr hostmask,value
PIConfig> @select hostmask=* PIconfig> @ends *.*.*.*, ALLOW
The above indicates that only PCs whose TCP/IP address start with 192.168.100 are allowed
to connect.
For more information, consult the PI Server User Manuals that are available for download
from http://techsupport.osisoft.com/downloadcenter.aspx
(http://techsupport.osisoft.com/downloadcenter.aspx) under "PI 3 Enterprise Server".
Page 9
Introduction
Trust Database
The trust database on the machine on which PI 3 Server is running may be configured to
allow access without explicit login by PCs on which PI DataLink is running. For example,
PIconfig> @table pitrust PIconfig> @ostr trust,ipaddr,iphost,piuser
PIconfig> @select trust=* PIconfig> @ends
MyPCTrust,0.0.0.0,mypc,piadmin
The above indicates that any app connecting to PI 3 Server from "mypc" gets piadmin
privileges by default.
For more information, consult the PI Server User Manuals that are available for download
from http://techsupport.osisoft.com/downloadcenter.aspx
(http://techsupport.osisoft.com/downloadcenter.aspx) under "PI 3 Enterprise Server".
Point Access/Data Access Attributes
When PI DataLink connects to PI 3 Server, it asks the user for a username and password.
This username is used in conjunction with the PtOwner, PtAccess, DataOwner, and
DataAccess fields.
For example, if the tag SINUSOID is configured such that PtAccess is O:RW, G:NONE,
W:NONE, and PtOwner is USER1, PI DataLink users must log in as USER1 in order to see
this tag. Otherwise, the tag will not be found.
Also, if SINUSOID DataAccess is O:R, G:NONE, W:NONE, and DataOwner is USER1, PI
DataLink users must log in as USER1 in order to see data for this tag. Otherwise, a read
access error message is returned.
However, even logging on as USER1 in this case will not allow PI DataLink to write data to
SINUSOID because the DataAccess attribute is O:R (read only). The PI System Manager
would need to change DataAccess to O:RW (read and write). Only after this change is made
can PI DataLink users who log in as USER1 be able to read and write data for SINUSOID.
For more information, consult the PI Server User Manuals that are available for download
from http://techsupport.osisoft.com/downloadcenter.aspx
(http://techsupport.osisoft.com/downloadcenter.aspx) under "PI 3 Enterprise Server".
Note: The user PIAdmin is a "super"-privileged user. A user of PI DataLink who logs in
as PIAdmin has read and write access to all tags. For this reason, PI DataLink
users normally should NOT log in as PIAdmin.
Page 10
Overview
The PI DataLink add-in for Excel provides users of Microsoft Excel with the ability to
retrieve data associated with tags on a PI Server, directly into a spreadsheet. Moreover, users
have the ability to write spreadsheet values back into PI.
PI DataLink provides the following functions to retrieve data from PI:
Current value
Value at a specific time
Tag attributes
Evenly spaced (sampled) data
Sampled data while a given expression is true
Compressed (archived) data
Compressed data while a given expression is true
Sampled data for a user specified array of timestamps
Data from calculations on PI tag expressions
Amount of time while a PI tag expression was true
Totals, minima, maxima, standard deviations, ranges, averages, counts and means for PI
Page 11
Add-in to Excel
Tutorial
The goal of this tutorial is to get you started with using PI DataLink in Excel as quickly as
possible. PI DataLink's features are not discussed in detail in this tutorial. Rather, it will serve
to familiarize the user with the overall operation of this add-in.
If the Status indicates that the PI Server is not connected, click the checkbox to connect. If the
default user account for your selected PI Server requires a password, the login dialog appears
to prompt you for the password:
Page 12
Tutorial
In this dialog, you can also change the user name to log in as a different user from the default
user.
A valid username/password changes the Status in the Connections dialog box and displays
the user that DataLink is connected as. Dismiss the Connections dialog box by clicking
Cancel.
If you receive a login failure dialog box, confirm that you have a valid PI
username/password. The appearance of the login failure dialog box even though the PI
username/password is valid indicates that PI DataLink cannot connect to the PI Server. Check
the Troubleshooting (page 137) section.
Page 13
Add-in to Excel
5. Click Search to find tags that being with "BA". The Search Results list should contain at
least five tags: BA:ACTIVE.1, BA:CONC.1, BA:LEVEL.1, BA:PHASE.1, and
BA:TEMP.1.
6. Select these five tags from the Search Results list by clicking on the first tag
(BA:ACTIVE.1) and then simultaneously holding the CTRL key and clicking on each of
the four other tags. Then, click OK to copy the five tags along a single column, from A2
to A6.
7. Move the cursor to cell B2. From the PI menu, select Tag Attributes.... Click the edit box
under Tagname(s).
Page 14
Tutorial
8. Position the mouse over cell A2 in the spreadsheet. Click and drag to select the reference
A2:A6.
9. Type or select "descriptor" from drop-down box below Attribute.
10. Click OK in the dialog box. PI DataLink then retrieves Tag descriptors into cells B2 to
B6.
11. Move the cursor to cell C2. From the PI menu, select Current Value.... Click the edit
box under Tagname. Position the mouse over cell A2 in the spreadsheet. Click and drag
to select the reference A2:A6. In the dialog box, click the time at left radio button.
Page 15
Add-in to Excel
12. Click OK in the dialog box. PI DataLink then retrieves current values and the timestamps
of these current values into columns D and C, respectively.
13. Move the cursor to cell E2 in the spreadsheet. From the PI menu, select Tag Attributes...
again. Click the edit box under Tagname(s).
14. Position the mouse over cell A2 in the spreadsheet. Click and drag to select the reference
A2:A6. Select engunits from the Attribute list box.
15. Click OK in the dialog box. PI DataLink then retrieves engineering units into cells E2 to
E6.
Page 16
Tutorial
4. Click OK. PI DataLink then retrieves interpolated data from midnight to 8:00am at
1-hour intervals.
Page 17
Add-in to Excel
3. Change the end time from "+8h" to "+9h" and click OK. PI DataLink then retrieves
interpolated data from midnight to 9:00am at 1-hour intervals. Note that the array size has
increased by one row.
Page 18
Tutorial
PI DataLink Summary
As the above examples indicate, the fastest way to use PI DataLink to transfer data between
PI and Excel is to select an option from the PI menu item. A dialog box then appears. Enter
the appropriate parameters and PI DataLink retrieves the requested PI values. The next
sections describe the features of PI DataLink in greater detail.
Page 19
Add-in to Excel
PI Menu
When PI DataLink is added to Excel, it adds the PI menu item to Excel's menu bar.
Page 20
PI Menu
Pop-up menu selections are available from this menu item. These are:
Current Value retrieves the current value for a tag
Archive Value retrieves a single value from the archive (may be interpolated)
Tag Attributes retrieves a tag attribute
Compressed Data (Start Time/Number) retrieves compressed data based on a start time
filter condition
Timed Data retrieves sampled data synchronized with an array of timestamps
Calculated Data retrieves totals, minima, maxima, ranges, standard deviations, averages
Page 21
Add-in to Excel
Dialog Boxes
Edit Fields
The edit fields can contain either the necessary text information or references to cells, which
contain the necessary text information. PI DataLink determines the type of information
entered in the edit field by context.
As opposed to typing in the cell reference, you may also use the mouse to click the edit field,
and then click the cell (or click the cell and drag to adjacent cells) on the spreadsheet. In this
procedure, Excel automatically enters the cell reference(s) into the edit field for you.
For example, in the dialog box below, the edit fields for Tagname and Output ask for a cell
on the spreadsheet that contains the tagname and a cell on the spreadsheet where you wish to
place the output of the current value, respectively.
Page 22
Dialog Boxes
List Boxes
List boxes appear for the Mode field in Archive Value..., for the Type fields in Compressed
Data (Number) and (Times)..., for the Mode fields in Calculated and Advanced Calculated
data..., and for the Time Unit fields in Time Filtered... dialog boxes. The default retrieval
mode from Archive Value... is interpolated, the default boundary type from both Compressed
Data (Number) and (Times)... is inside, the default calculation mode from both Calculated
and Advanced Calculated Data... is total, the default expression sampling mode from
Advanced Calculated Data... is pt. compressed, and the default time unit for Time Filtered...
is seconds.
Page 23
Add-in to Excel
Combo Boxes
Combo boxes appear for the Attribute field in Tag Attributes.... The Point Class field is
automatically populated with all the available point classes for the listed PI server. Whenever
a new PI server is selected in the PI Server field, the Point Class field is repopulated.
Whenever a point class is selected in the Point Class field, the Attribute field is repopulated.
When a valid tag is entered, its point class will be retrieved and entered into the Point Class
field automatically.
Time in PI DataLink
Returned Values
The timestamps returned by the PI DataLink dialog boxes are in Excel format; i.e., the
number represents the number of days since 1900. For example, 10-Dec-99 7:12pm is entered
into a cell as the number 36504.8.
However PI DataLink formats these timestamps into a PI time string; specifically,
dd-mmm-yy hh:mm:ss. For example, 7:12 PM on December 10th, 1999 is displayed as
10-Dec-99 19:12:00.
You can change this format to another by selecting the cells and choosing Format, Cells,
Number. See your Excel documentation for more information on formatting numbers as time.
Page 24
Time in PI DataLink
The number format "0.0" formats numbers to one decimal place and the time format
"hh:mm:ss" timestamps to be hour:minute:seconds.
The entries for the number format and time format fields may be any valid Excel format code
from Format, Cells, Number, Custom.
For example in German, the equivalent of "General" and "dd-mmm-yyyy hh:mm" are
"Standard" and "TT-MM-JJJJ hh:mm" respectively.
Page 25
Add-in to Excel
Page 26
Time in PI DataLink
Page 27
Add-in to Excel
values.
The timestamps are displayed according to the orientation (rowwise or columnwise)
specified. For instance, if the orientation is columnwise and if all check boxes are selected,
the order of the columns from left to right would be: start time, end time, the timestamp of the
minimum value, the timestamp of the maximum value. If the check box for End Time is
cleared, for the same example the order from left to right would be: start time, the timestamp
of the minimum value, the timestamp of the maximum value.
Page 28
PI DataLink Functions
PI DataLink Functions
Functions vs. Values
When a PI DataLink dialog box brings data from the PI Server to Excel, it does not put the
actual value into a cell. Rather, PI DataLink pastes a custom PI function into the cell.
For example, when you call up the Current Value dialog box and enter SINUSOID into the
Tagname field, PI DataLink pastes the following function into the cell:
=PICurrVal("sinusoid",0,)
Excel then evaluates this function, and displays the resulting number. Thus, the PI DataLink
dialog boxes are a front end to construct the corresponding PI DataLink functions, and to
format the output.
These PI DataLink functions can also be entered manually into the cells in a worksheet. The
arguments to the function are described further in Details for PI DataLink Functions and
Dialog Boxes (page 32). Since most of the PI DataLink functions return more than one data
element, the functions should be entered into Excel as array functions. Please see the Entering
PI Functions Directly into Excel section below for a more detailed explanation of how array
functions are used.
These PI DataLink functions can only be used in cells of a worksheet. They cannot be called
within a procedure in Excel Visual Basic. Visual Basic does not recognize PI DataLink
functions. The only way to invoke the PI DataLink functions in VBA is to formulate the
function as a text string and then set the formula Array property of a range of cells to this text
string. This is the same as manually entering the PI functions into that range of cells. The
VBA code can then check the cell values for the PI function results. For an example of
entering PI functions into the spreadsheet using VBA, see the putval_code module in the
piexam32.xls distributed with PI DataLink.
The PI DataLink output function PIPutVal() is an Excel Macro function and cannot be used
directly in the cells of a worksheet. PIPutVal() can only be used in an Excel 4.0 macro sheet
or run as a macro in VBA. In VBA, use the application.run method to invoke macro
functions. Please refer to the putval_code module in the piexam32.xls for an example of
invoking the macro function in VBA.
Error Reporting
PI DataLink is written in C++ and Visual Basic and utilizes both the PI System's SDK and
Microsoft Excel's API. When an error occurs at the PI SDK level, PI DataLink displays the PI
SDK error in the cell. For example, if you try to find the current value for a tag which does
not exist, the message "PIPoint not found" appears in the output cell.
Page 29
Add-in to Excel
Page 30
PI DataLink Functions
Array Values
All of PI DataLink functions except PIPutVal() return array values. This being the case, you
must first select the appropriate array output range. Next, enter the PI function and its
arguments into Excel's formula bar. Finally, place the PI function into the cells with the
CTRL+SHIFT+ENTER combination of keystrokes. Refer to the online help for Microsoft
Excel for more information on array functions. Also, note that Excel function wizard will
only insert function into one cell on the spreadsheet. Therefore, it may not be appropriate to
use the function wizard to enter PI functions into Excel.
Outcode
The outcode argument is an integer that controls whether or not the timestamps are returned
and whether the output cells are row or column oriented.
For example, an outcode of 0 in PICurrVal() results in the snapshot value in the single cell.
An outcode of 1 places the snapshot time in column one and the snapshot value in column
two of a 1 x 2 array. An outcode of 2 places the snapshot time in row one and the snapshot
value in row two of a 2 x 1 array. Refer to the detail description for each individual PI
function for the meaning of its outcode. In general, if you specify an array output range that is
greater than the number of values returned from the function, the extra cells are displayed as
empty cells even though they have an embedded formula.
String Arguments
For string arguments to functions, you need to surround the arguments with double quotes.
For example, select a 1 x 2 output array and enter:
=PICurrVal("sinusoid", 1, "casaba")
to retrieve the snapshot time and value for the tag sinusoid from the PI Server "casaba."
Page 31
Add-in to Excel
gives the same result as the example above if the three arguments are stored in cell A1, A2,
and A3 respectively.
PIServer Argument
The PIServer argument is optional. The default PIServer can be changed in the Connections
dialog box. If you want to use the default server, you can omit the PIServer argument. For
example, to retrieve the current value for the tag sinusoid from the default PI Server, enter:
=PICurrVal("sinusoid",0,)
Page 32
PICurrVal()
PICurrVal(tagname, outcode, PIServer)
Arguments
Argument
Explanation
Tagname (string)
The tag for which you want the snapshot (current) value.
outcode (integer)
PIServer (string)
The PI Server.
Returns
Outcode
Column 1
Current value
Timestamps
Column 2
Current value
An output code of 2 transposes the output array that results from an output code of 1.
Example
The following retrieves the current value and the corresponding timestamp for the tag let439
from the PI Server "holden:"
=PICurrVal("let439",1,"holden")
4 tags on PI 2 Server and tags with step attribute set on PI 3 Server. For this special case,
the previous value is simply carried forward.
Auto - Same as interpolated except for resolution code 4 tags on PI 2 Server and tags with
step attribute set on PI 3 Server. For this special case, the value at or before the specified
timestamp is returned
Page 33
Add-in to Excel
Next - Retrieves the value in the archive at or after the specified timestamp
Next Only - Retrieves the value in the archive only after the specified timestamp
Exact Time - Retrieves the value in the archive for a specified time if an entry exists at
that time. If no value exists, the message "No events found" is returned
Required Fields
Tagname or Expression
Timestamp
Related Topics
PIArcVal() (page 34)
PIExpVal() (page 35)
PIArcVal()
PIArcVal(tagname, timestamp, outcode, PIServer, mode)
Arguments
Argument
Explanation
tagname (string)
The PI timestamp.
outcode (integer)
PIServer (string)
The PI Server.
mode (string)
Returns
Outcode
Column 1
Archive value
Timestamp
Column 2
Archive value
An output code of 2 transposes the output array that results from an output code of 1.
Page 34
Example
The following retrieves the interpolated value for the tag cdep158 at 7:20pm on December 11,
1992 from the PI Server "casaba:"
=PIArcVal("cdep158","11-dec-92 19:20",0, "casaba","interpolated")
PIExpVal()
PIExpVal(expression, timestamp, PIServer)
Arguments
Argument
Explanation
expression (string)
The PI timestamp.
PIServer (string)
The PI Server.
Returns
Outcode
Column 1
Archive value
Timestamp
Column 2
Archive value
An output code of 2 transposes the output array that results from an output code of 1.
Example
The following calculates the square root of the value of the tag sinusoid from the PI Server
named THEVAX at midnight yesterday:
=PIExpVal("sqr('sinusoid')","y",0,"thevax")
Page 35
Add-in to Excel
For PI3, the list of tag attributes depends on the point class selected. For a complete list of tag
attributes, refer to the attributes listed in the combo box or to the description of attributes for
each point class in the PI Server User Manuals, available from
http://techsupport.osisoft.com/downloadcenter.aspx
(http://techsupport.osisoft.com/downloadcenter.aspx) under "PI 3 Enterprise Server".
For PI 2, choose a tag attribute from the combo box. The default attribute is descriptor. Tag
attributes are:
Page 36
Attribute
Explanation
Descriptor
Exdesc
typicalvalue
Typical value
Units
Zero
Zero
Span
Span
digstartcode
Code for the first digital state string for the tag
dignumber
pointtype
pointsource
location1
Location parameter 1
location2
Location parameter 2
location3
Location parameter 3
location4
Location parameter 4
location5
Location parameter 5
filtercode
Filter code
squareroot
scan
Scan flag
excdev
excmin
Attribute
Explanation
excmax
archiving
Archiving flag
compressing
Compression flag
Res
Resolution code
compdev
compmin
compmax
totalcode
Totalization code
convers
displaydigits
instrumenttag
sourcept
taglong
tagshort
12 character tagname
creator
createdate
changer
changedate
pointnumber
pointid
PITagAtt()
PITagAtt(tagname, attribute, PIServer)
Arguments
Argument
Explanation
tagname (string)
attribute (string)
The tag attribute, see the list under Tag Attributes Dialog Box (page 35).
PIServer (string)
The PI Server.
Returns
Tag attribute
Page 37
Add-in to Excel
Example
The following retrieves from the default PI Server the engineering units for the tag located in
cell D1:
=PITagAtt(d1,"units",)
Filter Expression
If a filter expression is specified, the specified number of compressed values are retrieved
from the PI Server while a given filter expression is true. If the mark as filtered option is
selected, a "Filtered" status is returned for each group of values that does not satisfy the filter
expression. See Filter Expressions (page 146) for more information on the filter expression
syntax.
Boundary Type
There are 4 boundary types:
Inside (default) - Returns specified number of data points from starttime including value
or prior to starttime
Interpolated - Returns specified number of data points from starttime including a data
Page 38
Check Boxes
Select backwards in time if you want to gather data from the archive going backwards from
the time that was entered in Start time.
Select show bits if you want to show the extended status bits associated with the returned
events.
Select show annotations if you want to show the annotations associated with the
returned events.
Special Notes
This dialog box returns empty strings when there is a smaller number of values than the
number which you specified. For example, if you wish to retrieve 400 values starting from
midnight today and there are only 356 values (including filtered events), the final 44 cells
have blank strings in them.
If you enter the filter expression into a cell on the worksheet and refer to it in the dialog box,
be sure to begin the expression with a single quote so that Excel will interpret the expression
as a string. Since tag names in filter expression are enclosed with single quotes, if the filter
expression begins with a tagname, you must begin the expression with two single quotes
when the filter expression is stored in a cell on the worksheet.
Related Topics
Filter Expressions (page 146)
PINCompDat() (page 39)
PINCompFilDat() (page 40)
PINCompDat()
PINCompDat(tagname, stime, numvals, outcode, PIServer, mode)
Arguments
Argument
Explanation
tagname (string)
stime (string)
numvals (integer)
outcode (integer)
PIServer (string)
The PI Server.
mode (string)
Page 39
Add-in to Excel
Returns
Outcodes
Example
The following retrieves 10 compressed data points and corresponding time stamps for the tag
cdf144 starting from 1:00 a.m. this morning from the default PI Server with inside as
boundary type:
=PINCompDat("cdf144","1:00",10,1,,"inside")
PINCompFilDat()
PINCompFilDat(tagname, stime, numvals, filtexp, filtcode, outcode,
PIServer, mode)
Arguments
Argument
Explanation
tagname (string)
stime (string)
numvals (integer)
filtexp (string)
The filter expression. See Filter Expressions (page 146) for more
information on the filter expression syntax.
filtcode (integer)
outcode (integer)
PIServer (string)
The PI Server.
mode (string)
Returns
Refer to Outcodes.
Example
The following retrieves 10 compressed data points and the corresponding times, starting at
2:00 a.m., for the tag cdf144 while the tag cdep158 is greater than 38:
=PINCompFilDat("cdf144","2:00",10,"'cdep158'>38",1,1,,)
The status Filtered is displayed for times when the filter condition is false. Data are retrieved
from the default PI Server with inside as boundary type.
Page 40
Filter Expression
If a filter expression is specified, the specified range of compressed values are retrieved from
the PI Server while a given filter expression is true. If the mark as filtered option is selected,
a "Filtered" status is returned for each group of values that does not satisfy the filter
expression. See Filter Expressions (page 146) for more information on the filter expression
syntax.
Boundary Type
There are 4 boundary types:
Inside (default) - Returns data points at and between starttime and endtime
Outside - Returns data points between starttime and endtime including a data point at or
Page 41
Add-in to Excel
Select show bits if you want to show the extended status bits associated with the returned
events.
Select show annotations if you want to show the annotations associated with the returned
events.
Special Notes
This dialog box returns blank strings in the unused output cells when there is a smaller
number of values in the archive than the output array originally specified. This situation may
occur if you use relative time references. For example, if you retrieve values starting from y
to y+5h, the number of values in the PI Server may be different when you call up the
spreadsheet on different days.
If you enter the filter expression into a cell on the worksheet and refer to it in the dialog box,
be sure to begin the expression with a single quote so that Excel will interpret the expression
as a string. Since tag names in filter expression are enclosed with single quotes, if the filter
expression begins with a tagname, you must begin the expression with two single quotes
when the filter expression is stored in a cell on the worksheet.
Related Topics
Filter Expressions (page 146)
PICompDat() (page 42)
PICompFilDat() (page 43)
PICompDat()
PICompDat(tagname, stime, etime, outcode, PIServer, mode)
Arguments
Argument
Explanation
tagname (string)
stime (string)
etime (string)
outcode (integer)
PIServer (string)
The PI Server.
mode (string)
Returns
Refer to Outcodes.
Page 42
Example
The following retrieves compressed data points and corresponding time stamps for the tag
cdf144 starting from 1:00 a.m. to 3:00 a.m. this morning from the default PI Server with
inside as boundary type:
=PICompDat("cdf144","1:00","3:00",1,,"inside")
PICompFilDat()
PICompFilDat(tagname, stime, etime, filtexp, filtcode, outcode,
PIServer, mode)
Arguments
Argument
Explanation
tagname (string)
stime (string)
etime (string)
filtexp (string)
The filter expression. See Filter Expressions (page 146) for more
information on the filter expression syntax.
filtcode (integer)
outcode (integer)
PIServer (string)
The PI Server.
mode (string)
Returns
Refer to Outcodes.
Example
The following retrieves compressed data points and the corresponding times, starting from
2:00 a.m. and ending at 10:00 a.m., for the tag cdf144 when the tag cdep158 is greater than
38:
=PICompFilDat("cdf144","2:00","10:00","'cdep158'>38",1,1,,)
The status Filtered is displayed for times when the filter condition is false. Data are retrieved
from the default PI Server with inside as boundary type.
Page 43
Add-in to Excel
Required Fields
Tagname
Start Time
End Time
Time Interval
Filter Expression
If a filter expression is specified, the specified range of compressed values are retrieved from
the PI Server while a given filter expression is true. If the mark as filtered option is selected,
a "Filtered" status is returned for each continuous set (block) of sampled values that do not
satisfy the filter expression if the tag is on a PI 3 Server. If the tag is from a PI 2 Server, a
"Filtered" status is returned for each sampled value that does not satisfy the filter expression.
See Fi (page 146)lter Expressions for more information on the filter expression syntax.
Special Notes
If you can enter the filter expression into a cell on the worksheet and refer to it in the dialog
box, be sure to begin the expression with a single quote so that Excel will interpret the
expression as a string. Since tagname in filter expression should be enclosed with single
quotes, if the filter expression begins with a tagname, you need to begin the expression with
two single quotes when the filter expression is stored in a cell on the worksheet.
Related Topics
Filter Expressions (page 146)
PISampDat() (page 44)
PISampFilDat() (page 46)
PIExpDat() (page 47)
PISampDat()
PISampDat(tagname, stime, etime, interval, outcode, PIServer)
Arguments
Page 44
Argument
Explanation
tagname(string)
stime (string)
etime (string)
Argument
Explanation
interval (string)
outcode (integer)
PIServer (string)
The PI Server.
Returns
Outcode
Column 1
Sampled data
Timestamps
Column 2
Sampled data
An output code of 2 transposes the output array that results from an output code of 0 while an
output code of 3 transposes the output array that results from an output code of 1.
Example
The following retrieves sampled data for the tag located in cell B1, from midnight yesterday
to midnight today at 3-hour intervals:
=PISampDat(b1,"y","t","3h",1,)
Page 45
Add-in to Excel
PISampFilDat()
PISampFilDat(tagname, stime, etime, interval, filtexp, filtcode,
outcode, PI Server)
Arguments
Argument
Explanation
tagname(string)
stime (string)
etime (string)
interval (string)
filtexp (string)
The filter expression. See Filter Expressions (page 146) for more
information on the filter expression syntax.
filtcode (integer)
outcode (integer)
PIServer (string)
The PI Server.
Returns
Outcode
Column 1
Sampled data
Timestamps
Column 2
Sampled data
An output code of 2 transposes the output array that results from an output code of 0 and an
output code of 3 transposes the output array that results from an output code of 1.
Example
The following formula retrieves sampled data for SINUSOID at 11-Jan-97, 11-Jan-97
1:00AM, 11-Jan-97 2:00AM, and 11-Jan-97 3:00AM:
=PISampFilDat("sinusoid","11-Jan-97","+3h","1h",A1,1,1,)
Timestamps are shown in column1 and values in column2. A "Filtered" status is returned for
values do not satisfy the filter condition in cell A1.
Page 46
PIExpDat()
PIExpDat(expression, stime, etime, interval, outcode, PIServer)
Arguments
Argument
Explanation
expression (string)
stime (string)
etime (string)
interval (string)
outcode (integer)
PIServer (string)
The PI Server.
Returns
Outcode
Column 1
Calculated data
Timestamps
Column 2
Calculated data
An output code of 2 transposes the output array that results from an output code of 0 while an
output code of 3 transposes the output array that results from an output code of 1.
Example
The following calculates the square root of the value of the tag sinusoid from the PI Server
named THEVAX at one-hour intervals, starting from midnight yesterday to midnight today:
=PIExpDat("sqr('sinusoid')","y","t","1h",1,"thevax")
Page 47
Add-in to Excel
Required Fields
Tagname
Timestamp. The timestamp field has to be a reference to a time array. For PI 2, the
Explanation
tagname (string)
timestamps (reference)
PIServer (string)
The PI Server.
mode (string)
Returns
Sampled data. If the timestamps are in a single column, the data are returned along a single
column. If the timestamps are in a single row, the data are returned along a single row.
Example
The following retrieves interpolated timed data for the times located in cells B1 through B12
for the tag mytag from the default PI Server:
=PITimeDat("mytag",b1:b12,,"interpolated")
Page 48
PITimeExpDat()
PITimeExpDat(expression, timestamps, PIServer)
Arguments
Argument
Explanation
expression (string)
timestamps (reference)
PIServer (string)
The PI Server
Returns
Sampled data. If the timestamps are in a single column, the data are returned along a single
column. If the timestamps are in a single row, the data are returned along a single row.
Example
The following calculates the square root of the value of the tag sinusoid for the times located
in cells B1 through B12 from the default PI Server:
=PITimeExpDat("sqr('sinusoid')",b1:b12,)
Page 49
Add-in to Excel
All Calculation modes are time-weighted except for the mean function, which is
event-weighted.
Required Fields
Tagname
Start Time
End Time
Conversion Factor
Calculation Mode
Interval
To retrieve a single calculated value, do not specify an interval and the PICalcVal() function
is used. To retrieve evenly spaced calculated data, the specified interval determines the
spacing of the calculation and the PICalcDat() function is used.
Check Box
Check show pctgood if you want PI DataLink to display the percentage of the time range that
contains good value. We recommend that you always look at the percent good value before
using the calculation result. The percent good value is normally returned to the right of
calculated value cell. If the rows checkbox is selected, the percent good value is returned at
the cell below the calculated value cell.
Timestamp(s) are returned when the calculation mode is minimum, maximum, or range.
Mode
Column 1
Column 2
Minimum
Minimum value
Maximum
Maximum value
Range
Column 3
Range value
Special Notes
When an interval is not specified and the mode is Total, Standard Deviation, Average, Count
or Mean, the timestamps are not displayed even if the Show Timestamps check box is
selected. When an interval is specified and the mode is Max or Min, the timestamps displayed
are the start time of each calculation interval.
When the calculation is a time-weighted Total and part of the archived data within the range
are bad, the reported value is equal to the calculated total value divided by the fraction of the
time period with good archived data. This data normalization is equivalent to the assumption
that for the bad data time range, the tag value takes on the average value of the entire range.
Page 50
Page 51
Add-in to Excel
However, this assumption may not be valid when a large fraction of the time range contains
bad data. Therefore, we recommend that you always look at the percent good value before
using the calculation result.
The conversion factor is most often used when the calculation mode is Total and time unit of
the PI tag being totalized is not the same as the server default. In all the PI 3 Servers and in
most of the PI 2 Servers, the totalization default is "units per day." On the PI 2 Server, the
totalization default time (totdefaulttime is the time unit in seconds) can be found in the file
pilink:piparams.for.
The following table displays the conversion factors for two of the common PI 2 Server
default time units vs. various flow tag units.
Flow tag unit
Units/day
1.0
0.041667
Units/hour
24
Units/minute
1440
60
Units/second
86400
3600
Related Topics
PICalcVal() (page 52)
PICalcDat() (page 54)
PICalcVal()
PICalcVal(tagname, stime, etime, mode, cfactor, outcode, PIServer)
Arguments
Page 52
Argument
Explanation
tagname (string)
stime (string)
etime (string)
mode (string)
cfactor (number)
outcode (integer)
PIServer (string)
The PI Server.
Returns
If the outcode is 0, only the calculated value is returned.
If the outcode is 1, the following applies:
Mode
Column 1
Column 2
Total
Total value
Minimum
Minimum value
Maximum
Maximum value
Stdev
Stdev. Value
Range
Average
Average value
Count
Count value
Mean
Mean value
Column 3
Range value
An output code of 2 transposes the output array that results from an output code of 1, i.e.,
results are returned in rows instead of in columns.
Outcode of 3 is not used.
If the outcode is 4, the percent good is returned to the right of the value cell.
If the outcode is 5, the following applies:
Mode
Column 1
Column 2
Column 3
Total
Total value
Percent good
Minimum
Minimum value
Percent good
Maximum
Maximum value
Percent good
Stdev
Stdev. value
Percent good
Range
Average
Average value
Percent good
Count
Count value
Percent good
Mean
Mean value
Percent good
Range value
Column 4
Percent good
An output code of 6 transposes the output array that results from an output code of 4, i.e.,
results are returned in rows instead of in columns.
An output code of 7 transposes the output array that results from an output code of 5, i.e.,
results are returned in rows instead of in columns.
Page 53
Add-in to Excel
Example
The following calculates a time-weighted total for the tag cdf144 from yesterday to today
from the default PI Server:
=PICalcVal("cdf144","y","t","total",1440,4,)
The result is multiplied by 1440. The percent good is returned next to the total.
PICalcDat()
PICalcDat(tagname, stime, etime, interval, mode, cfactor, outcode,
PIServer)
Arguments
Argument
Explanation
tagname (string)
stime (string)
etime (string)
interval (string)
mode (string)
cfactor (number)
outcode (integer)
PIServer (string)
The PI Server.
Returns
The outcode affects the output as follows:
Page 54
Example
The following retrieves totals for the tag located in cell B1, from midnight yesterday to
midnight today at 3-hour intervals from the default PI Server specified in the PILogin.ini file:
=PICalcDat(b1,"y","t","3h","total",24,1,)
Timestamps are also returned. The values are multiplied by 24 before they are displayed in
the spreadsheet.
Required Fields
Tagname or Expression. See Calculation Expressions (page 143) for more information on
Filter Expression
If a filter expression is specified, the requested summaries on the source point are calculated
for the time ranges where the expression evaluates to true. See Filter Expressions (page 146)
for more information on the filter expression syntax.
Page 55
Add-in to Excel
Interval
To retrieve a single calculated value, do not specify an interval. To retrieve evenly spaced
calculated data, the specified interval determines the spacing of the calculation.
Expression Sampling Mode
There are 3 expression sampling modes for sampling the filter expression:
Pt. Compressed (default) - Evaluates the filter expression at the timestamp of any
There are 2 expression sampling modes for sampling the expression to be summarized:
Compressed (default) - Evaluates the expression at the timestamp of any compressed
they apply.
Event-Weighted - Weights each event with the same weight. There must be at least one
event within the time range to perform a successful calculation. For standard deviation,
two events are required.
Minimum Percent Good
The minimum percent good is the minimum percentage of good data over the time range at
which data will be returned instead of an error "Insufficient good data."
Page 56
Check Box
Refer to the Check Box description under Calculated Data Dialog Box (page 49).
Special Notes
Refer to the Special Notes section under Calculated Data Dialog Box (page 49).
Related Topics
Filter Expressions (page 146)
PIAdvCalcVal() (page 58)
PIAdvCalcFilVal() (page 59)
PIAdvCalcExpVal() (page 60)
PIAdvCalcExpFilVal() (page 61)
PIAdvCalcDat() (page 62)
PIAdvCalcFilDat() (page 63)
PIAdvCalcExpDat() (page 64)
PIAdvCalcExpFilDat() (page 65)
Page 57
Add-in to Excel
PIAdvCalcVal()
PIAdvCalcVal(tagname, stime, etime, mode, calcbasis, minpctgood,
cfactor, outcode, PIServer)
Arguments
Argument
Explanation
tagname (string)
stime (string)
etime (string)
mode (string)
calcbasis (integer)
minpctgood (number)
Cfactor (number)
outcode (integer)
PIServer (string)
The PI Server.
Returns
Refer to Returns section for PICalcVal() (page 52) function.
Example
The following calculates a time-weighted total for the tag cdf144 from yesterday to today
from the default PI Server:
=PIAdvCalcVal("cdf144","y","t","total",0,50,1,4,)
The result is multiplied by 1. The minpctgood is 50 percent so result will only be displayed if
percent good is 50 percent or greater. The percent good is returned next to the total.
Page 58
PIAdvCalcFilVal()
PIAdvCalcFilVal(tagname, stime, etime, filtexp, mode, calcbasis,
sampmode, sampinterval, minpctgood, cfactor, outcode, PIServer)
Arguments
Argument
Explanation
tagname (string)
stime (string)
etime (string)
filtexp (string)
mode (string)
calcbasis (integer)
sampmode (string)
sampinterval (string)
minpctgood (number)
Cfactor (number)
outcode (integer)
PIServer (string)
The PI Server.
Returns
Refer to Returns section for PICalcVal() (page 52) function.
Example
The following calculates a time-weighted total for the tag cdf144 from yesterday to today
during the time periods when tag cdm158 is in Manual from the default PI Server:
=PIAdvCalcFilVal("cdf144","y","t","'cdm158'=""Manual""","total",0,
"pt. compressed","10m",50,1,4,)
The result is multiplied by 1. Since pt.compressed is the specified sampling mode, the
sampling interval is ignored and the filter expression will be sampled at the compressed
events of cdf144. The minpctgood is 50 percent so result will only be displayed if percent
good is 50 percent or greater. The percent good is returned next to the total.
Page 59
Add-in to Excel
PIAdvCalcExpVal()
PIAdvCalcExpVal(expression, stime, etime, mode, calcbasis, sampmode,
sampinterval, minpctgood, cfactor, outcode, PIServer)
Arguments
Argument
Explanation
expression (string)
stime (string)
etime (string)
mode (string)
calcbasis (integer)
sampmode (string)
sampinterval (string)
minpctgood (number)
cfactor (number)
outcode (integer)
PIServer (string)
The PI Server.
Returns
Refer to Returns section for PICalcVal() (page 52) function.
Example
The following calculates a time-weighted total for the expression 'cdf144'+' cdt158' from
yesterday to today from the default PI Server:
=PIAdvCalcExpVal("'cdf144'+'cdt158'","y","t","total",0,"compressed
","10m",0,1,4,)
The result is multiplied by 1. Since compressed is the specified sampling mode, the sampling
interval is ignored and the expression will be sampled at the combined compressed events of
cdf144 and cdt158. The minpctgood is 50 percent so result will only be displayed if percent
good is 50 percent or greater. The percent good is returned next to the total.
Page 60
PIAdvCalcExpFilVal()
PIAdvCalcExpFilVal(expression, stime, etime, filtexp, mode,
calcbasis, sampmode, sampinterval, minpctgood, cfactor, outcode,
PIServer)
Arguments
Argument
Explanation
expression (string)
stime (string)
etime (string)
filtexp (string)
mode (string)
calcbasis (integer)
sampmode (string)
sampinterval (string)
minpctgood (number)
cfactor (number)
outcode (integer)
PIServer (string)
The PI Server.
Returns
Refer to Returns section for PICalcVal() (page 52) function.
Example
The following calculates a time-weighted total for the expression 'cdf144'+' cdt158' when
'productid' = "Product2" from yesterday to today from the default PI Server:
=PIAdvCalcExpFilVal("'cdf144'+'cdt158'","y","t","'productid'="Prod
uct2"", "total",0,"compressed","10m",0,1,4,)
The result is multiplied by 1. Since compressed is the specified sampling mode, the sampling
interval is ignored and the expression will be sampled at the combined compressed events of
cdf144 and cdt158. The minpctgood is 50 percent so result will only be displayed if percent
good is 50 percent or greater. The percent good is returned next to the total.
Page 61
Add-in to Excel
PIAdvCalcDat()
PIAdvCalcDat(tagname, stime, etime, interval, mode, calcbasis,
minpctgood, cfactor, outcode, PIServer)
Arguments
Argument
Explanation
tagname (string)
stime (string)
etime (string)
interval (string)
mode (string)
calcbasis (integer)
minpctgood (number)
cfactor (number)
outcode (integer)
PIServer (string)
The PI Server.
Returns
Refer to Returns section for PICalcDat() (page 54) function.
Example
The following retrieves totals for the tag cdf144, from midnight yesterday to midnight today
at 3-hour intervals from the default PI Server:
=PIAdvCalcDat("cdf144","y","t","3h","total",0,50,1,4,)
The result is multiplied by 1. The minpctgood is 50 percent so result will only be displayed if
percent good is 50 percent or greater. The percent good is returned next to the total.
Page 62
PIAdvCalcFilDat()
PIAdvCalcFilDat(tagname, stime, etime, interval, filtexp, mode,
calcbasis, sampmode, sampinterval, minpctgood, cfactor, outcode,
PIServer)
Arguments
Argument
Explanation
tagname (string)
stime (string)
etime (string)
interval (string)
filtexp (string)
mode (string)
calcbasis (integer)
sampmode (string)
sampinterval (string)
minpctgood (number)
cfactor (number)
outcode (integer)
PIServer (string)
The PI Server.
Returns
Refer to Returns section for PICalcDat() (page 54) function.
Example
The following retrieves totals for the tag cdf144, from midnight yesterday to midnight today
at 3-hour intervals during the time periods when tag cdf144 is in Manual from the default PI
Server:
=PIAdvCalcFilDat("cdf144","y","t","3h","'cdm158'=""Manual""","tota
l",0,"pt. compressed","10m",50,1,4,)
The result is multiplied by 1. Since pt.compressed is the specified sampling mode, the
sampling interval is ignored and the filter expression will be sampled at the compressed
events of cdf144. The percent good is returned next to the total.
Page 63
Add-in to Excel
PIAdvCalcExpDat()
PIAdvCalcExpDat(expression, stime, etime, interval, mode, calcbasis,
sampmode, sampinterval, minpctgood, cfactor, outcode, PIServer)
Arguments
Argument
Explanation
expression (string)
stime (string)
etime (string)
interval (string)
mode (string)
calcbasis (integer)
sampmode (string)
sampinterval (string)
minpctgood (number)
cfactor (number)
outcode (integer)
PIServer (string)
The PI Server.
Returns
Refer to Returns section for PICalcDat() (page 54) function.
Example
The following retrieves totals for the expression 'cdf144'+'cdt158', from midnight yesterday
to midnight today at 3-hour intervals from the default PI Server:
=PIAdvCalcExpDat("'cdf144'+'cdt158'","y","t","3h","total",0,"compr
essed", "10m",50,1,4,)
The result is multiplied by 1. Since compressed is the specified sampling mode, the sampling
interval is ignored and the expression will be sampled at the combined compressed events of
cdf144 and cdt158. The minpctgood is 50 percent so result will only be displayed if percent
good is 50 percent or greater. The percent good is returned next to the total.
Page 64
PIAdvCalcExpFilDat()
PIAdvCalcExpFilDat(expression, stime, etime, interval, filtexp,
mode, calcbasis, sampmode, sampinterval, minpctgood, cfactor,
outcode, PIServer)
Arguments
Argument
Explanation
expression (string)
stime (string)
etime (string)
interval (string)
filtexp (string)
mode (string)
calcbasis (integer)
sampmode (string)
sampinterval (string)
minpctgood (number)
cfactor (number)
outcode (integer)
PIServer (string)
The PI Server.
Returns
Refer to Returns section for PICalcDat() (page 54) function.
Example
The following calculates a time-weighted total for the expression 'cdf144'+' cdt158' when
'productid' = "Product2" at 3-hour intervals from yesterday to today from the default PI
Server:
=PIAdvCalcExpFilDat("'cdf144'+'cdt158'","y","t","3h","'productid'=
"Product2"","total",time-weighted,"compressed","10m",0,1,4,)
The result is multiplied by 1. Since compressed is the specified sampling mode, the sampling
interval is ignored and the expression will be sampled at the combined compressed events of
cdf144 and cdt158. The minpctgood is 50 percent so result will only be displayed if percent
good is 50 percent or greater. The percent good is returned next to the total.
Page 65
Add-in to Excel
expression syntax.
Start Time
End Time
Time units (default to seconds)
Special Notes
If you can enter the expression into a cell on the worksheet and refer to it in the dialog box,
begin the expression with a single quote so that Excel will interpret the expression as a string.
Since a tagname in a filter expression should be enclosed with single quotes, begin the
expression with two single quotes when the expression is stored in a cell on the worksheet if
the expression begins with a tagname.
Related Topics
Calculation Expressions (page 143)
PITimeFilterVal() (page 67)
PITimeFilter() (page 68)
Page 66
PITimeFilterVal()
PITimeFilterVal(expression, stime, etime, timeunit, outcode,
PIServer)
Arguments
Argument
Explanation
expression (string)
stime (string)
etime (string)
timeunit (string)
outcode (integer)
PIServer (string)
The PI Server.
Returns
If the outcode is 0, 1, or 2 only the calculated value is returned.
Outcode of 3 is not used.
If the outcode is 4 or 5, the percent good is returned to the right of the value cell.
If the outcode is 6 or 7, the percent good is returned below the value cell.
Example
The following calculates the amount of time that the expression from cell $A$1 is true from
the PI Server named THEVAX, starting from midnight yesterday to midnight today:
=PITimeFilterVal($A$1,"y","t","seconds",1,"thevax")
Page 67
Add-in to Excel
PITimeFilter()
PITimeFilter(expression, stime, etime, interval, timeunit, outcode,
PIServer)
Arguments
Argument
Explanation
expression (string)
stime (string)
etime (string)
interval (string)
timeunit (string)
outcode (integer)
PIServer (string)
The PI Server.
Returns
Outcode
Column 1
Calculated data
Timestamps
Column 2
Calculated data
An output code of 2 transposes the output array that results from an output code of 0 and an
output code of 3 transposes the output array that results from an output code of 1.
Example
The following calculates the amount of time that the expression from cell $A$1 is true from
the PI Server named THEVAX at one-hour intervals, starting from midnight yesterday to
midnight today:
=PITimeFilter($A$1,"y","t","1h","seconds",1,"thevax")
It also displays the timestamps for the start time of each calculation interval. The calculation
result is expressed in seconds.
Page 68
Related Topics
PIPointIDToTag() (page 69)
PIPointIDToTag()
PIPointIDToTag(pointid, PIServer)
Arguments
Argument
Explanation
pointid (string)
PIServer (string)
The PI Server.
Returns
Tagname
Example
The following returns the tagname of the tag with point ID of 123 from server named
THEVAX.
=PIPointIDToTag("123","thevax")
Page 69
Add-in to Excel
Related Topics
PIAttributeMaskToTag () (page 70)
PIAttributeMaskToTag ()
PIAttributeMaskToTag(tagname, descriptor, pointsource, pointtype,
pointclass, engunits, outcode, PIServer)
Arguments
Page 70
Argument
Explanation
tagname (string)
Tagname mask.
descriptor (string)
Descriptor mask.
pointsource (string)
pointtype (string)
pointclass (string)
engunits (string)
outcode (integer)
PIServer (string)
The PI Server.
Returns
Outcode
Column 1
Tagname
Column 2
An output code of 2 transposes the output array that results from an output code of 1.
Example
The following returns the tagname of the tags which start with "sin" from server named
THEVAX.
=PIAttributeMaskToTag("sin*","*","*","*","*","*",0,"thevax")
Related Topics
PIAliasToTag() (page 71)
PIAliasToTag()
PIAliasToTag(alias, modulepath, querydate, outcode, PIServer)
Arguments
Argument
Explanation
alias (string)
modulepath (string)
querydate (integer)
Outcode (integer)
PIServer (string)
The PI Server.
Page 71
Add-in to Excel
Returns
Outcode
Column 1
Tagname
Tagname
Column 2
Server of tag
An output code of 2 transposes the output array that results from an output code of 1.
Example
The following returns the tagname corresponding to the "Temperature" alias of module
"Reactor1" which is a submodule of "Unit1". "Unit1" is at the root of the module database for
a PI server named THEVAX. The module database is queried at current time.
=PIAliasToTag("Temperature","\Unit1\Reactor1","*",0,"thevax")
Related Topics
PIPropertyToValue() (page 73)
Page 72
PIPropertyToValue()
PIPropertyToValue(property, modulepath, querydate, PIServer, outcode)
Arguments
Argument
Explanation
Property (string)
modulepath (string)
querydate (integer)
PIServer (string)
The PI Server.
Outcode (integer)
Returns
An output code of 0 displays the value of the property in a column.
An output code of 2 displays the value of the property in a row.
Example
The following returns the value corresponding to the "Implementer" property of module
"Reactor1" which is a submodule of "Unit1". "Unit1" is at the root of the module database for
a PI server named THEVAX. The module database is queried at current time.
=PIPropertyToValue("Implementer","\Unit1\Reactor1","*","thevax")
Page 73
Add-in to Excel
To create a trend, a trend wizard is provided to make inserting trends easier. There are two
sources of data that the Trend Control can plot:
Worksheet Data
PI Data
Page 74
Data on Worksheet
The Trend Wizard can be used to create a trend from data on an Excel worksheet.
If the data is to come from the worksheet, the cell range of the data must be specified. The
cell range can be typed in manually or the mouse can be used to specify the range. To use the
mouse to specify the range, click button at the right of the field. Another dialog box will
appear. Selecting the range on the spreadsheet will generate the cell reference format in the
dialog box.
The First element is trace name option is used if a name is to be provided for the trace on
the trend. If this option is specified, the string in the first cell is used for the name of the trace.
The first cell is the cell above the first value of the range if the data is arranged in the column
format. If the data is arranged in the row format, then the first cell is the cell to the left of the
first value of the range.
For ease of use with PI DataLink functions, the Include all cells in array option is specified
as the default. If this option is specified, then only one cell of the array must be specified for
the cell range. The rest of the array is automatically added to the cell range reference when
the Add -> button is selected.
The Plot as stepped data option gives the trace a jagged-saw look. This option is usually
specified for discrete tags.
Page 75
Add-in to Excel
Data from PI
The Trend Wizard can also be used to create a trend from data directly from the PI Server.
To get data directly from the PI Server, the tagname needs to be specified. The tagname can
be conveniently searched for from the point database of the PI Server. By pressing the
Search... button, a Tag Search dialog box appears. This is the same Tag Search dialog box
as the one that comes from the PI menu. Any tags selected from the Tag Search dialog box
are automatically added to the list of traces.
By default DataLink displays color-blind markers to differentiate traces on monochrome
viewers; color-blind markers are evenly spaced along a trace and do not indicate archived
data points. Select the Markers checkbox to display markers that indicate the location of
archived data points on the trace.
Another way of specifying tags is by cell reference. If the tag names are on the Excel
spreadsheet, they can be referenced by checking the Cell Ref option box and specifying the
cell(s) where the tagname(s) are. The server name can be specified in the same way.
After clicking Next, the start time and end time of the trend needs to be specified in PI time
format.
Page 76
If a new worksheet is selected, the trend is placed on a blank worksheet at the top left corner.
To display value attribute icons at the top of the trend, select the Show Value Attributes
checkbox; icons appear when the range of data contains events that have the Questionable,
Substituted, or Annotated bits set.
If the existing worksheet option is specified, then the cell where the trend is to be placed must
be specified. The selected cell before entering the trend wizard is the default cell reference.
Make sure to choose a cell, which does not contain data. If the cell references a cell
containing data, the trend will cover the data. However, the data is not deleted. To move the
trend, right-click the trend and select Move/Resize.
Page 77
Add-in to Excel
To change the y-axis scaling, the Change Scale... option can be selected. There you can
change both the time range and y-axis of the trend. If a change in the scale is deemed
undesirable, the Revert option can be selected to undo the changed made. The Revert option
always reverts back to the settings defined in the Trend Wizard.
To scroll through time, scroll bars can be enabled with the Scroll Bar option. The scroll bar
appears at the bottom of the trend. Again, the Revert option can be used to undo changes
made by the scroll bar.
To change the format of the trace or the trend itself, the Format... option can be used.
Page 78
For instance, this option can be used to change the color or line thickness of a trace. Also it
can be used to add legends to the trend. Define Trend... and Define Trend Time Range... brings
back the Trend Wizard screens. Delete Trend option deletes the trend. Export Data... option
pastes the values used to plot the trend onto the spreadsheet. The Move/Resize option moves
and changes the trend to size of the specified cell range. The Copy/Paste option copies the
trend to the clipboard and then prompts for the destination of the paste. The pasted trend is a
copy of the trend in terms of all its formatting and references to cells.
Additional Information
For additional information on the use of the trend control, you can press the Help button on
the Trend Wizard. Also there are additional help files in ...\PIPC\HELP\PITrend*.
For instance, to learn more about Automation of the trend control, there is a
...\PIPC\HELP\PITrendAuto.hlp.
Page 79
Add-in to Excel
Tags are copied into the spreadsheet either along a single column or along a single row
depending on the option selected in the "Copy items to sheet" section of the PI DataLink
Settings... dialog.
The starting position where the copying takes place is the current cell. If the "Copy PIServer
Name" option is enabled, the server names are copied into the spreadsheet in a column to the
right of the tag names when the In a column option is selected in the "Copy items to sheet"
section. If the In a row option is selected in the "Copy items to sheet" section, the server
names are copied below the tag names in the spreadsheet.
Page 80
The dialog box mostly consists of a tree view of the module database. The dialog box enables
users to copy module database items to the spreadsheet. The tree view displays three types of
module database items.
Aliases
Properties
Modules
Page 81
Add-in to Excel
There are two ways to select aliases and properties from the module database with each
method copying a different set of items to the spreadsheet.
Selecting just one item copies that item to the spreadsheet.
Selecting "Aliases" or "Properties" item of a module copies all aliases or properties of
By using the right click menu, you can add additional PI Servers to the list, edit existing PI
Servers, remove existing PI Servers, and set an existing PI Server as the default PI Server.
Page 82
You can click on the checkbox to connect to and disconnect from PI Servers in the list. After
you successfully connect to a PI Server, the Status field changes to checked, the user column
returns the user that the connection is connected as, and the PI version column returns the
version of the PI server that it connected to.
The set of radio buttons In a row or In a column determines whether the selected tags in the
TagSearch dialog box are copied to the spreadsheet along a row or a column.
The Copy PIServer name check box determines whether the PI Server's name is copied
into the PIServer edit field if TagSearch is called from a PI dialog box. This option also
determines whether the server names are copied into the spreadsheet for selected tags if
TagSearch is called directly from the PI menu.
The Use PIServer Time Zone check box determines whether or not all the DataLink
functions interpret time using the PI server time zone instead of the client machine time
zone information. This option affects systems where the PI 3 Server machine has
different time zone settings than the client machine.
Page 83
Add-in to Excel
The Display #N/A instead of Blanks check box determines whether or not "#N/A" or
blanks are displayed when there is less data than the size of the DataLink function array.
Select this check box when the DataLink function results are plotted by the Excel
charting package.
The Locale Independent check box determines whether localized time strings should be
Select this check box to force PI DataLink to parse the time string according to PI
time format rules. This defines the date-time order as dd-MMM-yyyy hh:mm:ss, and
the language of any strings as English.
Clear this check box to enable PI DataLink to parse the time string according to your
local regional settings, including date-time format preferences. If locale-specific
parsing fails, PI DataLink will attempt to parse according to PI time format rules.
The Number format edit box lets you specify a default number formatting code. This
string may be any valid code from the Format, Cells, Number list.
The Time format edit box lets you specify a default time formatting code. This string
may be any valid code from the Format, Cells, Number list.
Select OK to save your settings; Cancel to abort your changes.
About
This menu choice displays PI DataLink version information.
Help
This menu choice calls PI DataLink Help.
Page 84
PIPutVal()
PIPutVal(tagname, value, time stamp, PIServer, outcell)
Arguments
Argument
Explanation
tagname (string)
value (reference)
PIServer (string)
The PI Server.
outcell (reference)
Returns
The string FALSE will be returned if the macro function failed and an error message will be
written to the outcell. If the write to the PI Server succeeds, the string TRUE will be returned
and the status digital state written, integer written, or real value written will be written to the
outcell.
Note: This function (PIPutVal) does not check whether the number to be written falls
within the user-specified range for a tag. The range for a tag is from the zero to
the zero + span, where zero and span are tag attributes specified by the user
during point (tag) creation. PI DataLink will return a value written message even
though "Over Range" or "Under Range" might have been entered into the PI
Server.
Note: PIPutVal supports all PI 3 data types (including string input to string tags) as well
as sub-second data. Timestamps are interpreted using client machine time zone
information unless the "Use PI Server Time Zone" option is enabled or it is a PI 2
Server.
Example
The following puts the value located in the cell A5 into the PI Server of the default PI Server
for midnight today for the tag testtag:
=PIPutVal("testtag",a5,"t",,e5)
The result of the macro function is placed into cell E5 on the macro sheet.
Page 85
Add-in to Excel
Page 86
Page 87
Tutorial
The goal of this section is to get you started using PI DataLink in Lotus 1-2-3 as quickly as
possible. PI DataLink's features are not discussed in detail in this tutorial. Rather, it will serve
to familiarize the user with the overall operation of this add-in.
If the Status indicates that the PI Server is DISCONNECTED, click the Connect button. If
the default user account for your selected PI Server requires a password, the login dialog
appears to prompt you for the password.
Page 88
Tutorial
In this dialog, you can also change the user name to log in as a different user from the default
user.
A valid username/password changes the Status in the Connections dialog box to either
READ or READ/WRITE. Dismiss the Connections dialog box by clicking Cancel.
If you receive a login failure dialog box, confirm that you have a valid PI
username/password. The appearance of the login failure dialog box even though the PI
username/password is valid indicates that PI DataLink cannot connect to the PI Server. Check
the Troubleshooting (page 137) section.
Page 89
4. Next, dismiss the dialog box and move the cursor to cell A2 in the spreadsheet.
5. Select Tag Search... from the PI menu and enter BA into the Tag Mask field so that it
reads "BA*".
Page 90
Tutorial
6. Click Search to find tags that begin with "BA". The Search Results list should contain at
least five tags: BA:ACTIVE.1, BA:CONC.1, BA:LEVEL.1, BA:PHASE.1, and
BA:TEMP.1.
7. Select these five tags from the Search Results list by clicking on the first tag
(BA:ACTIVE.1) and then simultaneously holding the CTRL key and clicking on each of
the four other tags. Then, click OK to copy the five tags along a single column, from A2
to A6.
8. Move the cursor to cell B2. From the PI menu, select Tag Attributes....
Notice that the current cell shows as the default in the Data output edit box.
9. Click the button to the right of the second edit box "Cells" under Tagname.
10. The current cell shows as the default. Highlight cells A:A2..A:A6. Manual input ranges
are also acceptable.
Page 91
11. When the edit box contains a valid range press OK. Notice the selected range is written
into the edit box on the Tag Attributes dialog box. If a single cell is selected, the text in
that cell is also displayed in the tagname edit box. If a range is selected, then just the
range is displayed and nothing is written to the tagname edit box. A single cell, a single
column, and a single row of tag names (on the same sheet) are examples of a valid range.
Invalid ranges are multiple ranges, ranges that consist of more than one sheet, a range
consisting of more than one column and row, or any cell address that does not contain tag
names.
12. From the list box labeled "Attributes" scroll down until the word "Descriptor" is visible.
Select "Descriptor."
13. In the edit box labeled "Macro Output [Opt]," manually enter the cell address as A:A10.
Alternatively, the "cell" button could have been selected, as described above. This option
will write the macro code associated with {PITAGATT} to the macro output cell address.
Note that the cell address is used in the macrocode when a cell address is designated in
the tagname address edit box. The absolute tag name is used if a tagname is written into
the tagname edit box. If both the cell address and a specific tag name are used, the
tagname will have priority and appears in the resulting macro.
14. If the user wants to get data from a server other than the default, the name of the server
should be entered into the designated edit box. No input is required for the PI Server edit
box if the default server is desired.
15. Click OK. PI DataLink will write the tag descriptors into cells A:B2..A:B6. It will also
write the necessary macro code used to obtain the tag descriptors into cells
A:A10..A:A14. Move the cell cursor to cell A:C2.
Page 92
Tutorial
17. In the second edit box under tagname, manually enter the cell address A:A2..A:A6 or
click the button beside the edit box and select A:A2..A:A6.
18. In the edit box labeled "Macro Output [Opt]," note that the cell address A:A15 already
exists. This is a feature that automatically pastes macro code below the previous macro
code entry until the user executes a dialog box without a cell address in the "Macro
Output [Opt]" edit box.
19. In the Data Output edit box, notice that the default cell address is already A:C2.
20. Below the Data Output edit box there are three radio buttons describing the relative
output location of the timestamp to that of the data. Select "Time on left."
21. Click OK and PI DataLink will write the current values into cells A:D2..A:D6 with their
associated timestamps into A:C2..A:C6. Also, notice that the associated macrocode is
written into cells A:A15..A:A19.
22. Move the cell cursor to cell A:E2. From the PI menu, select Tag Attributes... again.
23. In the second edit box under tagname, either manually enter the cell address A:A2..A:A6
or click the button beside the edit box and select A:A2..A:A6.
24. Select "Units" in the Attributes list box.
25. In the edit box labeled "Macro Output [Opt]," enter the cell address A:A20.
In the Data Output edit box, notice that the default cell address is already A:E2.
Page 93
26. Click OK and PI DataLink will write the engineering units into cells A:E2..A:E6 and the
associated macro code into cells A:A20..A:A24.
27. Move the cursor to cell A:A10. From the PI menu, select Tag Attributes.... Notice that the
dialog box is completely filled in based on the information provided in the macro in
A:A10. This is a time saving feature that is helpful when similar macrocode already
exists for the desired operation.
28. Experiment by moving the cursor to cell A:A15 and selecting Current Value... from the
PI menu.
29. Place the cursor on cell A:A2. From the PI menu, select Current Value.... Notice that the
dialog box detects that there is a tagname in the current cell and attempts to fill in the
dialog box as much as possible. The tagname is written to the tagname edit box. Since
there is data with timestamps directly to the right of the tagname, the dialog box writes to
the output cell edit box A:B2 with timestamps on the left.
30. Experiment by selecting ranges of tag names and selecting Current Value... or Tag
Attribute....
31. Experiment by selecting the entire range A:A2..A:A6 and then opening either the Current
Value... or the Tag Attribute... dialog box from the PI menu option.
32. To update the table created in prior steps, place the cursor on cell A:A10. Press the ALT
and F3 keys simultaneously. The Run Scripts & Macros dialog box appears:
Page 94
Tutorial
33. Click the Macro radio button and then click Run or press the Enter key. Lotus 1-2-3
executes the macro commands contained in cells A:A10 through A:A24.
The macro commands and their functions are summarized below:
Cell
Macro command
Function
A10
{PITagAtt}
A11
{PITagAtt}
A12
{PITagAtt}
A13
{PITagAtt}
A14
{PITagAtt}
A15
{PICurrVal}
A16
{PICurrVal}
A17
{PICurrVal}
A18
{PICurrVal}
A19
{PICurrVal}
A20
{PITagAtt}
A21
{PITagAtt}
A22
{PITagAtt}
A23
{PITagAtt}
A24
{PITagAtt}
After Lotus 1-2-3 executes the macro commands, cell B2 contains the descriptor for the tag,
BA:ACTIVE.1, cell D2 the current value for BA:CONC.1, cell C2 the corresponding time,
and cell E2 the engineering units. Similar data are found for the tags BA:LEVEL.1,
BA:PHASE.1, and BA:TEMP.1 in cells B3 through E3, B4 through E4, B5 through E5, and
B6 through E6, respectively.
Page 95
Note that a single quote (or apostrophe) prefaces many of the arguments to the macro
commands in A10 through A24. The reason is that Lotus 1-2-3 uses a single quote to indicate
a label or a string.
For example, the macro command in cell A10 and its arguments are:
{PITagAtt c2,'descriptor,',d2}
A reference to a tagname (cell C2);
A tag attribute ('descriptor);
No PI Server specified (blank label, or just a single quote or apostrophe); and
A cell representing the output cell (cell D2).
In the above macro command, there is a single space between the macro name (PITagAtt)
and the first macro argument (c2). Also, there are no spaces between each argument in the
macro and commas serve as argument separators.
If no PI Server is specified in the PIServer argument (i.e., blank, or just a single quote)
PI DataLink gets PI tag information from the default server. This is the PI Server specified in
your PILogin.ini file, which can be modified by using the PI > Connections... dialog box.
Page 96
Tutorial
4. Click the tagname cell reference button marked "Cell" and select cell A:C10. Enter a t
(for midnight today) in the Start time field, a +8h (eight hour offset) in the End time field.
Click the Show Times check box.
5. Click OK. PI DataLink will retrieve archived data from midnight to 8:00am into the
range, A:C10..A:C18.
PI DataLink Summary
As the above examples indicate, the fastest way to use PI DataLink to transfer data between
PI and 1-2-3 is to select an option from the PI menu. A dialog box appears. Enter the
appropriate parameters and PI DataLink retrieves the requested PI values. The next sections
describe the features of PI DataLink in greater detail.
Page 97
PI Menu
When PI DataLink is added to Lotus 1-2-3, it adds the PI menu item to 1-2-3's menu bar.
Page 98
PI Menu
The following pop-up menu selections are available from this menu item:
Current Value retrieves the current value for a tag.
Archive Value retrieves a single value from the archive (may be interpolated).
Exact Time Value retrieves a single value for a specific timestamp from the archive.
Calculated Value retrieves a single calculated (total, minimum, maximum, range,
time.
Timed Data retrieves sampled data synchronized with an array of timestamps.
Calculated Data retrieves totals, minima, maxima, ranges, standard deviations, averages
condition.
Filtered Compressed Data (number) retrieves a specified number of compressed data
Page 99
Dialog Boxes
The following sections describe the user interaction and operation with the dialog boxes.
Edit Fields
There are two types of edit fields in the dialog boxes: text edit fields and reference edit fields.
A Cell (or Cells) indicates reference edit fields next to the edit box. In a text edit field, you
type in the requested information. For example, in the Tagname field, type the name of the
tag for which you want data.
However, in a reference (Cell) edit field, you need to enter a reference to a cell on the
spreadsheet that contains the necessary information. In an array reference edit field, you may
enter a reference to an array of cells on the spreadsheet. In either case, you may also use the
mouse to click the Cell or Cells button which brings up the cell reference dialog box. Then
you can click the cell (or click the cell and drag to adjacent cells) on the spreadsheet. In this
procedure, Lotus 1-2-3 automatically enters the cell reference(s) into the edit field for you.
For example, in the PICurrVal dialog box in the tutorial section, the reference edit fields for
Tagname and Output ask for, a cell on the spreadsheet that contains the tagname and a cell
on the spreadsheet into which you wish to place the output of the current value, respectively.
Many of the parameters contain both a text edit field and a reference edit field. If entries exist
in both the text edit field and the reference edit field, the text edit field will override the
cell/range reference.
Optional Fields
The PIServer, Macro Output and Output fields in all of the dialog boxes are labeled as
"opt." or optional. If the PIServer text edit field is left blank, PI DataLink will connect to the
default PI Server. You can change the default PI Server in the Connection Dialog Box from
the PI menu.
The Macro Output field is a reference edit field, which allows you to specify the upper left
hand corner of the range where PI DataLink will place the macro code that retrieves your
data. The macro is useful if you want to run the command again to retrieve a new set of data
later.
The Output field allows you to specify the upper left-hand corner of the range where PI
DataLink will place the resulting data. If you do not specify an Output cell, this field defaults
to the active cell in the current worksheet.
Page 100
Dialog Boxes
List Boxes
List boxes appear for the Attribute field in Tag Attributes... and for the Mode field in the
Calculated value..., and Calculated data... dialog boxes. The default item in these list boxes is
the first item in the list. Thus, the default point attribute to retrieve from Tag Attributes... is
Descriptor and the default calculation mode is Average.
If the Calculated Value... is now selected from the PI menu option, the following dialog box
appears:
Page 101
You can then make minor changes to the dialog box, and execute the dialog box.
The above automatic filling of dialog boxes is not available for the Time Filtered... dialog box
in PI DataLink 1.9.
PI123DLG.123 will try to determine how to fill in the dialog box based on where the cursor
is placed in a spreadsheet containing data. For example, if the cursor is placed on a tagname
with two recognizable timestamps to the right of the tagname and a time interval to the right
of the timestamps, PI123DLG.123 will insert the spreadsheet information into the dialog box
appropriately.
The spreadsheet below depicts the above scenario:
Page 102
Dialog Boxes
When the Sampled Data... dialog box is opened with the range A1...A4 selected, the Sampled
Data dialog box would appear as below:
Notice that the Data Output cell is assumed to be the first free cell to the right of the
spreadsheet information. In the above case, the default Data Output cell is A:E1. This
scenario would also work if the spreadsheet data were below the tagname in column A.
Page 103
Time in PI DataLink
Returned Values
The timestamps returned by PI DataLink are in Lotus 1-2-3 format; i.e., it is a number that
represents the number of days since 1900. For example, 24-Jul-00 07:12:00 AM is entered
into a cell as the number 36731.3.
PI DataLink automatically formats these timestamps into a date and time format i.e.,
07/24/2000 07:12:00 AM. You can change this time format to another by selecting the cells
and using the Format... feature from the Range option of the menu bar. See your Lotus 1-2-3
documentation for more information.
Page 104
Time in PI DataLink
Note that for PI time in relative time format (e.g., '-1d), the reference time is different for the
start time and the end time. The current wall clock is the reference time for the translation of
the relative time in the start time field. However, the start time is used as the reference time
for the translation of the relative time in the end time field.
Refer to Examples of PI Time Strings (page 149) for examples of valid PI time strings. Place
parentheses around the time string if your time string is an absolute timestamp e.g., use
'(24-jun-00 13:38) to represent 1:38pm on June 24th, 2000.
Choose time at left if you want PI DataLink to return a timestamp into a cell to the left of the
retrieved values. Choose time on top if you want to display the timestamp in a cell on top of
the retrieved values.
However, if you use an array reference in the Tagname field and select either the time at left
or the time on top radio button, PI DataLink returns the timestamp and value depending on
whether the reference of tag names is horizontal or vertical. Specifically, when the tag names
are in a single column, the timestamps will appear to the left of the values. Likewise, when
the tag names are along a single row, the timestamps will appear on top of the values.
Page 105
Error Reporting
PI DataLink is written in LotusScript and C++ and utilizes both the PI System's API and
Lotus 1-2-3's SDK. When an error occurs at the PI API level, PI DataLink displays the PI
API error in the cell. For example, if you try to find the current value for a tag which does not
exist, the message "Tag not found: -5" appears in the output cell.
retrieves a value from the archive for the tag located in cell A1 at 8:00am of the current day.
You must re-run this macro when (1) you change the contents of the cell A1 and (2) when
you call up the spreadsheet for the first time each day because t+8h is a relative timestamp.
Page 106
{PICurrVal}
{PICurrVal tagname, outcode, PIServer, outcell}
Arguments
Argument
Explanation
tagname (string)
The tag for which you want the snapshot (current) value.
outcode (integer)
PIServer (string)
The PIServer.
outcell (reference)
Returns
Outcode
Column 1
Current value
Timestamps
Column 2
Current value
An output code of 2 transposes the output array that results from an output code of 1.
Example
To get the current value for cdf144 from the PI Server MYVAX and place the result into cell
A5:
{PICurrVal 'cdf144,0,'myvax,A5}
Page 107
{PIArcVal}
{PIArcVal tagname, timestamp, outcode, PIServer, outcell}
Arguments
Argument
Explanation
tagname (string)
The PI timestamp.
outcode (integer)
PIServer (string)
The PIServer.
outcell (reference)
Returns
Outcode
Column 1
Archive value
Timestamp
Column 2
Archive value
An output code of 2 transposes the output array that results from an output code of 1.
Example
To get the archive value from the PI Server PHOEBE for the tag sinusoid at midnight
yesterday and place the result into an output range whose upper left-hand corner is cell A5:
{PIArcVal 'sinusoid,'y,0,'phoebe,A5}
Page 108
{PIExTimeVal}
{PIExTimeVal tagname, timestamp, PIServer, outcell}
Arguments
Argument
Explanation
tagname (string)
The PI timestamp.
PIServer (string)
The PIServer.
outcell (reference)
Returns
A value from the PI Server if it exists. If no value exists, the message "No archive entry at
given time" is returned.
Example
To get the archive value from the PI Server PHOEBE for the tag sinusoid at exactly midnight
yesterday and place the result into an output range whose upper left-hand corner is cell A5:
{PIExTimeVal 'sinusoid,'y,'phoebe,A5}
Page 109
Required Fields
Tagname. The reference to tagname may be an array
Start time
End time
Conversion factor
Calculation mode
Check Box
Check show pctgood if you want PI DataLink to display the percentage of the time range that
contained good values. We recommend that you always look at the percent good value before
using the calculation result. The percent good value is normally returned to the right of
calculated value cell. If the time on top button is selected, the percent good value is returned
in the cell below the calculated value cell.
Timestamp(s) are returned when the calculation mode is minimum, maximum, or range.
Page 110
Mode
Column 1
Column 2
Minimum
Minimum value
Maximum
Maximum value
Range
Column 3
Range value
Special Notes
When the calculation mode is Total and part of the archived data within the range is bad, the
reported value is equal to the calculated total value divided by the fraction of the time period
with good archived data. This data normalization is equivalent to the assumption that for the
bad data time range, the tag value takes on the average value of the entire range. However,
this assumption may not be valid when a large fraction of the time range contains bad data.
Therefore, we recommend that you always look at the percent good value before using the
calculation result.
The conversion factor is used most often when the calculation mode is Total and the time
unit of the PI tag being totalized is not the same as the server default. For example, the time
unit of the server default is unit/day and the PI tag being totalized has units/hour, then use
conversion factor of 24. For PI 2 Server with default rate of units per hour, use conversion
factors of:
0.041667 for units/day
1 for units/hour
60 for units/minute
3600 for units/second
{PICalcVal}
{PICalcVal tagname, stime, etime, mode, cfactor, outcode, PIServer,
outcell}
Arguments
Argument
Explanation
tagname (string)
stime (string)
etime (string)
mode (string)
cfactor (number)
Should be 1 for max, min, avg, std and range. See special
note above for total.
outcode (integer)
PIServer (string)
The PI Server.
outcell (reference)
Returns
If the outcode is 0, only the calculated value is returned.
Page 111
Column 1
Column 2
Total
Total value
Minimum
Minimum value
Maximum
Maximum value
Stdev
Range
Average
Average value
Mean
Mean value
Column 3
Range value
An output code of 2 transposes the output array that results from an output code of 1, i.e.,
results are returned in rows instead of in columns.
Outcode of 3 is not used.
If the outcode is 4, the percent good is returned to the right of the value cell.
If the outcode is 5, the following applies:
Mode
Column 1
Column 2
Column 3
Total
Total value
Percent good
Minimum
Minimum value
Percent good
Maximum
Maximum value
Percent good
Stdev
Standard deviation
Percent good
Range
Average
Average value
Percent good
Mean
Mean value
Percent good
Range value
Column 4
Percent good
An output code of 6 transposes the output array that results from an output code of 4, i.e.,
results are returned in rows instead of in columns.
An output code of 7 transposes the output array that results from an output code of 5, i.e.,
results are returned in rows instead of in columns.
Example
To get the time of and minimum value (with a multiplicative factor of 1) during the most
recent 8 hours for the tag sqf100 from the default PI Server and place the result into an output
range whose upper left-hand corner is cell A5:
{PICalcVal 'sqf100,'*-8h,'*,'minimum,1,1,',A5}
Page 112
Choose a tag attribute from the list box. The default attribute is descriptor. Tag attributes are:
Attribute
Explanation
descriptor
exdesc
typicalvalue
Typical value
units
zero
Zero
span
Span
digstartcode
Code for the first digital state string for the tag
dignumber
pointtype
pointsource
location1
Location parameter 1
location2
Location parameter 2
location3
Location parameter 3
location4
Location parameter 4
location5
Location parameter 5
filtercode
Filter code
squareroot
scan
Scan flag
excdev
excmin
excmax
archiving
Archiving flag
compressing
Compression flag
res
Resolution code
compdev
compmin
Page 113
Attribute
Explanation
compmax
totalcode
Totalization code
convers
displaydigits
instrumenttag
sourcept
taglong
tagshort
12 character tagname
creator
createdate
changer
changedate
pointnumber
pointid
{PITagAtt}
{PITagAtt tagname, attribute, PIServer, outcell}
Arguments
Argument
Explanation
tagname (string)
Attribute (string)
PIServer (string)
The PI Server.
outcell (reference)
Returns
Tag attribute
Example
To get the tag descriptor for sinusoid from the default PI Server and place the result into cell
A5:
{PITagAtt 'sinusoid,'descriptor,',A5}
Page 114
{PISampDat}
{PISampDat tagname, stime, etime, interval, outcode, PIServer,
outcell}
Arguments
Argument
Explanation
Tagname(string)
Stime (string)
Etime (string)
Interval (string)
Outcode (integer)
PIServer (string)
The PI Server.
Outcell (reference)
Returns
Outcode
Column 1
Sampled data
Timestamps
Column 2
Sampled data
An output code of 2 transposes the output array that results from an output code of 0 and an
output code of 3 transposes the output array that results from an output code of 1.
Example
To get sampled data for sinusoid at three-hour intervals from midnight yesterday to midnight
today and place the result into an output range whose upper left hand corner is cell A5:
{PISampDat 'sinusoid,'y,'t,'3h,1,',A5}
Page 115
Check Boxes
Select backwards in time if you want to gather data from the archive going backwards from
the time that was entered in Start time.
Special Notes
This dialog box function only returns the actual number of archived data points in the PI
archive if this number is lower than the number of values asked for. For example, if you want
to retrieve 400 values starting from midnight today and there are only 356 values in the
archive, the final 44 cells are left blank by the PINCompDat function.
{PINCompDat}
{PINCompDat tagname, stime, numvals, outcode, PIServer, outcell}
Arguments
Page 116
Argument
Explanation
tagname (string)
stime (string)
Numvals (integer)
Outcode (integer)
PIServer (string)
The PI Server.
Outcell (reference)
Returns
Outcode
Column 1
Compressed data
Timestamps
Column 2
Compressed data
An output code of 2 transposes the output array that results from an output code of 0 and an
output code of 3 transposes the output array that results from an output code of 1.
Example
The following retrieves 10 compressed data points and corresponding time stamps for the tag
cdf144 starting from 1:00 a.m. this morning:
{PINCompDat 'cdf144,'(1:00),10,1,',A5}
The results are placed into an output range whose top left-hand corner is cell A5.
Special Notes
This dialog box function only returns the actual number of archived data points in the PI
archive. For example, if you ran the PICompDat function yesterday using the arguments 'y
and 't for starttime and endtime and retrieved 100 values. If you run the same function today,
the function will retrieve the values between midnight yesterday and midnight today and
regardless of how many values are retrieved, will display them as such. If there are only 50
values today, the first 50 values from yesterday will be replaced with new values; the last 50
values from yesterday's function call will remain on the spreadsheet.
{PICompDat}
{PICompDat tagname, stime, etime, outcode, PIServer, outcell}
Page 117
Arguments
Argument
Explanation
tagname (string)
stime (string)
etime (string)
outcode (integer)
PIServer (string)
The PI Server.
outcell (reference)
Returns
Outcode
Column 1
Compressed data
Timestamps
Column 2
Compressed data
An output code of 2 transposes the output array that results from an output code of 0 while an
output code of 3 transposes the output array that results from an output code of 1. The
number of data points retrieved from the given time interval is returned in the first cell of
row/column.
Example
The following retrieves compressed data points and corresponding time stamps for the tag
cdf144 starting from 1:00 a.m. to 3:00 a.m. this morning.
{PICompDat 'cdf144,'(1:00),'(3:00),1,',A5}
The results are placed into an output range whose top left-hand corner is cell A5.
Page 118
{PITimeDat}
{PITimeDat tagname, timestamps, PIServer, outcell}
Arguments
Argument
Explanation
tagname (string)
timestamps (reference)
PIServer (string)
The PI Server.
outcell (reference)
Returns
Sampled data. If the timestamps are in a single column, the data are returned along a single
column. If the timestamps are in a single row, the data are returned along a single row.
Example
To get sampled data for cdf144 from the default PI Server for the increasing timestamps
specified in cells A5 to A25 and place the result into an output range whose upper left hand
corner is cell B5:
{PITimeDat 'cdf144,A5..A25,',B5}
Page 119
Check Box
Check show pctgood if you want PI DataLink to display the percentage of the time range that
contains good values. We recommend that you always look at the percent good value before
using the calculation result. The percentage good values are normally returned to the right of
the calculated value cells. If the row button and the show time button are both selected, the
percent good values are returned at the cells below the calculated value cells.
Special Notes
See notes in Calculated Value Dialog Box (page 110).
{PICalcDat}
{PICalcDat tagname, stime, etime, interval, mode, cfactor, outcode,
PIServer, outcell}
Arguments
Argument
Explanation
tagname (string)
stime (string)
etime (string)
interval (string)
mode (string)
cfactor (number)
outcode (integer)
PIServer (string)
The PI Server.
outcell (reference)
Returns
The outcode affects the output as follows:
Calculated values along a column
Timestamps and values along 2 columns
Calculated values along a row
Page 120
Example
To get timestamps and totals (with a multiplicative factor of 24) at one hour intervals from
midnight yesterday to midnight today for the tag cdf144 from the default PI Server and place
the result into an output range whose upper left hand corner is cell A10:
{PICalcDat 'cdf144,'y,'t,'1h,'total,24,1,',A10}
expression syntax.
Check Boxes
Uncheck the Markers box to suppress the return of a "Filtered" status into the cell for the
time range when the values do not satisfy the filter condition.
Page 121
{PISampFilDat}
{PISampFilDat tagname, stime, etime, interval, filtexp, filtcode,
outcode, PIServer, outcell}
Arguments
Argument
Explanation
tagname(string)
stime (string)
etime (string)
interval (string)
filtexp (string)
filtcode (integer)
outcode (integer)
PIServer (string)
The PI Server.
outcell (reference)
Returns
Outcode
Column 1
Sampled data
Timestamps
Column 2
Sampled data
An output code of 2 transposes the output array that results from an output code of 0 and an
output code of 3 transposes the output array that results from an output code of 1.
Example
To get sampled data for sinusoid, when the tag cdep158 is greater than 80, at three-hour
intervals from midnight yesterday to midnight today from the default PI Server and place the
result into an output range whose upper left hand corner is cell A5:
{PISampFilDat 'sinusoid,'y,'t,'3h,'('cdep158'>80),1,1,',A5}
Page 122
expression syntax.
Check Boxes
Select backwards in time if you want to gather data from the archive going backwards from
the time that was entered in Start time.
Uncheck the markers box to suppress the return of a Filtered status into the cell for the time
range whose value does not satisfy the filter condition.
Special Notes
This dialog box function only returns the actual number of archived data points in the PI
archive if this number is lower than the number of values asked for. For example, if you want
to retrieve 400 values starting from midnight today and there are only 356 values in the
archive, the final 44 cells are left blank by the PINCompFilDat function.
Page 123
{PINCompFilDat}
{PINCompFilDat tagname, stime, numvals, filtexp, filtcode, outcode,
PIServer, outcell}
Arguments
Argument
Explanation
tagname (string)
stime (string)
numvals (integer)
filtexp (string)
filtcode (integer)
outcode (integer)
PIServer (string)
The PI Server.
outcell (reference)
Returns
Outcode
Column 1
Compressed data
Timestamps
Column 2
Compressed data
An output code of 2 transposes the output array that results from an output code of 0 and an
output code of 3 transposes the output array that results from an output code of 1.
Example
The following retrieves 10 compressed data points and the corresponding times, starting from
2:00 a.m., for the tag cdf144 while the tag cdep158 is greater than 80. The status "Filtered" is
displayed for times when the filter condition is false. The results are placed into an output
range whose upper left-hand corner is cell A5.
{PINCompFilDat 'cdf144,'(2:00),10,'('cdep158'>80),1,1,',A5}
Page 124
expression syntax.
Check Boxes
Uncheck the markers box to suppress the return of a Filtered status into the cell for the time
range whose value does not satisfy the filter condition.
Special Notes
This dialog box function only returns the actual number of archived data points in the PI
archive. For example, suppose you ran the PICompFilDat function yesterday using the
arguments 'y and 't for starttime and endtime and retrieved 100 values. If you run the same
function today, the function will retrieve the values between midnight yesterday and midnight
today. If there are only 50 values today that satisfy the filter criteria, the first 50 values from
yesterday will be replaced with new values, while the last 50 values from yesterday's function
call will remain on the spreadsheet.
Page 125
{PICompFilDat}
{PICompFilDat tagname, stime, etime, filtexp, filtcode, outcode,
PIServer, outcell}
Arguments
Argument
Explanation
tagname (string)
stime (string)
etime (string)
filtexp (string)
filtcode (integer)
outcode (integer)
PIServer (string)
The PI Server.
outcell (reference)
Returns
Outcode
Column 1
Compressed data
Timestamps
Column 2
Compressed data
An output code of 2 transposes the output array that results from an output code of 0 and an
output code of 3 transposes the output array that results from an output code of 1. The
number of data points retrieved from the given time interval is returned in the first cell of the
row/column.
Example
The following retrieves compressed data points and the corresponding timestamps, starting
from 0:00 a.m. yesterday till 0:00 a.m. today, for the tag cdf144 while the tag cdep158 is
greater than 80. The status "Filtered" is displayed for times when the filter condition is false.
The results are placed into an output range whose upper left-hand corner is cell A5:
{PICompFilDat'cdf144,'y,'t,'('cdep158'>80),1,1,',A5}
Page 126
expression syntax.
Start Time
End Time
Time Interval
{PIExpDat}
{PIExpDat expression, stime, etime, interval, outcode, PIServer,
outcell}
Arguments
Argument
Explanation
Expression (string)
Stime (string)
Etime (string)
Interval (string)
Outcode (integer)
PIServer (string)
The PI Server.
Outcell (reference)
Page 127
Returns
Outcode
Column 1
Calculated data
Timestamps
Column 2
Calculated data
An output code of 2 transposes the output array that results from an output code of 0 and an
output code of 3 transposes the output array that results from an output code of 1.
Example
To calculate the sum of the values of sinusoid and sqf100 at one-hour intervals from
midnight yesterday to midnight today from the default PI Server and place the timestamps
and the results into an output range whose upper left-hand corner is cell A5:
{PIExpDat'('sinusoid'+'sqf100'),'y,'t,'1h,1,',A5}
expression syntax.
Start Time
End Time
Time Interval
Time units (defaults to seconds)
Page 128
{PITimeFilter}
{PITimeFilter expression, stime, etime, interval, timeunit, outcode,
PIServer, outcell}
Arguments
Argument
Explanation
expression (string)
stime (string)
etime (string)
Interval (string)
Timeunit
Outcode (integer)
PIServer (string)
The PI Server.
Outcell (reference)
Returns
Outcode
Column 1
Calculated data
Timestamps
Column 2
Calculated data
An output code of 2 transposes the output array that results from an output code of 0 and an
output code of 3 transposes the output array that results from an output code of 1.
Example
{PITimeFilter($A$1,"y","t","1h","seconds",1,"thevax",E1}
The above macro calculates the amount of time that the expression from cell $A$1 is true
from the PI Server named THEVAX at one-hour intervals, starting from midnight yesterday
to midnight today and places the result in cells E1 and E2 of the active sheet. It also displays
the timestamps for the start time of each calculation interval. The calculation result is
expressed in seconds.
Page 129
By using the buttons on the bottom, you can perform the following tasks:
Add - adds additional PI Servers to the list
Edit - modifies existing PI Servers
Remove - removes existing PI Servers
Set as Default - defines an existing PI Server as the default PI Server.
You can use the buttons on the right to Connect to and Disconnect from PI Servers in the
list. After you successfully connect to a PI Server, the Status field changes to either READ or
READ/WRITE.
To find information such as local PC node name/address and PI Server name/address, click
the Information button.
Page 130
Tags are copied into the spreadsheet either along a single column or along a single row
depending on the option selected in the "Copy items to sheet" section of the PI DataLink
Settings... dialog. The cell position where the copying starts is the current cell. If the "Copy
PIServer Name" option is enabled, the server names are copied into the spreadsheet in a
column to the left of the tag names when the In a column option is selected in the "Copy
items to sheet" section. If the In a row option is selected, the server names are copied below
the tag names in the spreadsheet.
Page 131
The set of radio buttons In a row or In a column determines whether the selected tags in the
TagSearch dialog box are copied to the spreadsheet along a row or a column.
The Copy PIServer name check box supplies the option to copy the PI server name
alongside the tagname when using the TagSearch dialog box to populate cells in a
spreadsheet.
The Use PIServer Time Zone check box is used by PI DataLink to determine whether or not
the user wants DataLink to interpret all timestamps based on the PI server's Time Zone
settings.
The Connect to PIServer on startup check box determines whether PI DataLink
immediately connects to the default PI Server when Lotus 1-2-3 starts up.
Page 132
PI DataLink Help
This menu choice calls up help on PI DataLink.
About PI DataLink
This menu choice displays PI DataLink version information.
{PIPutVal}
{PIPutVal tagname, value, time stamp, PIServer, outcell}
Arguments
Argument
Explanation
tagname (string)
Value (reference)
PIServer (string)
The PI Server.
Outcell (reference)
Returns
If the macro function fails, an error message will be written to the output cell. If the function
succeeds, the string digital state sent, integer sent, or real value sent will be written to the
outcell.
Page 133
Note: PIPutVal does not check whether the number to be written falls within the
user-specified range for a tag. The range for a tag is from the zero to the zero +
span, where zero and span are tag attributes specified by the user during point
(tag) creation. PI DataLink will return a value written message even though "Over
Range" or "Under Range" might have been entered into the PI Data Archive.
Note: This function (PIPutVal) only supports integer, digital state and real data types. It
does not support writing string data to string tags and it does not support
sub-second timestamps. Timestamps are interpreted using server time zone
information.
Example
The following puts the value located in the cell A5 into the archive of the default PI Server
for midnight today for the tag testtag. The return status is placed into cell A10.
{PIPutVal 'testtag,a5,'t,',a10}
{PIPutValX}
{PIPutValX tagname, value, time stamp, PIServer, outcell}
Arguments
Argument
Explanation
tagname (string)
Value (reference)
PIServer (string)
The PI Server.
Outcell (reference)
Returns
If the macro function fails, an error message will be written to the output cell. If the function
succeeds, the string, value sent will be written to the outcell.
Note: PIPutValX does not check whether the number to be written falls within the
user-specified range for a tag. The range for a tag is from the zero to the zero +
span, where zero and span are tag attributes specified by the user during point
(tag) creation. PI DataLink will return a value written message even though "Over
Range" or "Under Range" might have been entered into the PI Data Archive.
Page 134
Note: This function (PIPutValX) supports all PI 3 Server data types (including string input
to string tags) as well as sub- second data. Timestamps are interpreted using
client machine time zone information unless the "Use PIServer Time Zone" option
is enabled or it is a PI 2 Server.
Example
The following puts the value located in the cell A5 into the archive of the default PI Server
for midnight today for the tag testtag. The return status is placed into cell A10.
{PIPutValX 'testtag,a5,'t,',a10}
Page 135
Appendix A: Troubleshooting
Consult the sections below if you are having difficulties with PI DataLink.
DataLink Add-in Doesn't Load Properly (page 137)
Connection Problems Reported in Log Files (page 138)
Limits from Excel for PI DataLink (page 86)
Limitations of PI DataLink for Lotus 1-2-3 (page 135)
If you are still having problems after following these suggestions, see Technical Support and
Resources (page 155) for details on contacting Technical Support.
Page 137
The above displays all messages that begin with the text "PINet" from 15 minutes ago to the
current time. (PI DataLink connection messages should begin with "PINet".)
For PI 2 Server, the log files are located as follows:
UCX
PISysExe:UCXPIServer.log
MultiNet
PISysExe:MTNPIServer.log
PathWay
PISysExe:PTWPIServer.log
TCPware
PISysExe:TCPIServer.log
The above displays all messages that are made by EXCEL.EXE from 15 minutes ago to the
current time. (PI DataLink connection messages should come from EXCEL.EXE.)
Page 139
For PI 3 Server
Check on the PC that PI DataLink is trying to connect to port 5450.
Select() Timeout in pipc.log
The select() timeout error usually indicates that PI 2 Server machine is not translating the
PC's address into a name fast enough. The solution is to add the PC's name and TCP/IP
address into the VAX/Alpha's local host table. See the previous section on name translation
for more information.
Also, you may increase PI DataLink's timeout parameter in the
C:\PIPC\DAT\pilogin.ini file:
[network] timeout=60
The above indicates that PI DataLink should wait 60 seconds before timing out while waiting
for a reply from the PI Server.
You should create the above [network] section and timeout entry if they do not currently
exist.
Recv: Error: 0 in pipc.log
The recv:Error:0 usually indicates that PI DataLink has successfully connected to port
545/5450 on the PI Server machine, but has not received a reply.
1. Confirm that the PI Server is indeed running on the PI Server machine.
2. For PI 2 Server, confirm that the PI Server service is configured correctly. See
PIBuild:PIServer.txt for more information.
Page 141
Calculation Expressions
The following describes the syntax of valid calculation expressions (used by PIExpDat) in PI
DataLink.
Note: The examples below use two tag delimiters, colon (:) and period (.). Your PI
System may use different ones.
In a tag calculation expression, mathematical operators and functions act upon tag names.
Page 143
Mathematical Operators
Mathematical operators are:
+
addition
subtraction
multiplication
division
raise to a power
Example
(('sinusoid')^3 + 'cdf144'/10)
The above expression determines the sum of the value of sinusoid cubed and the value of
cdf144 divided by 10.
Mathematical Functions
Supported Mathematical Functions are:
abs
absolute value
atn
cos
exp
int
log
natural logarithm
sgn
sin
sqr
tan
Example
(log('cdep158') - cos('cdep158'))
The above expression finds the difference between the natural logarithm of the value of the
tag cdep158 and the cosine of the value of the tag cdep158.
Calculation Expressions
Example
PctGood('cdep158', 'y', 't')
The PctGood function finds the time percentage, over a given range, when a tag's archived
values are good.
In the above example, the percentage of time between midnight yesterday and midnight
today, when the tag was receiving "good" values will be returned.
Curtime Keyword
You can refer to the timestamp of the calculation by using the keyword curtime explicitly in
the expression. For example, you specify 20-Oct-97 for Start time, 21-Oct-97 for End time,
12h for Time interval and the following expression in the PIExpDat PI function:
(curtime - `20-Oct-97')/1s
Page 145
For more information on Performance Equation functions, consult the PI Server Applications
Guide or the PI 3 Performance Equations Help File. Also, note that the PE syntax for PI 3
Server differs slightly from that on PI 2 Server.
Filter Expressions
The following describes the syntax of valid filter expressions in PI DataLink.
Note: The examples below use tag delimiters of : (colon) and . (period). Your PI system
may use different ones.
Relational Operators
A filter expression uses the same arithmetic operators and functions as a calculation
expression. In addition, one or more relational operators are necessary.
Relational operators are:
<
less than
equal to
>
greater than
<=
<>
not equal to
>=
Example
(abs('my:tag') >= 14.65)
The above expressions evaluates to TRUE (non-zero) if the absolute value of the tag mytag is
at least 14.65.
When comparing digital tags, use the negative of the digital state code number.
For PI 2.0.9 or higher, use the digital state string itself. For example:
('my:tag' = "Manual")
Filter Expressions
Logical Operators
A filter expression may also contain logical operators such as:
and returns TRUE if both its arguments are TRUE.
or returns TRUE if at least one of its arguments is TRUE.
not returns TRUE if its argument is FALSE, and vice-versa.
Example
The following expression evaluates to TRUE if the value of the tag sinusoid is less than 45
and the square root of the value of the tag vdf1002 is greater than 2:
('sinusoid' < 45 and sqr('vd:f1002') > 2)
Page 147
Meaning
'06-dec-91 15:00:00
'*
'25
'25-aug-92
'8:
'25 8:
't
'y
'*-1h
't+8h
'y-8h
'mon+14.5h
'sat-1m
Page 149
Time Interval
In the following examples, omit the leading quote if you are entering a PI time string directly
into a text edit field in an Excel dialog box.
PI Time String
Meaning
'1.5h
'32m
Thirty-two minutes
'49s
Forty-nine seconds
`+5h
`-5h
Note: A positive interval means to anchor off the starttime and a negative interval means
to anchor off the endtime. If no plus or minus sign is used, then interval is
assumed to be positive. So if starttime is "y", endtime is "t", and interval is "+5h"
for Sampled Data function, then interpolated values are generated at y, y+5h,
y+10h, y+15h, and y+20h. If the interval is "-5h" instead, then the interpolated
values are generated at y+4h, y+9h, y+14h, y+19h and t.
Page 150
Silent Installs
For silent installs, please use the silent.ini provided in the DataLink distribution kit. Please
make site-specific specifications as needed. Arguments in silent.ini are described further in PI
SDK Setup.ini Arguments and PI DataLink Setup.ini Arguments sections. To use silent ini,
type:
Setup.exe -f silent.ini
PI SDK Installation
There are a few arguments which can be added as arguments to the command line in order to
install the SDK silently. In order for any of the arguments to work, the command line must
have /qn in it. All arguments must be separated by a space. The following is an example of
how the setup.ini should look like:
[COMMANDLINE] 5 = /qn PI_SERVER=localhost
Argument
Meaning
/qn
Install silently
PI_SERVER
PI _ALIAS
PI_PORT
PI_TYPE
PI_USER
INSTALLDIR
Installation path
PIBUF_ENABL
E
Enables/disables buffering
ALLUSERS
Page 151
PI DataLink Installation
There are a few arguments which can be added as arguments to the command line in order to
install the PI DataLink. All arguments must be separated by a space. The following is an
example of how the setup.ini should look like:
[COMMANDLINE] 6 = /q SHARED=P:\APPS
Page 152
Argument
Meaning
/q
Install silently
SHARED
ALLUSERS
Appendix E: Outcodes
The outcode is just the decimal representation of binary bits. The bits are as follows:
1st bit: Show Timestamps bit
2nd bit: Orientation bit (columns/row)
3rd bit: Show Percent Good bit
4th bit: Hide Count bit
5th bit: Show Extended Status bit
6th bit: Show Annotations bit
7th bit: Show Start Time
8th bit: Show End Time
9th bit: Show Min/Max Time
xi 1
Note: Not all outcodes are valid for each function because not all options are available
for every function.
Page 153
Example
Suppose we want a Calculated Data function to display Percent Good, Start Time, and
Min/Max Time. Since Start Time and Min/Max Time are displayed, the Show Timestamps
bit must also be set.
bits set = { Show Timestamps, Show Pct Good, Show Start Time, Show Min/Max Time }
= {1, 3, 7, 9 }
outcode =
xi 1
= 211 + 2 31 + 2 7 1 + 2 91
i
0
= 2 + 2 2 + 2 6 + 28
= 1 + 4 + 64 + 256
= 325
Page 154
E-mail Support
E-mail technical support inquiries, including the problem description and message logs, to
techsupport@osisoft.com. You will receive a response within 24 hours.
Page 155
Knowledge Center
The Knowledge Center provides a searchable library of documentation and technical data, as
well as a special collection of resources for system managers. For these options, click
Knowledge Center in the Technical Support Web site.
The Search feature allows you to search Support Solutions, Bulletins, Support Pages,
sizing, backup scripts, daily health checks, daylight savings time configuration, PI Server
security, PI system sizing and configuration, PI trusts for interface nodes, and more.
> PI System > PI System Management Tools. In PI SMT, select the server name, then
under System Management Plug-Ins, open Operation > PI Version. The PI Version
tree lists all versions.
If you do not have PI SMT installed, open a command prompt, change to the pi\adm
directory, and enter piversion -v. To see individual version numbers for each
subsystem, change to the pi\bin directory and type the subsystem name followed by
the option -v (for example, piarchss.exe v).
Page 157
Index
A
ActiveX control 72
Advanced Calculated Data 53
Apostrophe 87
Archive Value 106
Array
Options 99
Attribute Mask to Tag 68
Averages 53, 108, 117
B
Bug Fixes
List of 5
C
Calculated Data 117
Calculated Value 108
Calculation Expressions 141
Calculation Modes 53, 108, 117
Can't Connect to the PI Server 136
Case-sensitive
Node names 6
Change arguments 17, 29
Change Scale option 76
Combo Boxes 23
Compressed Data
(Number) 37, 114
(Number) Filtered 121
(Times) 40, 115
(Times) Filtered 123
Configuring
Lotus 1-2-3 5
connect() timeout error 136
Connections 128
Dialog Box 128
Problems 136
Current Value 87, 105
Curtime Keyword 143
D
Data Access 9
PI 3 Server 9
Define Trend option 76
Delimiters 141
Dialog Box 98, 105
Advanced Calculated Data 53
Alias 69
Archive Value 106
Attribute Mask to Tag 68
Calculated Data 117
Calculated Value 108
Compressed Data (Number) 37, 114
Compressed Data (Times) 40, 115
Connections 128
Current Value 105
Edit Fields 98
Enter time in Excel 26
Enter time in Lotus 1-2-3 102
Exact Time Value 107
Expression Calculation 125
Filtered Compressed Data (Number) 121
Filtered Compressed Data (Times) 123
Filtered Sampled Data 119
Functions 31, 105
Module Database 79
Point ID to Tag 67
Property 70
Sampled Data 113
Page 159
Index
Settings 130
Tag Attributes 111
Tag Search 129
Time Filtered 126
Timed Data 116
E
Edit Fields 98
Enter Time to PI DataLink 102
Errors 135
connect() timeout error 136
Gethostbyname 136
recv Error 0 136
Reporting 104
select() timeout error 136
Exact Time Value 107
Expressions 46, 65, 66, 125
Calculation 125
Syntax 141
Time Filtered 126
F
Features Summary 95
Filter Expressions 144
Filtered Data
Compressed(Number) 121
Compressed(Times) 123
Sampled 119
Firewall Database 9
Format option 76
Functions 28
Dialog Boxes 31
Excel 31
Performance Equation 143
Provided in Excel 11
Provided in Lotus 1-2-3 85
G
Gethostbyname error 136
H
Help 82
I
Input Timestamps
Start and End Time 147
Time Interval 148
Installation
Arguments 150
Configuring 1-2-3 5
Local 4
Network 3
SDK 149
L
Limitations
PI DataLink for 1-2-3 133
List Boxes 99
Loading Problems 135
Lotus 1-2-3 Add-in 1, 85
M
Macros
Macro commands
Lotus 1-2-3 87
Macros vs. Dialogs 104
Output Fields 98
Output Option 102
Maxima and Minima 53, 108, 117
Mean Average 108, 117
Menu 96
Microsoft Excel
Add-in 1, 11
Module Database 79
MultiNet
Name Translation, PI Client 6
N
Node Authentication
PI 2 Server 6
Node Names
TCP/IP 6
O
Operating System 2
OSIsoft Technical Support 135
Output Fields 22, 98
Page 161
P
PathWay
Name Translation, PI Client 6
PC client name 6
Percent Good 108, 117
Performance Equation
Syntax 143
Performance Equations 141
PI 2 Server
Server configuration 6
PI 3 Server
configuration 9
security 9
PI DataLink
Functions 31
Installation arguments 150
Loading Problems 135
PI Expressions 141
Logical Operators 145
Math Functions 142
Mathematical Operators 142
Performance Equations 143
Relational Operators 144
PI Menu
Not displayed 135
PI SDK
Silent Installation 149
PI System Manager 6
PI time strings 147
PIADMIN
User Privileges 9
PIAdvCalcDat 60
PIAdvCalcExpDat 62
PIAdvCalcExpFilDat 63
PIAdvCalcExpFilVal 59
PIAdvCalcExpVal 58
PIAdvCalcFilDat 61
PIAdvCalcFilVal 57
PIAdvCalcVal 56
PIAliasToTag 69
PIArcVal 33, 106
PICalcDat 52, 118
R
recv Error 0 136
Refreshing PI data in a spreadsheet
Lotus 1-2-3 104
Reporting Errors 104
Revert option 76
S
Sampled Data 113
Example 16
Filtered 119
Scroll Bar option 76
Security
PI 2 Server 6
PI 3 Server 9
select() timeout error 136
Page 161
Index
Settings 130
setup.ini
Arguments 149
PI DataLink 150
Show Time Check Box 103
Single quote 87
Standard Deviations 53, 108, 117
Syntax
Performance Equation 143
T
Tag Attributes 87, 111
Tag Search 99, 129
TCP/IP 2
Node Names 6
TCPWare
Name Translation, PI Client 6
Timed Data 116
Timestamps
Entering into PI DataLink 26
In Lotus 1-2-3 102
In Microsoft Excel 102
Time Interval 148
Toolbar 96
Totals 108, 117
Trend
Right-click menu 76
Trend Control 72
Troubleshooting 135
Tutorial
DataLink for Lotus 1-2-3 86
DataLink for Microsoft Excel 86
U
UCX
Name Translation for PI Client 6
User Privileges
PIADMIN 9
username/password
PI 3 Server 9
V
Values
Writing into PI 82, 131
Verify Connections