I need to be able to swap 465 tag values between 1 and 3. whats the best way to go about doing something like that? each tag is in a different folder but has the same tag name. My thought was just to put it on a button but before I do anything I wanted to make sure there wasnt a better way, and also make sure that I would cause any issues by writing to so many tags at once.
Right now it is easiest to perform these writes using the system.tag.writeToTag function in scripting. In Ignition 7.3 (coming out soon) we have a new function called system.tag.writeToTags which allows you to write to multiple tags in one call. That is important because right now each system.tag.writeToTag function can take up to 70 ms a piece if you are not using the tag in the client. In your case it could take 30 seconds or so to perform the writes.
You could use a transaction group to perform the writes but you will have a lot of items and expression items so it is not the best route.
Try it on a button and see what the results are. If they are really slow there are a few techniques to speed it up. You can also make the script shorter by doing the following:
folders = ["Folder1", "Folder2", "Folder3", ...]
valueToWrite = 1
for folder in folders:
system.tag.writeToTag("%s/Value" % folder, valueToWrite)That way you don’t have 465 system.tag.writeToTag lines. Let us know how this goes.
thanks I was going to do something similar.
are you gonna also do a system.getTag"s"Value in 7.3, to go along with the system.tag.writeToTags?
IMHO, that is going to make ignition very, very powerful.
Yes, there is a
[tt]system.tag.getTagValues([path1, path2, …])[/tt]
[tt]system.tag.writeToTags([path1, path2, …], [value1, value2, …])[/tt]
and actually these are in 7.2.9.