Reading Tag Alarm state and append to DataSet

Dear All,

I am attempting to append the tag alarm state to the dataSet. However, I am encountering an error message 'com.inductiveautomation.ignition.common.alarming.AlarmStateTransition' object is not iterable

I have successfully read the alarm state of all the tags. I need to append their status to the Status column as per the attached image. Could someone kindly provide guidance on how to proceed?

Thank you

storeData = []
copyData = event.source.parent.getComponent('copyData').data
print copyData

for row in range(copyData.getRowCount()): 
	tagPath = copyData.getValueAt(row, "TagName")
	configTagPath = tagPath+"/ATestMem/A/Alarms/Test Alarm A.EventState"
	configValue=system.tag.readBlocking(configTagPath)
	alarmstate = configValue[0].value
	print alarmstate
	


headers = ['TagName', 'status']
testData = []
for row in range(copyData.getRowCount()):
	testData.append([copyData.getValueAt(row, "TagName") for column in range(copyData.getColumnCount())])
event.source.parent.getComponent('storeData').data = system.dataset.toDataSet(headers, testData)

Can you try this and see if it works? If it doesn't work, can you show the complete error message?

tagPaths = [tagPath + "/ATestMem/A/Alarms/Test Alarm A.EventState" for tagPath in event.source.parent.getComponent('copyData').data.getColumnAsList(0)]
tagValues = system.tag.readBlocking(tagPaths)
event.source.parent.getComponent('storeData').data = system.dataset.toDataSet(['TagName','status'],[[tagPath,str(tagValue.value)] for tagPath,tagValue in zip(tagPaths,system.tag.readBlocking(tagPaths))])
2 Likes

Hi,
Its working nice. thank you.

Just want to know that; Is there an any way only shows the ''Active'' state? I don't want to display ''clear'' state

Thanks in Advance.

What do you want to show when the value isn't "Active"? Just leave it empty?

Power table will be disappear if alarm state in not active.

I modified @leonardo.godoi's script to:

  • only read the tags once.
  • only return rows with an 'Active' state.

You can then bind the visibility property to an expression:
len({Root Container.storeData.data}) > 0

tagPaths = [tagPath + "/ATestMem/A/Alarms/Test Alarm A.EventState" for tagPath in event.source.parent.getComponent('copyData').data.getColumnAsList(0)]
tagValues = [tag.value for tag in system.tag.readBlocking(tagPaths)]
event.source.parent.getComponent('storeData').data = system.dataset.toDataSet(['TagName','status'],[[tagPath,str(tagValue)] for tagPath,tagValue in zip(tagPaths,tagValues) if tagValue == 'Active'])
1 Like

I have tried this code but it not fetching any data to power table.

tagPaths = [tagPath + "/ATestMem/A/Alarms/Test Alarm A.EventState" for tagPath in event.source.parent.getComponent('copyData').data.getColumnAsList(0)]
tagValues = [tag.value for tag in system.tag.readBlocking(tagPaths)]
event.source.parent.getComponent('storeData').data = system.dataset.toDataSet(['TagName','status'],[[tagPath,str(tagValue)] for tagPath,tagValue in zip(tagPaths,tagValues) if tagValue == 'Active'])

Therefore I removed the below condition then code fetches all the active and clear alarm state. But I am interested only to show active state.

if tagValue == 'Active'
if event.propertyName == 'name':

	tagPaths = [tagPath + "/ATestMem/A/Alarms/Test Alarm A.EventState" for tagPath in event.source.parent.getComponent('copyData').data.getColumnAsList(0)]
	tagValues = [tag.value for tag in system.tag.readBlocking(tagPaths)]
	event.source.parent.getComponent('storeData').data = system.dataset.toDataSet(['TagName','status'],[[tagPath,str(tagValue)] for tagPath,tagValue in zip(tagPaths,tagValues)])

Any suggestion in this subject highly appreciable.

Try using an if clause in the list comprehension