How to sum values (in sequence) whose beginning and end time is within 5 hours?
You can do this calculation by comparing your Current Value Time stamp with your Previous event Timestamp if it is less than 5 hrs then the calculation will sum up the two values otherwise it will ignore.
Can you provide a bit more context? For instance, it might be very beneficial to know what you are using to fetch data? For example, an answer for DataLink may be a very different if you are using AF SDK.
PI has does aggregation very well for many decades. In general, you are to provide a tag (or stream), and a time range (that is a start and end time). You also declare whether you want an event-weighted average or a time-weighted average.
From what you are asking, it doesn't seem to me that you may efficiently have the PI Data Archive send a small summarized data set back to you. Given your logic of stepping over each value in order to determine if it's within 5 hours not just from the previous value but from some arbitrary value back in time, then you may need to fetch all the data and methodically step through each value to determine whether it should be included in a summary. An I say "a" summary because I am guessing from your image that you want 3 different summaries, one for each red rectangle. Or do you want all 3 of the red rectangles in 1 summary?
this data is from totalyzer and represents pumping of some medium.
From some reason, during pumping are interruptions what we do not want to see.
These interruptions were never longer than 5 hours.
I want to get clean data with AF analytics, where there is no interruption shorter than 5 hours (all 3 of the red rectangles in 1 summary).
When I saw your post the first thing that came to my head was Dan Fishman's post on the new PI AF 2018 features. I did some testing and it looks to be successful.
I assumed it was ok for the Sum to happen over a period that you define.
I used the Sinusoid tag, which is a sine wave from 0 to 100. I filtered for values over 50 which filtered out half of the values as expected. I was then able to use the Total() function to sum all the values.
To adapt this for your case you would just have to define a value threshold which you would like values to be over.
Hope this helps and let me know if I can provide any clarification.
but for this solution I have to wait for PI AF upgrade to 2018 version.
Since you will need to wait for AF Analysis, see if the below works.
With the Compressed data you can have the formula do the required for you.
If the time difference is between the current cell and the previous cell is less than a day then sum both the values and the cell above it using a if condition.
Checks if the time difference is less than a day
Retrieving data ...