Contents
Partner Programs
Sepasoft - MES Modules
Cirrus Link - MQTT Modules
Resources
Knowledge Base Articles
Inductive University
Forum
IA Support
SDK Documentation
All Manual Versions
Ignition 8.0
Ignition 7.9
Ignition 7.8
Once an event has been selected, note that the top of the text area is defining a function. As a result, all code that should execute when this event occurs should be indented at least once to be included in the definition.
The Value Changed event is fired whenever the value of this particular Tag changes. This event has a variety of arguments available for use in the script:
[tagProvider]Folder/Folder/Tag
The currentValue and previousValue arguments are qualified values: objects that contain a value, timestamp, and quality. This means that to get to the value of the currentValue, your script would need to access currentValue.value
The Quality Changed event is fired whenever the quality of this particular Tag changes. Since Tags use a QualifiedValue, which include a value, quality, and timestamp, this script will fire whenever any of those change. Refer to Scripting Object Reference for more information. This event has a variety of arguments available for use in the script:
[tagProvider]Folder/Folder/Tag
The Alarm Active event fires whenever a new active alarm event occurs. This event has a variety of arguments available for use in the script:
[tagProvider]Folder/Folder/Tag
The Alarm Cleared event fires whenever an alarm becomes cleared on the Tag.This event has a variety of arguments available for use in the script:
[tagProvider]Folder/Folder/Tag
The Alarm Acknowledged event fires whenever an alarm event becomes acknowledged on the Tag. This event has a variety of arguments available for use in the script:
[tagProvider]Folder/Folder/Tag
Scripts defined in a project script can be called from a Tag Event Script. However, only scripts defined in the Gateway Script Project may be used. For more information on configuring the Gateway Scripting Project, please see the Project Library page.
Parameters on UDTs can be interacted with from Tag Event Scripts. There are two main approaches.
Parameters values can be accessed as dictionary values. The benefit of this approach is that value changes to UDT parameters will be reflected in subsequent calls. In most cases, this modern approach is preferable. Thus, if the script needs to access the most recent parameter values on a UDT, and the parameters can change through a means other than editing the UDT (which would restart the tag), then this approach should be used.
If trying to access the value of a parameter named "myParam" from a Tag Event Script within the UDT, the script would look like:
# Reminder: "tag" is a built-in argument on all Tag Event Scripts. Accessing the "parameters" key on the tag argument will # provide access to all UDT parameters. paramValue = tag['parameters']['myParam']
In Ignition release 7.9 and prior, UDT parameters could be access in Tag Event Scripts with the familiar curly brackets approach. Thus, if trying to access the value of a parameter named "myParam" from a Tag Event Script within the UDT, the script would look like:
paramValue = {myParam}
A large caveat with this approach is that value changes made to the parameter ("myParam", in the example above) would not be reflected in scripts until the UDT was restarted. UDT parameters are pre-compiled, which in this case means value changes are mostly ignored until the UDT is restarted.
In all cases, the modern approach above is preferred.
# This script will fetch all of the possible parameters in the Tag Changed Script. # Note that this will not print out to the console, but it will print to the wrapper logs located on the Gateway. path = tagPath prev = previousValue cur = currentValue init = initialChange missed = missedEvents print path, prev.value, cur.quality, init, missed
# This code can be used on a Value Changed script, and will automatically reset the value of the tag to 0 after it goes above 3000. # This can be useful for counter tags. if currentValue.value > 3000: system.tag.writeBlocking(["[default]IntegerCounterTag"], [0])
# This code can be used on a Value Changed script, and will record the highest value of the current tag onto another memory tag. # This can be useful for recording the highest temperature. highestRecordedTemp = system.tag.readBlocking(["[default]HighestTempTag"])[0].value if currentValue.value > highestRecordedTemp: system.tag.writeBlocking(["[default]HighestTempTag"], [currentValue.value])
# This code can be used on an Alarm Active script to automatically react to an alarm. This code should not be used in place of any safety controls. if alarmName == "Tank Pressure Critical": system.tag.writeBlocking(["[default]PressureReleaseValveTag"], [1]) if alarmName == "Tank Pressure Too Low": system.tag.writeBlocking(["[default]TankFillTag"], [1])