Digging slightly deeper... on the PI Web API GetRecorded call for the Stream controller, starttime and endtime are optional, and maxCount has a default of 1000. So the option #2 the key question would be how the PI Web API Translates a call to AFSDK calls. Will it use RecordedValuesByCount: Request Rejected ? As that will only retrieve the 20 Events, no matter what time period. So mainly lookingfor some confirmation that it does not do the filtering on the end of the PI Web API, but on the PI Data Archive.
1 of 1 people found this helpful
I was looking into this but GetRecorded under the hood calls RecordedValuesAsync on the AF object, but its unclear how the MaxCount parameter will affect the actual RPC that goes out to the Data Archive and how the Data Archive actually handles that RPC. Let me do a bit of digging and get a better answer out to you.
4 of 4 people found this helpful
As Vince said, Web API is not going to use RecordedValuesByCount. However, you can get RecordedValues[Async] to be functionally equivalent to RecordedValuesByCount. The key is that the AFTimeRange passed to the method needs to be constructed such that start time of the range > end time of the range. For example,
When the AFTimeRange is constructed like this, then the navigation direction on the PI Data Archive is backwards, allowing you to retrieve the most recent n events, where n is what is passed as the maxCount argument. On the PI Data Archive, navigation is ended once the maxCount parameter is fulfilled, so you do not need to worry about it continuing further back all the way to the end of your time range.
So to translate this back to how the Web API call should be made, make sure your startTime > endTime (and that your endTime reasonably encompasses your 20 events), and set MaxReturnedItems/maxCount to 20.
The optimization of navigation is not as tightly optimized when using a filter, so for best performance you should leave this as null/empty string.
Thanks! Exactly the information i was looking for!
Saves me a lot of time to experiment and find out...