Disabling Alarm Acknowledge based on Associated Data

Hello!

I am trying to disable acknowledging alarms using an associated data parameter I added to my alarms called “Alarm Group”. I am using the isAcknowledgeEnabled extension function on the Alarm Status Table Object. The script that I wrote to prove the concept is shown below. I want to disable acknowledge if any of the selected alarms have an Alarm Group of “Group 1”. Currently with this script, acknowledging is disabled all the time.

	ackEnable = 1
	
	for alarmEvent in selectedAlarmEvents: 
		if alarmEvent.get("Alarm Group") != "Group 1":
			ackEnable = 0
			
	if ackEnable == 1:
		return True
	else:
		return False

Thanks!

Hmm, your script actually worked for me as written. I set up two boolean memory tags with alarms, and set the ‘Alarm Group’ to ‘Group 1’ and ‘Group 2’ respectively, then dropped your function as written onto an alarm status table, and it worked right away.

That said, even your proof of concept can be cleaned up a bit; for instance, you’re already using ackEnable as a true/false, so you could just return bool(ackEnable) instead of an additional if step. Or, if you want to get fancy about it, replace the whole script with:
return all(alarmEvent.get("Alarm Group") != "Group 1" for alarmEvent in selectedAlarmEvents)

all is a Python builtin that will (lazily) evaluate every boolean in the sequence provided; in this case, checking each alarm group to check that it does not match “Group 1”. If any event does match Group 1, the function will immediately return False and stop iterating the list.

As for why your example isn’t working - try adding print alarmEvent.sourcePath, alarmEvent.get("Alarm Group") or something similar before the Group 1 check in your example; maybe there’s a typo in the property or set value on one or more of your alarms. The logic itself seems fine.

Thanks Paul,

It works for me too now. I actually did not realize that we could use the print() function within the extension functions. I thought they would kind of run all the time so printing would break.

And I will be using the all() function as well.

Thanks again!

1 Like