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:
The currentValue and previousValue arguments are qualified values. This means that to get to the actual current value, it would look like currentValue.value. |
The Quality Changed event is fired whenever the quality of this particular Tag changes. Since Tags use a 'qualified value', which include a value, quality, and timestamp, this script will fire whenever any of those change. This event has a variety of arguments available for use in the script:
The Alarm Active event fires whenever an alarm becomes active on the Tag. This event has a variety of arguments available for use in the script:
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:
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:
# 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.write("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.read("HighestTempTag").value if currentValue.value > highestRecordedTemp: system.tag.write("HighestTempTag", currentValue.value) |