Recognize More AF SDK Data Methods

Version 2

    Table of Contents

     

    The AF Applet for this course was originally designed for reviewing data for a single attribute at a time.  Keep in mind that the courseware is a beginning level introduction to developing applications in AF SDK, which itself is a topic so immense that we are unable to cover every topic under the sun.  This is particularly true with regards to the burden of your own time to review these videos and work through the exercises.  Understand that we have presented a decent foundation for you to build your programming skillset, but there are many more methods and features for you to discover.  Without going too deep into the details, we will briefly mention some popular ones below.  You should at least be aware that these exist because you may find yourself using them sooner than you think.

     

    An Individual AFAttribute

    For an individual AFAttribute we started off using GetValue an GetValues, then later modified the app to include Rich Data Access (RDA) methods of RecordedValues, InterpolatedValues, and PlotValues.  Note the RDA methods belong to the AFData class.  And the AFData class has many more methods for you to explore at your own pace outside of the course.

     

    AFData.Summary Method returns several summaries for a single AFAttribute for a single time range.  Possible summary types are: Total, Average, Minimum, Maximum, Range, StdDev, PopulationStdDev, Count, and PercentGood.  Only the calculated summary result is returned, which leads to reduced to network traffic.  Another key parameter to Summary is the AFCalculationBasis, which is usually TimeWeighted or EventWeighted.

     

    AFData.Summaries Method returns several summaries for a single AFAttribute over a single time range for each interval within that time range.

     

    Some AFData methods have an equivalent Async version.  In a front-end application, the UI thread can stay responsive during a data access call.  In client and server applications, the number of overall threads used to service a call can be reduced, as waiting threads can be returned to the thread pool for re-use.  And the negative effect of network latency can be mitigated because remote calls may be executed concurrently.

     

    Bulk Many AFAttributes

    You may bundle a collection of many AFAttributes into a single AFAttributeList.  There are many data calls for an AFAttributeList where you may issue a bulk call for the entire list.  Obviously AFAttributeList.GetValue is a key one to know.  The AFAttributeList.Data property returns an AFListData object, which has some bulk calls for RecordedValues, InterpolatedValues, and PlotValues.

     

    In general, one of the best performance tips is to use bulk where possible.  An application that has 1000 attributes but issues 1000 separate AFAttribute.GetValue calls one at a time will perform much slower than an application that issues a single AFAttributeList.GetValue call.

     

    You are free to explore on your own to see that AFListData offers some Async counterparts as well.

     

    PIPoints

    The AF Applet only deals with AFAttributes.  If writing an application against a PI Data Archive, a PIPoint is analogous to an AFAttribute.  Data methods for a PIPoint are fairly similar to those for an AFAttribute including async, summaries, and the RDA calls.   Just as many AFAttribute(s) may be bundled into an AFAttributeList collection, many PIPoint(s) may be bundled into a PIPointList for bulk data calls.

     

    A Known Limit on Data Calls

    When you first start out with simple calls, you may not run into any data limits.  Certainly for the AF Applet you should not run into any data limits but perhaps now is a good place to talk about it because one day you may likely run head first into it.  There are 2 specific limits that may make a data call fail.  This will be true regardless of whether the data call is for an AFAttribute or PIPoint, an AFAttributeList or PIPointList, etc.  The limits apply to one data call at a time.

     

    The first limit is an operation timeout.  A data call will throw an exception if it does not complete within a certain amount of time.  This amount of time may be declared when connection to a PISystem or PIServer object.  For small data calls, such as current value, this should not be a problem.  But if you wanted to make bulk summary calls for lots items in an AFAttributeList or PIPointList over a very wide time range, then chances are the operation may timeout.  It will then be your job as a developer to find the sweet spot between how many items should be bulked in a collection, as well as breaking your time range into a few smaller windows.

     

    The other known data limit is determined by the ArcMaxCollect tuning parameter.  The default for this is typically 1.5 million.  What it means is that any given data call must return less than ArcMaxCollect values, otherwise an exception will be thrown.  Oddly enough a summary call should not cause this exception since it produces an aggregate value.  But again dealing with huge AFAttributeList or PIPointList could trigger this exception if you have dense data for the specified time range.  Even an GetValues or RecordedValues call on an individual AFAttribute or PIPoint could trigger this exception if your time range is too wide and/or the data is quite dense.  Your job as a developer would be finding the sweet spot of how many items go into a list, or else to break up the time range into smaller windows.

     

    Where to Find HELP

    There are many data methods and options to explore.  We only briefly talked about async and bulk.  This online course lays the foundation to help you get started.  But much of your future career as an AF Developer will most likely require you to discover and learn about other methods.  Towards that end, the best link to provide is:

     

    Where to Find HELP

     

    If you have any questions about AF SDK data methods, please use the discussion forum to discuss and ask any questions about this topic.