I am writing into a client tag on Tag change Client Event scripts, but it seems that it doesn’t get updated whenever the value in tag changes.
On the other hand, if I re-launch the client then it’s getting updated.
How should I tackle this situation?
Show your script. (After you paste, highlight all the code and click the “pre-formatted text” button so the pasted code is formatted correctly.)
'''This script is on Tag Chanage of "ConditionTag" and making its value 1 every 30 sec through Timer script''' import time if newValue.value == 1: newStr = system.tag.read("[client]Tag2.Value").value #Client tag s2 = system.tag.read("[default]Tag3.Value").value #This tag is changing in realtime Sleeptime = 0.25 newStr2 = newStr[1:] + s2[0:] system.tag.write("[client]Tag2", newStr2) #Writing into client tag time.sleep(Sleeptime) system.tag.write("[client]ConditionTag",0)
I have a tag binding of client tag “Tag2” to a label. But this label is not updating in realtime.
The sleep is probably jacking you over. Consider making Condition an expression tag with the value:
floor(getSecond(now()) / 30)
This will toggle between 0 and 1 at the 0 and 30 of the minute. The upshot is that it will simplify your script to just the operation affecting Tag2 and Tag3.
Also, consider using readBlocking() and writeBlocking() functions to read and write your tags.
tagList = ['[client]Tag2', '[default]Tag3'] tagValues = [tag.value for tag in system.tag.readBlocking(tagList)] # Read the tags, extracting the values stringOut = tagValues[1:] + tagValues[0:] system.tag.writeBlocking("[client]Tag2", stringOut) #Writing into client tag