[noise]
In this video we'll
show how to set up an expression
analysis. Expression analyses
are a way to do calculations with
AF attributes. Think about what
calculations do you use your data for
now and then look at this as a way to do
those calculations all within your PI
system. Let me give you an
example. I'm looking at
the AF database for this
manufacturing group in PI System
Explorer. And they have different elements for their different
pieces of equipment, and all their pieces of
equipment, like this BP988
have an AF
attribute for status, which describes
whether or not the piece of equipment is running
or it's down. Operations wants to be able to track
for each shift what percentage of the
time was each piece of equipment up
and running. Let's set up an expression analysis to do that
calculation. Expressions
are configured for a given element using
the analyses tab. If you don't see this
analyses tab in PI System Explorer
you probably aren't using the latest version of the
PI server, which includes AF2.6
or you don't have the latest version of
the client tool. But there are a
lot of pieces of equipment in this AF
database. There's just these four for
this line, but there's multiple lines and
multiple sites. And I don't want to set up that
calculation for each individual piece of
equipment. Fortunately these equipment
elements are built off of a
template, so what we need to do is set up the expression
analyses only once on the template
level. Go to Library
and then under element templates there's
this OEE unit template
which each piece of equipment is based
off of. And you can see the status listed
as one of the attributes of the
template. For a template, analyses will be set up under
this analysis templates. So let's navigate there.
The steps are essentially the
same whether you are doing this on an element or a
template level. We'll select create a new
analysis, and the first
thing that we're going to do is start over here on the right
hand side, giving the analysis a name and
description. So as we talked about
earlier, we're going to be looking for the up-time
percentage for the equipment, and I'll give a full
description
and for organizational purposes
I'm going to use my KPI category, since this is a
KPI we monitor. Create and use your own
categories that makes sense for organizational
purposes in your AF analysis. And the
analysis type is left at the default selection
of expression. Since we're dong this type of
analysis using a template, one additional thing that
we'll need to do is to have an example
elements selected. An example
element is needed because the template itself
doesn't have set attributes and
values. Right now one of the
elements has already been selected but I can
change this by clicking on it and looking at, say,
another piece of equipment if
I wanted. The expression will be entered
in this field down here, and there's a list of
available functions here on the right. Let's take a look at
these functions. Some of these functions
are things that are probably pretty
familiar things, like operators,
math,
logics, and there are some that are
specific to things like the PI
system, including those under the search and
retrieval category.
And you can use a combination of any
functions to create a given
expression. If you've used performance equations you'll
notice that these look very
familiar. And if you're interested in seeing a list of all
the functions you could select
all, and the full list is also available
in the PI System Explorer user
manual under the expression functions reference
section. The particular function we're interested
in is under search and retrieval
and it's
called TimeEq, right
here. And once I have this
function selected down
below, it will tell me what the
input requirements are
and what it will output, as
well as an example.
This particular function will find the
total time within a given range when the point is
equal to a given value; and this is what I'll need to use for my
up-time percentage. I'm ready
to start the expression, so I'm going to
navigate here, click on this
box. One thing I could do is insert this directly
from here, or I can just start
typing in TimeEq
and you'll notice that IntelliSense picks
up the available functions and provides them
for us.
The next thing it does is that it tells us
what the requirements are; so I'll need to do the
attribute tag name, and it also tells me specific
syntax rules for expressions. For
instance the attribute name needs to be
enclosed in single quotes. Okay, so I'll need
to do the attribute name in single
quotes. If I type a single quote what it does is it
pulls up all the attributes that are in that
element. Now, if I was trying to use attributes that weren't in this
specific element, then I could
actually use this attributes
tab to look in my hierarchy and find the ones that I'm
looking for. I can add
attributes from here, but in my case I can just
type it, since the attributes status is part of the
element template.
The next thing I'll need to do is to do the
start time. I'm going to run this calculation
at the end of my shift and I want it to
represent the entire shift. My shifts are
eight hours long, so I'm going to use
relative time references and
do the asterisk minus
8H. You'll notice I was using
single quotes just like
the information stated I needed
to do.
And now I'll need to do
the end time and that also has to be in single quotes because it's a
time reference. And finally I'll need
to do the value. Now, for the
syntax rules, if the value is
a number, like 80, I could type that
as is, but my value is actually
a string--- running, so I'll need to do that
in double quotes. I have this set up and what this
will do is it will basically
be evaluating how long was the
status running within
this time period. But that's
not actually my uptime percentage, which is what
I really want. In order to get it into that
format I will need to divide by the
number of seconds in my shift, and then I will need to
multiply that by 100%. I can
keep typing and do that, but one
of the really nice options is I have the ability
to do multiple expressions to give them
variable names and then they'll be evaluated
sequentially. So that's what I'm going to do
in this case. And this just makes it easier
to see how things were set up and for de-bugging
purposes. I'll give this a name of
UptimeSeconds; I'm not really able to put spaces and names so
I'll do it like that. And then my
other expression, let's do the ShiftSeconds
for the number of seconds in
a shift and let's see; my shift is
eight hours long, and then there are
60 minutes in an hour and 60 seconds
in a minute. And
then I'll set up a final new expression
for my UptimePercent.
In this case I can
actually use my variable
names, and if I want I can
use the evaluate button to see what they'll be at
the current time for the example
element; so I'll hit evaluate.
And the next thing I need to do is
say where I'm going to map this
calculation to. I can
map any of my expressions but I'm really only
interested in the UptimePercent
output, so that's the only one I'll choose to map. So I'll
click map, and right now it give me all
the attributes in my template. However,
I don't have an attribute for the uptime
percentage yet, so what I'll do is I'll do the new
attribute template, and I'll give my attribute certain
properties.
To keep things
nice and organized I'll choose the KPI
category, and it's always good to set a
unit of measure to keep track of
things.
And
I'm going to keep the data reference as PI
point and select the
settings. One of the exciting new options is the ability
to write the analysis outputs to
PI tags, and to have those tags created
through AF using this tag creation selection
option. It's actually highly recommended to store
the analysis to PI tags so that you can
historize the data, and it also improves the
AF performance. And I can even set the
attributes of the PI tag
here
so I'll hit
okay. And the last thing I'll need to do is
to schedule it. When scheduling something there are
two choices: event triggered
and periodic. Now, event
triggered will trigger basically the
calculation whenever the status attribute
changes. If I had more than one attribute in
my calculation I could
choose. But I'm really interested in having this
calculation run at the
end of my shift, so I'm going
to do periodic because that's a clock-based
scheduling. Select periodic, and then
choose the configure option. Now, in this
case, as I mentioned, my shift is eight hours, so I'll
change that here.
Once I have eight hours specified you'll notice that there's
also these example evaluation times at the
bottom. My shifts are eight hours but they
happen to not be at these precise
times, so I'll use the specify offset
option.
So let's say my
shifts start at 7am, 3pm and
11pm. For the sake of this video
in order for us to see the calculation actually
occur, since it's 3.01 now,
I'm going to slightly
modify this
time. So say these are the starts of
my shifts. So I'll hit
okay, and now I'm ready to check in
my changes.
Let's take a look
at the elements. Under my
elements I can see that I now have this
uptime percentage attribute. There's a little bit of a
strange message; it says PI point
not found. So we had selected the tag creation
option but we still need to actually go ahead and
create those tags. A fast way to do this
in bulk for all of the
elements would be to do a
right click and do a create or update data
reference.
And I'll check
in this in. And now if I
look, you'll see that my uptime
percentage now says point created, because the
tag has been created but we haven't created a value to it
yet. But I'm thinking scheduling
wise, that will change pretty soon, so I'm going to go
ahead and hit refresh.
Okay. So you can see it is now
3.03pm, which is the
start of my shift, so I have computed this for the
end of my last shift. And this
uptime percentage is now available for each
equipment piece.