Check out the GetPISummaryData method in IPITimeSeries interface. Using this method you can get averages, means, minima, maxima, ranges, totals, values, counts, and both sample and population standard deviations. You pass your objects to do the summary over, time range, and the action using the PISummaryDataRequest which in turn includes PISummaryManner encapsulating your desired operation.
You can find more information and short code snippet in the PI Web Services user manual, available on the vCampus Library (under vCampus PI Products Kit > Data Access Technologies).
Thank you Ahmad and steven for the responses.
Sorry , my previous was not clear. i need to report this data aggregated at 15 minute intervals over a period of the day. so if i give startime and end time..i need to get a response aggregated in 15 minute intervals for the whole duration.
You are very welcome! You should be able to tweak the above-mentioned GetPISummaryData to get what you want. Posting your code and what you have right now would be very helpful in moving forward and seeing what we are missing here.
Well, I did some reading and figured out how to do what i was asking. Now i got a different problem. i have a tag value every 2 seconds. this value can be either 1 or 0. at the end of the day i need to aggregate this tag at 15 minute intervals based on a condition. that is in the 15 minute period if all the 2 sec values were 1 then only the 15 minute value can be 1. or else 0.
For example purpose lets assume there is a value at every 5 minute interval
So my resultset would be
can this be done with a single call to the GetPISummaryData? Or do we need to create a performance equation for this purpose.
I would suggest to use a performance equation like:
IF TIMEGT('tag', '*-15m', '*', 0) = 900 THEN 1 ELSE 0
Essentially it is just testing for the amount of time in the last 15 minutes where the value of the tag is greater than 0. If it is equal to 15 mins (900 sec) then return 1, else return 0. This way, you will get the result that you want directly.
If you go with the route of using GetPISummaryData, you can probably find the sum or average, which can help you determine if it should be 1 or 0, but it means you still have to analyze it based on the return result.
Also, you probably want to test the equation for different scenarios like missing values and cases where the value before and after your boundaries are 0.
As explained in the "Web Services Inputs" section of the PI Web Services User Guide, you can pass a Performance Equation (PE) expression directly to the web methods of the PITimeSeries interfaces (e.g. GetIArchiveData). It should start with the "pe:" designator, rather than "pi:" for a PI Point path or "af:" for an AF Attribute path.
Alternatively you can create a PE tag directly on the PI Server, as Han Yong suggested, which might be better if this equation is useful in other contexts as well (e.g. users might want to trend that in PI ProcessBook or create an Excel report that includes that information, using PI DataLink).
Thank you guys. The reason i am trying to avoid any kind of PE is, we have a bunch of tags..and for each tag i will end up creating PE. So i was trying the approach suggested han yong and implement it as a Pi webservice path like steven suggested.
I am still not getting the correct results.
and all my source values from 12:300 to 13:15 that day are 1's. so i am basically expecting to see the first 3 values as 1's. and rest 0's
I gave the amount of time as 450 seconds to see if that makes a difference since they are at 2 sec intervals. but either case whether it is 900 or 450, it is giving me the same result. I understand the logic i should be applying. but i dont understand how the combination of these parameters work together to give me what i want.
what am i doing wrong?
I am getting the following error -
"Cannot do summary calculation on non-numeric data", when i try to do a summary calculation on a tag.
I believe the datatype is Digital for that tag.
are there any conversion functions, or is there a work around to perform summary calculations on Digital data? - the tag values are either 1 or 0
I am not aware of any easy method to make that kind of conversion. PI SDK Summary methods also work on numeric data types only. To take one step back, I would question why a 0-1 tag is built as Digital to begin with.
When you were trying to apply the PE equation to the PI Web Services call, where you using the GetPISummaryData method or the GetPIArchiveData method? Seems like you are using the GetPISummaryData method, since there are summary parameters in the screenshot.
I would try using GetPIArchiveData method instead, here's an xml view of my request to PI Web Services:
<Path>pe:\\hyong\IF TIMEGT('testcountstate', '*-15m', '*', 0) = 900 THEN 1 ELSE 0</Path>
I've attached my test data in the form of a csv file. The only difference is that the interval of values is 1 minutes instead of 2 second. You can see that I am interpolating for data every 15 minutes interval (by requesting for 9 values in a 2 hours time period), which essentially is calculating at 15 minutes interval.
The result I get are as follows (again in xml view):
-<TimeSeries Path="pe:\\hyong\IF TIMEGT('testcountstate', '*-15m', '*', 0) = 900 THEN 1 ELSE 0"Error="0"SeriesID="1c396dfb-c136-42d6-9e0e
The first result is actually the result of the PE equation from 7:45 to 8:00 which I did not backfill any test data, hence 0 would be the expected result. And for the rest, if you refer to my test data, you can see that the 0s corresponds to the 15 minute period where there are 0 values. I believe this is what you are expecting to get, from your description in the previous posts.
state.csv 4.7 KB
@Keethi: Just like to follow up on this, were you able get to your desired result?
Issue1 - For getting summary over 15 minutes fo the CF tag with 1's and 0's logic - turns out , i was over thinking the whole thing. So i used a maximum function - to get the result i desired.
Issue 2 - Summary on Digital type tags.i was able to achieve this using the Int(string(tagval)). which is still kind of crude. but it solves my purpose for now.
Thank you all for your help on these. I learnt a lot during the process