Before we create any expressions using Performance
Equation Syntax, let's just go over over some of the syntax rules.
Numbers are just the way you would expect. They appear
as numbers. Tag names,
oddly enough, always appear within
single quotes. So, 'sinusoid'
represents 'sinusoid.' That represents that PI
tag. Always within single quotes.
Now if you have timestamps in your functions, you would
also associate those with single quotes or,
I should say, delimit those with single quotes.
Now, strings are always gonna be in
double quotes, and that would include things like
statuses, like a Digital state, like
open-close or auto-manual.
Those are strings.
And, finally,
you can make use of a filter expression
using a fairly simple syntax, the Performance Equation
Syntax, in which we, we're
basically saying we want to filter certain values like
when this is greater than 50, then show those values only.
So, that is a filter expression that's available.
The PE Expression Syntax supports
an If-Then-Else construct. We don't support the case
statement, though, so in order to do something like a case statement,
you would have to nest other If-Then-Else
expressions within the expressions in a,
kind of a, a parent If-Then-Else
function. So, that If-Then-Else
function works, and it is actually
possible to specify function
that doesn't send anything to PI.
So, for example, if I would
like to have a value go into alarm
at a certain, at a certain stage,
like for example, if the average of 'sinusoid'
is greater than 80 during the last hour,
then I can specify that. I can say THEN Alarm,
and it will take the Digital State Alarm
ELSE NoOutput. So, NoOutput basically says don't
do anything.
We also support some functions
that measure, well,
things folks in manufacturing really need. Like, for example,
we've got a function here called TimeLessThan,
and it measures the amount of time a PI
tag has been less than a given value
during a specific period of time. So, for example, here,
TimeGreaterThan, we're saying how long has that tag,
from yesterday at midnight to today, been greater than
10? And let's divide that by
86,400. That's the number of seconds in a day.
So we're gonna return the value in seconds and this, this
would give us, in this case, a percentage -- how long it's
been greater than, than that value,
10.
Sometimes you're going to want to have a calculation
that is triggered based on just a traditional Scan Class.
So, for example, if you take a look at this
right here. We've got a function,
the TimeGreaterThan function. We're specifying
we'd like to determine how long 'sinusoid'
has been greater than 70 in the last eight hours.
So, for example, that's something where you'd probably
want to schedule that once every eight hours,
for example, at the beginning of each shift: at 7 o'clock,
then 3 PM, and then 11 PM.
Now, that would be an example of a traditional
Scan Class-based, calendar-based
calculation. I compare that
to a calculation that has an event trigger.
Here's a, here's a calculation
in which we specify that the event
trigger is the PI tag called 'sinusoid.'
And the calculation itself is
this TagAverage function.
Now, this entire phrase that you
see right here, this is what you would put in the Extended
Descriptor for this Calculation tag.
And, the syntax that we're using
basically identifies that this is going to be
the trigger, and this is the calculation itself.
So, this is an example of a,
of a calculation that, well, this is simply
triggered every time this, or one of these
inputs changes, or this input right here
changes the 'sinusoid' tag. So, each time a new
Snapshot value comes in, we will do a new calculation.
Now, all of these
calculations can be tested within
SMT using the Performance Equations
plug-in. Now let's take a look at this real quickly.
If you go into Points, within Points
it's Performance Equations. And this is where you would
place your equation.
You would brace...place your expression right here,
and then choose Evaluate. So,
for example, TimeGreaterThan
of 'sinusoid'. Let's go with asterisk
minus eight hours --
to asterisk --
and I'll say how long has it been greater than 70?
Now, when I evaluate this, this is gonna come back
with the answer, in seconds. So,
that tag has been greater than 70
for that many seconds. Then, again, if we
would take this and divide by,
for example, the number of seconds in eight hours. That would be
60x60x8.
This would give me the answer in percent.
Yeah, for 45 percent of the time, it's been greater than
70. So, this is an example of how you can,
using this Performance Equations
plug-in, you can test the equation. And we'll take a look at some of the other
things you can do with this plug-in later.