Alarm Indication based off multiple tags inside UDT

Hello,

I have a UDT with several OPC tags within, and would like to have an indicator show different colors (based off the highest priority) if any of these tags have an active alarm. The path of the UDT I’m looking for is also indircted (an integer 1-20).

I have been trying to use alarms = system.alarm.queryStatus(source = [“Process “+str(number)+”/PLC/UDTName/*”]) but I’m not quite sure how search through the results.

The manual states:

but how exactly do I “examine” the results list? I have tried iterating through alarms but I keep getting errors with incorrect syntax. Any ideas? Or is there a better way of achieving this? Thanks for the help.

The code I have below will return a list of basic alarm events which looks like a list of dictionaries when printed. Before you can do anything with the returned object you’ll have to iterate through the list of dictionaries to get down to the individual alarm objects. I would need to see your full code to give you a complete answer, so I’ll give you an example and see if you can’t work through it.

I created a UDT with three OPC tags that are float8. Each of those tags have one alarm configured called “Alarm”.

status = system.alarm.queryStatus(source= [’*Alarm’]) ‘’‘returns as status all alarm objects that end in ‘Alarm’ as a list of dictionaries–each dictionary represents one alarm.’’’

for dict in status:
print dict
‘’‘this will iterate through each dictionary in your list and print it you can then you can see what the object looks like’’’

for dict in status:
print dict.getDisplayPathorSource()
‘’‘this will iterate through the dictionaries and return the source or path for each object’’’

Returns:

UDTs/alarmTest/sine1/Alarm
UDTs/alarmTest/sine0/Alarm
UDTs/alarmTest/sine1/Alarm
UDTs/alarmTest/sine0/Alarm
UDTs/alarmTest/sine0/Alarm
UDTs/alarmTest/sine2/Alarm
UDTs/alarmTest/sine0/Alarm
UDTs/alarmTest/sine1/Alarm
UDTs/alarmTest/sine1/Alarm
UDTs/alarmTest/sine1/Alarm
UDTs/alarmTest/sine0/Alarm

for dict in status:
print dict.priority
‘’‘will print the priority level of each alarm’’’

Returns:

Critical
Critical
Critical
Critical
Critical
Critical
Critical
Critical
Critical
Critical
Critical

for dict in status:
print dict.getState()
‘’‘will print the state of each alarm returned’’’

Returns:

Cleared, Unacknowledged
Cleared, Unacknowledged
Active, Unacknowledged
Active, Unacknowledged
Cleared, Unacknowledged
Cleared, Unacknowledged
Cleared, Unacknowledged
Cleared, Unacknowledged
Cleared, Unacknowledged
Cleared, Unacknowledged
Cleared, Unacknowledged

The full list of methods and extension functions available for the basic alarm event object are below. You can just append them to your object variable and play around.

ackData
acked
acknowledge
active
activeData
addPropertyChangeListener
class
clear
cleared
clearedData
contains
count
displayPath
displayPathOrSource
equals
forEach
get
getAckData
getActiveData
getClass
getClearedData
getCount
getDisplayPath
getDisplayPathOrSource
getId
getLastEventState
getName
getNotes
getOrDefault
getOrElse
getPriority
getProperties
getRawValueMap
getSource
getState
getValues
hashCode
id
isAcked
isCleared
isExtended
isInherited
isShelved
iterator
lastEventState
merge
name
notes
notify
notifyAll
of
priority
properties
propertyChange
propertyChangeListener
rawValueMap
remove
removePropertyChangeListener
set
setDirect
setRawValueMap
shelved
source
spliterator
state
toString
values
wait

Good luck!

I create two expression tags in my UDTs, HighestPriority and HighestUnackPriority, and then use the following expressions to capture the alarm status of all the tags that have alarms in the UDT.

HighestPriority -

max({Tag1.AlarmHighestAckPriority}, {Tag1.AlarmHighestUnackPriority}, {Tag2.AlarmHighestAckPriority}, {Tag2.AlarmHighestUnackPriority})
HighestUnackPriority-

max({Tag1.AlarmHighestUnackPriority}, {Tag2.AlarmHighestUnackPriority})

1 Like

Apologies for the late response, thanks for the replies. These definitely helped guide me in the right direction. Appreciate the help!