Files
Stream_PHX_A7/Gateways/FE/projects/.resources/7906f6d5e683d826942089f42b91f001a851b4fc57ab9213394777b43de25abc

38 lines
1.5 KiB
Plaintext

def update_alarms_in_udts(root_path): #, enable_tag_path, custom_props):
"""This script will update all the alarms under a base path so that the
alarm is enabled based on the "Meta/Alarms Enabled" tag, and the Building, EqName,
Area Served, Location, and Alarms Enabled properties have been set to their Meta tag equivalent."""
def update_alarm_config(base_path, path):
"""This function will take a tag path as an input and update the alarms."""
configs = system.tag.getConfiguration(path, False)
for config in configs:
if "alarms" in config:
for alarm in config["alarms"]:
alarm["ackPipeline"] = {"bindType": "UDTParameter", "value": "{AckPipeline}"}
alarm["activePipeline"] = {"bindType": "UDTParameter", "value": "{ActivePipeline}"}
alarm["clearPipeline"] = {"bindType": "UDTParameter", "value": "{ClearPipeline}"}
system.tag.configure(base_path, config, "o")
print "The following tag was update: %s" % config["path"]
else:
print "\nERROR: The following tag did not have an alarm: %s\n" % config["path"]
def recurse_tags(base_path):
"""Locate all the alarms underneath a base_path and call update_alarm_config when found."""
tags = system.tag.browse(base_path)
for tag in tags:
if str(tag["tagType"]) == "UdtType":
isUdt = True
else:
isUdt = False
if str(tag["tagType"]) == "AtomicTag" and "alarm" in tag["attributes"]:
update_alarm_config(base_path, tag["fullPath"])
elif tag["hasChildren"]:
recurse_tags(tag["fullPath"])
recurse_tags(root_path)