Capture Total Alarm active time

So here is what we want to do and I can’t seem to wrap my head around the best way to do it.
So part of our line is automated and basically whenever an alarm on the automated packing line comes up the packing line will shut down but the rest of the line will normally keep running so line downtime isn’t directly affected.
What we want to do is anytime an alarm in the particular area goes active (probably on the order of 100 tags) I want to start a timer to capture the total time any alarm is active.
Looking for ideas to best accomplish this (hopefully with having to write script with 100 “or” statements)
Thanks is advance !

I don’t know if it’s the best way, but you could do it with 3 tags and notification pipelines.
The first tag would be a count of how many alarms are active at the moment,
the second one would track when that count is 0 or above,
and the last one would be the total time.

You’d have a script block of this kind in the active pipeline:

paths = ["[]path/to/alarm_count", "[]path/to/time_tracker"]
alarm_count, time_tracker= [tag.value for tag in system.tag.readBlocking(paths)]
if alarm_count == 0:
	time_tracker = now
alarm_count += 1
system.tag.writeBlocking(paths, [alarm_count, time_tracker])

and the clear pipeline:

paths = ["[]path/to/alarm_count", "[]path/to/time_tracker", "[]path/to/total_time"]
alarm_count, time_tracker, total_time = [tag.value for tag in system.tag.readBlocking(paths)]
alarm_count -= 1
if alarm_count == 0:
	# get current time,
	# get the difference between now and time_tracker,
	# add it to total_time,
	# probably better done with java time classes
	# I'll let you figure this out yourself
	time_tracker = now
system.tag.writeBlocking(paths, [alarm_count, time_tracker, total_time])

If all your alarms are not currently sent to the same pipeline, you can redirect them depending on associated data that you’ll have to add,
and if there are other alarms sent to the same pipeline but that must not be used for this counter, just add an expression that checks for some associated data to split them, send one branch through the script and join them back together afterward.

There may or may not be a way to globally store alarms related data in a pipeline. If there is, it could be used instead of tags.

If you need to add associated data/change or add a pipeline to a lot of alarms, the easiest way is through scripting. I have a “tag walk” script that I can share if needed, but that will have to wait until monday as it’s on my work computer.

That’s an interesting way of looking at it…using the alarm pipeline. Thank you for that!