AF Analysis has supported arrays for a while, but doesn't support looping them with a typical for loop statement. A lot of use cases for loops are converted by the
filter and aggregate methods such as
In this post, I want to explore an other way to loop over arrays.
The idea is quite simple, say you have an array of 5 element and would like to loop over it over one minute. We can schedule an analysis to run every 12 seconds (60/5 = 12). We can then use the number of seconds method to pick an element of an array.
Here is the analysis that picks a different element of the array each time it runs:
The analysis will have to be modified if you want to loop over something different than 1 minute.
Building up an XY-plot
Here is an example of using such technique. I was recently asked how to monitor pressure across a pipeline. The pipeline had manholes every few kilometers, at each manholes inlet or outlet (sometime both) pressure were collected. In between manholes, we assume the pressure just drops linearly. Visualizing this in PI Vision can be a bit tricky as the x-axis is not time, but distance along the pipeline. An X=Y plot is much closer, but the raw data is made up of 1-2 tag per manhole. Thus, there is the need to combine the data before displaying it.
Now, I built up an analysis similar to the one above, but looping over both arrays.
We are forced to pick a timestamp for this display, I couldn't find a good choice for this graph, thus I picked midnight of each day. Thus, the red line will show the latest values for the particular display. If somebody can think of a better output time, please let me know!