Hi All,
I am trying to figure out why a script on Value Changed does not appear to be executing. I have viewed several other posts and tried many thing, but all to no avail.
Ultimately, I want to write to an OPC tag when another tag's state changes. In the process of trying to chase down why it wasn't working, I resorted to creating a few memory tags (all within the same tag provider and folder). One memory tag has a simple tag change script. When executing, it is to write a new value to a different tag.
I have tried the following script in the Script Console (using absolute tag paths) and it works as expected. I have tried it within the tag change script with both absolute and relative paths, but no luck.
The diagnostics on the tag shows no errors.
The "enabled" check box for the Value Changed script is checked. I've tried toggling it off and on.
The tag provider is executing. I created an expression script to toggle a boolean on/off every one second and this works fine.
I have tried finding a log that has any indication of this script running or errors, but have been unsuccessful.
Places I have looked for a log:
Ignition Designer > Tools > Console
Ignition Server Webpage > Status > Diagnostics > Logs
Ignition Server Webpage > Status > Diagnostics > Running Scripts
Ignition Server Webpage > Systems > Gateway Scripts > Tag Change
And here's the simple script (various iterations commented):
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
# test4 is an integer memory tag
# test2 is a boolean memory tag
system.tag.writeAsync(['[.]test4'], [123])
# system.tag.writeAsync(['[provider]Copied/Path/To/test4'], [123])
# system.tag.writeAsync(['[.]test2'], [1])
# system.tag.writeAsync(['[provider]Copied/Path/To/test2'], [1])
I've been banging my head on the wall (or desk) for some time and unable to get this resolved. Any help would be greatly appreciated. Thanks in advance.
Have you looked on the tag's diagnostics tab? This is where value change script errors will go. They most likely appear in the wrapper log / gw logs as well, not sure though what they would be logged under
By the tag's diagnostics, I assume you mean the "heartbeat" graphic on the top-right of the tag-editor window. Yes. There are no errors.
Is the wrapper log / gw log indicated in the list in first post? If so, I have thoroughly checked those with no indication in them at all of the script or tag.
You can also print the return from the tag write... actually you'll need to change it to a blocking read, or use a callback function... into a gw logger
LOGGER = system.util.getLogger('Superman')
ret = system.tag.writeBlocking(...)
LOGGER.info(ret)
Thanks. I imported the tags. Set the value of "New Tag" to 0 (zero). Then changed the value of "New Tag 1". I would expect the script on "New Tag 1" to update the value of "New Tag" to the number 123. However, it does not change the value at all. I am puzzled.
I'm assuming this is where to find the Logger? I've replaced the script in "New Tag 1" with what you provided. (replacing the tag path and value for writeBlocking, of course) Then making a change to the tag value.
I've changed the value a few times, but no dice. It's not showing up in the logger. I'm thinking either I am missing something really dumb or something is wacky on the server.
I've experienced the same thing. When it happened, I copied the script that was not working and created a new tag change event and pasted the code into the new. I then deactivated the old and activated the new. Once the new worked, I deleted the old. No idea what made this happen, I assume somehow a link got broken when I was making changes, but this made it work, so I never worried about finding the cause.
Unfortunately, we have discovered that this is a widespread issue and many tag structures (that existed prior to my working on this project) that have an event change script are no-longer working. We are waiting for a response from Ignition. I'm thinking the quick-fix is rebooting the server. This, however, would not be a solution, but inevitably mask any underlying problem that caused it in the first place.
Update on the troubleshooting efforts. The cause was determined to be from an abundance of scripts and queries running. The threshold was increased to prevent this issue from occurring.