Perspective Alarm Status Table Selecting/Deselecting Alarms via Script

I would like to prevent some alarms from even being able to be selected in an AlarmStatusTable so I have an on-click event script on the table where I check for a bad alarm in the array of actively selected alarms and remove it from the selection with:

del self.props.get('selection').get('active').get('data')[-1]

This correctly removes the most recently selected alarm (will always remove bad alarms and keep all selected good alarms) as shown in the empty "data" array:
AlarmStatusTable_EmptySelectedArray

The problem is that the table doesn't seem to present the bad alarm as unselected in the table. It still has the checkmark and can still be acknowledged:
AlarmStatusTable_AlarmSelected

The alarm does sometimes correctly unselect but very inconsistently.
It seems that I'm unselecting an alarm incorrectly and that there is a better way to do this.

Any update on this? Did you manage to figure out how to do this?

I am also trying to acknowledge the selected alarms on an "Alarm Status Table" using a button.

Yes actually, though it feels like a bad work around. I noticed that when alarm journal filters are changed, all alarms are deselected so I currently have a script that quickly changes the filter settings (then changed back to what the user is filtering on) when they try to acknowledge an alarm they don't have permissions for.

Regarding your acknowledge via button question, you can get the alarmID of all selected alarms and use system.alarm.acknowledge.
More about system.alarm.acknowledge here

1 Like

Hi @Ethan_Caplea thanks for your response. A question. How do find all the selected alarms using script?
A sample script woule be great.

Thanks

I don't currently have access to the environment but everything I've used was found in Ignition documentation.
Ignition Perspective Alarm Status Tables


This section here ^ is what I use to get the active alarm data. The data array contains UUIDs (which is what you would pass into the system.alarms.acknowledge function) and other useful information.

*Note that it is read-only, I was originally trying to change something in there and wasn't sure why it wasn't working until I saw that.

1 Like

Finally got this working with the following code.

	data = self.parent.parent.getChild("AlarmStatusTable").props.selection.active.data
	rowCount = len(data)
	
	if rowCount > 0 :
		uuids = []
		for r in range(0, rowCount):
			uuids.append(str(data[r].eventId))
		
		system.alarm.acknowledge(uuids, None, None)
1 Like

How do you clear the selection?

I tried to use the one on the original post, but I cannot figure out how to make it work. As a test I tried a script and run as noted by the OP.

del self.props.get('selection').get('active').get('data')[-1]

I also tried manually seting the property to [] or 0, but If I am not mistaken thats readonly.

self.props.selection.active.data = []