Blog

Editing Tag Alarms via Scripting in Ignition

Editing Tag Alarms via Scripting in Ignition

The Ignition platform, created by Inductive Automation, is a powerful tool for system integration. One of its most versatile features is the ability to attach Python scripts to practically any component or property on changes, actions, timers, etc. Inductive Automation provides a system library as part of their Ignition software that provides easy access to the different aspects of an Ignition project through Python scripts.

Add or Edit Alarms

The function that we will focus on today is the system.tag.editAlarmConfig() function. Normally, editing or adding alarms in Ignition can be a fairly manual process, even if one can make intelligent use of User Defined Types (UDTs). The system.tag.editAlarmConfig() function allows for a much more dynamic process to edit or add alarms to tags in bulk, or on specific triggers. This could be used to only add alarms in specific cases to tags, or perhaps to allow tags to be added directly from.

An example of a simple script that uses this function is shown below:

 alarmConfig = {"targetAlarm": [ ] "propertyToChange", "Value", "newValue"[, ]"anotherProperty", "Value", "anotherNewValue"[ ]} 
system.tag.editAlarmConfig([tagPath], alarmConfig) 

Tag Binding

When manually creating an alarm in Ignition, you have the option to bind properties of the alarm to tags or expression. In provided examples using this function, however, it is only shown that the properties of the alarm configuration are able to be set to a constant value. Fortunately, Ignition does provide the ability to associate bindings to alarm properties rather than values.

To create a tag binding in an alarm configuration, replace the second item in the list, normally labeled ‘Value’, with ‘Tag’. Then replace the third item in the list with either a relative or absolute tag path. Similarly, to create an expression binding in an alarm config, replace the second item in the list with ‘Expression’ and the third item in the list with a string containing your expression.

This offers much more flexibility in creating alarms, and allows all of the versatility of the manual alarm creation process to be applied to your script

An example script is shown below that applies tag bindings to alarm properties:

 assetPath = "[default]PressureSensor1" 
alarmConfig = {}  
alarmProperties = [ ] 
tagPath = assetPath + "/Value" 
alarmProperties.append(["mode","value","2"]) 
alarmProperties.append(["setpointA"."Tag","].[ High Alarm Setpoint"]) 
alarmproperties.append(["displayPath","Expression","'"+assetpath+"'+{].[Tag Name} "]) 
alarmConfig['High Alarm'] = alarmProperties 
system.tag.editAlarmConfig([tagPath], alarmConfig) 

 

With this hidden functionality, editing alarms in an Ignition project becomes easier and more time efficient.

Learn more about DMC’s Ignition Expertise and contact us with any inquiries.

Comments

There are currently no comments, be the first to post one.

Post a comment

Name (required)

Email (required)

CAPTCHA image
Enter the code shown above:

Related Blog Posts