In an earlier video we took a look at the Settings
for the PI Point Data References, but
only inasmuch as we needed to specify the Tag Names
and the Unit of Measures, and I said we would come back to that. So now's
the time to take a look at these different retrieval methods, and
let's start with the most common types of retrievals.
Now that would be the retrievals in which you're
interested in some kind of an aggregation, like an Average.
Let me demonstrate. I, I'm going to demonstrate this
using a -- let's look at a PI
Tag that's got fairly regular behavior.
This is a Tag called Sinusoid. As you can
see, it's a Tag that, that takes a Value
from Zero to 100, and
if we were to take at look at this over the period of
24 hours or so, you'll notice every 12 hours it goes
from Zero to 100, so it has an Average roughly every
12 hours, just about any 12 hours you look at, it's going to be around
50. And, also, if you look at this.
I've got the markers turned on that here so we can see the actual Values.
It's not generating a lot of Data.
So, it's only going to be generating about I think it's about
40 Values every two days, something like that, maybe 25
Values a day. So it's a good
Option for us to use so that
we can kind of tell, you know, what we're looking at, what the -- we know what the
Average should be. We know about what the Count should be.
So, this, and
what I'm looking at right here is this is the actual
PI Tag, Sinusoid. Now this, on the other
hand, is an AF Data Reference. It's a Data
Reference to this AF
Element called Mixing Tank 2.
We're looking at the Pressure Attribute. And the
reason we have Sinusoid and this on the same screen is because,
in fact, that Attribute is pointing to
the Tag Sinusoid. So the changes that we see
over here are going to reflect, essentially,
what's going on with Sinusoid. And, and that's what we're seeing
right here. The Value here is 73.5.
It's coming up here as 73.4996.
Anyway, as you can see, that's, you know, we're,
we're looking at essentially the same Value here, both
in the Actual PI Tag and in the AF
Attribute. The point -- well, so far, so good. That, that would be
expected. Now, let's say I'm interested in
producing a -- I think we'll look first
at a series of, how about 12-hour counts? We
want to see how many Values we're getting every 12 hours.
It's kind of an unusual Calculation. Normally, people
do things like Totals or Averages, but we're just going to do
a Count, because it's a little easier to work with. Well, in order
to do that, what I would choose is I would specify
Time Range from my Retrieval Method by
Time, and for my Relative Time, I'm going to
specify * minus 12 hours, or I can just use
minus 12 hours. Now as far as the
actual Calculation, that's set once you've
specified Time Range. In this By Time Range you
specify what it is you're interested in. So I could specify
a Total or an Average.
In this case, I'm interested in a Count. Now this last
field, By Case, is something that is not supported
at this point. It will not be supported until we
support Event Frames within AF,
and, and right now that's not supported so you can ignore this.
Now there's only one last thing I do need to
consider, and that is whether this is a Time-weighted or
an Event-weighted Calculation. If it's a Time-weighted Calculation,
the way we actually do that with something like Count,
we would just count the Number of Seconds in that 12-hour period, kind of a
meaningless Calculation. When we do Averages,
we count the Values, interpolate Values once
a second, and then divide by the number of seconds. So, Count
produces that kind of an unusual Time-weighted Count.
But, if I'd simply specify this as Event-
weighted, what you'll see is it's going to
return the Number of Events, and it's telling me it's got nine
Events in the last 12 hours, which
just about matches what we see here. This is
only 8 hours we're looking at here, but that's about 9 Events.
And just a minor point here. Look at what
happens when you do Event-weighted -- or Time-weighted,
excuse me. , that's, that's returning the Number
of Seconds in 12 hours, 43,200.
So, and, and
it returns it that way because of the way we
do Time-weighted Averages. Essentially, a Time-weighted Average
is an Interpolated Value
for each second, add all those up, divide by the number of
seconds, so when we're using Count that's why we get that
number. Anyway, that's a bit of a digression.
The point is what I've specified is that we've got
this, we're doing a Calculation. It's now by Time
Range, and that's the Time Range. And, in this case, the Calculation
is Count. I could have just as easily chosen Average.
The 12-hour Average for Sinusoid
should be around 50, and as you can see, that's what it is.
, here's my Tag Pressure. That's the 12-hour
Average. The 12-hour Count is around
9. Now let's take a
look at how this affects the ProcessBook
Trend. Before I can actually see that in ProcessBook,
though, I do need to check this in. I'll go ahead and check
it in. We'll go out here,
and as you can see, this is now showing me this Count of 9.
So, for that 12-hour period that's
what we see. Now,
did you notice that, that, that just changed from 9 to 7?
What happened? Did we, did we just lose 2
Values? Actually, no. It's an interesting
artifact of the design. What we're looking at
here is we're looking at something that's a,
a, a Calculation that
pays attention to the Time Context.
So, the Time Context is actually being passed
over to AF, and we're returning the Value
given the current Time Context. And the Kind --
Time Context here is 8 hours. So, for example,
if I go out to -- let's go with 1.3 Days,
watch what happens over here. We've got
23 Values. If I go out further,
we'll see more and more Values. And, that's because,
as I said, the Context
is being passed over to AF, and
the Calculation is being retrieved given that Context.
It's a nice feature that, when we -- of course, when we support
Event Frames it'll be a lot, very, very useful
for Batch-oriented Retrieval,
so, by passing Time Context or supporting
Time Context, we'll have a nice, a nice
mechanism for, you know, for showing things
on an Event-by-Event basis.
So, and if I go
ahead and switch this back -- there we go. Now we're back to --
I've restored the Defaults, and then
when this updates, and this is updating
every 15 seconds -- , there we go. Back to 8
hours. You know, so this is, this is going back to the
Saved Version when I Revert. That's why we keep coming back to
9, and then within 8 -- within 15 seconds this'll
update with the current context. So, as you can see, it's
very active, pro-active I guess you'd say,
it's, it's using the Time Context it picks up
from ProcessBook. That's something
that can be changed by using this
Option here called Time Range Override.
By Time Range Override, what we're specifying here
is that -- and let me go ahead and check this in --
what we're specifying is that we would like to
override whatever the local context settings are.
So, in this case, now
if I were to go back,
look at a couple of days. No problem. Since I've set this
to Time Range Override, that Time Range Override
on the AF side's going to override whatever local context
we have.
Okay. And there's one other thing that we can do with this
I'd like to demonstrate. And, that is,
we do support doing a kind of a Time Offset.
Well, actually, before we look at that, let's look at a more useful
thing than Count. More useful than
Count, of course, would be to look at something like Average.
So, if I specify Average, again, watch what happens
if I just choose Time Range, and I'm choosing Average.
Let's make this, in this case let's make this
Time-weighted. People are generally interested in Time-weighted.
And, I think what I'll do here is let's go with 4
hours. We're using 4 hours because, of course, the 12-hour Average
of Sinusoid is always going to be 50,
no matter what time of day you look at it, because it is that -- has that
12-hour period from Zero to a hundred. So now
that I've set this to be a 4-hour
Average, using my Relative Time
here, then this is coming back as 89,
and if I were to take a look over here -- oh, let me check it in.
Always make sure you check this in
if you want to see the effect over here. And we're seeing that's coming
back as 89. But, watch what happens as I start to
scroll back in time. As I scroll back in time,
again, because I'm, I'm using the Time Range
without the Time Range Override, this is doing the Calculation
for us going back, each time
producing a 4-hour Average with the End-
time as the end-point of this Average.
Watch as we move backward in time. That timestamp
right here, 1:11, it's picking that up from the End-
time here.