Você está na página 1de 11

PI Menu

Quando FactoryTalk Historiador DataLink é adicionado para o Excel, ele adiciona o item de
menu PI para Excel barra de menu.
.

Seleções de menu pop-up estão disponíveis a partir deste item de menu. São eles:

 Current Value Recupera valor de um tag


 Archive Value recupera um valor único a partir do arquivo (pode ser interpolado
 Tag Attributes recupera atributod de um tag
 Compressed Data (Start Time/Number) recupera dados compactados com base em
uma hora de início e um número especificado de valores com uma condição de filtro
opcional.
 Compressed data (Start Time/End Time) recupera dados compactados com base em
uma hora de inícioe um tempo de terminar com uma condição de filtro opcional.
 Sampled Data recupera espaçados (amostra) os dados do arquivo com uma condição
opcional de filtro.
 Timed Data recupera dados amostrados dados sincronizados com uma variedade de
marcas de tempo.
 Calculated Data recupera dados totais, mínimo, máximo, faixas, desvios padrão,
médias e meios para vários períodos de tempo.
 Advanced Calculated Data Os dados são semelhantes aos dados calculados, mas com
opções mais avançadas.
 Time Filtered recupera a quantidade de tempo durante o qual a expressão de um tag é
verdadeiro.
 Point ID to Tag recupera a identificação de um tagname do ponto especificado.
 Attribute Mask to Tag recupera máscaras atributo para tagnames especificado.
 Alias recupera um tagname alias do banco de dados do módulo.
 Property recupera um valor de propriedade do banco de dados do módulo.
 Insert Trend cria uma tendência que se pode obter diretamente dados de PI ou fora da
planilha.
 Tag Search procura por tags PI tags.
 Module Database exibe o conteúdo do módulo de banco de dados, tais como aliases e
propriedades.
 Connections gerencia as conexões PI Server.
 Settings exibe Configurações FactoryTalk Historiador DataLink e preferências.
 About displays version information on FactoryTalk Historian DataLink.
 Help displays help on FactoryTalk Historian DataLink.

Dialog Boxes
Edit Fields
The edit fields can contain either the necessary text information or references to cells, which
contain the necessary text information. FactoryTalk Historian 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.

PI Server and Output Fields


The PI Server field allows the selection of a PI server from the known servers list. In the
drop-down list, the servers above the dotted line are the servers currently connected and the
ones below are currently disconnected. The PI Server field in all of the dialog boxes is
labeled as opt. or optional. If the PI Server field is blank, FactoryTalk Historian DataLink
will use the default PI Server. You can change the default PI Server in the
Connections... dialog box available from the PI menu.
The Output field allows you to specify the upper left-hand corner of the range where
FactoryTalk Historian DataLink will place the resulting data.
Data Displayed as Columns or Rows
For dialog boxes that expect to return an array of PI values (for example, Sampled data),
there is a set of radio buttons with options column(s) or row(s). Choose column(s) to display
the data in either one column, two columns if timestamps OR percent good are to be

displayed, or three columns if timestamps AND percent good are to be displayed. Choose
row(s) to display the data in either one, two, or three rows.

radio buttons with options no timestamp, time at left or time on top. Choose time at left to
display data in two columns. Choose time on top to display data in two rows.
For dialog boxes that support an array of tags, the orientation of the tag array will override
your row/column option selection in determining the orientation of the output data.

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.
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.
Tag Search in Dialog Boxes
The <...> button next to the tagname field in the dialog boxes allows you to search the PI
database for tags. Clicking the button will bring up the Tag Search dialog box. If you press
OK in the Tag Search dialog box, the first tagname selected will be copied to the tagname
edit field. The PI Server name is also copied to the PI Server edit field if you checked the
"Copy PI Server name" box in the FactoryTalk Historian DataLink settings.

Time in FactoryTalk Historian DataLink


Returned Values
The timestamps returned by the FactoryTalk Historian 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 FactoryTalk Historian 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.
User-Specified Time and Number Formatting
If you do not like the general and dd-mmm-yy hh:mm:ss formatting codes for number and
time, respectively, you can specify another default number and time formatting code in
FactoryTalk Historian DataLink. This is done via the PI > Settings... dialog box.

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.
Entering Timestamps into FactoryTalk Historian DataLink
Many of the dialog boxes ask for a start time and an end time. In the edit fields, type the
desired PI time string, for example, 10-Dec-99 19:12. Note that for PI time in relative time
format (for example, '-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.
If you want to use cell references, you may refer either to cells that contain a PI time in string
format (e.g., '10-Dec-99 19:12) or to cells that contain an Excel time (for example, 36504.8,
formatted in whatever style you wish). Remember that Excel stores time as the number of
days since 1900, but displays it according to Format, Cells, Number.
For the time interval edit field, you may specify a number followed by an h or an m or an s
(for hours, minutes, or seconds, respectively). For example, to indicate a time interval of
thirty two minutes, type 32m into the edit field.
If you want to use cell references, you may refer only to cells that contain a valid PI time
interval string. That is, you cannot refer to a cell containing an Excel time (i.e., a number).
For example, to specify an interval of 32 minutes, the time interval edit field of a dialog box
must refer to a cell that contains the string 32m.

strings.
Show Time Check Box
A show time check box appears in some of the dialog boxes, whose PI function normally
returns an array of PI values. Selecting this check box returns the timestamps as well as the
values. These timestamps appear at the leftmost column if the column(s) radio button is
selected; and along the topmost row if the row(s) is selected. If this box is unchecked,
FactoryTalk Historian DataLink does not display the timestamps.
If you reference an array of tags in either the Sampled Data or Calculated Data dialog box,
FactoryTalk Historian DataLink returns one common set of timestamps for the entire group
of tags.

Positioning Timestamp Data Returned by FactoryTalk Historian DataLink


Some dialog boxes that return a single value (for example, Current Value) provide radio
buttons that control where timestamps are displayed.
􀂉 Select no timestamp to suppress the timestamp.
􀂉 Select time at left to return a timestamp into a cell to the left of the retrieved values.
􀂉 Select time on top to display the timestamp in a cell above the retrieved values.
Note: When an array reference is specified in the Tagname field, the time at left and
time on top radio buttons produce the same result. In this case, FactoryTalk
Historian DataLink returns the timestamp and value depending on whether the
reference of tag names is horizontal or vertical. For tag names in a single column,
timestamps will appear to the left of the values. For tag names in a single row,
timestamps will appear on top of the values.
Timestamp Data for a Time Interval or Range
Some dialog boxes that return a single value for each interval of time (for example,
Calculated Data) provide check boxes that control which timestamps are displayed.
When a time interval is specified:
􀂉 Select Start Time to display the start time of the interval.
􀂉 Select End Time to display the end time of the interval.
For minimum, maximum, and range functions:
􀂉 Select Min/Max Time to display timestamps for the interval's minimum and maximum
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.

FactoryTalk Historian DataLink Functions


Functions vs. Values
When a FactoryTalk Historian DataLink dialog box brings data from the PI Server to
Excel, it does not put the actual value into a cell. Rather, FactoryTalk Historian 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, FactoryTalk Historian DataLink pastes the following function into the cell:
=PICurrVal("sinusoid",0,)
Excel then evaluates this function, and displays the resulting number. Thus, the FactoryTalk
Historian DataLink dialog boxes are a front end to construct the corresponding FactoryTalk
Historian DataLink functions, and to format the output.
These FactoryTalk Historian DataLink functions can also be entered manually into the cells
in a worksheet. The arguments to the function are described further in Details for FactoryTalk
Historian DataLink Functions and Dialog Boxes (page 30). Since most of the FactoryTalk
Historian 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 FactoryTalk Historian 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 FactoryTalk Historian DataLink functions. The only way to invoke the FactoryTalk
Historian 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
FactoryTalk Historian DataLink.
The FactoryTalk Historian 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
FactoryTalk Historian DataLink is written in C++ and Visual Basic and utilizes both the
FactoryTalk Historian System's SDK and Microsoft Excel's API. When an error occurs at the

PI SDK level, FactoryTalk Historian 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.

Refreshing PI Data in a Spreadsheet


There are two ways to refresh the data on a spreadsheet. One way is to right click on any part
of the array and select the Recalculate (Resize) function. This method works best if you have a
variable size array where the number of values returned could be different depending on what
range of values retrieved. If there are fewer values, there is no problem. However, if more
values are retrieved, those values will not show unless the Recalculate function is selected.
The second way is to make a change to the arguments passed to the FactoryTalk Historian
DataLink functions. Because FactoryTalk Historian DataLink retrieves data from the PI
Server via functions, values on the spreadsheet update only when a function argument
changes. Pressing F9 in Excel does not force FactoryTalk Historian DataLink functions to get
new data from the PI server. The only exception is the Current value function, which updates
whenever Excel recalculates. This was intentionally done because most of the other DataLink
functions do not represent chronically changing data. However, to bypass this,
Ctrl+Alt+Shift+F9 forces all DataLink functions to recalculate.
The best way to create a spreadsheet that updates with minimal user interaction is to use some
Excel dynamic time functions like now() or today() to build a time stamp, e.g. use
(today()+1/3) for 8am today. Then refer to this cell in the start time or end time
argument of the DataLink query. Whenever Excel recalculates (due to the user pressing F9 or
changing any cells in the spreadsheet), the dynamic time functions will be updated by Excel,
causing the FactoryTalk Historian DataLink function to run. Note that the value of the time
stamp does not have to change in order for Excel to trigger the FactoryTalk Historian
DataLink function. As long as an Excel dynamic time function is used to construct the time
stamp and this time stamp is used in the DataLink argument, Excel will trigger the DataLink
function when the spreadsheet recalculates.

Existem duas maneiras de atualizar os dados em uma planilha. Uma maneira é clicar
com botão direito do mouse em qualquer parte do relatório que contenha dados e
selecione a função Recalcular (Resize). Este método funciona melhor se você tiver um
matriz de tamanho variável, onde o número de valores retornados poderia ser
diferente, dependendo do intervalo de valores recuperados. Se houver menos valores,
não há problema. No entanto, se mais valores são recuperados, esses valores não
serão exibidos, a menos que a função Recalcular é selecionada.
A segunda maneira é fazer uma mudança para os argumentos passados para o
historiador FactoryTalk DataLink. Porque FactoryTalk Historiador DataLink recupera
dados do Servidor PI através de funções, atualização nos valores na planilha somente
ocorre quando há alterações de um argumento da função. Pressionando F9 no Excel
não força funções FactoryTalk Historiador DataLink para obter novos dados do
servidor PI. A única exceção é a função de valor atual, que atualiza sempre que o
Excel recalcula. Isto foi feito intencionalmente porque a maioria dos outros DataLink
funções não representam cronicamente alteração de dados. No entanto, para
contornar isto, Ctrl + Alt + Shift + F9 forças todas as funções DataLink para recalcular.
A melhor maneira de criar uma planilha que se atualiza com mínima interação do
usuário é a utilização de algumas funções de tempo dinâmico do Excel como now () ou
hoje () para construir uma marca de tempo, por exemplo, uso (Hoje () 1 / 3) para oito
horas de hoje. Em seguida, referem-se a esta célula na hora de início ou final
argumento da consulta DataLink. Sempre que o Excel recalcula (devido ao usuário
pressionar F9 ou alterando as células da planilha), as funções de tempo dinâmico será
atualizado pelo Excel, fazendo com que o historiador FactoryTalk função DataLink
para ser executado. Note que o valor da marca de tempo não tem que mudar para que
o Excel para acionar o historiador FactoryTalk Função DataLink. Enquanto uma função
de tempo dinâmico do Excel é usado para construir a marca de tempo e essa marca
de tempo é usado no argumento DataLink, Excel irá acionar o DataLink função quando
a planilha recalcula.

Changing Arguments using Dialog Boxes


If an argument needs to be changed, right click on any part of the array and select the
FactoryTalk Historian DataLink function. A dialog box will appear with all the edit fields
filled in with the arguments that were previously specified for that array. Any of the edit
fields can be changed and the new array will reflect those changes.
If the output edit field is changed, there are two different behaviors depending on what new
cell is referenced. If the newly referenced cell is part of the original array, then the entire
array gets moved with the upper-leftmost cell of the array at the newly referenced cell. If the
newly referenced cell is not part of the original array, then the array is pasted with the
upper-leftmost cell of the array at the newly referenced cell.

Selecting an Entire DataLink Function


If a large FactoryTalk Historian DataLink function array needs to be copied, moved or
deleted, the easiest way is to right click on any part of the array and select Select DataLink
Formula. Then perform the desired operation. The entire Excel function array must be moved
or deleted, or an error "You cannot change part of an array" appears.
Entering PI Functions Directly into Excel
Array Values
All of FactoryTalk Historian 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."

Using Cell Reference in Arguments


You can use cell references for all the arguments in all of FactoryTalk Historian DataLink
functions. For example, the following function:
=PICurrVal(A1, A2, A3)
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,)
into a 1x1 output range .
Details for FactoryTalk Historian DataLink Functions and Dialog
Boxes
The following sections describe each of the FactoryTalk Historian DataLink functions in
detail. Each section describes the dialog box first and then discusses each of the arguments
for the corresponding custom PI function or functions.
Current Value Dialog Box
This dialog box gets the current Snapshot value of a PI tag.
Required Field
Tagname. The reference to Tagname may be an array.
Special Notes
This function updates whenever Excel calculates or recalculates any cell in the spreadsheet.
To force an immediate recalculation, press the F9 key.
PICurrVal()
PICurrVal(tagname, outcode, PIServer)

Arguments

Returns
Outcode Column 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")
Archive Value Dialog Box
This dialog box gets a value at a specified time. There are five modes to select from:
􀂉 Previous - Retrieves the value in the archive at or before the specified timestamp
􀂉 Previous only - Retrieves the value in the archive only before the specified timestamp
􀂉 Interpolated - Interpolates the value at the specified timestamp 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 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
􀂉 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 32)
PIExpVal() (page 33)
PIArcVal()
PIArcVal(tagname, timestamp, outcode, PIServer, mode)

Arguments

Returns
An output code of 2 transposes the output array that results from an output code of 1.
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")

Você também pode gostar