Calculate Rates in AF Formula

Discussion created by rdavin Employee on Nov 11, 2009
Latest reply on Nov 17, 2009 by cescamilla

I have sporadic data fetched approximately every 2-weeks.  All PI Points in an element will have the exact same sample date+time.  I am using AF 2.1 due in part that 2.1 now allows ExactTime for the PI Points.  ACE is not a part of the solution.  I’m opened minded that Performance Equations (PE) might be used.  I’ve written custom data references before but will always try to find a non-code solution first.


I am trying to calculate a rate between consecutive sample readings.  Using the PI Point DR, I can fetch the previous value using a TimeMethod=Before.  Grabbing hold of the respective event timestamps with a Formula DR has me stumped.  Is there something I am missing?


A given element has attributes like:


Volume       attribute, PI Point DR with TimeMethod=ExactTime
PrevVal       child attribute, PI Point DR = |Volume;TimeMethod=Before


All fine and dandy but to calculate rate I need to know the event timestamps of each.  I can write a custom DR but that’s usually the last resort as eventually I’ll need to register the DR on a couple a hundred PI Systems one day.  I’d prefer this be solely in AF but if a performance equation can solve the problem, I may use it over a custom DR.


Note that if I were to write a DR, I would not write one merely to calc the rate.  Instead, I would write one to grab the timestamps.  I'd imagine some config parameter such as CurrEvent, PrevEvent, and even NextEvent to return a timestamp into an attribute.  Perhaps the ConfigString would look something like "Event=Previous".  Don't know yet.  I'll jump off that bridge when I get there.  But I could then calc the rate in a Formula DR and be flexible enough to fetch timestamps for other future needs.


Any suggestions?