Edit alarm property in multiple byte tags

I have around 200 byte tags with alarms defined for each bit in that byte. That 1600 alarms.
What I need to do is change the priority property from 1-Low to 2-Medium on all alarms, which name includes a word “ERROR”.
Here is one byte:

   <Tag name="MB590" path="Napake2" type="OPC">
      <Property name="Value">0</Property>
      <Property name="DataType">1</Property>
      <Property name="OPCServer">Ignition OPC-UA Server</Property>
      <Property name="OPCItemPath">[DKC_Bulky1]MB590</Property>
      <Property name="ScanClass">Alarms_1s</Property>
      <Property name="SourceDataType">0</Property>
      <Alarms>
         <Alarm name="ERROR STRAPPING MACHINE 2235 -R2235 (M590.6)">
            <Property name="mode">9</Property>
            <Property name="bitPosition">6</Property>
            <Property name="displayPath">R2235</Property>
            <Property name="ackMode">1</Property>
         </Alarm>
         <Alarm name="COMMUNICATION WITH MFCS SWITCHED OFF -BULKY (M590.4)">
            <Property name="mode">9</Property>
            <Property name="bitPosition">4</Property>
            <Property name="displayPath">BULKY</Property>
            <Property name="ackMode">1</Property>
         </Alarm>
         <Alarm name="CONVERT ERROR INTEGER TO S5 TIME -BULKY (M590.5)">
            <Property name="mode">9</Property>
            <Property name="bitPosition">5</Property>
            <Property name="displayPath">BULKY</Property>
            <Property name="ackMode">1</Property>
         </Alarm>
         <Alarm name="FIFO STORAGE FULL -BULKY (M590.3)">
            <Property name="mode">9</Property>
            <Property name="bitPosition">3</Property>
            <Property name="displayPath">BULKY</Property>
            <Property name="ackMode">1</Property>
         </Alarm>
         <Alarm name="POWER OFF (MAIN CABINET) -BULKY (M590.0)">
            <Property name="mode">9</Property>
            <Property name="displayPath">BULKY</Property>
            <Property name="ackMode">1</Property>
         </Alarm>
         <Alarm name="RESERVE -BULKY (M590.2)">
            <Property name="mode">9</Property>
            <Property name="bitPosition">2</Property>
            <Property name="displayPath">BULKY</Property>
            <Property name="ackMode">1</Property>
         </Alarm>
         <Alarm name="ERROR STRAPPING MACHINE 2507 -C2507 (M590.7)">
            <Property name="mode">9</Property>
            <Property name="bitPosition">7</Property>
            <Property name="displayPath">C2507</Property>
            <Property name="ackMode">1</Property>
         </Alarm>
         <Alarm name="TWO SYSTEM PALLETS WITH THE SAME BARCODE - BULKY (M590.1)">
            <Property name="mode">9</Property>
            <Property name="bitPosition">1</Property>
            <Property name="displayPath">BULKY</Property>
            <Property name="ackMode">1</Property>
         </Alarm>
      </Alarms>
   </Tag>

The priority property is not shown in the exported xml, if the priority is left on 1-Low, which is default, when you create an alarm.
I know about system.tag.editAlarmConfig but I failed to see, how to do it on multiple tags with multiple alarms…

Well, it happened again…
5 minutes after I posted this post it came to me… :roll_eyes:
This is what I came up with:

tagConfig = system.tag.browseConfiguration('DKCBulky1/AlarmsTest', False)
x=1
alarmConfig = {}
# Iterate through the configuration data
for tag in tagConfig:
    tagFullPath = tag.getFullPath()
    alarmList = tag.getAlarms()
    for alarm in alarmList:
    	alarmname = alarm.name
    	containError = alarmname.find('ERROR')
    	if containError>-1:
    		tagPaths = [tagFullPath]
    		alarmConfigKeyValuePair = {alarmname:[["priority","Value","Medium"]]}
    		alarmConfig.update(alarmConfigKeyValuePair)    #add new KeyValue pair
    		x+=1
    print "alarmConfig= ", alarmConfig
    print "x= ", x
    system.tag.editAlarmConfig(tagPaths, alarmConfig)
    alarmConfig = {}

I run this in Script Console and all 1600 alarms are done in 5 seconds… :scream:

1 Like