I just want to build a simple totaliser type analysis that sums all time number of hours a pump has been in service (I have a tag that is 0 or 1 depending on if the pump is in service). What is the best way to do this?
Create an analysis that runs for example every 5 min. And then check the time it is equal to 0 or 1, depending of your needs. See the screenshot for our solution to count the running hours of a pump.
Robert's example is a good approach, to give you some additional information:
To not overload the PI Data Archive or reach one of the max query parameters (ArcMaxCollect, MaxQueryExecution, etc) always limit the data volume you are querying.
A good practice (in the real world) is to not query raw data for more than a day at the time. Since this is a 0-1 value with likely not that many values you can likely without issues run it on a entire month (keep in mind how many values there is on the raw tag on many instances you can easily reach arcmaxcollect on just a week of data).
I had a draft that was a bit more advanced than Robert's example, Since I already drafted it I can publish it as well:
Month to date:
Year to date:
I've tried your method:
When I back fill, the Pump Active MtD calculation works fine, but the YtD and Grand Total calculations do not - I get 'Calc Failed'.
Any obvious reason why? Could it occur if I get bad values for the On/Off tag itself? If so, how can I get my calculation to filter these?
Thanks for your help,
Yes - if there is any bad data in one of your tags, it's possible you'll throw a "Calc Failed" error. There's a function you can use called BadVal() that can help. Here's a nice write-up on using this: KB00434 - How to filter out bad or undesired values from Performance Equations, Analyses, and AF Formulas
Here's a good example:
IF BadVal('tagname') THEN NoOutput() ELSE 'tagname' * 2
By leveraging an IF statement, you can basically return the function gracefully, rather than having it terminate due to an error.
In this use case, if BadVal('tagname') evaluates to TRUE (which it would, if 'tagname' had a system state, or something like that), the calculation will execute NoOutput(), which just means nothing happens. If BadVal() evaluated to false, then it would do it's normal calculation.
Retrieving data ...