I'm looking for a straight forward scripted means to get the value of an Alarm Associated Data property that has an expression binding (Ignition v8.1). I want the current value of the property, not the definition of the binding.
Use case (not super important to the request above)
For the alarm configuration of each alarm that is to produce audible notification we add an Alarm Associated Data property named "AudibleAlertFileName". The presence of this alarm property flags the alarm as triggering audible notification and value of this property indicates the filename for the pre-generated audio clip that will be added to the notification queue.
Due to extensive use of UDTs in many cases the value of the "AudibleAlertFileName" is generated by an expression binding to make it dynamic for different UDT instances without needing to override the entire alarm configuration on each UDT instance. For example: "pod_"+{Pod Number}+"_liquid_level_high.mp3"
I wish to make a scripted query to:
- Identify all alarm configurations that have the "AudibleAlertFileName" alarm property defined
- Return the path for each of those alarm configurations.
- Return the value of the "AudibleAlertFileName" alarm property (not the binding definition) for each of those alarm configurations.
Failed Attempts
Using the system.alarm.queryStatus function does not suffice as that only return alarm events and does not include alarm configuration that does not have an current event.
alarm_property_name = "AudibleAlertFileName"
print "Finding alarm events with '{}' defined...".format(alarm_property_name)
events = system.alarm.queryStatus(
priority =[0,1,2,3,4]
, defined = [alarm_property_name]
)
for event in events:
print event, event.activeData
print "Done"
Alternatively, using system.tag.query to return a list of tags with alarms and the iterating through the alarm data for each of those tags yields enough info produce the path to the alarm configuration but gives the the expression binding definition for the "AudibleAlertFileName" alarm property, not an actual value.
query = {
"options": {
"includeUdtMembers": True,
"includeUdtDefinitions": False
},
"condition": {
"attributes": {
"values": ["alarm"],
"requireAll": True
}
},
"returnProperties": [
"alarms"
]
}
results = system.tag.query('default', query)
# Filter the results to include only alarms having "AudibleAlertFileName" defined.
filtered_results = []
for result in results:
alarms = result.get("alarms")
if alarms:
for alarm in alarms:
if alarm.has_key("AudibleAlertFileName"):
filtered_results.append({
"fullPath":result.get("fullPath")
, "alarm_name":alarm.get("name")
, "AudibleAlertFileName":alarm.get("AudibleAlertFileName")
})
count=0
for fr in filtered_results:
print count, fr
count += 1
Example return value:
22 {'fullPath': [default]Pod 9/Cooler/Fault, 'alarm_name': u'Cooler Fault', 'AudibleAlertFileName': {u'bindType': u'Expression', u'value': u'"pod_"+{Pod Number}+"_cooler_faulted.mp3"'}}
23 {'fullPath': [default]Pod 4/Pod Tub Level Switches, 'alarm_name': u'Tub High Level', 'AudibleAlertFileName': {u'bindType': u'Expression', u'value': u'"pod_"+{Pod Number}+"_liquid_level_high.mp3"'}}
Any help is appreciated. I have that nagging feeling that I'm overlooking something dead simple.