I am trying to find a better way to do production counts over specific intervals using tag history.
Example, I have a tag TestCount
, right now it’s a memory tag, but typically this would be an OPC tag from a PLC that increments. I can’t use Count
aggregationMode because it may not “catch” each transition, example, it may go from 10 to 13. My desire is to be able to chart this data over a period of time, example, 12 hours, with a certain interval, example 1 hour. So, if at the start of the hour the value was 100 and the end it was 113, then I would chart 13. Also, this value can reset. I have done this before with SQL queries, but was hoping to find an easier way with tag history.
Is there an aggregationMode that will accomplish this that I’m missing? Or, does anyone have any recommendations?
Here is an example, I did a system.tag.queryTagHistory
for startDate = ‘2021-06-29 11:00:00’ and endDate = ‘2021-06-30 11:00:00’. Results (tstamp,value):
Tue Jun 29 15:36:58 EDT 2021 0
Tue Jun 29 15:37:14 EDT 2021 1
Tue Jun 29 15:37:16 EDT 2021 2
Tue Jun 29 15:37:19 EDT 2021 3
Tue Jun 29 15:37:23 EDT 2021 4
Tue Jun 29 15:42:59 EDT 2021 5
Tue Jun 29 15:43:13 EDT 2021 6
Tue Jun 29 15:43:54 EDT 2021 7
Tue Jun 29 15:46:01 EDT 2021 8
Tue Jun 29 15:46:04 EDT 2021 9
Tue Jun 29 15:46:41 EDT 2021 10
Tue Jun 29 15:46:44 EDT 2021 11
Tue Jun 29 15:46:48 EDT 2021 12
Tue Jun 29 15:46:58 EDT 2021 0
Tue Jun 29 15:47:08 EDT 2021 1
Tue Jun 29 15:47:49 EDT 2021 2
Tue Jun 29 15:48:28 EDT 2021 1
Tue Jun 29 15:51:06 EDT 2021 2
Tue Jun 29 15:51:10 EDT 2021 3
Tue Jun 29 15:51:13 EDT 2021 4
Tue Jun 29 15:52:50 EDT 2021 0
Tue Jun 29 15:53:46 EDT 2021 1
Wed Jun 30 08:56:45 EDT 2021 5
Wed Jun 30 10:48:46 EDT 2021 6
Wed Jun 30 10:49:32 EDT 2021 8
So, if I want to see counts per hour it would be something like:
Tue Jun 29 11:00:00 EDT 2021 0
Tue Jun 29 12:00:00 EDT 2021 0
Tue Jun 29 13:00:00 EDT 2021 0
Tue Jun 29 14:00:00 EDT 2021 0
Tue Jun 29 15:00:00 EDT 2021 19
Tue Jun 29 16:00:00 EDT 2021 0
Tue Jun 29 17:00:00 EDT 2021 0
Tue Jun 29 18:00:00 EDT 2021 0
Tue Jun 29 19:00:00 EDT 2021 0
Tue Jun 29 20:00:00 EDT 2021 0
Tue Jun 29 21:00:00 EDT 2021 0
Tue Jun 29 22:00:00 EDT 2021 0
Tue Jun 29 23:00:00 EDT 2021 0
Wed Jun 30 00:00:00 EDT 2021 0
Wed Jun 30 01:00:00 EDT 2021 0
Wed Jun 30 02:00:00 EDT 2021 0
Wed Jun 30 03:00:00 EDT 2021 0
Wed Jun 30 04:00:00 EDT 2021 0
Wed Jun 30 05:00:00 EDT 2021 0
Wed Jun 30 06:00:00 EDT 2021 0
Wed Jun 30 07:00:00 EDT 2021 0
Wed Jun 30 08:00:00 EDT 2021 4
Wed Jun 30 09:00:00 EDT 2021 0
Wed Jun 30 10:00:00 EDT 2021 3
Is this possible with the current aggregation options? If not, does anyone have any help on this?