Alarm queryStatus: Read label of the alarm object

I ran into this a while back, and this post is where I got started.

This is what I ended up using, which also gets the associated data named 'Class'.

from com.inductiveautomation.ignition.common.alarming.config import CommonAlarmProperties

def alarmStatus(displaypath):
	results = system.alarm.queryStatus(displaypath=displaypath)
	
	activeDurationData = []
	nameData = []
	labelData = []
	classData = []
	for row in results:
		activeDurationData.append(float(row.get(CommonAlarmProperties.ActiveDurationMS) / 1000.0))
		nameData.append(str(row.get(CommonAlarmProperties.Name)))
		labelData.append(str(row.get(CommonAlarmProperties.Label)))
		classValue = ''
		for prop in row.getActiveData().getProperties():
			if str(prop) == 'Class':
				classValue = str(row.get(prop))
				break
		classData.append(classValue)
	
	output = results.getDataset()
	output = system.dataset.addColumn(output,labelData,'Label',type(str()))
	output = system.dataset.addColumn(output,activeDurationData,'ActiveDuration',type(0.0))
	output = system.dataset.addColumn(output,nameData,'Name',type(str()))
	output = system.dataset.addColumn(output,classData,'Class',type(str()))
	
	return output
1 Like