Sorry for a newbie question. I need to modify parameters via reference tags in the UDT using Tag Change script.
It works fine without ‘if’ conditioning, however once ‘if cur.value is True: ’ is enabled in the script ifs not writing to the tag. Of course Im testing in with value changed from 0 to 1. Tried examples from manuals/forum and in general every example with IF failed to write to the tag. Any ideas ?
Just wanted to add this, since Phil didn't mention it, but system.tag.read() has been deprecated and you should be using system.tag.readBlocking() which is designed to read multiple paths at once and so accepts a list of tag paths and returns a list of qualified values.
I'm not sure why you're reading pathB in this script since you don't show it being used but if you did need both values it should be read like this.
tagA,tagB = system.tag.readBlocking(['[.]PLC_Path_A','[.]PLC_Path_B'])
#Or
#tagA = system.tag.readBlocking(['[.]PLC_Path_A','[.]PLC_Path_B'])[0].value
if currentValue.value:
system.tag.writeBlocking(['[.]PLC_Path_Ref'],[tagA.value])
I'm also surprised that @pturmel didn't caution you about running blocking scripts in tag value change scripts. Do a search for the pitfalls, particularly if this UDT will have many instances.
The intention of this scripting is to replace OPCItempath in the UDT instances for redundant S7400 comms based on Master/Slave status PLC tag (bool). This tag only change and execute UDT scripts once in year, or even less often. Should I be aware of any Ignition performance issues etc.. ?
Tag Change scripting looks bit neater solution comparing to gateway script.
I wouldn't bother with a script at all then, I would just create a UDT parameter and change it manually if it needed it. Oh well. Either way, I guarantee that it runs more than that. So while it may seem harmless to you, you should definitely be aware of the rope you're walking on. The thread pool available for tag scripts is very small, and if you're not careful you'll have random failures due to chewing up that pool. It will be very difficult to find when you notice it (I have been there, and done that, not fun.)