Hi! I am looking for Ideas. I have the historian logging some process event information and what I want to do now is to see if I can divide the information by shifts, for example, I would like to have a historian query that returns the “Count On” of the events that happened on Monday and Wednesday between 6:00am and 6:00pm. My plan B is add a transaction group and start logging the information that way but since I already have the information on the historian I would like to use it if possible to avoid duplicating records.
Any ideas on how to solve this? I was thinking on adding a custom aggregate but at the time I am not able to get it to work, I’ve tried implementing the example with the myCount function (link: https://docs.inductiveautomation.com/display/DOC79/Custom+Tag+History+Aggregates) but it just returns the data on my table, nothing that resembles a counter.
Any help will be appreciated.
Did you ever figure this out? I’m struggling to get the myCount sample to work and getting the same results.
The documentation is wrong in places, and the examples won’t work as presented.
First up, this comment is explicitly the opposite of the behavior I’ve observed:
When calling a custom tag history aggregate, the returnSize argument must be set to natural (returnSize = 0).
From all my tests, (returnSize=0) causes the aggregator functions to be skipped and raw history values to be returned, while any positive value will trigger the aggregator functions. (Or you can use any of the
intervalXxx parameters which effectively gives you a non-zero returnSize.)
Second up, for the example of calling
shared.aggregates.myCnt function directly, the function won’t be found if stored in a project library named “aggregates”. I was able to get it to work by saving the function in a project library named “shared_aggregates” and using
shared_aggregates.myCnt in the call to queryTagHistory.
I think the history query functions do a
aggregationMode.startswith('shared') test and if true will look for a function with that name in the Python environment directly (w/o stripping the leading “shared”).